Fix extra skill charges being removed if you teleport

Close #404
This commit is contained in:
Melledy 2022-05-02 17:25:26 -07:00
parent 7395a268ef
commit a93d7c579f
3 changed files with 41 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState;
import emu.grasscutter.server.packet.send.PacketAvatarDieAnimationEndRsp; import emu.grasscutter.server.packet.send.PacketAvatarDieAnimationEndRsp;
import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify;
import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify; import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify;
import emu.grasscutter.server.packet.send.PacketAvatarSkillInfoNotify;
import emu.grasscutter.server.packet.send.PacketAvatarTeamUpdateNotify; import emu.grasscutter.server.packet.send.PacketAvatarTeamUpdateNotify;
import emu.grasscutter.server.packet.send.PacketChangeAvatarRsp; import emu.grasscutter.server.packet.send.PacketChangeAvatarRsp;
import emu.grasscutter.server.packet.send.PacketChangeMpTeamAvatarRsp; import emu.grasscutter.server.packet.send.PacketChangeMpTeamAvatarRsp;
@ -263,6 +264,13 @@ public class TeamManager {
// Packets // Packets
getPlayer().getWorld().broadcastPacket(new PacketSceneTeamUpdateNotify(getPlayer())); getPlayer().getWorld().broadcastPacket(new PacketSceneTeamUpdateNotify(getPlayer()));
// Skill charges packet - Yes, this is official server behavior as of 2.6.0
for (EntityAvatar entity : getActiveTeam()) {
if (entity.getAvatar().getSkillExtraChargeMap().size() > 0) {
getPlayer().sendPacket(new PacketAvatarSkillInfoNotify(entity.getAvatar()));
}
}
// Run callback // Run callback
if (responsePacket != null) { if (responsePacket != null) {
getPlayer().sendPacket(responsePacket); getPlayer().sendPacket(responsePacket);

View File

@ -25,6 +25,7 @@ import emu.grasscutter.scripts.data.SceneBlock;
import emu.grasscutter.scripts.data.SceneGadget; import emu.grasscutter.scripts.data.SceneGadget;
import emu.grasscutter.scripts.data.SceneGroup; import emu.grasscutter.scripts.data.SceneGroup;
import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.scripts.data.ScriptArgs;
import emu.grasscutter.server.packet.send.PacketAvatarSkillInfoNotify;
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify; import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify;
@ -271,6 +272,13 @@ public class Scene {
} }
this.addEntity(player.getTeamManager().getCurrentAvatarEntity()); this.addEntity(player.getTeamManager().getCurrentAvatarEntity());
// Notify the client of any extra skill charges
for (EntityAvatar entity : player.getTeamManager().getActiveTeam()) {
if (entity.getAvatar().getSkillExtraChargeMap().size() > 0) {
player.sendPacket(new PacketAvatarSkillInfoNotify(entity.getAvatar()));
}
}
} }
private void addEntityDirectly(GameEntity entity) { private void addEntityDirectly(GameEntity entity) {

View File

@ -0,0 +1,25 @@
package emu.grasscutter.server.packet.send;
import java.util.Map.Entry;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarSkillInfoNotifyOuterClass.AvatarSkillInfoNotify;
import emu.grasscutter.net.proto.AvatarSkillInfoOuterClass.AvatarSkillInfo;
public class PacketAvatarSkillInfoNotify extends BasePacket {
public PacketAvatarSkillInfoNotify(Avatar avatar) {
super(PacketOpcodes.AvatarSkillInfoNotify);
AvatarSkillInfoNotify.Builder proto = AvatarSkillInfoNotify.newBuilder()
.setGuid(avatar.getGuid());
for (Entry<Integer, Integer> entry : avatar.getSkillExtraChargeMap().entrySet()) {
proto.putSkillMap(entry.getKey(), AvatarSkillInfo.newBuilder().setMaxChargeCount(entry.getValue()).build());
}
this.setData(proto);
}
}