Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.88 KB | None | 0 0
  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6.  
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License version 3
  9. as published by the Free Software Foundation. You may not use, modify
  10. or distribute this program under any other version of the
  11. GNU Affero General Public License.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU Affero General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Affero General Public License
  19. along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21.  
  22. /*
  23. * ItemEndEffect.java
  24. *
  25. * Created on 29. November 2007, 01:34
  26. */
  27.  
  28. package server;
  29.  
  30. import java.awt.Point;
  31. import java.awt.Rectangle;
  32. import java.io.Serializable;
  33. import java.lang.ref.WeakReference;
  34. import java.util.ArrayList;
  35. import java.util.Arrays;
  36. import java.util.Collections;
  37. import java.util.List;
  38. import java.util.Map;
  39. import java.util.concurrent.ScheduledFuture;
  40.  
  41. import client.IItem;
  42. import client.ISkill;
  43. import client.MapleBuffStat;
  44. import client.MapleCharacter;
  45. import client.MapleDisease;
  46. import client.inventory.MapleInventory;
  47. import client.inventory.MapleInventoryType;
  48. import client.MapleJob;
  49. import client.inventory.MapleMount;
  50. import client.MapleStat;
  51. import client.SkillFactory;
  52. import client.status.MonsterStatus;
  53. import client.status.MonsterStatusEffect;
  54. import config.skills.SuperGM;
  55. import handling.channel.ChannelServer;
  56. import provider.MapleData;
  57. import provider.MapleDataTool;
  58. import server.life.MapleMonster;
  59. import server.maps.MapleDoor;
  60. import server.maps.MapleMap;
  61. import server.maps.MapleMapObject;
  62. import server.maps.MapleMapObjectType;
  63. import server.maps.MapleMist;
  64. import server.maps.MapleSummon;
  65. import server.maps.SummonMovementType;
  66. import handling.world.PlayerCoolDownValueHolder;
  67. import handling.MaplePacket;
  68. import tools.ArrayMap;
  69. import tools.packet.MaplePacketCreator;
  70. import tools.Pair;
  71. import config.configuration.Configuration;
  72.  
  73. /**
  74. * @author Matze
  75. * @author Frz
  76. */
  77.  
  78. public class MapleStatEffect implements Serializable {
  79.  
  80. static final long serialVersionUID = 9179541993413738569L;
  81. private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MapleStatEffect.class);
  82. private short watk, matk, wdef, mdef, acc, avoid, hands, speed, jump;
  83. private short hp, mp;
  84. private double hpR, mpR;
  85. private short mpCon, hpCon;
  86. private int duration;
  87. private boolean overTime;
  88. private int sourceid;
  89. private int moveTo;
  90. private boolean skill;
  91. private List<Pair<MapleBuffStat, Integer>> statups;
  92. private Map<MonsterStatus, Integer> monsterStatus;
  93. private int x, y, z;
  94. private double prop;
  95. private int itemCon, itemConNo;
  96. private int damage, attackCount, bulletCount, bulletConsume;
  97. private Point lt, rb;
  98. private int mobCount;
  99. private int moneyCon;
  100. private int cooldown;
  101. private boolean isMorph = false;
  102. private int morphId = 0;
  103. private List<MapleDisease> cureDebuffs;
  104. private int mastery, range, fixDamage;
  105.  
  106. public MapleStatEffect() {
  107. }
  108.  
  109. public static MapleStatEffect loadSkillEffectFromData(MapleData source, int skillid, boolean overtime) {
  110. return loadFromData(source, skillid, true, overtime);
  111. }
  112.  
  113. public static MapleStatEffect loadItemEffectFromData(MapleData source, int itemid) {
  114. return loadFromData(source, itemid, false, false);
  115. }
  116.  
  117. private static void addBuffStatPairToListIfNotZero(List<Pair<MapleBuffStat, Integer>> list, MapleBuffStat buffstat, Integer val) {
  118. if (val.intValue() != 0) {
  119. list.add(new Pair<MapleBuffStat, Integer>(buffstat, val));
  120. }
  121. }
  122.  
  123.  
  124. private static MapleStatEffect loadFromData(MapleData source, int sourceid, boolean skill, boolean overTime) {
  125. MapleStatEffect ret = new MapleStatEffect();
  126. ret.duration = MapleDataTool.getIntConvert("time", source, -1);
  127. ret.hp = (short) MapleDataTool.getInt("hp", source, 0);
  128. ret.hpR = MapleDataTool.getInt("hpR", source, 0) / 100.0;
  129. ret.mp = (short) MapleDataTool.getInt("mp", source, 0);
  130. ret.mpR = MapleDataTool.getInt("mpR", source, 0) / 100.0;
  131. ret.mpCon = (short) MapleDataTool.getInt("mpCon", source, 0);
  132. ret.hpCon = (short) MapleDataTool.getInt("hpCon", source, 0);
  133. int iprop = MapleDataTool.getInt("prop", source, 100);
  134. ret.prop = iprop / 100.0;
  135. ret.mobCount = MapleDataTool.getInt("mobCount", source, 1);
  136. ret.cooldown = MapleDataTool.getInt("cooltime", source, 0);
  137. ret.morphId = MapleDataTool.getInt("morph", source, 0);
  138. ret.fixDamage = MapleDataTool.getInt("fixdamage", source, -1);
  139. ret.isMorph = ret.morphId > 0 ? true : false;
  140.  
  141. ret.sourceid = sourceid;
  142. ret.skill = skill;
  143.  
  144. if (!ret.skill && ret.duration > -1) {
  145. ret.overTime = true;
  146. } else {
  147. ret.duration *= 1000; // items have their times stored in ms, of course
  148. ret.overTime = overTime;
  149. }
  150. ArrayList<Pair<MapleBuffStat, Integer>> statups = new ArrayList<Pair<MapleBuffStat, Integer>>();
  151.  
  152. ret.watk = (short) MapleDataTool.getInt("pad", source, 0);
  153. ret.wdef = (short) MapleDataTool.getInt("pdd", source, 0);
  154. ret.matk = (short) MapleDataTool.getInt("mad", source, 0);
  155. ret.mdef = (short) MapleDataTool.getInt("mdd", source, 0);
  156. ret.acc = (short) MapleDataTool.getIntConvert("acc", source, 0);
  157. ret.avoid = (short) MapleDataTool.getInt("eva", source, 0);
  158. ret.speed = (short) MapleDataTool.getInt("speed", source, 0);
  159. ret.jump = (short) MapleDataTool.getInt("jump", source, 0);
  160. if (ret.overTime && ret.getSummonMovementType() == null) {
  161. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WATK, Integer.valueOf(ret.watk));
  162. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WDEF, Integer.valueOf(ret.wdef));
  163. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MATK, Integer.valueOf(ret.matk));
  164. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MDEF, Integer.valueOf(ret.mdef));
  165. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.ACC, Integer.valueOf(ret.acc));
  166. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.AVOID, Integer.valueOf(ret.avoid));
  167. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.SPEED, Integer.valueOf(ret.speed));
  168. addBuffStatPairToListIfNotZero(statups, MapleBuffStat.JUMP, Integer.valueOf(ret.jump));
  169. }
  170.  
  171. MapleData ltd = source.getChildByPath("lt");
  172. if (ltd != null) {
  173. ret.lt = (Point) ltd.getData();
  174. ret.rb = (Point) source.getChildByPath("rb").getData();
  175. }
  176.  
  177. int x = MapleDataTool.getInt("x", source, 0);
  178. ret.x = x;
  179. ret.y = MapleDataTool.getInt("y", source, 0);
  180. ret.z = MapleDataTool.getInt("z", source, 0);
  181. ret.damage = MapleDataTool.getIntConvert("damage", source, 100);
  182. ret.attackCount = MapleDataTool.getIntConvert("attackCount", source, 1);
  183. ret.bulletCount = MapleDataTool.getIntConvert("bulletCount", source, 1);
  184. ret.bulletConsume = MapleDataTool.getIntConvert("bulletConsume", source, 0);
  185. ret.moneyCon = MapleDataTool.getIntConvert("moneyCon", source, 0);
  186. ret.mastery = MapleDataTool.getIntConvert("mastery", source, 0);
  187. ret.range = MapleDataTool.getIntConvert("range", source, 0);
  188.  
  189. ret.itemCon = MapleDataTool.getInt("itemCon", source, 0);
  190. ret.itemConNo = MapleDataTool.getInt("itemConNo", source, 0);
  191. ret.moveTo = MapleDataTool.getInt("moveTo", source, -1);
  192.  
  193. List<MapleDisease> localCureDebuffs = new ArrayList<MapleDisease>();
  194. if (MapleDataTool.getInt("poison", source, 0) > 0) {
  195. localCureDebuffs.add(MapleDisease.POISON);
  196. }
  197. if (MapleDataTool.getInt("seal", source, 0) > 0) {
  198. localCureDebuffs.add(MapleDisease.SEAL);
  199. }
  200. if (MapleDataTool.getInt("darkness", source, 0) > 0) {
  201. localCureDebuffs.add(MapleDisease.DARKNESS);
  202. }
  203. if (MapleDataTool.getInt("weakness", source, 0) > 0) {
  204. localCureDebuffs.add(MapleDisease.WEAKEN);
  205. }
  206. if (MapleDataTool.getInt("curse", source, 0) > 0) {
  207. localCureDebuffs.add(MapleDisease.CURSE);
  208. }
  209. ret.cureDebuffs = localCureDebuffs;
  210.  
  211. Map<MonsterStatus, Integer> monsterStatus = new ArrayMap<MonsterStatus, Integer>();
  212.  
  213. if (skill) { // hack because we can't get from the datafile...
  214. switch (sourceid) {
  215. case 2001002: // magic guard
  216. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MAGIC_GUARD, Integer.valueOf(x)));
  217. break;
  218. case 2301003: // invincible
  219. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.INVINCIBLE, Integer.valueOf(x)));
  220. break;
  221. case 9101004: // hide
  222. ret.duration = 2100000000;
  223. ret.overTime = true;
  224. case 4001003: // darksight
  225. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, Integer.valueOf(x)));
  226. break;
  227. case 4211003: // pickpocket
  228. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.PICKPOCKET, Integer.valueOf(x)));
  229. break;
  230. case 4211005: // mesoguard
  231. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MESOGUARD, Integer.valueOf(x)));
  232. break;
  233. case 4111001: // mesoup
  234. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MESOUP, Integer.valueOf(x)));
  235. break;
  236. case 4111002: // shadowpartner
  237. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SHADOWPARTNER, Integer.valueOf(x)));
  238. break;
  239. case 3101004: // soul arrow
  240. case 3201004:
  241. case 2311002: // mystic door - hacked buff icon
  242. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SOULARROW, Integer.valueOf(x)));
  243. break;
  244. case 1211003:
  245. case 1211004:
  246. case 1211005:
  247. case 1211006: // wk charges
  248. case 1211007:
  249. case 1211008:
  250. case 1221003:
  251. case 1221004:
  252. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WK_CHARGE, Integer.valueOf(x)));
  253. break;
  254. case 1101004:
  255. case 1101005: // booster
  256. case 1201004:
  257. case 1201005:
  258. case 1301004:
  259. case 1301005:
  260. case 2111005: // spell booster, do these work the same?
  261. case 2211005:
  262. case 3101002:
  263. case 3201002:
  264. case 4101003:
  265. case 4201002:
  266. case 5101006:
  267. case 5201003:
  268. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.BOOSTER, Integer.valueOf(x)));
  269. break;
  270. //case 5121009:
  271. // statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SPEED_INFUSION, ret.x));
  272. // break;
  273. case 5121009:
  274. case 5221010:
  275. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SPEED_INFUSION, Integer.valueOf(-4)));
  276. break;
  277. case 1101006: // rage
  278. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WDEF, Integer.valueOf(ret.wdef)));
  279. case 1121010: // enrage
  280. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WATK, Integer.valueOf(ret.watk)));
  281. break;
  282. case 1301006: // iron will
  283. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MDEF, Integer.valueOf(ret.mdef)));
  284. case 1001003: // iron body
  285. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WDEF, Integer.valueOf(ret.wdef)));
  286. break;
  287. case 2001003: // magic armor
  288. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WDEF, Integer.valueOf(ret.wdef)));
  289. break;
  290. case 2101001: // meditation
  291. case 2201001: // meditation
  292. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MATK, Integer.valueOf(ret.matk)));
  293. break;
  294. case 4101004: // haste
  295. case 4201003: // haste
  296. case 9101001: // gm haste
  297. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SPEED, Integer.valueOf(ret.speed)));
  298. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.JUMP, Integer.valueOf(ret.jump)));
  299. break;
  300. case 2301004: // bless
  301. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WDEF, Integer.valueOf(ret.wdef)));
  302. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MDEF, Integer.valueOf(ret.mdef)));
  303. case 3001003: // focus
  304. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.ACC, Integer.valueOf(ret.acc)));
  305. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.AVOID, Integer.valueOf(ret.avoid)));
  306. break;
  307. case 9101003: // gm bless
  308. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MATK, Integer.valueOf(ret.matk)));
  309. case 3121008: // concentrate
  310. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.WATK, Integer.valueOf(ret.watk)));
  311. break;
  312. case 5001005: // Dash
  313. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DASH, Integer.valueOf(1)));
  314. break;
  315. case 1101007: // pguard
  316. case 1201007:
  317. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.POWERGUARD, Integer.valueOf(x)));
  318. break;
  319. case 1301007:
  320. case 9101008:
  321. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HYPERBODYHP, Integer.valueOf(x)));
  322. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HYPERBODYMP, Integer.valueOf(ret.y)));
  323. break;
  324. case 1001: // recovery
  325. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.RECOVERY, Integer.valueOf(x)));
  326. break;
  327. case 1111002: // combo
  328. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.COMBO, Integer.valueOf(1)));
  329. break;
  330. case 1004: // monster riding
  331. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, Integer.valueOf(1)));
  332. break;
  333. case 5221006: // 4th Job - Pirate riding
  334. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, 1932000));
  335. break;
  336. case 1311006: //dragon roar
  337. ret.hpR = -x / 100.0;
  338. break;
  339. case 1311008: // dragon blood
  340. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DRAGONBLOOD, Integer.valueOf(ret.x)));
  341. break;
  342. case 1121000: // maple warrior, all classes
  343. case 1221000:
  344. case 1321000:
  345. case 2121000:
  346. case 2221000:
  347. case 2321000:
  348. case 3121000:
  349. case 3221000:
  350. case 4121000:
  351. case 4221000:
  352. case 5121000:
  353. case 5221000:
  354. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MAPLE_WARRIOR, Integer.valueOf(ret.x)));
  355. break;
  356. case 3121002: // sharp eyes bow master
  357. case 3221002: // sharp eyes marksmen
  358. // hack much (TODO is the order correct?)
  359. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SHARP_EYES, Integer.valueOf(ret.x << 8 | ret.y)));
  360. break;
  361. case 1321007: // Beholder
  362. case 2221005: // ifrit
  363. case 2311006: // summon dragon
  364. case 2321003: // bahamut
  365. case 3121006: // phoenix
  366. case 5211001: // Pirate octopus summon
  367. case 5211002: // Pirate bird summon
  368. case 5220002: // wrath of the octopi
  369. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
  370. break;
  371. case 2311003: // hs
  372. case 9101002: // GM hs
  373. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HOLY_SYMBOL, Integer.valueOf(x)));
  374. break;
  375. case 4121006: // spirit claw
  376. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SHADOW_CLAW, Integer.valueOf(0)));
  377. break;
  378. case 2121004:
  379. case 2221004:
  380. case 2321004: // Infinity
  381. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.INFINITY, Integer.valueOf(x)));
  382. break;
  383. case 1121002:
  384. case 1221002:
  385. case 1321002: // Stance
  386. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.STANCE, Integer.valueOf(iprop)));
  387. break;
  388. case 1005: // Echo of Hero
  389. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.ECHO_OF_HERO, Integer.valueOf(ret.x)));
  390. break;
  391. case 2121002: // mana reflection
  392. case 2221002:
  393. case 2321002:
  394. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MANA_REFLECTION, Integer.valueOf(1)));
  395. break;
  396. case 2321005: // holy shield
  397. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HOLY_SHIELD, Integer.valueOf(x)));
  398. break;
  399. case 3111002: // puppet ranger
  400. case 3211002: // puppet sniper
  401. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.PUPPET, Integer.valueOf(1)));
  402. break;
  403.  
  404. // ----------------------------- MONSTER STATUS PUT! ----------------------------- //
  405. case 4001002: // disorder
  406. monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
  407. monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
  408. break;
  409. case 1201006: // threaten
  410. monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
  411. monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
  412. break;
  413. case 1111005: // coma: sword
  414. case 1111006: // coma: axe
  415. case 1111008: // shout
  416. case 1211002: // charged blow
  417. case 3101005: // arrow bomb
  418. case 4211002: // assaulter
  419. case 4221007: // boomerang step
  420. case 5101002: // Backspin Blow
  421. case 5101003: // Double Uppercut
  422. case 5121004: // pirate 8 hit punches
  423. case 5121005: // pirate pull mob skill? O.o
  424. case 5121007: // pirate 6 hit shyt...
  425. case 5201004: // pirate blank shot
  426. monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
  427. break;
  428. //case 5201004: // pirate blank shot
  429. case 4121003:
  430. case 4221003:
  431. monsterStatus.put(MonsterStatus.SHOWDOWN, Integer.valueOf(1));
  432. break;
  433. case 2201004: // cold beam
  434. case 2211002: // ice strike
  435. case 2211006: // il elemental compo
  436. case 2221007: // Blizzard
  437. case 3211003: // blizzard
  438. case 5211005:
  439. monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
  440. ret.duration *= 2; // freezing skills are a little strange
  441. break;
  442. case 2121006://Paralyze
  443. case 2101003: // fp slow
  444. case 2201003: // il slow
  445. monsterStatus.put(MonsterStatus.SPEED, Integer.valueOf(ret.x));
  446. break;
  447. case 2101005: // poison breath
  448. case 2111006: // fp elemental compo
  449. monsterStatus.put(MonsterStatus.POISON, Integer.valueOf(1));
  450. break;
  451. case 2311005:
  452. monsterStatus.put(MonsterStatus.DOOM, Integer.valueOf(1));
  453. break;
  454. case 3111005: // golden hawk
  455. case 3211005: // golden eagle
  456. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
  457. monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
  458. break;
  459. case 2121005: // elquines
  460. case 3221005: // frostprey
  461. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
  462. monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
  463. break;
  464. case 2111004: // fp seal
  465. case 2211004: // il seal
  466. monsterStatus.put(MonsterStatus.SEAL, 1);
  467. break;
  468. case 4111003: // shadow web
  469. monsterStatus.put(MonsterStatus.SHADOW_WEB, 1);
  470. break;
  471. case 3121007: // Hamstring
  472. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.HAMSTRING, Integer.valueOf(x)));
  473. monsterStatus.put(MonsterStatus.SPEED, x);
  474. break;
  475. case 3221006: // Blind
  476. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.BLIND, Integer.valueOf(x)));
  477. monsterStatus.put(MonsterStatus.ACC, x);
  478. break;
  479. default:
  480. // nothing needs to be added, that's ok
  481. }
  482. }
  483.  
  484. if (ret.isMorph()) {
  485. statups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MORPH, Integer.valueOf(ret.getMorph())));
  486. }
  487.  
  488. ret.monsterStatus = monsterStatus;
  489. // TODO: fixDamage, coolTime
  490.  
  491. statups.trimToSize();
  492. ret.statups = statups;
  493.  
  494. return ret;
  495. }
  496. /**
  497. * @param applyto
  498. * @param obj
  499. * @param attack damage done by the skill
  500. */
  501. public void applyPassive(MapleCharacter applyto, MapleMapObject obj, int attack) {
  502. if (makeChanceResult()) {
  503. switch (sourceid) {
  504. // MP eater
  505. case 2100000:
  506. case 2200000:
  507. case 2300000:
  508. if (obj == null || obj.getType() != MapleMapObjectType.MONSTER)
  509. return;
  510. MapleMonster mob = (MapleMonster) obj;
  511. // x is absorb percentage
  512. if (!mob.isBoss()) {
  513. int absorbMp = Math.min((int) (mob.getMaxMp() * (getX() / 100.0)), mob.getMp());
  514. if (absorbMp > 0) {
  515. mob.setMp(mob.getMp() - absorbMp);
  516. applyto.addMP(absorbMp);
  517. applyto.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(sourceid, 1));
  518. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showBuffeffect(applyto.getId(), sourceid, 1, (byte) 3), false);
  519. }
  520. }
  521. break;
  522. }
  523. }
  524. }
  525.  
  526. public boolean applyTo(MapleCharacter chr) {
  527. return applyTo(chr, chr, true, null);
  528. }
  529.  
  530. public boolean applyTo(MapleCharacter chr, boolean hide, boolean login) {
  531. if (isHide()) {
  532. chr.Hide(hide, login);
  533. }
  534. return applyTo(chr, chr, true, null);
  535. }
  536.  
  537. public boolean applyTo(MapleCharacter chr, Point pos) {
  538. return applyTo(chr, chr, true, pos);
  539. }
  540.  
  541. private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos) {
  542. if(skill && (this.sourceid == 4001003 || this.sourceid == 5101007) && applyfrom.getMap().getDisableInvincibilitySkills() && !applyfrom.isGM())
  543. {
  544. applyfrom.getClient().getSession().write(MaplePacketCreator.enableActions());
  545. applyfrom.getClient().getSession().write(MaplePacketCreator.serverNotice(5, "Invincibility skills are disabled in this map."));
  546. return false;
  547. }
  548.  
  549. int hpchange = calcHPChange(applyfrom, primary);
  550. int mpchange = calcMPChange(applyfrom, primary);
  551.  
  552. if (primary) {
  553. if (itemConNo != 0) {
  554. MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemCon);
  555. MapleInventoryManipulator.removeById(applyto.getClient(), type, itemCon, itemConNo, false, true);
  556. }
  557. }
  558. if (cureDebuffs.size() > 0) {
  559. for (MapleDisease debuff : cureDebuffs) {
  560. applyfrom.dispelDebuff(debuff);
  561. }
  562. }
  563. List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
  564. if (!primary && isResurrection()) {
  565. hpchange = applyto.getMaxHp();
  566. applyto.setStance(0);
  567. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
  568. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapobject(applyto), false);
  569. } if (isDispel() && makeChanceResult()) {
  570. applyto.dispelDebuffs();
  571. } else if (isHeroWill()) {
  572. applyto.dispelSeduce();
  573. }
  574. if (hpchange != 0) {
  575. if (hpchange < 0 && (-hpchange) > applyto.getHp()) {
  576. return false;
  577. }
  578. int newHp = applyto.getHp() + hpchange;
  579. if (newHp < 1) {
  580. newHp = 1;
  581. }
  582. applyto.setHp(newHp);
  583. hpmpupdate.add(new Pair<MapleStat, Integer>(MapleStat.HP, Integer.valueOf(applyto.getHp())));
  584. }
  585. if (mpchange != 0) {
  586. if (mpchange < 0 && (-mpchange) > applyto.getMp()) {
  587. return false;
  588. }
  589. applyto.setMp(applyto.getMp() + mpchange);
  590. hpmpupdate.add(new Pair<MapleStat, Integer>(MapleStat.MP, Integer.valueOf(applyto.getMp())));
  591. }
  592. applyto.getClient().getSession().write(MaplePacketCreator.updatePlayerStats(hpmpupdate, true));
  593. if (moveTo != -1) {
  594. if (applyto.getMap().getReturnMapId() != applyto.getMapId()) {
  595. MapleMap target;
  596. if (moveTo == 999999999) {
  597. target = applyto.getMap().getReturnMap();
  598. } else {
  599. target = ChannelServer.getInstance(applyto.getClient().getChannel()).getMapFactory().getMap(moveTo);
  600. if (target.getId() / 10000000 != 60 && applyto.getMapId() / 10000000 != 61) {
  601. if (target.getId() / 10000000 != 21 && applyto.getMapId() / 10000000 != 20) {
  602. if (target.getId() / 10000000 != applyto.getMapId() / 10000000) {
  603. log.info("Player {} is trying to use a return scroll to an illegal location ({}->{})", new Object[] { applyto.getName(), applyto.getMapId(), target.getId() });
  604. applyto.getClient().disconnect();
  605. return false;
  606. }
  607. }
  608. }
  609. }
  610. applyto.changeMap(target, target.getPortal(0));
  611. } else {
  612. return false;
  613. }
  614. }
  615. if (isShadowClaw()) {
  616. int projectile = 0;
  617. MapleInventory use = applyto.getInventory(MapleInventoryType.USE);
  618. MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
  619. for (int i = 0; i < 255; i++) { // impose order...
  620. IItem item = use.getItem((byte) i);
  621. if (item != null) {
  622. boolean isStar = mii.isThrowingStar(item.getItemId());
  623. if (isStar && item.getQuantity() >= 200) {
  624. projectile = item.getItemId();
  625. break;
  626. }
  627. }
  628. }
  629. if (projectile == 0) {
  630. return false;
  631. } else {
  632. MapleInventoryManipulator.removeById(applyto.getClient(), MapleInventoryType.USE, projectile, 200, false, true);
  633. }
  634. }
  635. if (overTime) {
  636. applyBuffEffect(applyfrom, applyto, primary);
  637. }
  638. if (primary && (overTime || isHeal())) {
  639. applyBuff(applyfrom);
  640. }
  641. if (primary && isMonsterBuff()) {
  642. applyMonsterBuff(applyfrom);
  643. }
  644.  
  645.  
  646. final SummonMovementType summonMovementType = getSummonMovementType();
  647. if (summonMovementType != null && pos != null) {
  648. final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
  649. if (!tosummon.isPuppet()) {
  650. applyfrom.getCheatTracker().resetSummonAttack();
  651. }
  652. applyfrom.getMap().spawnSummon(tosummon);
  653. applyfrom.getSummons().put(sourceid, tosummon);
  654. tosummon.addHP((short) x);
  655. if (isBeholder()) {
  656. tosummon.addHP((short) 1);
  657. }
  658. } else if (isMagicDoor()) { // Magic Door
  659. MapleDoor door = new MapleDoor(applyto, new Point(applyto.getPosition())); // Current Map door
  660. applyto.getMap().spawnDoor(door);
  661. applyto.addDoor(door);
  662.  
  663. MapleDoor townDoor = new MapleDoor(door); // Town door
  664. applyto.addDoor(townDoor);
  665. door.getTown().spawnDoor(townDoor);
  666.  
  667. if (applyto.getParty() != null) { // update town doors
  668. applyto.silentPartyUpdate();
  669. }
  670. applyto.disableDoor();
  671.  
  672. } else if (isMist()) {
  673. final Rectangle bounds = calculateBoundingBox(pos != null ? pos : applyfrom.getPosition(), applyfrom.isFacingLeft());
  674. final MapleMist mist = new MapleMist(bounds, applyfrom, this);
  675. applyfrom.getMap().spawnMist(mist, getDuration(), sourceid == 2111003, false);
  676.  
  677. } else if (isTimeLeap()) { // Time Leap
  678. for (PlayerCoolDownValueHolder i : applyto.getAllCooldowns()) {
  679. if (i.skillId != 5121010) {
  680. applyto.removeCooldown(i.skillId);
  681. applyto.getClient().getSession().write(MaplePacketCreator.skillCooldown(i.skillId, 0));
  682. }
  683. }
  684. }
  685. return true;
  686. }
  687.  
  688.  
  689.  
  690. private void applyBuff(MapleCharacter applyfrom) {
  691. if (isPartyBuff() && (applyfrom.getParty() != null || isGmBuff())) {
  692. Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
  693. List<MapleMapObject> affecteds = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapleMapObjectType.PLAYER));
  694. List<MapleCharacter> affectedp = new ArrayList<>(affecteds.size());
  695. for (MapleMapObject affectedmo : affecteds) {
  696. MapleCharacter affected = (MapleCharacter) affectedmo;
  697. if (affected != applyfrom && (isGmBuff() || applyfrom.getParty().equals(affected.getParty()))) {
  698. if ((isResurrection() && !affected.isAlive()) || (!isResurrection() && affected.isAlive())) {
  699. affectedp.add(affected);
  700. }
  701. if (isTimeLeap()) {
  702. for (PlayerCoolDownValueHolder i : affected.getAllCooldowns()) {
  703. affected.removeCooldown(i.skillId);
  704. }
  705. }
  706. }
  707. }
  708. for (MapleCharacter affected : affectedp) {
  709. applyTo(applyfrom, affected, false, null);
  710. affected.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(sourceid, 2));
  711. affected.getMap().broadcastMessage(affected,MaplePacketCreator.showBuffeffect(affected.getId(), sourceid, 2, (byte) 3), false);
  712. }
  713. }
  714. }
  715.  
  716. private void applyMonsterBuff(MapleCharacter applyfrom) {
  717. Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
  718. List<MapleMapObject> affected = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapleMapObjectType.MONSTER));
  719. ISkill skill_ = SkillFactory.getSkill(sourceid);
  720. int i = 0;
  721. for (MapleMapObject mo : affected) {
  722. MapleMonster monster = (MapleMonster) mo;
  723. if (makeChanceResult()) {
  724. monster.applyStatus(applyfrom, new MonsterStatusEffect(getMonsterStati(), skill_, false), isPoison(), getDuration());
  725. }
  726. i++;
  727. if (i >= mobCount) {
  728. break;
  729. }
  730. }
  731. }
  732.  
  733. private Rectangle calculateBoundingBox(Point posFrom, boolean facingLeft) {
  734. Point mylt;
  735. Point myrb;
  736. if (facingLeft) {
  737. mylt = new Point(lt.x + posFrom.x, lt.y + posFrom.y);
  738. myrb = new Point(rb.x + posFrom.x, rb.y + posFrom.y);
  739. } else {
  740. myrb = new Point(lt.x * -1 + posFrom.x, rb.y + posFrom.y);
  741. mylt = new Point(rb.x * -1 + posFrom.x, lt.y + posFrom.y);
  742. }
  743. Rectangle bounds = new Rectangle(mylt.x, mylt.y, myrb.x - mylt.x, myrb.y - mylt.y);
  744. return bounds;
  745. }
  746.  
  747. public void silentApplyBuff(MapleCharacter chr, long starttime) {
  748. int localDuration = duration;
  749. localDuration = alchemistModifyVal(chr, localDuration, false);
  750. CancelEffectAction cancelAction = new CancelEffectAction(chr, this, starttime);
  751. ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, ((starttime + localDuration) - System.currentTimeMillis()));
  752. chr.registerEffect(this, starttime, schedule);
  753. SummonMovementType summonMovementType = getSummonMovementType();
  754. if (summonMovementType != null) {
  755. final MapleSummon tosummon = new MapleSummon(chr, sourceid, chr.getPosition(), summonMovementType);
  756. if (!tosummon.isPuppet()) {
  757. chr.getMap().spawnSummon(tosummon);
  758. chr.getCheatTracker().resetSummonAttack();
  759. chr.getSummons().put(sourceid, tosummon);
  760. tosummon.addHP(x);
  761. }
  762. }
  763. }
  764.  
  765.  
  766. private void applyBuffEffect(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary) {
  767. if(skill && (this.sourceid == 4001003 || this.sourceid == 5101007) && applyfrom.getMap().getDisableInvincibilitySkills() && !applyfrom.isGM())
  768. {
  769. applyfrom.getClient().getSession().write(MaplePacketCreator.enableActions());
  770. applyfrom.getClient().getSession().write(MaplePacketCreator.serverNotice(5, "Invincibility skills are disabled in this map."));
  771. return;
  772. }
  773. if (sourceid != 5221006) {
  774. if (!this.isMonsterRiding()) {
  775. applyto.cancelEffect(this, true, -1);
  776. }
  777. } else {
  778. applyto.cancelEffect(this, true, -1);
  779. }
  780. List<Pair<MapleBuffStat, Integer>> localstatups = statups;
  781. int localDuration = duration;
  782. int localsourceid = sourceid;
  783. int localX = x;
  784. int localY = y;
  785. int seconds = localDuration / 1000;
  786. MapleMount givemount = null;
  787. if (isMonsterRiding()) {
  788. int ridingLevel = 0; // mount id
  789. IItem mount = applyfrom.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18);
  790. if (mount != null) {
  791. ridingLevel = mount.getItemId();
  792. }
  793. if (sourceid == 5221006) {
  794. ridingLevel = 1932000;
  795. givemount = new MapleMount(applyto, ridingLevel, 5221006);
  796. givemount.setActive(false);
  797. } else {
  798. if (applyto.getMount() == null) {
  799. applyto.Mount(ridingLevel, sourceid);
  800. }
  801. givemount = applyto.getMount();
  802. givemount.startSchedule();
  803. givemount.setActive(true);
  804. }
  805. localDuration = sourceid;
  806. localsourceid = ridingLevel;
  807. localstatups = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, 0));
  808. }
  809. if (isPirateMorph()) {
  810. localstatups = new ArrayList<Pair<MapleBuffStat, Integer>>();
  811. localstatups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.SPEED, Integer.valueOf(40)));
  812. localstatups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.JUMP, Integer.valueOf(20)));
  813. localstatups.add(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MORPH, getMorph(applyto)));
  814. }
  815. if (primary) {
  816. localDuration = alchemistModifyVal(applyfrom, localDuration, false);
  817. }
  818. if (localstatups.size() > 0) {
  819. if (isDash()) {
  820. localstatups = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DASH, 1));
  821. applyto.getClient().getSession().write(MaplePacketCreator.showDashP(localstatups, localX, localY, seconds));
  822. } else if (isInfusion()) {
  823. applyto.getClient().getSession().write(MaplePacketCreator.giveInfusion(seconds, x));
  824. } else {
  825. applyto.getClient().getSession().write(MaplePacketCreator.giveBuff((skill ? localsourceid : -localsourceid), localDuration, localstatups, isMorph(), isMonsterRiding(), givemount));
  826. }
  827. }// else if (!this.isResurrection()) {
  828. //log.warn(applyto.getName() + " is applying an empty statup.");
  829. //}
  830. if (isDs()) {
  831. List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
  832. MapleBuffStat.DARKSIGHT, 0));
  833. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), dsstat, false),
  834. false);
  835. }
  836. if (isCombo()) {
  837. List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
  838. MapleBuffStat.COMBO, 1));
  839. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat, false),
  840. false);
  841. } else if (isMonsterRiding()) {
  842. if (givemount.getItemId() != 0) {
  843. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showMonsterRiding(applyto.getId(), Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.MONSTER_RIDING, 1)), givemount), false);
  844. }
  845. localDuration = duration;
  846. }
  847. if (isShadowPartner()) {
  848. List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
  849. MapleBuffStat.SHADOWPARTNER, 0));
  850. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat, false),
  851. false);
  852. }
  853. if (isSoulArrow()) {
  854. List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
  855. MapleBuffStat.SOULARROW, 0));
  856. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat, false),
  857. false);
  858. }
  859.  
  860. if (isEnrage()) {
  861. applyto.handleOrbconsume();
  862. }
  863. if (isMorph() || isOakBarrel() || isPirateMorph()) { //Not sure o.o
  864. List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(
  865. MapleBuffStat.MORPH, Integer.valueOf(getMorph(applyto))));
  866. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignBuff(applyto.getId(), stat, true),
  867. false);
  868. }
  869. if (isTimeLeap()) {
  870. for (PlayerCoolDownValueHolder i : applyto.getAllCooldowns()) {
  871. if (i.skillId != 5121010) {
  872. applyto.removeCooldown(i.skillId);
  873. }
  874. }
  875. }
  876. if (localstatups.size() > 0) {
  877. long starttime = System.currentTimeMillis();
  878. CancelEffectAction cancelAction = new CancelEffectAction(applyto, this, starttime);
  879. ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, localDuration);
  880. applyto.registerEffect(this, starttime, schedule);
  881. }
  882. if (primary) {
  883. if (isDash()) {
  884. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showDashEffecttoOthers(applyto.getId(), localX, localY, seconds), false);
  885. } else if (isInfusion()) {
  886. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.giveForeignInfusion(applyto.getId(), x, seconds), false);
  887. } else {
  888. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showBuffeffect(applyto.getId(), sourceid, 1, (byte) 3), false);
  889. }
  890. }
  891. if (isOakBarrel() || isPirateMorph()) { //Kinda a hacky fix, but who cares..
  892. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getObjectId()), false);
  893. applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapobject(applyto), false);
  894. }
  895. }
  896.  
  897. private int calcHPChange(MapleCharacter applyfrom, boolean primary) {
  898. if(isGMHeal()) return 30000;
  899. int hpchange = 0;
  900. if (hp != 0) {
  901. if (!skill) {
  902. if (primary) {
  903. hpchange += alchemistModifyVal(applyfrom, hp, true);
  904. } else {
  905. hpchange += hp;
  906. }
  907. } else { // assumption: this is heal
  908. hpchange += makeHealHP(hp / 100.0, applyfrom.getTotalMagic(), 3, 5);
  909. }
  910. }
  911. if (hpR != 0) {
  912. hpchange += (int) (applyfrom.getCurrentMaxHp() * hpR);
  913. applyfrom.checkBerserk();
  914. }
  915. // actually receivers probably never get any hp when it's not heal but whatever
  916. if (primary) {
  917. if (hpCon != 0) {
  918. hpchange -= hpCon;
  919. }
  920. }
  921. if (isChakra()) {
  922. hpchange += makeHealHP(getY() / 100.0, applyfrom.getTotalLuk(), 2.3, 3.5);
  923. }
  924. return hpchange;
  925. }
  926.  
  927. private int makeHealHP(double rate, double stat, double lowerfactor, double upperfactor) {
  928.  
  929. int maxHeal = (int) (stat * upperfactor * rate);
  930. int minHeal = (int) (stat * lowerfactor * rate);
  931. return (int) ((Math.random() * (maxHeal - minHeal + 1)) + minHeal);
  932. }
  933.  
  934. private int calcMPChange(MapleCharacter applyfrom, boolean primary) {
  935. if(isGMHeal()) return 30000;
  936. int mpchange = 0;
  937. if (mp != 0) {
  938. if (primary) {
  939. mpchange += alchemistModifyVal(applyfrom, mp, true);
  940. } else {
  941. mpchange += mp;
  942. }
  943. }
  944. if (mpR != 0) {
  945. mpchange += (int) (applyfrom.getCurrentMaxMp() * mpR);
  946. }
  947. if (primary) {
  948. if (mpCon != 0) {
  949. double mod = 1.0;
  950. boolean isAFpMage = applyfrom.getJob().isA(MapleJob.FP_MAGE);
  951. if (isAFpMage || applyfrom.getJob().isA(MapleJob.IL_MAGE)) {
  952. ISkill amp;
  953. if (isAFpMage) {
  954. amp = SkillFactory.getSkill(2110001);
  955. } else {
  956. amp = SkillFactory.getSkill(2210001);
  957. }
  958. int ampLevel = applyfrom.getSkillLevel(amp);
  959. if (ampLevel > 0) {
  960. MapleStatEffect ampStat = amp.getEffect(ampLevel);
  961. mod = ampStat.getX() / 100.0;
  962. }
  963. }
  964. mpchange -= mpCon * mod;
  965. if (applyfrom.getBuffedValue(MapleBuffStat.INFINITY) != null) {
  966. mpchange = 0;
  967. }
  968. }
  969. }
  970. return mpchange;
  971. }
  972.  
  973. private int alchemistModifyVal(MapleCharacter chr, int val, boolean withX) {
  974. if (!skill && (chr.getJob().isA(MapleJob.HERMIT) || chr.getJob().isA(MapleJob.NIGHTLORD))) {
  975. MapleStatEffect alchemistEffect = getAlchemistEffect(chr);
  976. if (alchemistEffect != null) {
  977. return (int) (val * ((withX ? alchemistEffect.getX() : alchemistEffect.getY()) / 100.0));
  978. }
  979. }
  980. return val;
  981. }
  982.  
  983. private MapleStatEffect getAlchemistEffect(MapleCharacter chr) {
  984. ISkill alchemist = SkillFactory.getSkill(4110000);
  985. int alchemistLevel = chr.getSkillLevel(alchemist);
  986. if (alchemistLevel == 0) {
  987. return null;
  988. }
  989. return alchemist.getEffect(alchemistLevel);
  990. }
  991.  
  992. public void setSourceId(int newid) {
  993. sourceid = newid;
  994. }
  995.  
  996. public short getHpCon() {
  997. return hpCon;
  998. }
  999.  
  1000. public short getMpCon() {
  1001. return mpCon;
  1002. }
  1003.  
  1004.  
  1005. public final boolean isGmBuff() {
  1006. switch (sourceid) {
  1007. case 10001075: //Empress Prayer
  1008. case 9001000: // GM dispel
  1009. case 9001001: // GM haste
  1010. case 9001002: // GM Holy Symbol
  1011. case 9001003: // GM Bless
  1012. case 9001005: // GM resurrection
  1013. case 9001008: // GM Hyper body
  1014.  
  1015. case 9101000:
  1016. case 9101001:
  1017. case 9101002:
  1018. case 9101003:
  1019. case 9101005:
  1020. case 9101008:
  1021. return true;
  1022. default:
  1023. return Configuration.isBeginnerJob(sourceid / 10000) && sourceid % 10000 == 1005;
  1024. }
  1025. }
  1026.  
  1027. private boolean isMonsterBuff() {
  1028. if (!skill) {
  1029. return false;
  1030. }
  1031. switch (sourceid) {
  1032. case 1201006: // threaten
  1033. case 2101003: // fp slow
  1034. case 2201003: // il slow
  1035. case 2211004: // il seal
  1036. case 2111004: // fp seal
  1037. case 2311005: // doom
  1038. case 4111003: // shadow web
  1039. return true;
  1040. }
  1041. return false;
  1042. }
  1043.  
  1044. private boolean isPartyBuff() {
  1045. if (lt == null || rb == null) {
  1046. return false;
  1047. }
  1048. if ((sourceid >= 1211003 && sourceid <= 1211008) || sourceid == 1221003 || sourceid == 1221004) { // wk charges have lt and rb set but are neither player nor monster buffs
  1049. return false;
  1050. }
  1051. return true;
  1052. }
  1053.  
  1054. public boolean isHeal() {
  1055. return sourceid == 2301002 || sourceid == 9101000;
  1056. }
  1057.  
  1058. public boolean isResurrection() {
  1059. return sourceid == 9101005 || sourceid == 2321006 || sourceid == SuperGM.RESURRECTION;
  1060. }
  1061.  
  1062. public boolean isTimeLeap() {
  1063. return sourceid == 5121010;
  1064. }
  1065.  
  1066. public boolean isInfusion() {
  1067. return skill && sourceid == 0000000;
  1068. }
  1069.  
  1070. public final boolean isMonsterRiding_() {
  1071. return skill && (sourceid == 1004 || sourceid == 10001004 || sourceid == 20001004 || sourceid == 20011004 || sourceid == 11004 || sourceid == 20021004 || sourceid == 80001000);
  1072. }
  1073.  
  1074. public short getHp() {
  1075. return hp;
  1076. }
  1077.  
  1078. public short getMp() {
  1079. return mp;
  1080. }
  1081.  
  1082. public short getWatk() {
  1083. return watk;
  1084. }
  1085.  
  1086. public short getMatk() {
  1087. return matk;
  1088. }
  1089.  
  1090. public short getWdef() {
  1091. return wdef;
  1092. }
  1093.  
  1094. public short getMdef() {
  1095. return mdef;
  1096. }
  1097.  
  1098. public short getAcc() {
  1099. return acc;
  1100. }
  1101.  
  1102. public short getAvoid() {
  1103. return avoid;
  1104. }
  1105.  
  1106. public short getHands() {
  1107. return hands;
  1108. }
  1109.  
  1110. public short getSpeed() {
  1111. return speed;
  1112. }
  1113.  
  1114. public short getJump() {
  1115. return jump;
  1116. }
  1117.  
  1118. public int getDuration() {
  1119. return duration;
  1120. }
  1121.  
  1122. public boolean isOverTime() {
  1123. return overTime;
  1124. }
  1125.  
  1126. public List<Pair<MapleBuffStat, Integer>> getStatups() {
  1127. return statups;
  1128. }
  1129.  
  1130. public boolean sameSource(MapleStatEffect effect) {
  1131. return this.sourceid == effect.sourceid && this.skill == effect.skill;
  1132. }
  1133.  
  1134. public int getX() {
  1135. return x;
  1136. }
  1137.  
  1138. public int getY() {
  1139. return y;
  1140. }
  1141.  
  1142. public int getZ() {
  1143. return z;
  1144. }
  1145.  
  1146. public int getDamage() {
  1147. return damage;
  1148. }
  1149.  
  1150. public int getAttackCount() {
  1151. return attackCount;
  1152. }
  1153.  
  1154. public int getBulletCount() {
  1155. return bulletCount;
  1156. }
  1157.  
  1158. public int getBulletConsume() {
  1159. return bulletConsume;
  1160. }
  1161.  
  1162. public int getMoneyCon() {
  1163. return moneyCon;
  1164. }
  1165.  
  1166. public int getCooldown() {
  1167. return cooldown;
  1168. }
  1169.  
  1170. public Map<MonsterStatus, Integer> getMonsterStati() {
  1171. return monsterStatus;
  1172. }
  1173.  
  1174. public boolean isHide() {
  1175. return skill && sourceid == 9101004;
  1176. }
  1177.  
  1178. public boolean isDragonBlood() {
  1179. return skill && sourceid == 1311008;
  1180. }
  1181.  
  1182. public boolean isBerserk() {
  1183. return skill && sourceid == 1320006;
  1184. }
  1185.  
  1186. private boolean isDs() {
  1187. return skill && sourceid == 4001003;
  1188. }
  1189.  
  1190. private boolean isOakBarrel() {
  1191. return skill && sourceid == 5101007;
  1192. }
  1193.  
  1194. private boolean isCombo() {
  1195. return skill && sourceid == 1111002;
  1196. }
  1197.  
  1198. private boolean isEnrage() {
  1199. return skill && sourceid == 1121010;
  1200. }
  1201.  
  1202. public boolean isMPRecovery() {
  1203. return skill && sourceid == 5101005;
  1204. }
  1205.  
  1206. public boolean isBeholder() {
  1207. return skill && sourceid == 1321007;
  1208. }
  1209.  
  1210. public boolean isPhoenix() {
  1211. return skill && sourceid == 3121006;
  1212. }
  1213.  
  1214. public boolean isMarksMan() {
  1215. return skill && sourceid == 3221005;
  1216. }
  1217.  
  1218. public boolean isMageSummon() {
  1219. return skill && sourceid == 2121005;
  1220. }
  1221.  
  1222. public boolean isMageSummon2() {
  1223. return skill && sourceid == 2221005;
  1224. }
  1225.  
  1226. private boolean isShadowPartner() {
  1227. return skill && sourceid == 4111002;
  1228. }
  1229.  
  1230. private boolean isChakra() {
  1231. return skill && sourceid == 4211001;
  1232. }
  1233.  
  1234. public boolean isMonsterRiding() {
  1235. return skill && (sourceid == 1004 || sourceid == 5221006);
  1236. }
  1237.  
  1238. public boolean isBattleShip() {
  1239. return skill && sourceid == 5221006;
  1240. }
  1241.  
  1242. public boolean isMagicDoor() {
  1243. return skill && sourceid == 2311002;
  1244. }
  1245.  
  1246. public boolean isMesoGuard() {
  1247. return skill && sourceid == 4211005;
  1248. }
  1249.  
  1250. public boolean isCharge() {
  1251. return skill && sourceid >= 1211003 && sourceid <= 1211008;
  1252. }
  1253.  
  1254. public boolean isPoison() {
  1255. return skill && (sourceid == 2111003 || sourceid == 2101005 || sourceid == 2111006);
  1256. }
  1257.  
  1258. private boolean isMist() {
  1259. return skill && (sourceid == 2111003 || sourceid == 4221006); // poison mist and smokescreen
  1260. }
  1261.  
  1262. private boolean isSoulArrow() {
  1263. return skill && (sourceid == 3101004 || sourceid == 3201004); // bow and crossbow
  1264. }
  1265.  
  1266. private boolean isShadowClaw() {
  1267. return skill && sourceid == 4121006;
  1268. }
  1269.  
  1270. private boolean isDispel() {
  1271. return skill && (sourceid == 2311001 || sourceid == 9101000);
  1272. }
  1273.  
  1274. private boolean isHeroWill() {
  1275. return skill && (sourceid == 1121011 || sourceid == 1221012 || sourceid == 1321010 || sourceid == 2121008 || sourceid == 2221008 || sourceid == 2321009 || sourceid == 3121009 || sourceid == 3221008 || sourceid == 4121009 || sourceid == 4221008 || sourceid == 5121008 || sourceid == 5221010);
  1276. }
  1277.  
  1278. private boolean isDash() {
  1279. return skill && sourceid == 5001005;
  1280. }
  1281.  
  1282. public boolean isPirateMorph() {
  1283. return skill && (sourceid == 5111005 || sourceid == 5121003);
  1284. }
  1285.  
  1286. public boolean isMorph() {
  1287. return morphId > 0;
  1288. }
  1289.  
  1290. public int getMorph() {
  1291. return morphId;
  1292. }
  1293. public boolean isGMHeal()
  1294. {
  1295. return skill && sourceid == 9101000;
  1296. }
  1297. public int getMorph(MapleCharacter chr) {
  1298. if (isOakBarrel()) {
  1299. return 1002;
  1300. }
  1301. if (isPirateMorph()) {
  1302. if (this.sourceid == 5111005) { // transform
  1303. if (chr.getGender() == 0)
  1304. return 1000;
  1305. else
  1306. return 1100;
  1307. } else if (sourceid == 5121003) { //super transform
  1308. if (chr.getGender() == 0)
  1309. return 1001;
  1310. else
  1311. return 1101;
  1312. }
  1313. }
  1314. return morphId;
  1315. }
  1316.  
  1317. public SummonMovementType getSummonMovementType() {
  1318. if (!skill) {
  1319. return null;
  1320. }
  1321. switch (sourceid) {
  1322. case 3211002: // puppet sniper
  1323. case 3111002: // puppet ranger
  1324. case 5211001: // octopus - pirate
  1325. case 5220002: // advanced octopus - pirate
  1326. return SummonMovementType.STATIONARY;
  1327. case 3211005: // golden eagle
  1328. case 3111005: // golden hawk
  1329. case 2311006: // summon dragon
  1330. case 3221005: // frostprey
  1331. case 3121006: // phoenix
  1332. case 5211002: // bird - pirate
  1333. return SummonMovementType.CIRCLE_FOLLOW;
  1334. case 1321007: // beholder
  1335. case 2121005: // elquines
  1336. case 2221005: // ifrit
  1337. case 2321003: // bahamut
  1338. return SummonMovementType.FOLLOW;
  1339. }
  1340. return null;
  1341. }
  1342.  
  1343. public boolean isSkill() {
  1344. return skill;
  1345. }
  1346.  
  1347. public int getSourceId() {
  1348. return sourceid;
  1349. }
  1350.  
  1351. public int getMastery() {
  1352. return mastery;
  1353. }
  1354.  
  1355. public int getRange() {
  1356. return range;
  1357. }
  1358.  
  1359. public int getMobCount() {
  1360. return mobCount;
  1361. }
  1362.  
  1363. public int getFixDamage() {
  1364. return fixDamage;
  1365. }
  1366.  
  1367. /**
  1368. *
  1369. * @return true if the effect should happen based on it's probablity, false otherwise
  1370. */
  1371. public boolean makeChanceResult() {
  1372. return prop == 1.0 || Math.random() < prop;
  1373. }
  1374.  
  1375. private static class CancelEffectAction implements Runnable {
  1376.  
  1377. private MapleStatEffect effect;
  1378. private WeakReference<MapleCharacter> target;
  1379. private long startTime;
  1380.  
  1381. public CancelEffectAction(MapleCharacter target, MapleStatEffect effect, long startTime) {
  1382. this.effect = effect;
  1383. this.target = new WeakReference<>(target);
  1384. this.startTime = startTime;
  1385. }
  1386.  
  1387. @Override
  1388. public void run() {
  1389. MapleCharacter realTarget = target.get();
  1390. if (realTarget != null) {
  1391. realTarget.cancelEffect(effect, false, startTime);
  1392. }
  1393. }
  1394. }
  1395. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement