📄 maplestateffect.java
字号:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* ItemEndEffect.java
*
* Created on 29. November 2007, 01:34
*
* To change this template, choose Tools | Template Manager and open the template in the editor.
*/
package net.sf.odinms.server;
import java.awt.Point;
import java.awt.Rectangle;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import net.sf.odinms.client.IItem;
import net.sf.odinms.client.ISkill;
import net.sf.odinms.client.MapleBuffStat;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.MapleInventoryType;
import net.sf.odinms.client.MapleJob;
import net.sf.odinms.client.MapleStat;
import net.sf.odinms.client.SkillFactory;
import net.sf.odinms.client.status.MonsterStatus;
import net.sf.odinms.client.status.MonsterStatusEffect;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.provider.MapleData;
import net.sf.odinms.provider.MapleDataTool;
import net.sf.odinms.server.life.MapleMonster;
import net.sf.odinms.server.maps.MapleDoor;
import net.sf.odinms.server.maps.MapleMap;
import net.sf.odinms.server.maps.MapleMapObject;
import net.sf.odinms.server.maps.MapleMapObjectType;
import net.sf.odinms.server.maps.MapleMist;
import net.sf.odinms.server.maps.MapleSummon;
import net.sf.odinms.server.maps.SummonMovementType;
import net.sf.odinms.tools.ArrayMap;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.Pair;
/**
* @author Matze
* @author Frz
*/
public class MapleStatEffect {
private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MapleStatEffect.class);
private short watk, matk, wdef, mdef, acc, avoid, hands, speed, jump;
private short hp, mp;
private double hpR, mpR;
private short mpCon, hpCon;
private int duration;
private boolean overTime;
private int sourceid;
private int moveTo;
private boolean skill;
private List<Pair<MapleBuffStat, Integer>> statups;
private Map<MonsterStatus, Integer> monsterStatus;
private int x, y, z;
private double prop;
private int itemCon, itemConNo;
private int damage, attackCount, bulletCount, bulletConsume;
private Point lt, rb;
private int mobCount;
private int moneyCon;
private MapleStatEffect() {
}
public static MapleStatEffect loadSkillEffectFromData(MapleData source, int skillid, boolean overtime) {
return loadFromData(source, skillid, true, overtime);
}
public static MapleStatEffect loadItemEffectFromData(MapleData source, int itemid) {
return loadFromData(source, itemid, false, false);
}
private static void addBuffStatPairToListIfNotZero(List<Pair<MapleBuffStat, Integer>> list, MapleBuffStat buffstat, Integer val) {
if (val.intValue() != 0) {
list.add(new Pair<MapleBuffStat, Integer>(buffstat, val));
}
}
private static MapleStatEffect loadFromData(MapleData source, int sourceid, boolean skill, boolean overTime) {
MapleStatEffect ret = new MapleStatEffect();
ret.duration = MapleDataTool.getInt("time", source, -1);
ret.hp = (short) MapleDataTool.getInt("hp", source, 0);
ret.hpR = MapleDataTool.getInt("hpR", source, 0) / 100.0;
ret.mp = (short) MapleDataTool.getInt("mp", source, 0);
ret.mpR = MapleDataTool.getInt("mpR", source, 0) / 100.0;
ret.mpCon = (short) MapleDataTool.getInt("mpCon", source, 0);
ret.hpCon = (short) MapleDataTool.getInt("hpCon", source, 0);
ret.prop = MapleDataTool.getInt("prop", source, 100) / 100.0;
ret.mobCount = MapleDataTool.getInt("mobCount", source, 1);
ret.sourceid = sourceid;
ret.skill = skill;
if (!ret.skill && ret.duration > -1) {
ret.overTime = true;
} else {
ret.duration *= 1000; // items have their times stored in ms, of course
ret.overTime = overTime;
}
ArrayList<Pair<MapleBuffStat, Integer>> statups = new ArrayList<Pair<MapleBuffStat, Integer>>();
ret.watk = (short) MapleDataTool.getInt("pad", source, 0);
ret.wdef = (short) MapleDataTool.getInt("pdd", source, 0);
ret.matk = (short) MapleDataTool.getInt("mad", source, 0);
ret.mdef = (short) MapleDataTool.getInt("mdd", source, 0);
ret.acc = (short) MapleDataTool.getIntConvert("acc", source, 0);
ret.avoid = (short) MapleDataTool.getInt("eva", source, 0);
ret.speed = (short) MapleDataTool.getInt("speed", source, 0);
ret.jump = (short) MapleDataTool.getInt("jump", source, 0);
if (ret.overTime && ret.getSummonMovementType() == null) {
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WATK, Integer.valueOf(ret.watk));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WDEF, Integer.valueOf(ret.wdef));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MATK, Integer.valueOf(ret.matk));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MDEF, Integer.valueOf(ret.mdef));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.ACC, Integer.valueOf(ret.acc));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.AVOID, Integer.valueOf(ret.avoid));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.SPEED, Integer.valueOf(ret.speed));
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.JUMP, Integer.valueOf(ret.jump));
}
MapleData ltd = source.getChildByPath("lt");
if (ltd != null) {
ret.lt = (Point) ltd.getData();
ret.rb = (Point) source.getChildByPath("rb").getData();
}
int x = MapleDataTool.getInt("x", source, 0);
ret.x = x;
ret.y = MapleDataTool.getInt("y", source, 0);
ret.z = MapleDataTool.getInt("z", source, 0);
ret.damage = MapleDataTool.getIntConvert("damage", source, 100);
ret.attackCount = MapleDataTool.getIntConvert("attackCount", source, 1);
ret.bulletCount = MapleDataTool.getIntConvert("bulletCount", source, 1);
ret.bulletConsume = MapleDataTool.getIntConvert("bulletConsume", source, 0);
ret.moneyCon = MapleDataTool.getIntConvert("moneyCon", source, 0);
ret.itemCon = MapleDataTool.getInt("itemCon", source, 0);
ret.itemConNo = MapleDataTool.getInt("itemConNo", source, 0);
ret.moveTo = MapleDataTool.getInt("moveTo", source, -1);
Map<MonsterStatus, Integer> monsterStatus = new ArrayMap<MonsterStatus, Integer>();
// TODO hs, wk charges (?), recovery (?) (beginner)
// dragonblood (? - takes away hp constantly), meso guard,
// sharpeyes, maplehero, more 4th skills ?
// others should see pg damage
if (skill) { // hack because we can't get from the datafile...
switch (sourceid) {
case 2001002: // magic guard
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MAGIC_GUARD, Integer.valueOf(x)));
break;
case 2301003: // invincible
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.INVINCIBLE, Integer.valueOf(x)));
break;
case 5101004: // hide
ret.duration = 60 * 120 * 1000;
ret.overTime = true;
// falltrough intended
case 4001003: // darksight
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, Integer.valueOf(x)));
break;
case 4211003: // pickpocket
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.PICKPOCKET, Integer.valueOf(x)));
break;
case 4211005: // mesoguard
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MESOGUARD, Integer.valueOf(x)));
break;
case 4111001: // mesoup
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MESOUP, Integer.valueOf(x)));
break;
case 4111002: // shadowpartner
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SHADOWPARTNER, Integer.valueOf(x)));
break;
case 3101004: // soul arrow
case 3201004:
case 2311002: // mystic door - hacked buff icon
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SOULARROW, Integer.valueOf(x)));
break;
case 1211006: // wk charges
case 1211003:
case 1211004:
case 1211005:
case 1211008:
case 1211007:
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WK_CHARGE, Integer.valueOf(x)));
break;
case 1101005: // booster
case 1101004:
case 1201005:
case 1201004:
case 1301005:
case 1301004:
case 3101002:
case 3201002:
case 4101003:
case 4201002:
case 2111005: // spell booster, do these work the same?
case 2211005:
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.BOOSTER, Integer.valueOf(x)));
break;
case 1101007: // pguard
case 1201007:
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.POWERGUARD, Integer.valueOf(x)));
break;
case 1301007:
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HYPERBODYHP, Integer.valueOf(x)));
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HYPERBODYMP, Integer.valueOf(ret.y)));
break;
case 1001: // recovery
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.RECOVERY, Integer.valueOf(x)));
break;
case 1111002: // combo
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.COMBO, Integer.valueOf(1)));
break;
case 1004: // monster riding
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, Integer.valueOf(1)));
break;
case 1311006: //dragon roar
ret.hpR = -x / 100.0;
break;
case 1311008: // dragon blood
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DRAGONBLOOD, Integer.valueOf(ret.x)));
break;
case 1121000: // maple warrior, all classes
case 1221000:
case 1321000:
case 2121000:
case 2221000:
case 2321000:
case 3121000:
case 3221000:
case 4121000:
case 4221000:
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MAPLE_WARRIOR, Integer.valueOf(ret.x)));
break;
case 3121002: // sharp eyes bow master
case 3221002: // sharp eyes marksmen
// hack much (TODO is the order correct?)
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SHARP_EYES, Integer.valueOf(ret.x << 8 | ret.y)));
break;
case 4001002: // disorder
monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
break;
case 1201006: // threaten
monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
break;
case 1211002: // charged blow
case 1111008: // shout
case 4211002: // assaulter
case 3101005: // arrow bomb
case 1111005: // coma: sword
case 1111006: // coma: axe
monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
break;
case 2201004: // cold beam
case 2211002: // ice strike
case 3211003: // blizzard
case 2211006: // il elemental compo
monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
ret.duration *= 2; // freezing skills are a little strange
break;
case 2101003: // fp slow
case 2201003: // il slow
monsterStatus.put(MonsterStatus.SPEED, Integer.valueOf(ret.x));
break;
case 2101005: // poison breath
// case 2111003: // poison mist - does not poison itself
case 2111006: // fp elemental compo
monsterStatus.put(MonsterStatus.POISON, Integer.valueOf(1));
break;
case 2311005:
monsterStatus.put(MonsterStatus.DOOM, Integer.valueOf(1));
break;
case 3111002: // puppet ranger
case 3211002: // puppet sniper
statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.PUPPET, Integer.valueOf(1)));
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -