From ec27c47db4fd9813eb75debb90c0f89f7899bbe1 Mon Sep 17 00:00:00 2001 From: BaiSugar Date: Tue, 3 May 2022 21:56:54 +0800 Subject: [PATCH] Approaching StatuesOfTheSeven will restore all health of the current team --- proto/EnterTransPointRegionNotify.proto | 7 +++++ .../HandlerEnterTransPointRegionNotify.java | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 proto/EnterTransPointRegionNotify.proto create mode 100644 src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterTransPointRegionNotify.java diff --git a/proto/EnterTransPointRegionNotify.proto b/proto/EnterTransPointRegionNotify.proto new file mode 100644 index 000000000..b6bb9fa9f --- /dev/null +++ b/proto/EnterTransPointRegionNotify.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +option java_package = "emu.grasscutter.net.proto"; +message EnterTransPointRegionNotify { + uint32 scene_id = 1; + uint32 point_id = 2; +} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterTransPointRegionNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterTransPointRegionNotify.java new file mode 100644 index 000000000..de874cd7e --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterTransPointRegionNotify.java @@ -0,0 +1,27 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.game.props.FightProperty; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify; +import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify; + +@Opcodes(PacketOpcodes.EnterTransPointRegionNotify) +public class HandlerEnterTransPointRegionNotify extends PacketHandler { + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception{ + session.getPlayer().getTeamManager().getActiveTeam().forEach(entity -> { + boolean isAlive = entity.isAlive(); + entity.setFightProperty( + FightProperty.FIGHT_PROP_CUR_HP, + entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) + ); + entity.getWorld().broadcastPacket(new PacketAvatarFightPropUpdateNotify(entity.getAvatar(), FightProperty.FIGHT_PROP_CUR_HP)); + if (!isAlive) { + entity.getWorld().broadcastPacket(new PacketAvatarLifeStateChangeNotify(entity.getAvatar())); + } + }); + } +}