Fix some revives; improve dungeon exit flow (#2409)

This commit is contained in:
longfruit
2023-10-25 19:27:48 -07:00
committed by GitHub
parent 837e30e04b
commit f86259a430
8 changed files with 145 additions and 31 deletions

View File

@@ -67,6 +67,11 @@ public class EntityAvatar extends GameEntity {
}
this.initAbilities();
// New EntityAvatar instances are created on every scene transition.
// Ensure that isDead is properly carried over between scenes.
// Otherwise avatars could have 0 HP but not considered dead.
this.checkIfDead();
}
@Override

View File

@@ -174,13 +174,7 @@ public abstract class GameEntity {
}
this.lastAttackType = attackType;
// Check if dead
if (this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
this.isDead = true;
}
this.checkIfDead();
this.runLuaCallbacks(event);
// Packets
@@ -194,6 +188,17 @@ public abstract class GameEntity {
}
}
public void checkIfDead() {
if (this.getFightProperties() == null || !hasFightProperty(FightProperty.FIGHT_PROP_CUR_HP)) {
return;
}
if (this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
this.isDead = true;
}
}
/**
* Runs the Lua callbacks for {@link EntityDamageEvent}.
*
@@ -333,6 +338,8 @@ public abstract class GameEntity {
if (entityController != null) {
entityController.onDie(this, getLastAttackType());
}
this.isDead = true;
}
/** Invoked when a global ability value is updated. */