mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 14:24:37 +01:00
Split hp/sp for normal and extra lineups
This commit is contained in:
@@ -16,6 +16,7 @@ import emu.lunarcore.data.excel.AvatarExcel;
|
||||
import emu.lunarcore.game.inventory.GameItem;
|
||||
import emu.lunarcore.game.inventory.ItemMainType;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.game.player.PlayerLineup;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.game.scene.entity.GameEntity;
|
||||
import emu.lunarcore.proto.AvatarOuterClass.Avatar;
|
||||
@@ -34,6 +35,7 @@ import emu.lunarcore.server.packet.send.PacketPlayerSyncScNotify;
|
||||
import emu.lunarcore.util.Position;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -52,11 +54,14 @@ public class GameAvatar implements GameEntity {
|
||||
@Setter private int promotion;
|
||||
private AvatarData data;
|
||||
|
||||
private int currentHp;
|
||||
private int currentSp;
|
||||
private Set<Integer> takenRewards;
|
||||
private long timestamp;
|
||||
|
||||
@Getter(AccessLevel.NONE) private int currentHp;
|
||||
@Getter(AccessLevel.NONE) private int currentSp;
|
||||
@Getter(AccessLevel.NONE) private int extraLineupHp;
|
||||
@Getter(AccessLevel.NONE) private int extraLineupSp;
|
||||
|
||||
private transient int entityId;
|
||||
private transient Int2ObjectMap<GameItem> equips;
|
||||
private transient Int2LongMap buffs;
|
||||
@@ -138,16 +143,38 @@ public class GameAvatar implements GameEntity {
|
||||
return this.getExcel().getMaxSp();
|
||||
}
|
||||
|
||||
public void setCurrentHp(int amount) {
|
||||
this.currentHp = Math.max(Math.min(amount, 10000), 0);
|
||||
public int getCurrentHp(PlayerLineup lineup) {
|
||||
return !lineup.isExtraLineup() ? this.currentHp : this.extraLineupHp;
|
||||
}
|
||||
|
||||
public void setCurrentSp(int amount) {
|
||||
this.currentSp = Math.max(Math.min(amount, getMaxSp()), 0);
|
||||
public int getCurrentSp(PlayerLineup lineup) {
|
||||
return !lineup.isExtraLineup() ? this.currentSp : this.extraLineupSp;
|
||||
}
|
||||
|
||||
public void setCurrentHp(PlayerLineup lineup, int amount) {
|
||||
amount = Math.max(Math.min(amount, 10000), 0);
|
||||
if (!lineup.isExtraLineup()) {
|
||||
this.currentHp = amount;
|
||||
} else {
|
||||
this.extraLineupHp = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentSp(PlayerLineup lineup, int amount) {
|
||||
amount = Math.max(Math.min(amount, getMaxSp()), 0);
|
||||
if (!lineup.isExtraLineup()) {
|
||||
this.currentSp = amount;
|
||||
} else {
|
||||
this.extraLineupSp = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return this.getCurrentHp() > 0;
|
||||
return this.isAlive(this.getOwner().getCurrentLineup());
|
||||
}
|
||||
|
||||
public boolean isAlive(PlayerLineup lineup) {
|
||||
return this.getCurrentHp(lineup) > 0;
|
||||
}
|
||||
|
||||
public int getRank() {
|
||||
@@ -273,12 +300,12 @@ public class GameAvatar implements GameEntity {
|
||||
return proto;
|
||||
}
|
||||
|
||||
public LineupAvatar toLineupAvatarProto(int slot) {
|
||||
public LineupAvatar toLineupAvatarProto(PlayerLineup lineup, int slot) {
|
||||
var proto = LineupAvatar.newInstance()
|
||||
.setAvatarType(AvatarType.AVATAR_FORMAL_TYPE)
|
||||
.setId(this.getAvatarId())
|
||||
.setSpBar(SpBarInfo.newInstance().setCurSp(this.getCurrentSp()).setMaxSp(this.getMaxSp()))
|
||||
.setHp(this.getCurrentHp())
|
||||
.setSpBar(SpBarInfo.newInstance().setCurSp(this.getCurrentSp(lineup)).setMaxSp(this.getMaxSp()))
|
||||
.setHp(this.getCurrentHp(lineup))
|
||||
.setSlot(slot);
|
||||
|
||||
return proto;
|
||||
@@ -294,7 +321,7 @@ public class GameAvatar implements GameEntity {
|
||||
return proto;
|
||||
}
|
||||
|
||||
public BattleAvatar toBattleProto(int index) {
|
||||
public BattleAvatar toBattleProto(PlayerLineup lineup, int index) {
|
||||
var proto = BattleAvatar.newInstance()
|
||||
.setAvatarType(AvatarType.AVATAR_FORMAL_TYPE)
|
||||
.setId(this.getExcel().getAvatarID())
|
||||
@@ -302,8 +329,8 @@ public class GameAvatar implements GameEntity {
|
||||
.setPromotion(this.getPromotion())
|
||||
.setRank(this.getRank())
|
||||
.setIndex(index)
|
||||
.setHp(this.getCurrentHp())
|
||||
.setSpBar(SpBarInfo.newInstance().setCurSp(this.getCurrentSp()).setMaxSp(this.getMaxSp()))
|
||||
.setHp(this.getCurrentHp(lineup))
|
||||
.setSpBar(SpBarInfo.newInstance().setCurSp(this.getCurrentSp(lineup)).setMaxSp(this.getMaxSp()))
|
||||
.setWorldLevel(this.getOwner().getWorldLevel());
|
||||
|
||||
// Skill tree
|
||||
|
||||
@@ -193,7 +193,7 @@ public class Battle {
|
||||
if (avatar == null) continue;
|
||||
|
||||
// Add to proto
|
||||
proto.addBattleAvatarList(avatar.toBattleProto(i));
|
||||
proto.addBattleAvatarList(avatar.toBattleProto(lineup, i));
|
||||
|
||||
// Add buffs from avatars
|
||||
if (avatar.getBuffs().size() > 0) {
|
||||
|
||||
@@ -244,8 +244,8 @@ public class BattleService extends BaseGameService {
|
||||
int currentHp = (int) Math.round((prop.getLeftHp() / prop.getMaxHp()) * 10000);
|
||||
int currentSp = (int) prop.getLeftSp() * 100;
|
||||
|
||||
avatar.setCurrentHp(Math.max(currentHp, minimumHp));
|
||||
avatar.setCurrentSp(Math.max(currentSp, 0));
|
||||
avatar.setCurrentHp(battle.getLineup(), Math.max(currentHp, minimumHp));
|
||||
avatar.setCurrentSp(battle.getLineup(), Math.max(currentSp, 0));
|
||||
avatar.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,10 @@ public class MazeSkillModifySP extends MazeSkillAction {
|
||||
|
||||
@Override
|
||||
public void onCast(GameAvatar caster, MotionInfo castPosition) {
|
||||
caster.setCurrentSp(amount + caster.getCurrentSp());
|
||||
caster.setCurrentSp(
|
||||
caster.getOwner().getCurrentLineup(),
|
||||
amount + caster.getCurrentSp(caster.getOwner().getCurrentLineup())
|
||||
);
|
||||
// TODO Perhaps we should send a sync lineup packet here
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
lineup.forEachAvatar(avatar -> {
|
||||
avatar.setCurrentHp(10000);
|
||||
avatar.setCurrentSp(avatar.getMaxSp() / 2);
|
||||
avatar.setCurrentHp(lineup, 10000);
|
||||
avatar.setCurrentSp(lineup, avatar.getMaxSp() / 2);
|
||||
});
|
||||
// Set technique points
|
||||
lineup.setMp(5);
|
||||
@@ -51,8 +51,8 @@ public class ChallengeManager extends BasePlayerManager {
|
||||
if (lineup.getAvatars().size() == 0) return;
|
||||
// Reset hp/sp
|
||||
lineup.forEachAvatar(avatar -> {
|
||||
avatar.setCurrentHp(10000);
|
||||
avatar.setCurrentSp(avatar.getMaxSp() / 2);
|
||||
avatar.setCurrentHp(lineup, 10000);
|
||||
avatar.setCurrentSp(lineup, avatar.getMaxSp() / 2);
|
||||
});
|
||||
// Set technique points
|
||||
lineup.setMp(5);
|
||||
|
||||
@@ -104,13 +104,13 @@ public class PlayerLineup {
|
||||
if (avatar == null) continue;
|
||||
|
||||
// Dont heal dead avatars if we are not allowed to revive
|
||||
if (avatar.getCurrentHp() <= 0 && !allowRevive) {
|
||||
if (avatar.getCurrentHp(this) <= 0 && !allowRevive) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Heal avatar
|
||||
if (avatar.getCurrentHp() < 10000) {
|
||||
avatar.setCurrentHp(Math.min(avatar.getCurrentHp() + heal, 10000));
|
||||
if (avatar.getCurrentHp(this) < 10000) {
|
||||
avatar.setCurrentHp(this, Math.min(avatar.getCurrentHp(this) + heal, 10000));
|
||||
avatar.save();
|
||||
hasHealed = true;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class PlayerLineup {
|
||||
GameAvatar avatar = owner.getAvatars().getAvatarById(getAvatars().get(slot));
|
||||
if (avatar == null) continue;
|
||||
|
||||
proto.addAvatarList(avatar.toLineupAvatarProto(slot));
|
||||
proto.addAvatarList(avatar.toLineupAvatarProto(this, slot));
|
||||
}
|
||||
|
||||
return proto;
|
||||
|
||||
@@ -52,8 +52,8 @@ public class RogueManager extends BasePlayerManager {
|
||||
|
||||
// Reset hp/sp
|
||||
lineup.forEachAvatar(avatar -> {
|
||||
avatar.setCurrentHp(10000);
|
||||
avatar.setCurrentSp(avatar.getMaxSp());
|
||||
avatar.setCurrentHp(lineup, 10000);
|
||||
avatar.setCurrentSp(lineup, avatar.getMaxSp());
|
||||
|
||||
data.getBaseAvatarIds().add(avatar.getAvatarId());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user