2022-04-17 12:43:07 +00:00
|
|
|
package emu.grasscutter.game.avatar;
|
|
|
|
|
2022-04-21 23:37:25 +00:00
|
|
|
import java.util.ArrayList;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
2022-04-21 23:37:25 +00:00
|
|
|
import java.util.List;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.util.Map;
|
2022-05-01 02:34:50 +00:00
|
|
|
import java.util.Map.Entry;
|
2022-04-17 12:43:07 +00:00
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import org.bson.types.ObjectId;
|
|
|
|
|
|
|
|
import dev.morphia.annotations.Entity;
|
|
|
|
import dev.morphia.annotations.Id;
|
|
|
|
import dev.morphia.annotations.Indexed;
|
|
|
|
import dev.morphia.annotations.PostLoad;
|
|
|
|
import dev.morphia.annotations.PrePersist;
|
|
|
|
import dev.morphia.annotations.Transient;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.data.GameData;
|
2022-05-28 11:21:47 +00:00
|
|
|
import emu.grasscutter.data.binout.OpenConfigEntry;
|
|
|
|
import emu.grasscutter.data.binout.OpenConfigEntry.SkillPointModifier;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.data.common.FightPropData;
|
2022-05-28 11:21:47 +00:00
|
|
|
import emu.grasscutter.data.excels.AvatarData;
|
|
|
|
import emu.grasscutter.data.excels.AvatarPromoteData;
|
|
|
|
import emu.grasscutter.data.excels.AvatarSkillData;
|
|
|
|
import emu.grasscutter.data.excels.AvatarSkillDepotData;
|
|
|
|
import emu.grasscutter.data.excels.AvatarTalentData;
|
|
|
|
import emu.grasscutter.data.excels.EquipAffixData;
|
|
|
|
import emu.grasscutter.data.excels.ProudSkillData;
|
|
|
|
import emu.grasscutter.data.excels.ReliquaryAffixData;
|
|
|
|
import emu.grasscutter.data.excels.ReliquaryLevelData;
|
|
|
|
import emu.grasscutter.data.excels.ReliquaryMainPropData;
|
|
|
|
import emu.grasscutter.data.excels.ReliquarySetData;
|
|
|
|
import emu.grasscutter.data.excels.WeaponCurveData;
|
|
|
|
import emu.grasscutter.data.excels.WeaponPromoteData;
|
|
|
|
import emu.grasscutter.data.excels.AvatarSkillDepotData.InherentProudSkillOpens;
|
|
|
|
import emu.grasscutter.data.excels.ItemData.WeaponProperty;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.database.DatabaseHelper;
|
|
|
|
import emu.grasscutter.game.entity.EntityAvatar;
|
|
|
|
import emu.grasscutter.game.inventory.EquipType;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.game.inventory.GameItem;
|
2022-04-30 17:04:36 +00:00
|
|
|
import emu.grasscutter.game.inventory.ItemType;
|
2022-04-27 04:24:25 +00:00
|
|
|
import emu.grasscutter.game.player.Player;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.game.props.ElementType;
|
|
|
|
import emu.grasscutter.game.props.EntityIdType;
|
2022-04-21 23:37:25 +00:00
|
|
|
import emu.grasscutter.game.props.FetterState;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.game.props.FightProperty;
|
|
|
|
import emu.grasscutter.game.props.PlayerProperty;
|
|
|
|
import emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo;
|
|
|
|
import emu.grasscutter.net.proto.AvatarInfoOuterClass.AvatarInfo;
|
2022-05-01 02:34:50 +00:00
|
|
|
import emu.grasscutter.net.proto.AvatarSkillInfoOuterClass.AvatarSkillInfo;
|
2022-04-30 17:04:36 +00:00
|
|
|
import emu.grasscutter.net.proto.FetterDataOuterClass.FetterData;
|
|
|
|
import emu.grasscutter.net.proto.ShowAvatarInfoOuterClass;
|
|
|
|
import emu.grasscutter.net.proto.ShowAvatarInfoOuterClass.ShowAvatarInfo;
|
|
|
|
import emu.grasscutter.net.proto.ShowEquipOuterClass.ShowEquip;
|
2022-04-21 04:03:18 +00:00
|
|
|
import emu.grasscutter.server.packet.send.PacketAbilityChangeNotify;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.server.packet.send.PacketAvatarEquipChangeNotify;
|
|
|
|
import emu.grasscutter.server.packet.send.PacketAvatarFightPropNotify;
|
|
|
|
import emu.grasscutter.utils.ProtoHelper;
|
|
|
|
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
|
|
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
|
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
|
|
|
2022-05-20 22:57:59 +00:00
|
|
|
import static emu.grasscutter.Configuration.GAME_OPTIONS;
|
|
|
|
|
2022-04-21 01:11:57 +00:00
|
|
|
@Entity(value = "avatars", useDiscriminator = false)
|
2022-04-27 04:21:57 +00:00
|
|
|
public class Avatar {
|
2022-04-17 12:43:07 +00:00
|
|
|
@Id private ObjectId id;
|
|
|
|
@Indexed private int ownerId; // Id of player that this avatar belongs to
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
@Transient private Player owner;
|
2022-04-17 12:43:07 +00:00
|
|
|
@Transient private AvatarData data;
|
2022-05-08 12:31:53 +00:00
|
|
|
@Transient private AvatarSkillDepotData skillDepot;
|
2022-04-17 12:43:07 +00:00
|
|
|
@Transient private long guid; // Player unique id
|
|
|
|
private int avatarId; // Id of avatar
|
|
|
|
|
|
|
|
private int level = 1;
|
|
|
|
private int exp;
|
|
|
|
private int promoteLevel;
|
|
|
|
private int satiation; // ?
|
|
|
|
private int satiationPenalty; // ?
|
|
|
|
private float currentHp;
|
2022-05-24 20:29:28 +00:00
|
|
|
private float currentEnergy;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
@Transient private final Int2ObjectMap<GameItem> equips;
|
2022-04-17 12:43:07 +00:00
|
|
|
@Transient private final Int2FloatOpenHashMap fightProp;
|
2022-04-21 04:03:18 +00:00
|
|
|
@Transient private Set<String> extraAbilityEmbryos;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-04-21 23:42:17 +00:00
|
|
|
private List<Integer> fetters;
|
2022-04-21 23:37:25 +00:00
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
private Map<Integer, Integer> skillLevelMap; // Talent levels
|
2022-05-01 02:34:50 +00:00
|
|
|
private Map<Integer, Integer> skillExtraChargeMap; // Charges
|
2022-04-17 12:43:07 +00:00
|
|
|
private Map<Integer, Integer> proudSkillBonusMap; // Talent bonus levels (from const)
|
|
|
|
private int skillDepotId;
|
|
|
|
private int coreProudSkillLevel; // Constellation level
|
|
|
|
private Set<Integer> talentIdList; // Constellation id list
|
|
|
|
private Set<Integer> proudSkillList; // Character passives
|
|
|
|
|
|
|
|
private int flyCloak;
|
|
|
|
private int costume;
|
|
|
|
private int bornTime;
|
2022-04-22 14:27:40 +00:00
|
|
|
|
|
|
|
private int fetterLevel = 1;
|
|
|
|
private int fetterExp;
|
2022-04-22 22:08:37 +00:00
|
|
|
|
|
|
|
private int nameCardRewardId;
|
2022-04-23 15:48:06 +00:00
|
|
|
private int nameCardId;
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-05-08 12:31:53 +00:00
|
|
|
@Deprecated // Do not use. Morhpia only!
|
2022-04-27 04:21:57 +00:00
|
|
|
public Avatar() {
|
2022-04-17 12:43:07 +00:00
|
|
|
this.equips = new Int2ObjectOpenHashMap<>();
|
|
|
|
this.fightProp = new Int2FloatOpenHashMap();
|
2022-04-21 04:03:18 +00:00
|
|
|
this.extraAbilityEmbryos = new HashSet<>();
|
2022-04-21 23:37:25 +00:00
|
|
|
this.proudSkillBonusMap = new HashMap<>();
|
2022-04-27 04:21:57 +00:00
|
|
|
this.fetters = new ArrayList<>(); // TODO Move to avatar
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// On creation
|
2022-04-27 04:21:57 +00:00
|
|
|
public Avatar(int avatarId) {
|
|
|
|
this(GameData.getAvatarDataMap().get(avatarId));
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public Avatar(AvatarData data) {
|
2022-04-17 12:43:07 +00:00
|
|
|
this();
|
|
|
|
this.avatarId = data.getId();
|
2022-04-22 22:08:37 +00:00
|
|
|
this.nameCardRewardId = data.getNameCardRewardId();
|
2022-04-23 15:48:06 +00:00
|
|
|
this.nameCardId = data.getNameCardId();
|
2022-04-17 12:43:07 +00:00
|
|
|
this.data = data;
|
|
|
|
this.bornTime = (int) (System.currentTimeMillis() / 1000);
|
|
|
|
this.flyCloak = 140001;
|
|
|
|
|
|
|
|
this.skillLevelMap = new HashMap<>();
|
2022-05-01 02:34:50 +00:00
|
|
|
this.skillExtraChargeMap = new HashMap<>();
|
2022-04-17 12:43:07 +00:00
|
|
|
this.talentIdList = new HashSet<>();
|
|
|
|
this.proudSkillList = new HashSet<>();
|
|
|
|
|
|
|
|
// Combat properties
|
|
|
|
for (FightProperty prop : FightProperty.values()) {
|
|
|
|
if (prop.getId() <= 0 || prop.getId() >= 3000) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
this.setFightProperty(prop, 0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skill depot
|
2022-05-08 12:31:53 +00:00
|
|
|
this.setSkillDepotData(getAvatarData().getSkillDepot());
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
// Set stats
|
|
|
|
this.recalcStats();
|
|
|
|
this.currentHp = getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
|
|
|
setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.currentHp);
|
2022-05-24 20:29:28 +00:00
|
|
|
this.currentEnergy = 0f;
|
2022-04-17 12:43:07 +00:00
|
|
|
// Load handler
|
|
|
|
this.onLoad();
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public Player getPlayer() {
|
2022-04-17 12:43:07 +00:00
|
|
|
return this.owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ObjectId getObjectId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AvatarData getAvatarData() {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void setAvatarData(AvatarData data) {
|
2022-05-08 12:31:53 +00:00
|
|
|
if (this.data != null) return;
|
|
|
|
this.data = data; // Used while loading this from the database
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getOwnerId() {
|
|
|
|
return ownerId;
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public void setOwner(Player player) {
|
2022-04-17 12:43:07 +00:00
|
|
|
this.owner = player;
|
2022-04-19 09:22:21 +00:00
|
|
|
this.ownerId = player.getUid();
|
2022-04-27 04:21:57 +00:00
|
|
|
this.guid = player.getNextGameGuid();
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getSatiation() {
|
|
|
|
return satiation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSatiation(int satiation) {
|
|
|
|
this.satiation = satiation;
|
|
|
|
}
|
|
|
|
|
2022-04-22 22:08:37 +00:00
|
|
|
public int getNameCardRewardId() {
|
|
|
|
return nameCardRewardId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNameCardRewardId(int nameCardRewardId) {
|
|
|
|
this.nameCardRewardId = nameCardRewardId;
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public int getSatiationPenalty() {
|
|
|
|
return satiationPenalty;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSatiationPenalty(int satiationPenalty) {
|
|
|
|
this.satiationPenalty = satiationPenalty;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AvatarData getData() {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getGuid() {
|
|
|
|
return guid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAvatarId() {
|
|
|
|
return avatarId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLevel() {
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLevel(int level) {
|
|
|
|
this.level = level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getExp() {
|
|
|
|
return exp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setExp(int exp) {
|
|
|
|
this.exp = exp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPromoteLevel() {
|
|
|
|
return promoteLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPromoteLevel(int promoteLevel) {
|
|
|
|
this.promoteLevel = promoteLevel;
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public Int2ObjectMap<GameItem> getEquips() {
|
2022-04-17 12:43:07 +00:00
|
|
|
return equips;
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public GameItem getEquipBySlot(EquipType slot) {
|
2022-04-17 12:43:07 +00:00
|
|
|
return this.getEquips().get(slot.getValue());
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
private GameItem getEquipBySlot(int slotId) {
|
2022-04-17 12:43:07 +00:00
|
|
|
return this.getEquips().get(slotId);
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public GameItem getWeapon() {
|
2022-04-17 12:43:07 +00:00
|
|
|
return this.getEquipBySlot(EquipType.EQUIP_WEAPON);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSkillDepotId() {
|
|
|
|
return skillDepotId;
|
|
|
|
}
|
|
|
|
|
2022-05-08 12:31:53 +00:00
|
|
|
public AvatarSkillDepotData getSkillDepot() {
|
|
|
|
return skillDepot;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void setSkillDepot(AvatarSkillDepotData skillDepot) {
|
|
|
|
if (this.skillDepot != null) return;
|
|
|
|
this.skillDepot = skillDepot; // Used while loading this from the database
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSkillDepotData(AvatarSkillDepotData skillDepot) {
|
|
|
|
// Set id and depot
|
2022-04-17 12:43:07 +00:00
|
|
|
this.skillDepotId = skillDepot.getId();
|
2022-05-08 12:31:53 +00:00
|
|
|
this.skillDepot = skillDepot;
|
2022-04-17 12:43:07 +00:00
|
|
|
// Clear, then add skills
|
|
|
|
getSkillLevelMap().clear();
|
|
|
|
if (skillDepot.getEnergySkill() > 0) {
|
|
|
|
getSkillLevelMap().put(skillDepot.getEnergySkill(), 1);
|
|
|
|
}
|
|
|
|
for (int skillId : skillDepot.getSkills()) {
|
|
|
|
if (skillId > 0) {
|
|
|
|
getSkillLevelMap().put(skillId, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add proud skills
|
|
|
|
this.getProudSkillList().clear();
|
|
|
|
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
|
|
|
|
if (openData.getProudSkillGroupId() == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) {
|
|
|
|
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
|
2022-04-27 04:21:57 +00:00
|
|
|
if (GameData.getProudSkillDataMap().containsKey(proudSkillId)) {
|
2022-04-17 12:43:07 +00:00
|
|
|
this.getProudSkillList().add(proudSkillId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Map<Integer, Integer> getSkillLevelMap() {
|
|
|
|
return skillLevelMap;
|
|
|
|
}
|
2022-05-01 02:34:50 +00:00
|
|
|
|
|
|
|
public Map<Integer, Integer> getSkillExtraChargeMap() {
|
|
|
|
if (skillExtraChargeMap == null) {
|
|
|
|
skillExtraChargeMap = new HashMap<>();
|
|
|
|
}
|
|
|
|
return skillExtraChargeMap;
|
|
|
|
}
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
public Map<Integer, Integer> getProudSkillBonusMap() {
|
|
|
|
return proudSkillBonusMap;
|
|
|
|
}
|
|
|
|
|
2022-04-21 04:03:18 +00:00
|
|
|
public Set<String> getExtraAbilityEmbryos() {
|
|
|
|
return extraAbilityEmbryos;
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 23:37:25 +00:00
|
|
|
public void setFetterList(List<Integer> fetterList) {
|
2022-04-21 23:49:35 +00:00
|
|
|
this.fetters = fetterList;
|
2022-04-21 23:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Integer> getFetterList() {
|
2022-04-21 23:49:35 +00:00
|
|
|
return fetters;
|
2022-04-21 23:37:25 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 14:27:40 +00:00
|
|
|
public int getFetterLevel() {
|
|
|
|
return fetterLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFetterLevel(int fetterLevel) {
|
|
|
|
this.fetterLevel = fetterLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFetterExp() {
|
|
|
|
return fetterExp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFetterExp(int fetterExp) {
|
|
|
|
this.fetterExp = fetterExp;
|
|
|
|
}
|
|
|
|
|
2022-04-23 15:48:06 +00:00
|
|
|
public int getNameCardId() {
|
|
|
|
return nameCardId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNameCardId(int nameCardId) {
|
|
|
|
this.nameCardId = nameCardId;
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public float getCurrentHp() {
|
|
|
|
return currentHp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentHp(float currentHp) {
|
|
|
|
this.currentHp = currentHp;
|
|
|
|
}
|
|
|
|
|
2022-05-24 20:29:28 +00:00
|
|
|
public void setCurrentEnergy() {
|
2022-05-24 20:59:14 +00:00
|
|
|
if (GAME_OPTIONS.energyUsage) {
|
|
|
|
this.setCurrentEnergy(this.currentEnergy);
|
|
|
|
}
|
2022-05-24 20:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentEnergy(float currentEnergy) {
|
|
|
|
if (this.getSkillDepot() != null && this.getSkillDepot().getEnergySkillData() != null) {
|
|
|
|
ElementType element = this.getSkillDepot().getElementType();
|
|
|
|
this.setFightProperty(element.getMaxEnergyProp(), this.getSkillDepot().getEnergySkillData().getCostElemVal());
|
|
|
|
|
|
|
|
if (GAME_OPTIONS.energyUsage) {
|
|
|
|
this.setFightProperty(element.getCurEnergyProp(), currentEnergy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.setFightProperty(element.getCurEnergyProp(), this.getSkillDepot().getEnergySkillData().getCostElemVal());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentEnergy(FightProperty curEnergyProp, float currentEnergy) {
|
2022-05-24 20:59:14 +00:00
|
|
|
if (GAME_OPTIONS.energyUsage) {
|
|
|
|
this.setFightProperty(curEnergyProp, currentEnergy);
|
|
|
|
this.currentEnergy = currentEnergy;
|
|
|
|
this.save();
|
|
|
|
}
|
2022-05-24 20:29:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
public Int2FloatOpenHashMap getFightProperties() {
|
|
|
|
return fightProp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFightProperty(FightProperty prop, float value) {
|
|
|
|
this.getFightProperties().put(prop.getId(), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setFightProperty(int id, float value) {
|
|
|
|
this.getFightProperties().put(id, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addFightProperty(FightProperty prop, float value) {
|
|
|
|
this.getFightProperties().put(prop.getId(), getFightProperty(prop) + value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getFightProperty(FightProperty prop) {
|
|
|
|
return getFightProperties().getOrDefault(prop.getId(), 0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Integer> getTalentIdList() {
|
|
|
|
return talentIdList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCoreProudSkillLevel() {
|
|
|
|
return coreProudSkillLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCoreProudSkillLevel(int constLevel) {
|
|
|
|
this.coreProudSkillLevel = constLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Integer> getProudSkillList() {
|
|
|
|
return proudSkillList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFlyCloak() {
|
|
|
|
return flyCloak;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFlyCloak(int flyCloak) {
|
|
|
|
this.flyCloak = flyCloak;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCostume() {
|
|
|
|
return costume;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCostume(int costume) {
|
|
|
|
this.costume = costume;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getBornTime() {
|
|
|
|
return bornTime;
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public boolean equipItem(GameItem item, boolean shouldRecalc) {
|
2022-05-04 08:45:41 +00:00
|
|
|
// Sanity check equip type
|
2022-04-17 12:43:07 +00:00
|
|
|
EquipType itemEquipType = item.getItemData().getEquipType();
|
|
|
|
if (itemEquipType == EquipType.EQUIP_NONE) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-05-04 08:45:41 +00:00
|
|
|
|
|
|
|
// Check if other avatars have this item equipped
|
|
|
|
Avatar otherAvatar = getPlayer().getAvatars().getAvatarById(item.getEquipCharacter());
|
|
|
|
if (otherAvatar != null) {
|
|
|
|
// Unequip other avatar's item
|
|
|
|
if (otherAvatar.unequipItem(item.getItemData().getEquipType())) {
|
|
|
|
getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType()));
|
|
|
|
}
|
|
|
|
// Swap with other avatar
|
|
|
|
if (getEquips().containsKey(itemEquipType.getValue())) {
|
|
|
|
GameItem toSwap = this.getEquipBySlot(itemEquipType);
|
|
|
|
otherAvatar.equipItem(toSwap, false);
|
|
|
|
}
|
|
|
|
// Recalc
|
|
|
|
otherAvatar.recalcStats();
|
|
|
|
} else if (getEquips().containsKey(itemEquipType.getValue())) {
|
|
|
|
// Unequip item in current slot if it exists
|
2022-04-17 12:43:07 +00:00
|
|
|
unequipItem(itemEquipType);
|
|
|
|
}
|
|
|
|
|
2022-05-04 08:45:41 +00:00
|
|
|
// Set equip
|
2022-04-17 12:43:07 +00:00
|
|
|
getEquips().put(itemEquipType.getValue(), item);
|
|
|
|
|
|
|
|
if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) {
|
|
|
|
item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
|
|
|
}
|
|
|
|
|
|
|
|
item.setEquipCharacter(this.getAvatarId());
|
|
|
|
item.save();
|
|
|
|
|
2022-04-21 04:03:18 +00:00
|
|
|
if (this.getPlayer().hasSentAvatarDataNotify()) {
|
|
|
|
this.getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(this, item));
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
if (shouldRecalc) {
|
|
|
|
this.recalcStats();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean unequipItem(EquipType slot) {
|
2022-04-27 04:21:57 +00:00
|
|
|
GameItem item = getEquips().remove(slot.getValue());
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
if (item != null) {
|
|
|
|
item.setEquipCharacter(0);
|
|
|
|
item.save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void recalcStats() {
|
2022-04-21 04:03:18 +00:00
|
|
|
recalcStats(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void recalcStats(boolean forceSendAbilityChange) {
|
2022-04-17 12:43:07 +00:00
|
|
|
// Setup
|
|
|
|
AvatarData data = this.getAvatarData();
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarPromoteData promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel());
|
2022-04-17 12:43:07 +00:00
|
|
|
Int2IntOpenHashMap setMap = new Int2IntOpenHashMap();
|
2022-04-21 04:03:18 +00:00
|
|
|
|
|
|
|
// Extra ability embryos
|
|
|
|
Set<String> prevExtraAbilityEmbryos = this.getExtraAbilityEmbryos();
|
|
|
|
this.extraAbilityEmbryos = new HashSet<>();
|
2022-04-21 23:37:25 +00:00
|
|
|
|
|
|
|
// Fetters
|
|
|
|
this.setFetterList(data.getFetters());
|
2022-04-23 13:03:29 +00:00
|
|
|
this.setNameCardRewardId(data.getNameCardRewardId());
|
2022-04-23 15:48:06 +00:00
|
|
|
this.setNameCardId(data.getNameCardId());
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
// Get hp percent, set to 100% if none
|
|
|
|
float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
|
|
|
|
2022-05-20 03:01:41 +00:00
|
|
|
// Store current energy value for later
|
2022-05-21 17:43:55 +00:00
|
|
|
float currentEnergy = (this.getSkillDepot() != null) ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) : 0f;
|
2022-05-20 03:01:41 +00:00
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
// Clear properties
|
|
|
|
this.getFightProperties().clear();
|
|
|
|
|
|
|
|
// Base stats
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel()));
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel()));
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel()));
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical());
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt());
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f);
|
|
|
|
|
|
|
|
if (promoteData != null) {
|
|
|
|
for (FightPropData fightPropData : promoteData.getAddProps()) {
|
|
|
|
this.addFightProperty(fightPropData.getProp(), fightPropData.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set energy usage
|
2022-05-24 20:29:28 +00:00
|
|
|
setCurrentEnergy(currentEnergy);
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
// Artifacts
|
|
|
|
for (int slotId = 1; slotId <= 5; slotId++) {
|
|
|
|
// Get artifact
|
2022-04-27 04:21:57 +00:00
|
|
|
GameItem equip = this.getEquipBySlot(slotId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (equip == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Artifact main stat
|
2022-04-27 04:21:57 +00:00
|
|
|
ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (mainPropData != null) {
|
2022-04-27 04:21:57 +00:00
|
|
|
ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (levelData != null) {
|
|
|
|
this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Artifact sub stats
|
|
|
|
for (int appendPropId : equip.getAppendPropIdList()) {
|
2022-04-27 04:21:57 +00:00
|
|
|
ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get(appendPropId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (affixData != null) {
|
|
|
|
this.addFightProperty(affixData.getFightProp(), affixData.getPropValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Set bonus
|
|
|
|
if (equip.getItemData().getSetId() > 0) {
|
|
|
|
setMap.addTo(equip.getItemData().getSetId(), 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set stuff
|
|
|
|
for (Int2IntOpenHashMap.Entry e : setMap.int2IntEntrySet()) {
|
2022-04-27 04:21:57 +00:00
|
|
|
ReliquarySetData setData = GameData.getReliquarySetDataMap().get(e.getIntKey());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (setData == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate how many items are from the set
|
|
|
|
int amount = e.getIntValue();
|
|
|
|
|
|
|
|
// Add affix data from set bonus
|
|
|
|
for (int setIndex = 0; setIndex < setData.getSetNeedNum().length; setIndex++) {
|
|
|
|
if (amount >= setData.getSetNeedNum()[setIndex]) {
|
|
|
|
int affixId = (setData.getEquipAffixId() * 10) + setIndex;
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (affix == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add properties from this affix to our avatar
|
|
|
|
for (FightPropData prop : affix.getAddProps()) {
|
|
|
|
this.addFightProperty(prop.getProp(), prop.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add any skill strings from this affix
|
2022-04-21 04:03:18 +00:00
|
|
|
this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true);
|
2022-04-17 12:43:07 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Weapon
|
2022-04-27 04:21:57 +00:00
|
|
|
GameItem weapon = this.getWeapon();
|
2022-04-17 12:43:07 +00:00
|
|
|
if (weapon != null) {
|
|
|
|
// Add stats
|
2022-04-27 04:21:57 +00:00
|
|
|
WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (curveData != null) {
|
|
|
|
for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) {
|
|
|
|
this.addFightProperty(weaponProperty.getFightProp(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Weapon promotion stats
|
2022-04-27 04:21:57 +00:00
|
|
|
WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (wepPromoteData != null) {
|
|
|
|
for (FightPropData prop : wepPromoteData.getAddProps()) {
|
|
|
|
if (prop.getValue() == 0f || prop.getProp() == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
this.addFightProperty(prop.getProp(), prop.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add weapon skill from affixes
|
|
|
|
if (weapon.getAffixes() != null && weapon.getAffixes().size() > 0) {
|
|
|
|
// Weapons usually dont have more than one affix but just in case...
|
|
|
|
for (int af : weapon.getAffixes()) {
|
|
|
|
if (af == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Calculate affix id
|
|
|
|
int affixId = (af * 10) + weapon.getRefinement();
|
2022-04-27 04:21:57 +00:00
|
|
|
EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (affix == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add properties from this affix to our avatar
|
|
|
|
for (FightPropData prop : affix.getAddProps()) {
|
|
|
|
this.addFightProperty(prop.getProp(), prop.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add any skill strings from this affix
|
2022-04-21 04:03:18 +00:00
|
|
|
this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 09:06:58 +00:00
|
|
|
// Add proud skills and unlock them if needed
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId());
|
2022-04-19 09:06:58 +00:00
|
|
|
this.getProudSkillList().clear();
|
|
|
|
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
|
|
|
|
if (openData.getProudSkillGroupId() == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) {
|
|
|
|
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
|
2022-04-27 04:21:57 +00:00
|
|
|
if (GameData.getProudSkillDataMap().containsKey(proudSkillId)) {
|
2022-04-19 09:06:58 +00:00
|
|
|
this.getProudSkillList().add(proudSkillId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
// Proud skills
|
|
|
|
for (int proudSkillId : this.getProudSkillList()) {
|
2022-04-27 04:21:57 +00:00
|
|
|
ProudSkillData proudSkillData = GameData.getProudSkillDataMap().get(proudSkillId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (proudSkillData == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add properties from this proud skill to our avatar
|
|
|
|
for (FightPropData prop : proudSkillData.getAddProps()) {
|
|
|
|
this.addFightProperty(prop.getProp(), prop.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add any skill strings from this proud skill
|
2022-04-21 04:03:18 +00:00
|
|
|
this.addToExtraAbilityEmbryos(proudSkillData.getOpenConfig(), true);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Constellations
|
|
|
|
if (this.getTalentIdList().size() > 0) {
|
|
|
|
for (int talentId : this.getTalentIdList()) {
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarTalentData avatarTalentData = GameData.getAvatarTalentDataMap().get(talentId);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (avatarTalentData == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add any skill strings from this constellation
|
2022-04-21 04:03:18 +00:00
|
|
|
this.addToExtraAbilityEmbryos(avatarTalentData.getOpenConfig(), false);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set % stats
|
|
|
|
this.setFightProperty(
|
|
|
|
FightProperty.FIGHT_PROP_MAX_HP,
|
|
|
|
(getFightProperty(FightProperty.FIGHT_PROP_BASE_HP) * (1f + getFightProperty(FightProperty.FIGHT_PROP_HP_PERCENT))) + getFightProperty(FightProperty.FIGHT_PROP_HP)
|
|
|
|
);
|
|
|
|
this.setFightProperty(
|
|
|
|
FightProperty.FIGHT_PROP_CUR_ATTACK,
|
|
|
|
(getFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK) * (1f + getFightProperty(FightProperty.FIGHT_PROP_ATTACK_PERCENT))) + getFightProperty(FightProperty.FIGHT_PROP_ATTACK)
|
|
|
|
);
|
|
|
|
this.setFightProperty(
|
|
|
|
FightProperty.FIGHT_PROP_CUR_DEFENSE,
|
|
|
|
(getFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE) * (1f + getFightProperty(FightProperty.FIGHT_PROP_DEFENSE_PERCENT))) + getFightProperty(FightProperty.FIGHT_PROP_DEFENSE)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Set current hp
|
|
|
|
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent);
|
|
|
|
|
|
|
|
// Packet
|
|
|
|
if (getPlayer() != null && getPlayer().hasSentAvatarDataNotify()) {
|
2022-04-21 04:03:18 +00:00
|
|
|
// Update stats for client
|
2022-04-17 12:43:07 +00:00
|
|
|
getPlayer().sendPacket(new PacketAvatarFightPropNotify(this));
|
2022-04-21 04:03:18 +00:00
|
|
|
// Update client abilities
|
|
|
|
EntityAvatar entity = this.getAsEntity();
|
|
|
|
if (entity != null && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) || forceSendAbilityChange)) {
|
|
|
|
getPlayer().sendPacket(new PacketAbilityChangeNotify(entity));
|
|
|
|
}
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 04:03:18 +00:00
|
|
|
public void addToExtraAbilityEmbryos(String openConfig, boolean forceAdd) {
|
2022-04-17 12:43:07 +00:00
|
|
|
if (openConfig == null || openConfig.length() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
OpenConfigEntry entry = GameData.getOpenConfigEntries().get(openConfig);
|
2022-04-17 12:43:07 +00:00
|
|
|
if (entry == null) {
|
|
|
|
if (forceAdd) {
|
|
|
|
// Add config string to ability skill list anyways
|
2022-04-21 04:03:18 +00:00
|
|
|
this.getExtraAbilityEmbryos().add(openConfig);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.getAddAbilities() != null) {
|
|
|
|
for (String ability : entry.getAddAbilities()) {
|
2022-04-21 04:03:18 +00:00
|
|
|
this.getExtraAbilityEmbryos().add(ability);
|
2022-04-17 12:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-01 02:34:50 +00:00
|
|
|
public void recalcConstellations() {
|
2022-04-17 12:43:07 +00:00
|
|
|
// Clear first
|
|
|
|
this.getProudSkillBonusMap().clear();
|
2022-05-01 02:34:50 +00:00
|
|
|
this.getSkillExtraChargeMap().clear();
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
// Sanity checks
|
|
|
|
if (getData() == null || getData().getSkillDepot() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.getTalentIdList().size() > 0) {
|
|
|
|
for (int talentId : this.getTalentIdList()) {
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarTalentData avatarTalentData = GameData.getAvatarTalentDataMap().get(talentId);
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
if (avatarTalentData == null || avatarTalentData.getOpenConfig() == null || avatarTalentData.getOpenConfig().length() == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get open config to find which skill should be boosted
|
2022-04-27 04:21:57 +00:00
|
|
|
OpenConfigEntry entry = GameData.getOpenConfigEntries().get(avatarTalentData.getOpenConfig());
|
2022-04-17 12:43:07 +00:00
|
|
|
if (entry == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-05-01 02:34:50 +00:00
|
|
|
// Check if we can add charges to a skill
|
|
|
|
if (entry.getSkillPointModifiers() != null) {
|
|
|
|
for (SkillPointModifier mod : entry.getSkillPointModifiers()) {
|
|
|
|
AvatarSkillData skillData = GameData.getAvatarSkillDataMap().get(mod.getSkillId());
|
|
|
|
|
|
|
|
if (skillData == null) continue;
|
|
|
|
|
|
|
|
int charges = skillData.getMaxChargeNum() + mod.getDelta();
|
|
|
|
|
|
|
|
this.getSkillExtraChargeMap().put(mod.getSkillId(), charges);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a skill can be boosted by +3 levels
|
2022-04-17 12:43:07 +00:00
|
|
|
int skillId = 0;
|
|
|
|
|
|
|
|
if (entry.getExtraTalentIndex() == 2 && this.getData().getSkillDepot().getSkills().size() >= 2) {
|
|
|
|
// E skill
|
|
|
|
skillId = this.getData().getSkillDepot().getSkills().get(1);
|
|
|
|
} else if (entry.getExtraTalentIndex() == 9) {
|
|
|
|
// Ult skill
|
|
|
|
skillId = this.getData().getSkillDepot().getEnergySkill();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
if (skillId == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get proud skill group id
|
2022-04-27 04:21:57 +00:00
|
|
|
AvatarSkillData skillData = GameData.getAvatarSkillDataMap().get(skillId);
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
if (skillData == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add to bonus list
|
|
|
|
this.getProudSkillBonusMap().put(skillData.getProudSkillGroupId(), 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityAvatar getAsEntity() {
|
|
|
|
for (EntityAvatar entity : getPlayer().getTeamManager().getActiveTeam()) {
|
|
|
|
if (entity.getAvatar() == this) {
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEntityId() {
|
|
|
|
EntityAvatar entity = getAsEntity();
|
|
|
|
return entity != null ? entity.getId() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void save() {
|
|
|
|
DatabaseHelper.saveAvatar(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AvatarInfo toProto() {
|
2022-04-24 07:02:31 +00:00
|
|
|
int fetterLevel = this.getFetterLevel();
|
2022-04-21 23:37:25 +00:00
|
|
|
AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder()
|
2022-04-24 07:02:31 +00:00
|
|
|
.setExpLevel(fetterLevel);
|
|
|
|
|
|
|
|
if (fetterLevel != 10) {
|
|
|
|
avatarFetter.setExpNumber(this.getFetterExp());
|
|
|
|
}
|
|
|
|
|
2022-04-21 23:37:25 +00:00
|
|
|
|
2022-04-22 00:30:02 +00:00
|
|
|
if (this.getFetterList() != null) {
|
|
|
|
for (int i = 0; i < this.getFetterList().size(); i++) {
|
|
|
|
avatarFetter.addFetterList(
|
|
|
|
FetterData.newBuilder()
|
|
|
|
.setFetterId(this.getFetterList().get(i))
|
|
|
|
.setFetterState(FetterState.FINISH.getValue())
|
|
|
|
);
|
|
|
|
}
|
2022-04-21 23:37:25 +00:00
|
|
|
}
|
|
|
|
|
2022-04-23 15:48:06 +00:00
|
|
|
int cardId = this.getNameCardId();
|
|
|
|
|
|
|
|
if (this.getPlayer().getNameCardList().contains(cardId)) {
|
2022-04-24 07:02:31 +00:00
|
|
|
avatarFetter.addRewardedFetterLevelList(10);
|
2022-04-23 15:48:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-17 12:43:07 +00:00
|
|
|
AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder()
|
|
|
|
.setAvatarId(this.getAvatarId())
|
|
|
|
.setGuid(this.getGuid())
|
|
|
|
.setLifeState(1)
|
|
|
|
.addAllTalentIdList(this.getTalentIdList())
|
|
|
|
.putAllFightPropMap(this.getFightProperties())
|
|
|
|
.setSkillDepotId(this.getSkillDepotId())
|
|
|
|
.setCoreProudSkillLevel(this.getCoreProudSkillLevel())
|
|
|
|
.putAllSkillLevelMap(this.getSkillLevelMap())
|
|
|
|
.addAllInherentProudSkillList(this.getProudSkillList())
|
2022-04-26 21:44:30 +00:00
|
|
|
.putAllProudSkillExtraLevelMap(getProudSkillBonusMap())
|
2022-04-17 12:43:07 +00:00
|
|
|
.setAvatarType(1)
|
|
|
|
.setBornTime(this.getBornTime())
|
2022-04-21 23:37:25 +00:00
|
|
|
.setFetterInfo(avatarFetter)
|
2022-04-17 12:43:07 +00:00
|
|
|
.setWearingFlycloakId(this.getFlyCloak())
|
|
|
|
.setCostumeId(this.getCostume());
|
|
|
|
|
2022-05-01 02:34:50 +00:00
|
|
|
for (Entry<Integer, Integer> entry : this.getSkillExtraChargeMap().entrySet()) {
|
|
|
|
avatarInfo.putSkillMap(entry.getKey(), AvatarSkillInfo.newBuilder().setMaxChargeCount(entry.getValue()).build());
|
|
|
|
}
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
for (GameItem item : this.getEquips().values()) {
|
2022-04-17 12:43:07 +00:00
|
|
|
avatarInfo.addEquipGuidList(item.getGuid());
|
|
|
|
}
|
|
|
|
|
|
|
|
avatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()));
|
|
|
|
avatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp()));
|
|
|
|
avatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel()));
|
|
|
|
avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, 0));
|
|
|
|
avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, 0));
|
|
|
|
|
|
|
|
return avatarInfo.build();
|
|
|
|
}
|
2022-04-30 17:04:36 +00:00
|
|
|
|
|
|
|
// used only in character showcase
|
|
|
|
public ShowAvatarInfo toShowAvatarInfoProto() {
|
|
|
|
AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder()
|
|
|
|
.setExpLevel(this.getFetterLevel());
|
|
|
|
|
|
|
|
ShowAvatarInfo.Builder showAvatarInfo = ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder()
|
|
|
|
.setAvatarId(avatarId)
|
|
|
|
.addAllTalentIdList(this.getTalentIdList())
|
|
|
|
.putAllFightPropMap(this.getFightProperties())
|
|
|
|
.setSkillDepotId(this.getSkillDepotId())
|
|
|
|
.setCoreProudSkillLevel(this.getCoreProudSkillLevel())
|
|
|
|
.addAllInherentProudSkillList(this.getProudSkillList())
|
|
|
|
.putAllSkillLevelMap(this.getSkillLevelMap())
|
|
|
|
.putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap())
|
|
|
|
.setFetterInfo(avatarFetter)
|
|
|
|
.setCostumeId(this.getCostume());
|
|
|
|
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()));
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp()));
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel()));
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation()));
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiationPenalty()));
|
|
|
|
int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA);
|
|
|
|
showAvatarInfo.putPropMap(PlayerProperty.PROP_MAX_STAMINA.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina));
|
|
|
|
|
|
|
|
for (GameItem item : this.getEquips().values()) {
|
|
|
|
if (item.getItemType() == ItemType.ITEM_RELIQUARY) {
|
|
|
|
showAvatarInfo.addEquipList(ShowEquip.newBuilder()
|
|
|
|
.setItemId(item.getItemId())
|
|
|
|
.setReliquary(item.toReliquaryProto()));
|
|
|
|
} else if (item.getItemType() == ItemType.ITEM_WEAPON) {
|
|
|
|
showAvatarInfo.addEquipList(ShowEquip.newBuilder()
|
|
|
|
.setItemId(item.getItemId())
|
|
|
|
.setWeapon(item.toWeaponProto()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return showAvatarInfo.build();
|
|
|
|
}
|
2022-04-17 12:43:07 +00:00
|
|
|
|
|
|
|
@PostLoad
|
|
|
|
private void onLoad() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@PrePersist
|
|
|
|
private void prePersist() {
|
|
|
|
this.currentHp = this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
|
|
|
|
}
|
|
|
|
}
|