mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 06:31:26 +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();
|
return getPlayer().getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAlive() {
|
|
||||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Int2FloatMap getFightProperties() {
|
public Int2FloatMap getFightProperties() {
|
||||||
return getAvatar().getFightProperties();
|
return getAvatar().getFightProperties();
|
||||||
@ -137,13 +132,19 @@ public class EntityAvatar extends GameEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float heal(float amount, boolean mute) {
|
public float heal(float amount, boolean mute) {
|
||||||
// Do not heal character if they are dead
|
// Do not heal character if they are dead.
|
||||||
if (!this.isAlive()) {
|
var currentHp = this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
|
||||||
|
if (currentHp <= 0) {
|
||||||
return 0f;
|
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) {
|
if (healed > 0f) {
|
||||||
getScene()
|
getScene()
|
||||||
.broadcastPacket(
|
.broadcastPacket(
|
||||||
|
@ -15,9 +15,10 @@ import emu.grasscutter.scripts.data.controller.EntityController;
|
|||||||
import emu.grasscutter.server.event.entity.*;
|
import emu.grasscutter.server.event.entity.*;
|
||||||
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
||||||
import it.unimi.dsi.fastutil.ints.*;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
import java.util.*;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class GameEntity {
|
public abstract class GameEntity {
|
||||||
@Getter private final Scene scene;
|
@Getter private final Scene scene;
|
||||||
@Getter protected int id;
|
@Getter protected int id;
|
||||||
@ -33,6 +34,9 @@ public abstract class GameEntity {
|
|||||||
|
|
||||||
@Getter @Setter private boolean lockHP;
|
@Getter @Setter private boolean lockHP;
|
||||||
|
|
||||||
|
@Setter(AccessLevel.PROTECTED)
|
||||||
|
@Getter private boolean isDead = false;
|
||||||
|
|
||||||
// Lua controller for specific actions
|
// Lua controller for specific actions
|
||||||
@Getter @Setter private EntityController entityController;
|
@Getter @Setter private EntityController entityController;
|
||||||
@Getter private ElementType lastAttackType = ElementType.None;
|
@Getter private ElementType lastAttackType = ElementType.None;
|
||||||
@ -63,7 +67,7 @@ public abstract class GameEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
return true;
|
return !this.isDead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LifeState getLifeState() {
|
public LifeState getLifeState() {
|
||||||
@ -172,10 +176,9 @@ public abstract class GameEntity {
|
|||||||
this.lastAttackType = attackType;
|
this.lastAttackType = attackType;
|
||||||
|
|
||||||
// Check if dead
|
// Check if dead
|
||||||
boolean isDead = false;
|
|
||||||
if (this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
|
if (this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
|
||||||
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
|
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
|
||||||
isDead = true;
|
this.isDead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.runLuaCallbacks(event);
|
this.runLuaCallbacks(event);
|
||||||
@ -186,7 +189,7 @@ public abstract class GameEntity {
|
|||||||
new PacketEntityFightPropUpdateNotify(this, FightProperty.FIGHT_PROP_CUR_HP));
|
new PacketEntityFightPropUpdateNotify(this, FightProperty.FIGHT_PROP_CUR_HP));
|
||||||
|
|
||||||
// Check if dead.
|
// Check if dead.
|
||||||
if (isDead) {
|
if (this.isDead) {
|
||||||
this.getScene().killEntity(this, killerId);
|
this.getScene().killEntity(this, killerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package emu.grasscutter.game.player;
|
package emu.grasscutter.game.player;
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
|
||||||
|
|
||||||
import dev.morphia.annotations.*;
|
import dev.morphia.annotations.*;
|
||||||
import emu.grasscutter.*;
|
import emu.grasscutter.*;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
@ -23,9 +21,12 @@ import emu.grasscutter.server.packet.send.*;
|
|||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.*;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import lombok.*;
|
|
||||||
|
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public final class TeamManager extends BasePlayerDataManager {
|
public final class TeamManager extends BasePlayerDataManager {
|
||||||
@ -798,10 +799,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
|||||||
|
|
||||||
public void onAvatarDie(long dieGuid) {
|
public void onAvatarDie(long dieGuid) {
|
||||||
EntityAvatar deadAvatar = this.getCurrentAvatarEntity();
|
EntityAvatar deadAvatar = this.getCurrentAvatarEntity();
|
||||||
|
if (deadAvatar == null || deadAvatar.getId() != dieGuid) return;
|
||||||
if (deadAvatar.isAlive() || deadAvatar.getId() != dieGuid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerDieType dieType = deadAvatar.getKilledType();
|
PlayerDieType dieType = deadAvatar.getKilledType();
|
||||||
int killedBy = deadAvatar.getKilledBy();
|
int killedBy = deadAvatar.getKilledBy();
|
||||||
|
Loading…
Reference in New Issue
Block a user