mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 07:37:43 +00:00
Apply changes from #2310
This commit is contained in:
parent
dd78addc29
commit
65eaaa96f2
@ -88,11 +88,6 @@ public class EntityAvatar extends GameEntity {
|
||||
return getPlayer().getRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Int2FloatMap getFightProperties() {
|
||||
return getAvatar().getFightProperties();
|
||||
@ -137,13 +132,19 @@ public class EntityAvatar extends GameEntity {
|
||||
|
||||
@Override
|
||||
public float heal(float amount, boolean mute) {
|
||||
// Do not heal character if they are dead
|
||||
if (!this.isAlive()) {
|
||||
// Do not heal character if they are dead.
|
||||
var currentHp = this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
|
||||
if (currentHp <= 0) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
float healed = super.heal(amount, mute);
|
||||
// Check if the character hasn't been marked as dead.
|
||||
if (currentHp > 0 && this.isDead()) {
|
||||
this.setDead(false);
|
||||
mute = false;
|
||||
}
|
||||
|
||||
float healed = super.heal(amount, mute);
|
||||
if (healed > 0f) {
|
||||
getScene()
|
||||
.broadcastPacket(
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.*;
|
||||
import emu.grasscutter.data.GameData;
|
||||
@ -23,9 +21,12 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.*;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
@Entity
|
||||
public final class TeamManager extends BasePlayerDataManager {
|
||||
@ -798,10 +799,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
|
||||
public void onAvatarDie(long dieGuid) {
|
||||
EntityAvatar deadAvatar = this.getCurrentAvatarEntity();
|
||||
|
||||
if (deadAvatar.isAlive() || deadAvatar.getId() != dieGuid) {
|
||||
return;
|
||||
}
|
||||
if (deadAvatar == null || deadAvatar.getId() != dieGuid) return;
|
||||
|
||||
PlayerDieType dieType = deadAvatar.getKilledType();
|
||||
int killedBy = deadAvatar.getKilledBy();
|
||||
|
Loading…
Reference in New Issue
Block a user