DocumentSkill.java 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.engines.skills;
  20. import java.io.File;
  21. import java.util.List;
  22. import java.util.logging.Level;
  23. import javolution.util.FastList;
  24. import org.w3c.dom.Document;
  25. import org.w3c.dom.NamedNodeMap;
  26. import org.w3c.dom.Node;
  27. import com.l2jserver.gameserver.datatables.EnchantSkillGroupsData;
  28. import com.l2jserver.gameserver.engines.DocumentBase;
  29. import com.l2jserver.gameserver.model.StatsSet;
  30. import com.l2jserver.gameserver.model.conditions.Condition;
  31. import com.l2jserver.gameserver.model.skills.L2Skill;
  32. import com.l2jserver.gameserver.model.skills.L2SkillType;
  33. /**
  34. * @author mkizub
  35. */
  36. public class DocumentSkill extends DocumentBase
  37. {
  38. public static class Skill
  39. {
  40. public int id;
  41. public String name;
  42. public StatsSet[] sets;
  43. public StatsSet[] enchsets1;
  44. public StatsSet[] enchsets2;
  45. public StatsSet[] enchsets3;
  46. public StatsSet[] enchsets4;
  47. public StatsSet[] enchsets5;
  48. public StatsSet[] enchsets6;
  49. public StatsSet[] enchsets7;
  50. public StatsSet[] enchsets8;
  51. public int currentLevel;
  52. public List<L2Skill> skills = new FastList<>();
  53. public List<L2Skill> currentSkills = new FastList<>();
  54. }
  55. private Skill _currentSkill;
  56. private final List<L2Skill> _skillsInFile = new FastList<>();
  57. public DocumentSkill(File file)
  58. {
  59. super(file);
  60. }
  61. private void setCurrentSkill(Skill skill)
  62. {
  63. _currentSkill = skill;
  64. }
  65. @Override
  66. protected StatsSet getStatsSet()
  67. {
  68. return _currentSkill.sets[_currentSkill.currentLevel];
  69. }
  70. public List<L2Skill> getSkills()
  71. {
  72. return _skillsInFile;
  73. }
  74. @Override
  75. protected String getTableValue(String name)
  76. {
  77. try
  78. {
  79. return _tables.get(name)[_currentSkill.currentLevel];
  80. }
  81. catch (RuntimeException e)
  82. {
  83. _log.log(Level.SEVERE, "Error in table: " + name + " of Skill Id " + _currentSkill.id, e);
  84. return "";
  85. }
  86. }
  87. @Override
  88. protected String getTableValue(String name, int idx)
  89. {
  90. try
  91. {
  92. return _tables.get(name)[idx - 1];
  93. }
  94. catch (RuntimeException e)
  95. {
  96. _log.log(Level.SEVERE, "wrong level count in skill Id " + _currentSkill.id + " name: " + name + " index : " + idx, e);
  97. return "";
  98. }
  99. }
  100. @Override
  101. protected void parseDocument(Document doc)
  102. {
  103. for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  104. {
  105. if ("list".equalsIgnoreCase(n.getNodeName()))
  106. {
  107. for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  108. {
  109. if ("skill".equalsIgnoreCase(d.getNodeName()))
  110. {
  111. setCurrentSkill(new Skill());
  112. parseSkill(d);
  113. _skillsInFile.addAll(_currentSkill.skills);
  114. resetTable();
  115. }
  116. }
  117. }
  118. else if ("skill".equalsIgnoreCase(n.getNodeName()))
  119. {
  120. setCurrentSkill(new Skill());
  121. parseSkill(n);
  122. _skillsInFile.addAll(_currentSkill.skills);
  123. }
  124. }
  125. }
  126. protected void parseSkill(Node n)
  127. {
  128. NamedNodeMap attrs = n.getAttributes();
  129. int enchantLevels1 = 0;
  130. int enchantLevels2 = 0;
  131. int enchantLevels3 = 0;
  132. int enchantLevels4 = 0;
  133. int enchantLevels5 = 0;
  134. int enchantLevels6 = 0;
  135. int enchantLevels7 = 0;
  136. int enchantLevels8 = 0;
  137. int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
  138. String skillName = attrs.getNamedItem("name").getNodeValue();
  139. String levels = attrs.getNamedItem("levels").getNodeValue();
  140. int lastLvl = Integer.parseInt(levels);
  141. if (attrs.getNamedItem("enchantGroup1") != null)
  142. {
  143. enchantLevels1 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 1, Integer.parseInt(attrs.getNamedItem("enchantGroup1").getNodeValue()));
  144. }
  145. if (attrs.getNamedItem("enchantGroup2") != null)
  146. {
  147. enchantLevels2 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 2, Integer.parseInt(attrs.getNamedItem("enchantGroup2").getNodeValue()));
  148. }
  149. if (attrs.getNamedItem("enchantGroup3") != null)
  150. {
  151. enchantLevels3 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 3, Integer.parseInt(attrs.getNamedItem("enchantGroup3").getNodeValue()));
  152. }
  153. if (attrs.getNamedItem("enchantGroup4") != null)
  154. {
  155. enchantLevels4 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 4, Integer.parseInt(attrs.getNamedItem("enchantGroup4").getNodeValue()));
  156. }
  157. if (attrs.getNamedItem("enchantGroup5") != null)
  158. {
  159. enchantLevels5 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 5, Integer.parseInt(attrs.getNamedItem("enchantGroup5").getNodeValue()));
  160. }
  161. if (attrs.getNamedItem("enchantGroup6") != null)
  162. {
  163. enchantLevels6 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 6, Integer.parseInt(attrs.getNamedItem("enchantGroup6").getNodeValue()));
  164. }
  165. if (attrs.getNamedItem("enchantGroup7") != null)
  166. {
  167. enchantLevels7 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 7, Integer.parseInt(attrs.getNamedItem("enchantGroup7").getNodeValue()));
  168. }
  169. if (attrs.getNamedItem("enchantGroup8") != null)
  170. {
  171. enchantLevels8 = EnchantSkillGroupsData.getInstance().addNewRouteForSkill(skillId, lastLvl, 8, Integer.parseInt(attrs.getNamedItem("enchantGroup8").getNodeValue()));
  172. }
  173. _currentSkill.id = skillId;
  174. _currentSkill.name = skillName;
  175. _currentSkill.sets = new StatsSet[lastLvl];
  176. _currentSkill.enchsets1 = new StatsSet[enchantLevels1];
  177. _currentSkill.enchsets2 = new StatsSet[enchantLevels2];
  178. _currentSkill.enchsets3 = new StatsSet[enchantLevels3];
  179. _currentSkill.enchsets4 = new StatsSet[enchantLevels4];
  180. _currentSkill.enchsets5 = new StatsSet[enchantLevels5];
  181. _currentSkill.enchsets6 = new StatsSet[enchantLevels6];
  182. _currentSkill.enchsets7 = new StatsSet[enchantLevels7];
  183. _currentSkill.enchsets8 = new StatsSet[enchantLevels8];
  184. for (int i = 0; i < lastLvl; i++)
  185. {
  186. _currentSkill.sets[i] = new StatsSet();
  187. _currentSkill.sets[i].set("skill_id", _currentSkill.id);
  188. _currentSkill.sets[i].set("level", i + 1);
  189. _currentSkill.sets[i].set("name", _currentSkill.name);
  190. }
  191. if (_currentSkill.sets.length != lastLvl)
  192. {
  193. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + lastLvl + " levels expected");
  194. }
  195. Node first = n.getFirstChild();
  196. for (n = first; n != null; n = n.getNextSibling())
  197. {
  198. if ("table".equalsIgnoreCase(n.getNodeName()))
  199. {
  200. parseTable(n);
  201. }
  202. }
  203. for (int i = 1; i <= lastLvl; i++)
  204. {
  205. for (n = first; n != null; n = n.getNextSibling())
  206. {
  207. if ("set".equalsIgnoreCase(n.getNodeName()))
  208. {
  209. // Extractable item skills by Zoey76
  210. if ("capsuled_items_skill".equalsIgnoreCase(n.getAttributes().getNamedItem("name").getNodeValue()))
  211. {
  212. setExtractableSkillData(_currentSkill.sets[i - 1], getTableValue("#extractableItems", i));
  213. }
  214. else
  215. {
  216. parseBeanSet(n, _currentSkill.sets[i - 1], i);
  217. }
  218. }
  219. }
  220. }
  221. for (int i = 0; i < enchantLevels1; i++)
  222. {
  223. _currentSkill.enchsets1[i] = new StatsSet();
  224. _currentSkill.enchsets1[i].set("skill_id", _currentSkill.id);
  225. // currentSkill.enchsets1[i] = currentSkill.sets[currentSkill.sets.length-1];
  226. _currentSkill.enchsets1[i].set("level", i + 101);
  227. _currentSkill.enchsets1[i].set("name", _currentSkill.name);
  228. // currentSkill.enchsets1[i].set("skillType", "NOTDONE");
  229. for (n = first; n != null; n = n.getNextSibling())
  230. {
  231. if ("set".equalsIgnoreCase(n.getNodeName()))
  232. {
  233. parseBeanSet(n, _currentSkill.enchsets1[i], _currentSkill.sets.length);
  234. }
  235. }
  236. for (n = first; n != null; n = n.getNextSibling())
  237. {
  238. if ("enchant1".equalsIgnoreCase(n.getNodeName()))
  239. {
  240. parseBeanSet(n, _currentSkill.enchsets1[i], i + 1);
  241. }
  242. }
  243. }
  244. if (_currentSkill.enchsets1.length != enchantLevels1)
  245. {
  246. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels1 + " levels expected");
  247. }
  248. for (int i = 0; i < enchantLevels2; i++)
  249. {
  250. _currentSkill.enchsets2[i] = new StatsSet();
  251. // currentSkill.enchsets2[i] = currentSkill.sets[currentSkill.sets.length-1];
  252. _currentSkill.enchsets2[i].set("skill_id", _currentSkill.id);
  253. _currentSkill.enchsets2[i].set("level", i + 201);
  254. _currentSkill.enchsets2[i].set("name", _currentSkill.name);
  255. // currentSkill.enchsets2[i].set("skillType", "NOTDONE");
  256. for (n = first; n != null; n = n.getNextSibling())
  257. {
  258. if ("set".equalsIgnoreCase(n.getNodeName()))
  259. {
  260. parseBeanSet(n, _currentSkill.enchsets2[i], _currentSkill.sets.length);
  261. }
  262. }
  263. for (n = first; n != null; n = n.getNextSibling())
  264. {
  265. if ("enchant2".equalsIgnoreCase(n.getNodeName()))
  266. {
  267. parseBeanSet(n, _currentSkill.enchsets2[i], i + 1);
  268. }
  269. }
  270. }
  271. if (_currentSkill.enchsets2.length != enchantLevels2)
  272. {
  273. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels2 + " levels expected");
  274. }
  275. for (int i = 0; i < enchantLevels3; i++)
  276. {
  277. _currentSkill.enchsets3[i] = new StatsSet();
  278. _currentSkill.enchsets3[i].set("skill_id", _currentSkill.id);
  279. _currentSkill.enchsets3[i].set("level", i + 301);
  280. _currentSkill.enchsets3[i].set("name", _currentSkill.name);
  281. for (n = first; n != null; n = n.getNextSibling())
  282. {
  283. if ("set".equalsIgnoreCase(n.getNodeName()))
  284. {
  285. parseBeanSet(n, _currentSkill.enchsets3[i], _currentSkill.sets.length);
  286. }
  287. }
  288. for (n = first; n != null; n = n.getNextSibling())
  289. {
  290. if ("enchant3".equalsIgnoreCase(n.getNodeName()))
  291. {
  292. parseBeanSet(n, _currentSkill.enchsets3[i], i + 1);
  293. }
  294. }
  295. }
  296. if (_currentSkill.enchsets3.length != enchantLevels3)
  297. {
  298. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels3 + " levels expected");
  299. }
  300. for (int i = 0; i < enchantLevels4; i++)
  301. {
  302. _currentSkill.enchsets4[i] = new StatsSet();
  303. _currentSkill.enchsets4[i].set("skill_id", _currentSkill.id);
  304. _currentSkill.enchsets4[i].set("level", i + 401);
  305. _currentSkill.enchsets4[i].set("name", _currentSkill.name);
  306. for (n = first; n != null; n = n.getNextSibling())
  307. {
  308. if ("set".equalsIgnoreCase(n.getNodeName()))
  309. {
  310. parseBeanSet(n, _currentSkill.enchsets4[i], _currentSkill.sets.length);
  311. }
  312. }
  313. for (n = first; n != null; n = n.getNextSibling())
  314. {
  315. if ("enchant4".equalsIgnoreCase(n.getNodeName()))
  316. {
  317. parseBeanSet(n, _currentSkill.enchsets4[i], i + 1);
  318. }
  319. }
  320. }
  321. if (_currentSkill.enchsets4.length != enchantLevels4)
  322. {
  323. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels4 + " levels expected");
  324. }
  325. for (int i = 0; i < enchantLevels5; i++)
  326. {
  327. _currentSkill.enchsets5[i] = new StatsSet();
  328. _currentSkill.enchsets5[i].set("skill_id", _currentSkill.id);
  329. _currentSkill.enchsets5[i].set("level", i + 501);
  330. _currentSkill.enchsets5[i].set("name", _currentSkill.name);
  331. for (n = first; n != null; n = n.getNextSibling())
  332. {
  333. if ("set".equalsIgnoreCase(n.getNodeName()))
  334. {
  335. parseBeanSet(n, _currentSkill.enchsets5[i], _currentSkill.sets.length);
  336. }
  337. }
  338. for (n = first; n != null; n = n.getNextSibling())
  339. {
  340. if ("enchant5".equalsIgnoreCase(n.getNodeName()))
  341. {
  342. parseBeanSet(n, _currentSkill.enchsets5[i], i + 1);
  343. }
  344. }
  345. }
  346. if (_currentSkill.enchsets5.length != enchantLevels5)
  347. {
  348. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels5 + " levels expected");
  349. }
  350. for (int i = 0; i < enchantLevels6; i++)
  351. {
  352. _currentSkill.enchsets6[i] = new StatsSet();
  353. _currentSkill.enchsets6[i].set("skill_id", _currentSkill.id);
  354. _currentSkill.enchsets6[i].set("level", i + 601);
  355. _currentSkill.enchsets6[i].set("name", _currentSkill.name);
  356. for (n = first; n != null; n = n.getNextSibling())
  357. {
  358. if ("set".equalsIgnoreCase(n.getNodeName()))
  359. {
  360. parseBeanSet(n, _currentSkill.enchsets6[i], _currentSkill.sets.length);
  361. }
  362. }
  363. for (n = first; n != null; n = n.getNextSibling())
  364. {
  365. if ("enchant6".equalsIgnoreCase(n.getNodeName()))
  366. {
  367. parseBeanSet(n, _currentSkill.enchsets6[i], i + 1);
  368. }
  369. }
  370. }
  371. if (_currentSkill.enchsets6.length != enchantLevels6)
  372. {
  373. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels6 + " levels expected");
  374. }
  375. for (int i = 0; i < enchantLevels7; i++)
  376. {
  377. _currentSkill.enchsets7[i] = new StatsSet();
  378. _currentSkill.enchsets7[i].set("skill_id", _currentSkill.id);
  379. _currentSkill.enchsets7[i].set("level", i + 701);
  380. _currentSkill.enchsets7[i].set("name", _currentSkill.name);
  381. for (n = first; n != null; n = n.getNextSibling())
  382. {
  383. if ("set".equalsIgnoreCase(n.getNodeName()))
  384. {
  385. parseBeanSet(n, _currentSkill.enchsets7[i], _currentSkill.sets.length);
  386. }
  387. }
  388. for (n = first; n != null; n = n.getNextSibling())
  389. {
  390. if ("enchant7".equalsIgnoreCase(n.getNodeName()))
  391. {
  392. parseBeanSet(n, _currentSkill.enchsets7[i], i + 1);
  393. }
  394. }
  395. }
  396. if (_currentSkill.enchsets7.length != enchantLevels7)
  397. {
  398. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels7 + " levels expected");
  399. }
  400. for (int i = 0; i < enchantLevels8; i++)
  401. {
  402. _currentSkill.enchsets8[i] = new StatsSet();
  403. _currentSkill.enchsets8[i].set("skill_id", _currentSkill.id);
  404. _currentSkill.enchsets8[i].set("level", i + 801);
  405. _currentSkill.enchsets8[i].set("name", _currentSkill.name);
  406. for (n = first; n != null; n = n.getNextSibling())
  407. {
  408. if ("set".equalsIgnoreCase(n.getNodeName()))
  409. {
  410. parseBeanSet(n, _currentSkill.enchsets8[i], _currentSkill.sets.length);
  411. }
  412. }
  413. for (n = first; n != null; n = n.getNextSibling())
  414. {
  415. if ("enchant8".equalsIgnoreCase(n.getNodeName()))
  416. {
  417. parseBeanSet(n, _currentSkill.enchsets8[i], i + 1);
  418. }
  419. }
  420. }
  421. if (_currentSkill.enchsets8.length != enchantLevels8)
  422. {
  423. throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels8 + " levels expected");
  424. }
  425. makeSkills();
  426. for (int i = 0; i < lastLvl; i++)
  427. {
  428. _currentSkill.currentLevel = i;
  429. for (n = first; n != null; n = n.getNextSibling())
  430. {
  431. if ("cond".equalsIgnoreCase(n.getNodeName()))
  432. {
  433. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  434. Node msg = n.getAttributes().getNamedItem("msg");
  435. Node msgId = n.getAttributes().getNamedItem("msgId");
  436. if ((condition != null) && (msg != null))
  437. {
  438. condition.setMessage(msg.getNodeValue());
  439. }
  440. else if ((condition != null) && (msgId != null))
  441. {
  442. condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
  443. Node addName = n.getAttributes().getNamedItem("addName");
  444. if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
  445. {
  446. condition.addName();
  447. }
  448. }
  449. _currentSkill.currentSkills.get(i).attach(condition, false);
  450. }
  451. else if ("for".equalsIgnoreCase(n.getNodeName()))
  452. {
  453. parseTemplate(n, _currentSkill.currentSkills.get(i));
  454. }
  455. }
  456. }
  457. for (int i = lastLvl; i < (lastLvl + enchantLevels1); i++)
  458. {
  459. _currentSkill.currentLevel = i - lastLvl;
  460. boolean foundCond = false, foundFor = false;
  461. for (n = first; n != null; n = n.getNextSibling())
  462. {
  463. if ("enchant1cond".equalsIgnoreCase(n.getNodeName()))
  464. {
  465. foundCond = true;
  466. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  467. Node msg = n.getAttributes().getNamedItem("msg");
  468. if ((condition != null) && (msg != null))
  469. {
  470. condition.setMessage(msg.getNodeValue());
  471. }
  472. _currentSkill.currentSkills.get(i).attach(condition, false);
  473. }
  474. else if ("enchant1for".equalsIgnoreCase(n.getNodeName()))
  475. {
  476. foundFor = true;
  477. parseTemplate(n, _currentSkill.currentSkills.get(i));
  478. }
  479. }
  480. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  481. if (!foundCond || !foundFor)
  482. {
  483. _currentSkill.currentLevel = lastLvl - 1;
  484. for (n = first; n != null; n = n.getNextSibling())
  485. {
  486. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  487. {
  488. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  489. Node msg = n.getAttributes().getNamedItem("msg");
  490. if ((condition != null) && (msg != null))
  491. {
  492. condition.setMessage(msg.getNodeValue());
  493. }
  494. _currentSkill.currentSkills.get(i).attach(condition, false);
  495. }
  496. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  497. {
  498. parseTemplate(n, _currentSkill.currentSkills.get(i));
  499. }
  500. }
  501. }
  502. }
  503. for (int i = lastLvl + enchantLevels1; i < (lastLvl + enchantLevels1 + enchantLevels2); i++)
  504. {
  505. boolean foundCond = false, foundFor = false;
  506. _currentSkill.currentLevel = i - lastLvl - enchantLevels1;
  507. for (n = first; n != null; n = n.getNextSibling())
  508. {
  509. if ("enchant2cond".equalsIgnoreCase(n.getNodeName()))
  510. {
  511. foundCond = true;
  512. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  513. Node msg = n.getAttributes().getNamedItem("msg");
  514. if ((condition != null) && (msg != null))
  515. {
  516. condition.setMessage(msg.getNodeValue());
  517. }
  518. _currentSkill.currentSkills.get(i).attach(condition, false);
  519. }
  520. else if ("enchant2for".equalsIgnoreCase(n.getNodeName()))
  521. {
  522. foundFor = true;
  523. parseTemplate(n, _currentSkill.currentSkills.get(i));
  524. }
  525. }
  526. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  527. if (!foundCond || !foundFor)
  528. {
  529. _currentSkill.currentLevel = lastLvl - 1;
  530. for (n = first; n != null; n = n.getNextSibling())
  531. {
  532. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  533. {
  534. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  535. Node msg = n.getAttributes().getNamedItem("msg");
  536. if ((condition != null) && (msg != null))
  537. {
  538. condition.setMessage(msg.getNodeValue());
  539. }
  540. _currentSkill.currentSkills.get(i).attach(condition, false);
  541. }
  542. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  543. {
  544. parseTemplate(n, _currentSkill.currentSkills.get(i));
  545. }
  546. }
  547. }
  548. }
  549. for (int i = lastLvl + enchantLevels1 + enchantLevels2; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3); i++)
  550. {
  551. boolean foundCond = false, foundFor = false;
  552. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2;
  553. for (n = first; n != null; n = n.getNextSibling())
  554. {
  555. if ("enchant3cond".equalsIgnoreCase(n.getNodeName()))
  556. {
  557. foundCond = true;
  558. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  559. Node msg = n.getAttributes().getNamedItem("msg");
  560. if ((condition != null) && (msg != null))
  561. {
  562. condition.setMessage(msg.getNodeValue());
  563. }
  564. _currentSkill.currentSkills.get(i).attach(condition, false);
  565. }
  566. else if ("enchant3for".equalsIgnoreCase(n.getNodeName()))
  567. {
  568. foundFor = true;
  569. parseTemplate(n, _currentSkill.currentSkills.get(i));
  570. }
  571. }
  572. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  573. if (!foundCond || !foundFor)
  574. {
  575. _currentSkill.currentLevel = lastLvl - 1;
  576. for (n = first; n != null; n = n.getNextSibling())
  577. {
  578. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  579. {
  580. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  581. Node msg = n.getAttributes().getNamedItem("msg");
  582. if ((condition != null) && (msg != null))
  583. {
  584. condition.setMessage(msg.getNodeValue());
  585. }
  586. _currentSkill.currentSkills.get(i).attach(condition, false);
  587. }
  588. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  589. {
  590. parseTemplate(n, _currentSkill.currentSkills.get(i));
  591. }
  592. }
  593. }
  594. }
  595. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4); i++)
  596. {
  597. boolean foundCond = false, foundFor = false;
  598. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3;
  599. for (n = first; n != null; n = n.getNextSibling())
  600. {
  601. if ("enchant4cond".equalsIgnoreCase(n.getNodeName()))
  602. {
  603. foundCond = true;
  604. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  605. Node msg = n.getAttributes().getNamedItem("msg");
  606. if ((condition != null) && (msg != null))
  607. {
  608. condition.setMessage(msg.getNodeValue());
  609. }
  610. _currentSkill.currentSkills.get(i).attach(condition, false);
  611. }
  612. else if ("enchant4for".equalsIgnoreCase(n.getNodeName()))
  613. {
  614. foundFor = true;
  615. parseTemplate(n, _currentSkill.currentSkills.get(i));
  616. }
  617. }
  618. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  619. if (!foundCond || !foundFor)
  620. {
  621. _currentSkill.currentLevel = lastLvl - 1;
  622. for (n = first; n != null; n = n.getNextSibling())
  623. {
  624. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  625. {
  626. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  627. Node msg = n.getAttributes().getNamedItem("msg");
  628. if ((condition != null) && (msg != null))
  629. {
  630. condition.setMessage(msg.getNodeValue());
  631. }
  632. _currentSkill.currentSkills.get(i).attach(condition, false);
  633. }
  634. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  635. {
  636. parseTemplate(n, _currentSkill.currentSkills.get(i));
  637. }
  638. }
  639. }
  640. }
  641. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5); i++)
  642. {
  643. boolean foundCond = false, foundFor = false;
  644. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4;
  645. for (n = first; n != null; n = n.getNextSibling())
  646. {
  647. if ("enchant5cond".equalsIgnoreCase(n.getNodeName()))
  648. {
  649. foundCond = true;
  650. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  651. Node msg = n.getAttributes().getNamedItem("msg");
  652. if ((condition != null) && (msg != null))
  653. {
  654. condition.setMessage(msg.getNodeValue());
  655. }
  656. _currentSkill.currentSkills.get(i).attach(condition, false);
  657. }
  658. else if ("enchant5for".equalsIgnoreCase(n.getNodeName()))
  659. {
  660. foundFor = true;
  661. parseTemplate(n, _currentSkill.currentSkills.get(i));
  662. }
  663. }
  664. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  665. if (!foundCond || !foundFor)
  666. {
  667. _currentSkill.currentLevel = lastLvl - 1;
  668. for (n = first; n != null; n = n.getNextSibling())
  669. {
  670. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  671. {
  672. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  673. Node msg = n.getAttributes().getNamedItem("msg");
  674. if ((condition != null) && (msg != null))
  675. {
  676. condition.setMessage(msg.getNodeValue());
  677. }
  678. _currentSkill.currentSkills.get(i).attach(condition, false);
  679. }
  680. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  681. {
  682. parseTemplate(n, _currentSkill.currentSkills.get(i));
  683. }
  684. }
  685. }
  686. }
  687. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6); i++)
  688. {
  689. boolean foundCond = false, foundFor = false;
  690. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5;
  691. for (n = first; n != null; n = n.getNextSibling())
  692. {
  693. if ("enchant6cond".equalsIgnoreCase(n.getNodeName()))
  694. {
  695. foundCond = true;
  696. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  697. Node msg = n.getAttributes().getNamedItem("msg");
  698. if ((condition != null) && (msg != null))
  699. {
  700. condition.setMessage(msg.getNodeValue());
  701. }
  702. _currentSkill.currentSkills.get(i).attach(condition, false);
  703. }
  704. else if ("enchant6for".equalsIgnoreCase(n.getNodeName()))
  705. {
  706. foundFor = true;
  707. parseTemplate(n, _currentSkill.currentSkills.get(i));
  708. }
  709. }
  710. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  711. if (!foundCond || !foundFor)
  712. {
  713. _currentSkill.currentLevel = lastLvl - 1;
  714. for (n = first; n != null; n = n.getNextSibling())
  715. {
  716. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  717. {
  718. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  719. Node msg = n.getAttributes().getNamedItem("msg");
  720. if ((condition != null) && (msg != null))
  721. {
  722. condition.setMessage(msg.getNodeValue());
  723. }
  724. _currentSkill.currentSkills.get(i).attach(condition, false);
  725. }
  726. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  727. {
  728. parseTemplate(n, _currentSkill.currentSkills.get(i));
  729. }
  730. }
  731. }
  732. }
  733. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7); i++)
  734. {
  735. boolean foundCond = false, foundFor = false;
  736. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5 - enchantLevels6;
  737. for (n = first; n != null; n = n.getNextSibling())
  738. {
  739. if ("enchant7cond".equalsIgnoreCase(n.getNodeName()))
  740. {
  741. foundCond = true;
  742. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  743. Node msg = n.getAttributes().getNamedItem("msg");
  744. if ((condition != null) && (msg != null))
  745. {
  746. condition.setMessage(msg.getNodeValue());
  747. }
  748. _currentSkill.currentSkills.get(i).attach(condition, false);
  749. }
  750. else if ("enchant7for".equalsIgnoreCase(n.getNodeName()))
  751. {
  752. foundFor = true;
  753. parseTemplate(n, _currentSkill.currentSkills.get(i));
  754. }
  755. }
  756. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  757. if (!foundCond || !foundFor)
  758. {
  759. _currentSkill.currentLevel = lastLvl - 1;
  760. for (n = first; n != null; n = n.getNextSibling())
  761. {
  762. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  763. {
  764. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  765. Node msg = n.getAttributes().getNamedItem("msg");
  766. if ((condition != null) && (msg != null))
  767. {
  768. condition.setMessage(msg.getNodeValue());
  769. }
  770. _currentSkill.currentSkills.get(i).attach(condition, false);
  771. }
  772. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  773. {
  774. parseTemplate(n, _currentSkill.currentSkills.get(i));
  775. }
  776. }
  777. }
  778. }
  779. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7 + enchantLevels8); i++)
  780. {
  781. boolean foundCond = false, foundFor = false;
  782. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5 - enchantLevels6 - enchantLevels7;
  783. for (n = first; n != null; n = n.getNextSibling())
  784. {
  785. if ("enchant8cond".equalsIgnoreCase(n.getNodeName()))
  786. {
  787. foundCond = true;
  788. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  789. Node msg = n.getAttributes().getNamedItem("msg");
  790. if ((condition != null) && (msg != null))
  791. {
  792. condition.setMessage(msg.getNodeValue());
  793. }
  794. _currentSkill.currentSkills.get(i).attach(condition, false);
  795. }
  796. else if ("enchant8for".equalsIgnoreCase(n.getNodeName()))
  797. {
  798. foundFor = true;
  799. parseTemplate(n, _currentSkill.currentSkills.get(i));
  800. }
  801. }
  802. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  803. if (!foundCond || !foundFor)
  804. {
  805. _currentSkill.currentLevel = lastLvl - 1;
  806. for (n = first; n != null; n = n.getNextSibling())
  807. {
  808. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  809. {
  810. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  811. Node msg = n.getAttributes().getNamedItem("msg");
  812. if ((condition != null) && (msg != null))
  813. {
  814. condition.setMessage(msg.getNodeValue());
  815. }
  816. _currentSkill.currentSkills.get(i).attach(condition, false);
  817. }
  818. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  819. {
  820. parseTemplate(n, _currentSkill.currentSkills.get(i));
  821. }
  822. }
  823. }
  824. }
  825. _currentSkill.skills.addAll(_currentSkill.currentSkills);
  826. }
  827. private void makeSkills()
  828. {
  829. int count = 0;
  830. _currentSkill.currentSkills = new FastList<>(_currentSkill.sets.length + _currentSkill.enchsets1.length + _currentSkill.enchsets2.length + _currentSkill.enchsets3.length + _currentSkill.enchsets4.length + _currentSkill.enchsets5.length + _currentSkill.enchsets6.length + _currentSkill.enchsets7.length + _currentSkill.enchsets8.length);
  831. for (int i = 0; i < _currentSkill.sets.length; i++)
  832. {
  833. try
  834. {
  835. _currentSkill.currentSkills.add(i, _currentSkill.sets[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.sets[i]));
  836. count++;
  837. }
  838. catch (Exception e)
  839. {
  840. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.sets[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.sets[i]).getDisplayId() + "level" + _currentSkill.sets[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.sets[i]).getLevel(), e);
  841. }
  842. }
  843. int _count = count;
  844. for (int i = 0; i < _currentSkill.enchsets1.length; i++)
  845. {
  846. try
  847. {
  848. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets1[i]));
  849. count++;
  850. }
  851. catch (Exception e)
  852. {
  853. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets1[i]).getDisplayId() + " level=" + _currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets1[i]).getLevel(), e);
  854. }
  855. }
  856. _count = count;
  857. for (int i = 0; i < _currentSkill.enchsets2.length; i++)
  858. {
  859. try
  860. {
  861. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets2[i]));
  862. count++;
  863. }
  864. catch (Exception e)
  865. {
  866. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets2[i]).getDisplayId() + " level=" + _currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets2[i]).getLevel(), e);
  867. }
  868. }
  869. _count = count;
  870. for (int i = 0; i < _currentSkill.enchsets3.length; i++)
  871. {
  872. try
  873. {
  874. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets3[i]));
  875. count++;
  876. }
  877. catch (Exception e)
  878. {
  879. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets3[i]).getDisplayId() + " level=" + _currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets3[i]).getLevel(), e);
  880. }
  881. }
  882. _count = count;
  883. for (int i = 0; i < _currentSkill.enchsets4.length; i++)
  884. {
  885. try
  886. {
  887. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets4[i]));
  888. count++;
  889. }
  890. catch (Exception e)
  891. {
  892. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets4[i]).getDisplayId() + " level=" + _currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets4[i]).getLevel(), e);
  893. }
  894. }
  895. _count = count;
  896. for (int i = 0; i < _currentSkill.enchsets5.length; i++)
  897. {
  898. try
  899. {
  900. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets5[i]));
  901. count++;
  902. }
  903. catch (Exception e)
  904. {
  905. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets5[i]).getDisplayId() + " level=" + _currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets5[i]).getLevel(), e);
  906. }
  907. }
  908. _count = count;
  909. for (int i = 0; i < _currentSkill.enchsets6.length; i++)
  910. {
  911. try
  912. {
  913. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets6[i]));
  914. count++;
  915. }
  916. catch (Exception e)
  917. {
  918. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets6[i]).getDisplayId() + " level=" + _currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets6[i]).getLevel(), e);
  919. }
  920. }
  921. _count = count;
  922. for (int i = 0; i < _currentSkill.enchsets7.length; i++)
  923. {
  924. try
  925. {
  926. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets7[i]));
  927. count++;
  928. }
  929. catch (Exception e)
  930. {
  931. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets7[i]).getDisplayId() + " level=" + _currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets7[i]).getLevel(), e);
  932. }
  933. }
  934. _count = count;
  935. for (int i = 0; i < _currentSkill.enchsets8.length; i++)
  936. {
  937. try
  938. {
  939. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets8[i]));
  940. count++;
  941. }
  942. catch (Exception e)
  943. {
  944. _log.log(Level.SEVERE, "Skill id=" + _currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets8[i]).getDisplayId() + " level=" + _currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets8[i]).getLevel(), e);
  945. }
  946. }
  947. }
  948. }