Rename and clean up MapleMonsterStats
This commit is contained in:
@@ -23,7 +23,7 @@ public class ChangeableStats extends OverrideMonsterStats {
|
||||
|
||||
public int watk, matk, wdef, mdef, level;
|
||||
|
||||
public ChangeableStats(MapleMonsterStats stats, OverrideMonsterStats ostats) {
|
||||
public ChangeableStats(MonsterStats stats, OverrideMonsterStats ostats) {
|
||||
hp = ostats.getHp();
|
||||
exp = ostats.getExp();
|
||||
mp = ostats.getMp();
|
||||
@@ -34,7 +34,7 @@ public class ChangeableStats extends OverrideMonsterStats {
|
||||
level = stats.getLevel();
|
||||
}
|
||||
|
||||
public ChangeableStats(MapleMonsterStats stats, int newLevel, boolean pqMob) { // here we go i think
|
||||
public ChangeableStats(MonsterStats stats, int newLevel, boolean pqMob) { // here we go i think
|
||||
final double mod = (double) newLevel / (double) stats.getLevel();
|
||||
final double hpRatio = (double) stats.getHp() / (double) stats.getExp();
|
||||
final double pqMod = (pqMob ? 1.5 : 1.0); // god damn
|
||||
@@ -48,7 +48,7 @@ public class ChangeableStats extends OverrideMonsterStats {
|
||||
level = newLevel;
|
||||
}
|
||||
|
||||
public ChangeableStats(MapleMonsterStats stats, float statModifier, boolean pqMob) {
|
||||
public ChangeableStats(MonsterStats stats, float statModifier, boolean pqMob) {
|
||||
this(stats, (int)(statModifier * stats.getLevel()), pqMob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class LifeFactory {
|
||||
private final static DataProvider stringDataWZ = DataProviderFactory.getDataProvider(WZFiles.STRING);
|
||||
private static final Data mobStringData = stringDataWZ.getData("Mob.img");
|
||||
private static final Data npcStringData = stringDataWZ.getData("Npc.img");
|
||||
private static final Map<Integer, MapleMonsterStats> monsterStats = new HashMap<>();
|
||||
private static final Map<Integer, MonsterStats> monsterStats = new HashMap<>();
|
||||
private static final Set<Integer> hpbarBosses = getHpBarBosses();
|
||||
|
||||
private static Set<Integer> getHpBarBosses() {
|
||||
@@ -89,7 +89,7 @@ public class LifeFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static Pair<MapleMonsterStats, List<MobAttackInfoHolder>> getMonsterStats(int mid) {
|
||||
private static Pair<MonsterStats, List<MobAttackInfoHolder>> getMonsterStats(int mid) {
|
||||
Data monsterData = data.getData(StringUtil.getLeftPaddedStr(mid + ".img", '0', 11));
|
||||
if (monsterData == null) {
|
||||
return null;
|
||||
@@ -97,11 +97,11 @@ public class LifeFactory {
|
||||
Data monsterInfoData = monsterData.getChildByPath("info");
|
||||
|
||||
List<MobAttackInfoHolder> attackInfos = new LinkedList<>();
|
||||
MapleMonsterStats stats = new MapleMonsterStats();
|
||||
MonsterStats stats = new MonsterStats();
|
||||
|
||||
int linkMid = DataTool.getIntConvert("link", monsterInfoData, 0);
|
||||
if (linkMid != 0) {
|
||||
Pair<MapleMonsterStats, List<MobAttackInfoHolder>> linkStats = getMonsterStats(linkMid);
|
||||
Pair<MonsterStats, List<MobAttackInfoHolder>> linkStats = getMonsterStats(linkMid);
|
||||
if (linkStats == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -239,9 +239,9 @@ public class LifeFactory {
|
||||
|
||||
public static Monster getMonster(int mid) {
|
||||
try {
|
||||
MapleMonsterStats stats = monsterStats.get(mid);
|
||||
MonsterStats stats = monsterStats.get(mid);
|
||||
if (stats == null) {
|
||||
Pair<MapleMonsterStats, List<MobAttackInfoHolder>> mobStats = getMonsterStats(mid);
|
||||
Pair<MonsterStats, List<MobAttackInfoHolder>> mobStats = getMonsterStats(mid);
|
||||
stats = mobStats.getLeft();
|
||||
setMonsterAttackInfo(mid, mobStats.getRight());
|
||||
|
||||
@@ -259,7 +259,7 @@ public class LifeFactory {
|
||||
|
||||
public static int getMonsterLevel(int mid) {
|
||||
try {
|
||||
MapleMonsterStats stats = monsterStats.get(mid);
|
||||
MonsterStats stats = monsterStats.get(mid);
|
||||
if (stats == null) {
|
||||
Data monsterData = data.getData(StringUtil.getLeftPaddedStr(mid + ".img", '0', 11));
|
||||
if (monsterData == null) {
|
||||
@@ -278,7 +278,7 @@ public class LifeFactory {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static void decodeElementalString(MapleMonsterStats stats, String elemAttr) {
|
||||
private static void decodeElementalString(MonsterStats stats, String elemAttr) {
|
||||
for (int i = 0; i < elemAttr.length(); i += 2) {
|
||||
stats.setEffectiveness(Element.getFromChar(elemAttr.charAt(i)), ElementalEffectiveness.getByNumber(Integer.parseInt(String.valueOf(elemAttr.charAt(i + 1)))));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
public class Monster extends AbstractLoadedLife {
|
||||
|
||||
private ChangeableStats ostats = null; //unused, v83 WZs offers no support for changeable stats.
|
||||
private MapleMonsterStats stats;
|
||||
private MonsterStats stats;
|
||||
private final AtomicInteger hp = new AtomicInteger(1);
|
||||
private final AtomicLong maxHpPlusHeal = new AtomicLong(1);
|
||||
private int mp;
|
||||
@@ -100,7 +100,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
private MonitoredReentrantLock animationLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MOB_ANI);
|
||||
private final MonitoredReentrantLock aggroUpdateLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MOB_AGGRO);
|
||||
|
||||
public Monster(int id, MapleMonsterStats stats) {
|
||||
public Monster(int id, MonsterStats stats) {
|
||||
super(id);
|
||||
initWithStats(stats);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
externalLock.unlock();
|
||||
}
|
||||
|
||||
private void initWithStats(MapleMonsterStats baseStats) {
|
||||
private void initWithStats(MonsterStats baseStats) {
|
||||
setStance(5);
|
||||
this.stats = baseStats.copy();
|
||||
hp.set(stats.getHp());
|
||||
@@ -277,7 +277,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
this.VenomMultiplier = multiplier;
|
||||
}
|
||||
|
||||
public MapleMonsterStats getStats() {
|
||||
public MonsterStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author Frz
|
||||
*/
|
||||
public class MapleMonsterStats {
|
||||
public class MonsterStats {
|
||||
public boolean changeable;
|
||||
public int exp, hp, mp, level, PADamage, PDDamage, MADamage, MDDamage, dropPeriod, cp, buffToGive = -1, removeAfter;
|
||||
public boolean boss, undead, ffaLoot, isExplosiveReward, firstAttack, removeOnMiss;
|
||||
@@ -56,7 +56,7 @@ public class MapleMonsterStats {
|
||||
public boolean isChangeable() {
|
||||
return changeable;
|
||||
}
|
||||
|
||||
|
||||
public int getExp() {
|
||||
return exp;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class MapleMonsterStats {
|
||||
for (int i = this.skills.size(); i < skills.size(); i++) {
|
||||
this.skills.add(null);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < skills.size(); i++) {
|
||||
this.skills.set(i, skills.get(i));
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class MapleMonsterStats {
|
||||
public void setSelfDestruction(selfDestruction sd) {
|
||||
this.selfDestruction = sd;
|
||||
}
|
||||
|
||||
|
||||
public void setExplosiveReward(boolean isExplosiveReward) {
|
||||
this.isExplosiveReward = isExplosiveReward;
|
||||
}
|
||||
@@ -303,49 +303,49 @@ public class MapleMonsterStats {
|
||||
public Pair<Integer, Integer> getCool() {
|
||||
return cool;
|
||||
}
|
||||
|
||||
|
||||
public int getPDDamage() {
|
||||
return PDDamage;
|
||||
}
|
||||
|
||||
|
||||
public int getMADamage() {
|
||||
return MADamage;
|
||||
}
|
||||
|
||||
|
||||
public int getMDDamage() {
|
||||
return MDDamage;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFriendly() {
|
||||
return friendly;
|
||||
}
|
||||
|
||||
|
||||
public void setFriendly(boolean value) {
|
||||
this.friendly = value;
|
||||
}
|
||||
|
||||
|
||||
public void setPDDamage(int PDDamage) {
|
||||
this.PDDamage = PDDamage;
|
||||
}
|
||||
|
||||
|
||||
public void setMADamage(int MADamage) {
|
||||
this.MADamage = MADamage;
|
||||
}
|
||||
|
||||
|
||||
public void setMDDamage(int MDDamage) {
|
||||
this.MDDamage = MDDamage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getFixedStance() {
|
||||
return this.fixedStance;
|
||||
}
|
||||
|
||||
|
||||
public void setFixedStance(int stance) {
|
||||
this.fixedStance = stance;
|
||||
}
|
||||
|
||||
public MapleMonsterStats copy() {
|
||||
MapleMonsterStats copy = new MapleMonsterStats();
|
||||
|
||||
public MonsterStats copy() {
|
||||
MonsterStats copy = new MonsterStats();
|
||||
try {
|
||||
FieldCopyUtil.setFields(this, copy);
|
||||
} catch (Exception e) {
|
||||
@@ -353,14 +353,14 @@ public class MapleMonsterStats {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (Exception ex) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
// FieldCopyUtil src: http://www.codesenior.com/en/tutorial/Java-Copy-Fields-From-One-Object-to-Another-Object-with-Reflection
|
||||
private static class FieldCopyUtil { // thanks to Codesenior dev team
|
||||
private static void setFields(Object from, Object to) {
|
||||
Reference in New Issue
Block a user