Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
8f5bd2f2
Commit
8f5bd2f2
authored
May 19, 2022
by
ImmuState
Committed by
Melledy
May 22, 2022
Browse files
Give correct amount of energy for collecting particles/orbs, and consume energy on burst cast.
parent
1df9acbb
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/avatar/Avatar.java
View file @
8f5bd2f2
...
...
@@ -493,6 +493,9 @@ public class Avatar {
// Get hp percent, set to 100% if none
float
hpPercent
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
)
<=
0
?
1
f
:
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
/
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
// Store current energy value for later
float
currentEnergy
=
(
data
.
getSkillDepot
()
!=
null
)
?
this
.
getFightProperty
(
data
.
getSkillDepot
().
getElementType
().
getCurEnergyProp
())
:
0
f
;
// Clear properties
this
.
getFightProperties
().
clear
();
...
...
@@ -514,7 +517,8 @@ public class Avatar {
if
(
data
.
getSkillDepot
()
!=
null
&&
data
.
getSkillDepot
().
getEnergySkillData
()
!=
null
)
{
ElementType
element
=
data
.
getSkillDepot
().
getElementType
();
this
.
setFightProperty
(
element
.
getMaxEnergyProp
(),
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
((
element
.
getMaxEnergyProp
().
getId
()
%
70
)
+
1000
,
data
.
getSkillDepot
().
getEnergySkillData
().
getCostElemVal
());
this
.
setFightProperty
(
element
.
getCurEnergyProp
(),
currentEnergy
);
//this.setFightProperty((element.getMaxEnergyProp().getId() % 70) + 1000, data.getSkillDepot().getEnergySkillData().getCostElemVal());
}
// Artifacts
...
...
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
8f5bd2f2
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.AvatarData
;
...
...
@@ -129,13 +130,27 @@ public class EntityAvatar extends GameEntity {
}
public
void
addEnergy
(
float
amount
)
{
this
.
addEnergy
(
amount
,
false
);
}
public
void
addEnergy
(
float
amount
,
boolean
isFlat
)
{
// Get current and maximum energy for this avatar.
FightProperty
curEnergyProp
=
getAvatar
().
getSkillDepot
().
getElementType
().
getCurEnergyProp
();
FightProperty
maxEnergyProp
=
getAvatar
().
getSkillDepot
().
getElementType
().
getMaxEnergyProp
();
// Get energy recharge.
float
energyRecharge
=
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CHARGE_EFFICIENCY
);
// Scale amount by energy recharge, if the amount is not flat.
if
(!
isFlat
)
{
amount
*=
energyRecharge
;
}
// Determine the new energy value.
float
curEnergy
=
this
.
getFightProperty
(
curEnergyProp
);
float
maxEnergy
=
this
.
getFightProperty
(
maxEnergyProp
);
float
newEnergy
=
Math
.
min
(
curEnergy
+
amount
,
maxEnergy
);
// Set energy and notify.
if
(
newEnergy
!=
curEnergy
)
{
setFightProperty
(
curEnergyProp
,
newEnergy
);
...
...
src/main/java/emu/grasscutter/game/player/TeamManager.java
View file @
8f5bd2f2
...
...
@@ -4,6 +4,7 @@ import java.util.*;
import
dev.morphia.annotations.Entity
;
import
dev.morphia.annotations.Transient
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.game.avatar.Avatar
;
...
...
@@ -19,6 +20,7 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketAvatarDieAnimationEndRsp
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify
;
...
...
@@ -583,20 +585,55 @@ public class TeamManager {
}
public
synchronized
void
addEnergyToTeam
(
GameItem
energyBall
)
{
// TODO
float
baseEnergy
=
2
;
for
(
int
i
=
0
;
i
<
getActiveTeam
().
size
();
i
++)
{
EntityAvatar
entity
=
getActiveTeam
().
get
(
i
);
float
energyGain
=
baseEnergy
;
// Check if the item is indeed an energy particle/orb.
if
(
energyBall
.
getItemId
()
<
2001
||
energyBall
.
getItemId
()
>
2024
)
{
return
;
}
// Determine the base amount of energy given by the particle/orb.
// Particles have a base amount of 1.0, and orbs a base amount of 3.0.
float
baseEnergy
=
(
energyBall
.
getItemId
()
<=
2008
)
?
3.0f
:
1.0f
;
// Add energy to every team member.
for
(
int
i
=
0
;
i
<
this
.
getActiveTeam
().
size
();
i
++)
{
EntityAvatar
entity
=
this
.
getActiveTeam
().
get
(
i
);
// On-field vs off-field multiplier.
float
offFieldPenalty
=
(
this
.
getCurrentCharacterIndex
()
==
i
)
?
1.0f
:
1.0f
-
this
.
getActiveTeam
().
size
()
*
0.1f
;
// Same element/neutral bonus.
ElementType
avatarElement
=
entity
.
getAvatar
().
getSkillDepot
().
getElementType
();
ElementType
ballElement
=
switch
(
energyBall
.
getItemId
())
{
case
2001
,
2017
->
ElementType
.
Fire
;
case
2002
,
2018
->
ElementType
.
Water
;
case
2003
,
2019
->
ElementType
.
Grass
;
case
2004
,
2020
->
ElementType
.
Electric
;
case
2005
,
2021
->
ElementType
.
Wind
;
case
2006
,
2022
->
ElementType
.
Ice
;
case
2007
,
2023
->
ElementType
.
Rock
;
default
->
null
;
};
float
elementBonus
=
(
ballElement
==
null
)
?
2.0f
:
(
avatarElement
==
ballElement
)
?
3.0f
:
1.0f
;
// Active character gets full hp
if
(
getCurrentCharacterIndex
()
!=
i
)
{
energyGain
*=
Math
.
max
(
1.0
-
(
getActiveTeam
().
size
()
*
.
1
f
),
.
6
f
);
}
// Add the energy.
entity
.
addEnergy
(
baseEnergy
*
elementBonus
*
offFieldPenalty
);
}
}
public
void
handleEvtDoSkillSuccNotify
(
GameSession
session
,
int
skillId
,
int
casterId
)
{
// Determine the entity that has cast the skill.
Optional
<
EntityAvatar
>
caster
=
this
.
getActiveTeam
().
stream
()
.
filter
(
character
->
character
.
getId
()
==
casterId
)
.
findFirst
();
if
(
caster
.
isEmpty
())
{
return
;
}
Avatar
avatar
=
caster
.
get
().
getAvatar
();
entity
.
addEnergy
(
energyGain
);
// If the cast skill was a burst, consume energy.
if
(
skillId
==
avatar
.
getSkillDepot
().
getEnergySkill
())
{
float
consumedEnergy
=
avatar
.
getFightProperty
(
avatar
.
getSkillDepot
().
getElementType
().
getMaxEnergyProp
());
avatar
.
getAsEntity
().
addEnergy
(-
consumedEnergy
);
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java
View file @
8f5bd2f2
...
...
@@ -19,5 +19,6 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler {
Vector
forwardVector
=
notify
.
getForward
();
Position
forward
=
new
Position
(
forwardVector
.
getX
(),
forwardVector
.
getY
(),
forwardVector
.
getZ
());
session
.
getPlayer
().
getStaminaManager
().
handleEvtDoSkillSuccNotify
(
session
,
skillId
,
casterId
);
session
.
getPlayer
().
getTeamManager
().
handleEvtDoSkillSuccNotify
(
session
,
skillId
,
casterId
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment