Implement food heal function

Co-authored-by: pris <lilch1022@hotmail.com>
This commit is contained in:
xtaodada
2022-05-03 12:07:41 +08:00
committed by Melledy
parent 765f569e55
commit b253e779a2
2 changed files with 36 additions and 2 deletions

View File

@@ -457,7 +457,31 @@ public class TeamManager {
return false;
}
public boolean healAvatar(Avatar avatar, int healRate, int healAmount) {
for (EntityAvatar entity : getActiveTeam()) {
if (entity.getAvatar() == avatar) {
if (!entity.isAlive()) {
return false;
}
entity.setFightProperty(
FightProperty.FIGHT_PROP_CUR_HP,
(float) Math.min(
(entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) +
entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * (float) healRate / 100.0 +
(float) healAmount / 100.0),
entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP)
)
);
getPlayer().sendPacket(new PacketAvatarFightPropUpdateNotify(entity.getAvatar(), FightProperty.FIGHT_PROP_CUR_HP));
getPlayer().sendPacket(new PacketAvatarLifeStateChangeNotify(entity.getAvatar()));
return true;
}
}
return false;
}
public void respawnTeam() {
// Make sure all team members are dead
for (EntityAvatar entity : getActiveTeam()) {