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