Apply changes from #2310

This commit is contained in:
KingRainbow44
2023-09-16 18:58:36 -04:00
Unverified
parent dd78addc29
commit 65eaaa96f2
3 changed files with 22 additions and 20 deletions
@@ -15,9 +15,10 @@ import emu.grasscutter.scripts.data.controller.EntityController;
import emu.grasscutter.server.event.entity.*;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import it.unimi.dsi.fastutil.ints.*;
import java.util.*;
import lombok.*;
import java.util.*;
public abstract class GameEntity {
@Getter private final Scene scene;
@Getter protected int id;
@@ -33,6 +34,9 @@ public abstract class GameEntity {
@Getter @Setter private boolean lockHP;
@Setter(AccessLevel.PROTECTED)
@Getter private boolean isDead = false;
// Lua controller for specific actions
@Getter @Setter private EntityController entityController;
@Getter private ElementType lastAttackType = ElementType.None;
@@ -63,7 +67,7 @@ public abstract class GameEntity {
}
public boolean isAlive() {
return true;
return !this.isDead;
}
public LifeState getLifeState() {
@@ -172,10 +176,9 @@ public abstract class GameEntity {
this.lastAttackType = attackType;
// Check if dead
boolean isDead = false;
if (this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
isDead = true;
this.isDead = true;
}
this.runLuaCallbacks(event);
@@ -186,7 +189,7 @@ public abstract class GameEntity {
new PacketEntityFightPropUpdateNotify(this, FightProperty.FIGHT_PROP_CUR_HP));
// Check if dead.
if (isDead) {
if (this.isDead) {
this.getScene().killEntity(this, killerId);
}
}