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
0db14721
Commit
0db14721
authored
Jun 14, 2022
by
ImmuState
Committed by
Melledy
Jun 14, 2022
Browse files
Adapt protocol for clearing energy.
parent
521deab4
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
0db14721
...
...
@@ -16,6 +16,7 @@ import emu.grasscutter.net.proto.AbilityControlBlockOuterClass.AbilityControlBlo
import
emu.grasscutter.net.proto.AbilityEmbryoOuterClass.AbilityEmbryo
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.ChangeEnergyReasonOuterClass.ChangeEnergyReason
;
import
emu.grasscutter.net.proto.ChangeHpReasonOuterClass.ChangeHpReason
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
...
...
@@ -31,6 +32,7 @@ import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropChangeReasonNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.Utils
;
...
...
@@ -108,13 +110,13 @@ public class EntityAvatar extends GameEntity {
public
void
onDeath
(
int
killerId
)
{
this
.
killedType
=
PlayerDieType
.
PLAYER_DIE_TYPE_KILL_BY_MONSTER
;
this
.
killedBy
=
killerId
;
clearEnergy
(
Prop
ChangeReason
.
PROP_
CHANGE_
REASON_STATUE_RECOVER
);
clearEnergy
(
Change
Energy
Reason
.
CHANGE_
ENERGY_REASON_NONE
);
}
public
void
onDeath
(
PlayerDieType
dieType
,
int
killerId
)
{
this
.
killedType
=
dieType
;
this
.
killedBy
=
killerId
;
clearEnergy
(
Prop
ChangeReason
.
PROP_
CHANGE_
REASON_STATUE_RECOVER
);
clearEnergy
(
Change
Energy
Reason
.
CHANGE_
ENERGY_REASON_NONE
);
}
@Override
...
...
@@ -130,14 +132,25 @@ public class EntityAvatar extends GameEntity {
return
healed
;
}
public
void
clearEnergy
(
PropChangeReason
reason
)
{
public
void
clearEnergy
(
ChangeEnergyReason
reason
)
{
// Fight props.
FightProperty
curEnergyProp
=
this
.
getAvatar
().
getSkillDepot
().
getElementType
().
getCurEnergyProp
();
FightProperty
maxEnergyProp
=
this
.
getAvatar
().
getSkillDepot
().
getElementType
().
getMaxEnergyProp
();
// Get max energy.
float
maxEnergy
=
this
.
avatar
.
getFightProperty
(
maxEnergyProp
);
// Set energy to zero.
this
.
avatar
.
setCurrentEnergy
(
curEnergyProp
,
0
);
this
.
getScene
().
broadcastPacket
(
new
PacketAvatarFightPropUpdateNotify
(
this
.
getAvatar
(),
curEnergyProp
));
this
.
getScene
().
broadcastPacket
(
new
PacketEntityFightPropChangeReasonNotify
(
this
,
curEnergyProp
,
0
f
,
reason
));
}
// Send packets.
this
.
getScene
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
this
,
curEnergyProp
));
if
(
reason
!=
ChangeEnergyReason
.
CHANGE_ENERGY_REASON_NONE
)
{
this
.
getScene
().
broadcastPacket
(
new
PacketEntityFightPropChangeReasonNotify
(
this
,
curEnergyProp
,
-
maxEnergy
,
reason
));
}
}
public
void
addEnergy
(
float
amount
,
PropChangeReason
reason
)
{
this
.
addEnergy
(
amount
,
reason
,
false
);
}
...
...
src/main/java/emu/grasscutter/game/managers/EnergyManager/EnergyManager.java
View file @
0db14721
...
...
@@ -22,6 +22,7 @@ import emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.Ability
import
emu.grasscutter.net.proto.AbilityIdentifierOuterClass.AbilityIdentifier
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult
;
import
emu.grasscutter.net.proto.ChangeEnergyReasonOuterClass.ChangeEnergyReason
;
import
emu.grasscutter.net.proto.EvtBeingHitInfoOuterClass.EvtBeingHitInfo
;
import
emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason
;
import
emu.grasscutter.server.game.GameSession
;
...
...
@@ -334,7 +335,7 @@ public class EnergyManager {
// If the cast skill was a burst, consume energy.
if
(
avatar
.
getSkillDepot
()
!=
null
&&
skillId
==
avatar
.
getSkillDepot
().
getEnergySkill
())
{
avatar
.
getAsEntity
().
clearEnergy
(
Prop
ChangeReason
.
PROP_
CHANGE_
REASON_ABILITY
);
avatar
.
getAsEntity
().
clearEnergy
(
Change
Energy
Reason
.
CHANGE_
ENERGY_REASON_SKILL_START
);
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketEntityFightPropChangeReasonNotify.java
View file @
0db14721
...
...
@@ -4,6 +4,7 @@ import emu.grasscutter.game.entity.GameEntity;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ChangeEnergyReasonOuterClass.ChangeEnergyReason
;
import
emu.grasscutter.net.proto.ChangeHpReasonOuterClass.ChangeHpReason
;
import
emu.grasscutter.net.proto.EntityFightPropChangeReasonNotifyOuterClass.EntityFightPropChangeReasonNotify
;
import
emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason
;
...
...
@@ -55,4 +56,17 @@ public class PacketEntityFightPropChangeReasonNotify extends BasePacket {
this
.
setData
(
proto
);
}
public
PacketEntityFightPropChangeReasonNotify
(
GameEntity
entity
,
FightProperty
prop
,
Float
value
,
ChangeEnergyReason
reason
)
{
super
(
PacketOpcodes
.
EntityFightPropChangeReasonNotify
);
EntityFightPropChangeReasonNotify
proto
=
EntityFightPropChangeReasonNotify
.
newBuilder
()
.
setEntityId
(
entity
.
getId
())
.
setPropType
(
prop
.
getId
())
.
setPropDelta
(
value
)
.
setChangeEnergyReson
(
reason
)
.
build
();
this
.
setData
(
proto
);
}
}
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