Implementes auto HP recovery at the statues.

- Respects player setting.
- SP + MP.
- Statue has unlimited HP volume (to be updated)
This commit is contained in:
gentlespoon
2022-05-06 00:05:38 -07:00
committed by Melledy
parent 2ad6f5934b
commit 198214ec53
3 changed files with 132 additions and 21 deletions

View File

@@ -1,5 +1,7 @@
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.managers.SotSManager.SotSManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
@@ -18,26 +20,10 @@ import java.util.List;
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();
if(entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) != entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP)){
Float hp = entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP)-entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
session.send(new PacketEntityFightPropUpdateNotify(entity,FightProperty.FIGHT_PROP_MAX_HP));
session.send(new PacketEntityFightPropChangeReasonNotify(
entity, FightProperty.FIGHT_PROP_CUR_HP, hp, List.of(3),
PropChangeReason.PROP_CHANGE_STATUE_RECOVER, ChangeHpReason.ChangeHpAddStatue));
entity.setFightProperty(
FightProperty.FIGHT_PROP_CUR_HP,
entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP)
);
session.send(new PacketAvatarFightPropUpdateNotify(entity.getAvatar(), FightProperty.FIGHT_PROP_CUR_HP));
if (!isAlive) {
entity.getWorld().broadcastPacket(new PacketAvatarLifeStateChangeNotify(entity.getAvatar()));
}
}
});
Player player = session.getPlayer();
SotSManager sotsManager = player.getSotSManager();
sotsManager.autoRevive(session);
sotsManager.scheduleAutoRecover(session);
// TODO: allow interaction with the SotS?
}
}