Rename and clean up MapleStatEffect

This commit is contained in:
P0nk
2021-09-09 22:51:02 +02:00
parent ca4bcd80d1
commit 18e1f6c50b
21 changed files with 225 additions and 231 deletions

View File

@@ -67,7 +67,7 @@ public class ItemInformationProvider {
protected Data insStringData;
protected Data petStringData;
protected Map<Integer, Short> slotMaxCache = new HashMap<>();
protected Map<Integer, MapleStatEffect> itemEffects = new HashMap<>();
protected Map<Integer, StatEffect> itemEffects = new HashMap<>();
protected Map<Integer, Map<String, Integer>> equipStatsCache = new HashMap<>();
protected Map<Integer, Equip> equipCache = new HashMap<>();
protected Map<Integer, Data> equipLevelInfoCache = new HashMap<>();
@@ -1258,8 +1258,8 @@ public class ItemInformationProvider {
return equip;
}
public MapleStatEffect getItemEffect(int itemId) {
MapleStatEffect ret = itemEffects.get(Integer.valueOf(itemId));
public StatEffect getItemEffect(int itemId) {
StatEffect ret = itemEffects.get(Integer.valueOf(itemId));
if (ret == null) {
Data item = getItemData(itemId);
if (item == null) {
@@ -1269,7 +1269,7 @@ public class ItemInformationProvider {
if (spec == null) {
spec = item.getChildByPath("spec");
}
ret = MapleStatEffect.loadItemEffectFromData(spec, itemId);
ret = StatEffect.loadItemEffectFromData(spec, itemId);
itemEffects.put(Integer.valueOf(itemId), ret);
}
return ret;

View File

@@ -57,8 +57,7 @@ import java.util.*;
* @author Frz
* @author Ronan
*/
public class MapleStatEffect {
public class StatEffect {
private short watk, matk, wdef, mdef, acc, avoid, speed, jump;
private short hp, mp;
private double hpR, mpR;
@@ -82,52 +81,50 @@ public class MapleStatEffect {
private short bulletCount, bulletConsume;
private byte mapProtection;
private CardItemupStats cardStats;
private static class CardItemupStats {
protected int itemCode, prob;
protected boolean party;
private List<Pair<Integer, Integer>> areas;
private final List<Pair<Integer, Integer>> areas;
private CardItemupStats(int code, int prob, List<Pair<Integer, Integer>> areas, boolean inParty) {
this.itemCode = code;
this.prob = prob;
this.areas = areas;
this.party = inParty;
}
private boolean isInArea(int mapid) {
if (this.areas == null) {
return true;
}
for (Pair<Integer, Integer> a : this.areas) {
if (mapid >= a.left && mapid <= a.right) {
return true;
}
}
return false;
}
}
private boolean isEffectActive(int mapid, boolean partyHunting) {
if (cardStats == null) return true;
if (cardStats == null) {
return true;
}
if (!cardStats.isInArea(mapid)) {
return false;
}
if (cardStats.party && !partyHunting) {
return false;
}
return true;
return !cardStats.party || partyHunting;
}
public boolean isActive(Character applyto) {
return isEffectActive(applyto.getMapId(), applyto.getPartyMembersOnSameMap().size() > 1);
}
public int getCardRate(int mapid, int itemid) {
if (cardStats != null) {
if (cardStats.itemCode == Integer.MAX_VALUE) {
@@ -142,15 +139,15 @@ public class MapleStatEffect {
}
}
}
return 0;
}
public static MapleStatEffect loadSkillEffectFromData(Data source, int skillid, boolean overtime) {
public static StatEffect loadSkillEffectFromData(Data source, int skillid, boolean overtime) {
return loadFromData(source, skillid, true, overtime);
}
public static MapleStatEffect loadItemEffectFromData(Data source, int itemid) {
public static StatEffect loadItemEffectFromData(Data source, int itemid) {
return loadFromData(source, itemid, false, false);
}
@@ -170,8 +167,8 @@ public class MapleStatEffect {
}
}
private static MapleStatEffect loadFromData(Data source, int sourceid, boolean skill, boolean overTime) {
MapleStatEffect ret = new MapleStatEffect();
private static StatEffect loadFromData(Data source, int sourceid, boolean skill, boolean overTime) {
StatEffect ret = new StatEffect();
ret.duration = DataTool.getIntConvert("time", source, -1);
ret.hp = (short) DataTool.getInt("hp", source, 0);
ret.hpR = DataTool.getInt("hpR", source, 0) / 100.0;
@@ -220,10 +217,10 @@ public class MapleStatEffect {
ret.mobSkillLevel = 0;
ret.target = 0;
}
Data mdds = source.getChildByPath("mob");
if (mdds != null) {
if (mdds.getChildren()!= null && mdds.getChildren().size() > 0) {
if (mdds.getChildren() != null && mdds.getChildren().size() > 0) {
ret.mob = DataTool.getInt("mob", mdds, 0);
}
}
@@ -249,10 +246,10 @@ public class MapleStatEffect {
ret.barrier = DataTool.getInt("barrier", source, 0);
addBuffStatPairToListIfNotZero(statups, BuffStat.AURA, ret.barrier);
ret.mapProtection = mapProtection(sourceid);
addBuffStatPairToListIfNotZero(statups, BuffStat.MAP_PROTECTION, (int) ret.mapProtection);
if (ret.overTime && ret.getSummonMovementType() == null) {
if (!skill) {
if (isPyramidBuff(sourceid)) {
@@ -307,14 +304,14 @@ public class MapleStatEffect {
int prob = 0, itemupCode = Integer.MAX_VALUE;
List<Pair<Integer, Integer>> areas = null;
boolean inParty = false;
Data con = source.getChildByPath("con");
if (con != null) {
areas = new ArrayList<>(3);
for (Data conData : con.getChildren()) {
int type = DataTool.getInt("type", conData, -1);
if (type == 0) {
int startMap = DataTool.getInt("sMap", conData, 0);
int endMap = DataTool.getInt("eMap", conData, 0);
@@ -324,54 +321,54 @@ public class MapleStatEffect {
inParty = true;
}
}
if (areas.isEmpty()) {
areas = null;
}
}
if (DataTool.getInt("mesoupbyitem", source, 0) != 0) {
addBuffStatPairToListIfNotZero(statups, BuffStat.MESO_UP_BY_ITEM, 4);
prob = DataTool.getInt("prob", source, 1);
}
int itemupType = DataTool.getInt("itemupbyitem", source, 0);
if (itemupType != 0) {
addBuffStatPairToListIfNotZero(statups, BuffStat.ITEM_UP_BY_ITEM, 4);
prob = DataTool.getInt("prob", source, 1);
switch (itemupType) {
case 2:
itemupCode = DataTool.getInt("itemCode", source, 1);
break;
case 3:
itemupCode = DataTool.getInt("itemRange", source, 1); // 3 digits
break;
}
}
if (DataTool.getInt("respectPimmune", source, 0) != 0) {
addBuffStatPairToListIfNotZero(statups, BuffStat.RESPECT_PIMMUNE, 4);
}
if (DataTool.getInt("respectMimmune", source, 0) != 0) {
addBuffStatPairToListIfNotZero(statups, BuffStat.RESPECT_MIMMUNE, 4);
}
if (DataTool.getString("defenseAtt", source, null) != null) {
addBuffStatPairToListIfNotZero(statups, BuffStat.DEFENSE_ATT, 4);
}
if (DataTool.getString("defenseState", source, null) != null) {
addBuffStatPairToListIfNotZero(statups, BuffStat.DEFENSE_STATE, 4);
}
int thaw = DataTool.getInt("thaw", source, 0);
if (thaw != 0) {
addBuffStatPairToListIfNotZero(statups, BuffStat.MAP_PROTECTION, thaw > 0 ? 1 : 2);
}
ret.cardStats = new CardItemupStats(itemupCode, prob, areas, inParty);
} else if (isExpIncrease(sourceid)) {
addBuffStatPairToListIfNotZero(statups, BuffStat.EXP_INCREASE, DataTool.getInt("expinc", source, 0));
@@ -542,7 +539,7 @@ public class MapleStatEffect {
break;
case Evan.SLOW:
statups.add(new Pair<>(BuffStat.SLOW, x));
// BOWMAN
// BOWMAN
case Priest.MYSTIC_DOOR:
case Hunter.SOUL_ARROW:
case Crossbowman.SOUL_ARROW:
@@ -773,7 +770,7 @@ public class MapleStatEffect {
break;
case Evan.PHANTOM_IMPRINT:
monsterStatus.put(MonsterStatus.PHANTOM_IMPRINT, x);
//ARAN
//ARAN
case Aran.COMBO_ABILITY:
statups.add(new Pair<>(BuffStat.ARAN_COMBO, 100));
break;
@@ -811,7 +808,7 @@ public class MapleStatEffect {
/**
* @param applyto
* @param obj
* @param attack damage done by the skill
* @param attack damage done by the skill
*/
public void applyPassive(Character applyto, MapObject obj, int attack) {
if (makeChanceResult()) {
@@ -867,7 +864,7 @@ public class MapleStatEffect {
applyto.toggleHide(false);
return true;
}
if (primary && isHeal()) {
affectedPlayers = applyBuff(applyfrom, useMaxRange);
}
@@ -940,7 +937,7 @@ public class MapleStatEffect {
}
if (isShadowClaw()) {
short projectileConsume = this.getBulletConsume(); // noticed by shavit
Inventory use = applyto.getInventory(InventoryType.USE);
use.lockInventory();
try {
@@ -966,7 +963,7 @@ public class MapleStatEffect {
SummonMovementType summonMovementType = getSummonMovementType();
if (overTime || isCygnusFA() || summonMovementType != null) {
if (summonMovementType != null && pos != null) {
if (summonMovementType.getValue() == summonMovementType.STATIONARY.getValue()) {
if (summonMovementType.getValue() == SummonMovementType.STATIONARY.getValue()) {
applyto.cancelBuffStats(BuffStat.PUPPET);
} else {
applyto.cancelBuffStats(BuffStat.SUMMON);
@@ -1071,7 +1068,7 @@ public class MapleStatEffect {
} else if (mobSkill > 0 && mobSkillLevel > 0) {
MobSkill ms = MobSkillFactory.getMobSkill(mobSkill, mobSkillLevel);
Disease dis = Disease.getBySkill(mobSkill);
if (target > 0) {
for (Character chr : applyto.getMap().getAllPlayers()) {
if (chr.getId() != applyto.getId()) {
@@ -1087,7 +1084,7 @@ public class MapleStatEffect {
private int applyBuff(Character applyfrom, boolean useMaxRange) {
int affectedc = 1;
if (isPartyBuff() && (applyfrom.getParty() != null || isGmBuff())) {
Rectangle bounds = (!useMaxRange) ? calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft()) : new Rectangle(Integer.MIN_VALUE / 2, Integer.MIN_VALUE / 2, Integer.MAX_VALUE, Integer.MAX_VALUE);
List<MapObject> affecteds = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapObjectType.PLAYER));
@@ -1106,7 +1103,7 @@ public class MapleStatEffect {
}
}
}
affectedc += affectedp.size(); // used for heal
for (Character affected : affectedp) {
applyTo(applyfrom, affected, false, null, useMaxRange, affectedc);
@@ -1213,12 +1210,12 @@ public class MapleStatEffect {
}
}
}
private void applyBuffEffect(Character applyfrom, Character applyto, boolean primary) {
if (!isMonsterRiding() && !isCouponBuff() && !isMysticDoor() && !isHyperBody() && !isCombo()) { // last mystic door already dispelled if it has been used before.
applyto.cancelEffect(this, true, -1);
}
List<Pair<BuffStat, Integer>> localstatups = statups;
int localDuration = getBuffLocalDuration();
int localsourceid = sourceid;
@@ -1230,7 +1227,7 @@ public class MapleStatEffect {
if (mount != null) {
ridingMountId = mount.getItemId();
}
if (sourceid == Corsair.BATTLE_SHIP) {
ridingMountId = 1932000;
} else if (sourceid == Beginner.SPACESHIP || sourceid == Noblesse.SPACESHIP) {
@@ -1244,11 +1241,11 @@ public class MapleStatEffect {
} else if (sourceid == Beginner.BALROG_MOUNT || sourceid == Noblesse.BALROG_MOUNT || sourceid == Legend.BALROG_MOUNT) {
ridingMountId = 1932010;
}
// thanks inhyuk for noticing some skill mounts not acting properly for other players when changing maps
givemount = applyto.mount(ridingMountId, sourceid);
applyto.getClient().getWorldServer().registerMountHunger(applyto);
localDuration = sourceid;
localsourceid = ridingMountId;
localstatups = Collections.singletonList(new Pair<>(BuffStat.MONSTER_RIDING, 0));
@@ -1286,8 +1283,10 @@ public class MapleStatEffect {
mbuff = PacketCreator.giveForeignBuff(applyto.getId(), dsstat);
} else if (isCombo()) {
Integer comboCount = applyto.getBuffedValue(BuffStat.COMBO);
if (comboCount == null) comboCount = 0;
if (comboCount == null) {
comboCount = 0;
}
List<Pair<BuffStat, Integer>> cbstat = Collections.singletonList(new Pair<>(BuffStat.COMBO, comboCount));
buff = PacketCreator.giveBuff((skill ? sourceid : -sourceid), localDuration, cbstat);
mbuff = PacketCreator.giveForeignBuff(applyto.getId(), cbstat);
@@ -1321,10 +1320,10 @@ public class MapleStatEffect {
if (buff != null) {
//Thanks flav for such a simple release! :)
//Thanks Conrad, Atoot for noticing summons not using buff icon
applyto.sendPacket(buff);
}
long starttime = Server.getInstance().getCurrentTime();
//CancelEffectAction cancelAction = new CancelEffectAction(applyto, this, starttime);
//ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, localDuration);
@@ -1422,7 +1421,7 @@ public class MapleStatEffect {
private int alchemistModifyVal(Character chr, int val, boolean withX) {
if (!skill && (chr.getJob().isA(Job.HERMIT) || chr.getJob().isA(Job.NIGHTWALKER3))) {
MapleStatEffect alchemistEffect = getAlchemistEffect(chr);
StatEffect alchemistEffect = getAlchemistEffect(chr);
if (alchemistEffect != null) {
return (int) (val * ((withX ? alchemistEffect.getX() : alchemistEffect.getY()) / 100.0));
}
@@ -1430,7 +1429,7 @@ public class MapleStatEffect {
return val;
}
private MapleStatEffect getAlchemistEffect(Character chr) {
private StatEffect getAlchemistEffect(Character chr) {
int id = Hermit.ALCHEMIST;
if (chr.isCygnus()) {
id = NightWalker.ALCHEMIST;
@@ -1488,10 +1487,8 @@ public class MapleStatEffect {
if (lt == null || rb == null) {
return false;
}
if ((sourceid >= 1211003 && sourceid <= 1211008) || sourceid == Paladin.SWORD_HOLY_CHARGE || sourceid == Paladin.BW_HOLY_CHARGE || sourceid == DawnWarrior.SOUL_CHARGE) {// wk charges have lt and rb set but are neither player nor monster buffs
return false;
}
return true;
// wk charges have lt and rb set but are neither player nor monster buffs
return (sourceid < 1211003 || sourceid > 1211008) && sourceid != Paladin.SWORD_HOLY_CHARGE && sourceid != Paladin.BW_HOLY_CHARGE && sourceid != DawnWarrior.SOUL_CHARGE;
}
private boolean isHeal() {
@@ -1550,11 +1547,11 @@ public class MapleStatEffect {
public static boolean isExpIncrease(int sourceid) {
return sourceid >= 2022450 && sourceid <= 2022452;
}
public static boolean isAriantShield(int sourceid) {
return sourceid == 2022269;
}
public static boolean isMonsterCard(int sourceid) {
int itemType = sourceid / 10000;
return itemType == 238;
@@ -1591,7 +1588,7 @@ public class MapleStatEffect {
private boolean isCouponBuff() {
return isRateCoupon(sourceid);
}
private boolean isAriantShield() {
int itemid = sourceid;
return isAriantShield(itemid);
@@ -1639,7 +1636,7 @@ public class MapleStatEffect {
private boolean isCrash() {
return skill && (sourceid == DragonKnight.POWER_CRASH || sourceid == Crusader.ARMOR_CRASH || sourceid == WhiteKnight.MAGIC_CRASH);
}
private boolean isSeal() {
return skill && (sourceid == ILMage.SEAL || sourceid == FPMage.SEAL || sourceid == BlazeWizard.SEAL);
}
@@ -1651,11 +1648,7 @@ public class MapleStatEffect {
private boolean isCureAllAbnormalStatus() {
if (skill) {
return isHerosWill(sourceid);
} else if (sourceid == 2022544) {
return true;
}
return false;
} else return sourceid == 2022544;
}
public static boolean isHerosWill(int skillid) {
@@ -1678,18 +1671,18 @@ public class MapleStatEffect {
return false;
}
}
private boolean isWkCharge() {
if (!skill) {
return false;
}
for (Pair<BuffStat, Integer> p : statups) {
if (p.getLeft().equals(BuffStat.WK_CHARGE)) {
return true;
}
}
return false;
}
@@ -1728,7 +1721,7 @@ public class MapleStatEffect {
private int getMorph(Character chr) {
if (morphId == 1000 || morphId == 1001 || morphId == 1003) { // morph skill
return chr.getGender() == 0 ? morphId : morphId + 100;
}
}
return morphId;
}
@@ -1784,11 +1777,11 @@ public class MapleStatEffect {
/*
private static class CancelEffectAction implements Runnable {
private MapleStatEffect effect;
private StatEffect effect;
private WeakReference<Character> target;
private long startTime;
public CancelEffectAction(Character target, MapleStatEffect effect, long startTime) {
public CancelEffectAction(Character target, StatEffect effect, long startTime) {
this.effect = effect;
this.target = new WeakReference<>(target);
this.startTime = startTime;
@@ -1859,7 +1852,7 @@ public class MapleStatEffect {
return statups;
}
public boolean sameSource(MapleStatEffect effect) {
public boolean sameSource(StatEffect effect) {
return this.sourceid == effect.sourceid && this.skill == effect.skill;
}

View File

@@ -42,7 +42,7 @@ import net.server.services.type.ChannelServices;
import net.server.world.Party;
import net.server.world.PartyCharacter;
import scripting.event.EventInstanceManager;
import server.MapleStatEffect;
import server.StatEffect;
import server.TimerManager;
import server.life.LifeFactory.BanishInfo;
import server.loot.LootManager;
@@ -1801,7 +1801,7 @@ public class Monster extends AbstractLoadedLife {
}
public boolean isCharacterPuppetInVicinity(Character chr) {
MapleStatEffect mse = chr.getBuffEffect(BuffStat.PUPPET);
StatEffect mse = chr.getBuffEffect(BuffStat.PUPPET);
if (mse != null) {
Summon summon = chr.getSummonByKey(mse.getSourceId());
@@ -2133,7 +2133,7 @@ public class Monster extends AbstractLoadedLife {
return;
}
MapleStatEffect puppetEffect = chrController.getBuffEffect(BuffStat.PUPPET);
StatEffect puppetEffect = chrController.getBuffEffect(BuffStat.PUPPET);
if (puppetEffect != null) {
Summon puppet = chrController.getSummonByKey(puppetEffect.getSourceId());

View File

@@ -54,7 +54,7 @@ import net.server.world.World;
import scripting.event.EventInstanceManager;
import scripting.map.MapScriptManager;
import server.ItemInformationProvider;
import server.MapleStatEffect;
import server.StatEffect;
import server.TimerManager;
import server.events.gm.*;
import server.life.*;
@@ -1401,7 +1401,7 @@ public class MapleMap {
for (MapObject mmo : this.getPlayers()) {
Character character = (Character) mmo;
if (character.isAlive()) {
MapleStatEffect statEffect = mii.getItemEffect(buff);
StatEffect statEffect = mii.getItemEffect(buff);
character.sendPacket(PacketCreator.showOwnBuffEffect(buff, 1));
broadcastMessage(character, PacketCreator.showBuffEffect(character.getId(), buff, 1), false);
statEffect.applyTo(character);
@@ -2535,7 +2535,7 @@ public class MapleMap {
}
}
MapleStatEffect summonStat = chr.getStatForBuff(BuffStat.SUMMON);
StatEffect summonStat = chr.getStatForBuff(BuffStat.SUMMON);
if (summonStat != null) {
Summon summon = chr.getSummonByKey(summonStat.getSourceId());
summon.setPosition(chr.getPosition());

View File

@@ -27,7 +27,7 @@ import client.Skill;
import client.SkillFactory;
import constants.skills.*;
import net.packet.Packet;
import server.MapleStatEffect;
import server.StatEffect;
import server.life.MobSkill;
import server.life.Monster;
import tools.PacketCreator;
@@ -41,7 +41,7 @@ public class Mist extends AbstractMapObject {
private final Rectangle mistPosition;
private Character owner = null;
private Monster mob = null;
private MapleStatEffect source;
private StatEffect source;
private MobSkill skill;
private final boolean isMobMist;
private boolean isPoisonMist;
@@ -58,7 +58,7 @@ public class Mist extends AbstractMapObject {
skillDelay = 0;
}
public Mist(Rectangle mistPosition, Character owner, MapleStatEffect source) {
public Mist(Rectangle mistPosition, Character owner, StatEffect source) {
this.mistPosition = mistPosition;
this.owner = owner;
this.source = source;