Commit b253e779 authored by xtaodada's avatar xtaodada Committed by Melledy
Browse files

Implement food heal function


Co-authored-by: default avatarpris <lilch1022@hotmail.com>
parent 765f569e
...@@ -941,6 +941,16 @@ public class InventoryManager { ...@@ -941,6 +941,16 @@ public class InventoryManager {
used = player.getTeamManager().reviveAvatar(target) ? 1 : 0; used = player.getTeamManager().reviveAvatar(target) ? 1 : 0;
} }
break; break;
case MATERIAL_NOTICE_ADD_HP:
if (useItem.getItemData().getUseTarget().equals("ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR")) {
if (target == null) {
break;
}
int[] SatiationParams = useItem.getItemData().getSatiationParams();
used = player.getTeamManager().healAvatar(target, SatiationParams[0], SatiationParams[1]) ? 1 : 0;
}
break;
case MATERIAL_CHEST: case MATERIAL_CHEST:
if (useItem.getRewardBoxId() > 0) { if (useItem.getRewardBoxId() > 0) {
used = handleRewardBox(player, useItem) ? 1 : 0; used = handleRewardBox(player, useItem) ? 1 : 0;
......
...@@ -458,6 +458,30 @@ public class TeamManager { ...@@ -458,6 +458,30 @@ public class TeamManager {
return false; 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() { public void respawnTeam() {
// Make sure all team members are dead // Make sure all team members are dead
for (EntityAvatar entity : getActiveTeam()) { for (EntityAvatar entity : getActiveTeam()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment