DocumentSkill.java 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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. else if ("channelingEffects".equalsIgnoreCase(n.getNodeName()))
  456. {
  457. parseTemplate(n, _currentSkill.currentSkills.get(i), true);
  458. }
  459. }
  460. }
  461. for (int i = lastLvl; i < (lastLvl + enchantLevels1); i++)
  462. {
  463. _currentSkill.currentLevel = i - lastLvl;
  464. boolean foundCond = false, foundFor = false;
  465. for (n = first; n != null; n = n.getNextSibling())
  466. {
  467. if ("enchant1cond".equalsIgnoreCase(n.getNodeName()))
  468. {
  469. foundCond = true;
  470. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  471. Node msg = n.getAttributes().getNamedItem("msg");
  472. if ((condition != null) && (msg != null))
  473. {
  474. condition.setMessage(msg.getNodeValue());
  475. }
  476. _currentSkill.currentSkills.get(i).attach(condition, false);
  477. }
  478. else if ("enchant1for".equalsIgnoreCase(n.getNodeName()))
  479. {
  480. foundFor = true;
  481. parseTemplate(n, _currentSkill.currentSkills.get(i));
  482. }
  483. }
  484. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  485. if (!foundCond || !foundFor)
  486. {
  487. _currentSkill.currentLevel = lastLvl - 1;
  488. for (n = first; n != null; n = n.getNextSibling())
  489. {
  490. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  491. {
  492. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  493. Node msg = n.getAttributes().getNamedItem("msg");
  494. if ((condition != null) && (msg != null))
  495. {
  496. condition.setMessage(msg.getNodeValue());
  497. }
  498. _currentSkill.currentSkills.get(i).attach(condition, false);
  499. }
  500. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  501. {
  502. parseTemplate(n, _currentSkill.currentSkills.get(i));
  503. }
  504. }
  505. }
  506. }
  507. for (int i = lastLvl + enchantLevels1; i < (lastLvl + enchantLevels1 + enchantLevels2); i++)
  508. {
  509. boolean foundCond = false, foundFor = false;
  510. _currentSkill.currentLevel = i - lastLvl - enchantLevels1;
  511. for (n = first; n != null; n = n.getNextSibling())
  512. {
  513. if ("enchant2cond".equalsIgnoreCase(n.getNodeName()))
  514. {
  515. foundCond = true;
  516. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  517. Node msg = n.getAttributes().getNamedItem("msg");
  518. if ((condition != null) && (msg != null))
  519. {
  520. condition.setMessage(msg.getNodeValue());
  521. }
  522. _currentSkill.currentSkills.get(i).attach(condition, false);
  523. }
  524. else if ("enchant2for".equalsIgnoreCase(n.getNodeName()))
  525. {
  526. foundFor = true;
  527. parseTemplate(n, _currentSkill.currentSkills.get(i));
  528. }
  529. }
  530. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  531. if (!foundCond || !foundFor)
  532. {
  533. _currentSkill.currentLevel = lastLvl - 1;
  534. for (n = first; n != null; n = n.getNextSibling())
  535. {
  536. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  537. {
  538. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  539. Node msg = n.getAttributes().getNamedItem("msg");
  540. if ((condition != null) && (msg != null))
  541. {
  542. condition.setMessage(msg.getNodeValue());
  543. }
  544. _currentSkill.currentSkills.get(i).attach(condition, false);
  545. }
  546. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  547. {
  548. parseTemplate(n, _currentSkill.currentSkills.get(i));
  549. }
  550. }
  551. }
  552. }
  553. for (int i = lastLvl + enchantLevels1 + enchantLevels2; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3); i++)
  554. {
  555. boolean foundCond = false, foundFor = false;
  556. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2;
  557. for (n = first; n != null; n = n.getNextSibling())
  558. {
  559. if ("enchant3cond".equalsIgnoreCase(n.getNodeName()))
  560. {
  561. foundCond = true;
  562. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  563. Node msg = n.getAttributes().getNamedItem("msg");
  564. if ((condition != null) && (msg != null))
  565. {
  566. condition.setMessage(msg.getNodeValue());
  567. }
  568. _currentSkill.currentSkills.get(i).attach(condition, false);
  569. }
  570. else if ("enchant3for".equalsIgnoreCase(n.getNodeName()))
  571. {
  572. foundFor = true;
  573. parseTemplate(n, _currentSkill.currentSkills.get(i));
  574. }
  575. }
  576. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  577. if (!foundCond || !foundFor)
  578. {
  579. _currentSkill.currentLevel = lastLvl - 1;
  580. for (n = first; n != null; n = n.getNextSibling())
  581. {
  582. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  583. {
  584. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  585. Node msg = n.getAttributes().getNamedItem("msg");
  586. if ((condition != null) && (msg != null))
  587. {
  588. condition.setMessage(msg.getNodeValue());
  589. }
  590. _currentSkill.currentSkills.get(i).attach(condition, false);
  591. }
  592. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  593. {
  594. parseTemplate(n, _currentSkill.currentSkills.get(i));
  595. }
  596. }
  597. }
  598. }
  599. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4); i++)
  600. {
  601. boolean foundCond = false, foundFor = false;
  602. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3;
  603. for (n = first; n != null; n = n.getNextSibling())
  604. {
  605. if ("enchant4cond".equalsIgnoreCase(n.getNodeName()))
  606. {
  607. foundCond = true;
  608. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  609. Node msg = n.getAttributes().getNamedItem("msg");
  610. if ((condition != null) && (msg != null))
  611. {
  612. condition.setMessage(msg.getNodeValue());
  613. }
  614. _currentSkill.currentSkills.get(i).attach(condition, false);
  615. }
  616. else if ("enchant4for".equalsIgnoreCase(n.getNodeName()))
  617. {
  618. foundFor = true;
  619. parseTemplate(n, _currentSkill.currentSkills.get(i));
  620. }
  621. }
  622. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  623. if (!foundCond || !foundFor)
  624. {
  625. _currentSkill.currentLevel = lastLvl - 1;
  626. for (n = first; n != null; n = n.getNextSibling())
  627. {
  628. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  629. {
  630. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  631. Node msg = n.getAttributes().getNamedItem("msg");
  632. if ((condition != null) && (msg != null))
  633. {
  634. condition.setMessage(msg.getNodeValue());
  635. }
  636. _currentSkill.currentSkills.get(i).attach(condition, false);
  637. }
  638. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  639. {
  640. parseTemplate(n, _currentSkill.currentSkills.get(i));
  641. }
  642. }
  643. }
  644. }
  645. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5); i++)
  646. {
  647. boolean foundCond = false, foundFor = false;
  648. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4;
  649. for (n = first; n != null; n = n.getNextSibling())
  650. {
  651. if ("enchant5cond".equalsIgnoreCase(n.getNodeName()))
  652. {
  653. foundCond = true;
  654. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  655. Node msg = n.getAttributes().getNamedItem("msg");
  656. if ((condition != null) && (msg != null))
  657. {
  658. condition.setMessage(msg.getNodeValue());
  659. }
  660. _currentSkill.currentSkills.get(i).attach(condition, false);
  661. }
  662. else if ("enchant5for".equalsIgnoreCase(n.getNodeName()))
  663. {
  664. foundFor = true;
  665. parseTemplate(n, _currentSkill.currentSkills.get(i));
  666. }
  667. }
  668. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  669. if (!foundCond || !foundFor)
  670. {
  671. _currentSkill.currentLevel = lastLvl - 1;
  672. for (n = first; n != null; n = n.getNextSibling())
  673. {
  674. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  675. {
  676. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  677. Node msg = n.getAttributes().getNamedItem("msg");
  678. if ((condition != null) && (msg != null))
  679. {
  680. condition.setMessage(msg.getNodeValue());
  681. }
  682. _currentSkill.currentSkills.get(i).attach(condition, false);
  683. }
  684. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  685. {
  686. parseTemplate(n, _currentSkill.currentSkills.get(i));
  687. }
  688. }
  689. }
  690. }
  691. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6); i++)
  692. {
  693. boolean foundCond = false, foundFor = false;
  694. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5;
  695. for (n = first; n != null; n = n.getNextSibling())
  696. {
  697. if ("enchant6cond".equalsIgnoreCase(n.getNodeName()))
  698. {
  699. foundCond = true;
  700. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  701. Node msg = n.getAttributes().getNamedItem("msg");
  702. if ((condition != null) && (msg != null))
  703. {
  704. condition.setMessage(msg.getNodeValue());
  705. }
  706. _currentSkill.currentSkills.get(i).attach(condition, false);
  707. }
  708. else if ("enchant6for".equalsIgnoreCase(n.getNodeName()))
  709. {
  710. foundFor = true;
  711. parseTemplate(n, _currentSkill.currentSkills.get(i));
  712. }
  713. }
  714. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  715. if (!foundCond || !foundFor)
  716. {
  717. _currentSkill.currentLevel = lastLvl - 1;
  718. for (n = first; n != null; n = n.getNextSibling())
  719. {
  720. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  721. {
  722. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  723. Node msg = n.getAttributes().getNamedItem("msg");
  724. if ((condition != null) && (msg != null))
  725. {
  726. condition.setMessage(msg.getNodeValue());
  727. }
  728. _currentSkill.currentSkills.get(i).attach(condition, false);
  729. }
  730. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  731. {
  732. parseTemplate(n, _currentSkill.currentSkills.get(i));
  733. }
  734. }
  735. }
  736. }
  737. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7); i++)
  738. {
  739. boolean foundCond = false, foundFor = false;
  740. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5 - enchantLevels6;
  741. for (n = first; n != null; n = n.getNextSibling())
  742. {
  743. if ("enchant7cond".equalsIgnoreCase(n.getNodeName()))
  744. {
  745. foundCond = true;
  746. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  747. Node msg = n.getAttributes().getNamedItem("msg");
  748. if ((condition != null) && (msg != null))
  749. {
  750. condition.setMessage(msg.getNodeValue());
  751. }
  752. _currentSkill.currentSkills.get(i).attach(condition, false);
  753. }
  754. else if ("enchant7for".equalsIgnoreCase(n.getNodeName()))
  755. {
  756. foundFor = true;
  757. parseTemplate(n, _currentSkill.currentSkills.get(i));
  758. }
  759. }
  760. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  761. if (!foundCond || !foundFor)
  762. {
  763. _currentSkill.currentLevel = lastLvl - 1;
  764. for (n = first; n != null; n = n.getNextSibling())
  765. {
  766. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  767. {
  768. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  769. Node msg = n.getAttributes().getNamedItem("msg");
  770. if ((condition != null) && (msg != null))
  771. {
  772. condition.setMessage(msg.getNodeValue());
  773. }
  774. _currentSkill.currentSkills.get(i).attach(condition, false);
  775. }
  776. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  777. {
  778. parseTemplate(n, _currentSkill.currentSkills.get(i));
  779. }
  780. }
  781. }
  782. }
  783. for (int i = lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7; i < (lastLvl + enchantLevels1 + enchantLevels2 + enchantLevels3 + enchantLevels4 + enchantLevels5 + enchantLevels6 + enchantLevels7 + enchantLevels8); i++)
  784. {
  785. boolean foundCond = false, foundFor = false;
  786. _currentSkill.currentLevel = i - lastLvl - enchantLevels1 - enchantLevels2 - enchantLevels3 - enchantLevels4 - enchantLevels5 - enchantLevels6 - enchantLevels7;
  787. for (n = first; n != null; n = n.getNextSibling())
  788. {
  789. if ("enchant8cond".equalsIgnoreCase(n.getNodeName()))
  790. {
  791. foundCond = true;
  792. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  793. Node msg = n.getAttributes().getNamedItem("msg");
  794. if ((condition != null) && (msg != null))
  795. {
  796. condition.setMessage(msg.getNodeValue());
  797. }
  798. _currentSkill.currentSkills.get(i).attach(condition, false);
  799. }
  800. else if ("enchant8for".equalsIgnoreCase(n.getNodeName()))
  801. {
  802. foundFor = true;
  803. parseTemplate(n, _currentSkill.currentSkills.get(i));
  804. }
  805. }
  806. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  807. if (!foundCond || !foundFor)
  808. {
  809. _currentSkill.currentLevel = lastLvl - 1;
  810. for (n = first; n != null; n = n.getNextSibling())
  811. {
  812. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  813. {
  814. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  815. Node msg = n.getAttributes().getNamedItem("msg");
  816. if ((condition != null) && (msg != null))
  817. {
  818. condition.setMessage(msg.getNodeValue());
  819. }
  820. _currentSkill.currentSkills.get(i).attach(condition, false);
  821. }
  822. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  823. {
  824. parseTemplate(n, _currentSkill.currentSkills.get(i));
  825. }
  826. }
  827. }
  828. }
  829. _currentSkill.skills.addAll(_currentSkill.currentSkills);
  830. }
  831. private void makeSkills()
  832. {
  833. int count = 0;
  834. _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);
  835. for (int i = 0; i < _currentSkill.sets.length; i++)
  836. {
  837. try
  838. {
  839. _currentSkill.currentSkills.add(i, _currentSkill.sets[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.sets[i]));
  840. count++;
  841. }
  842. catch (Exception e)
  843. {
  844. _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);
  845. }
  846. }
  847. int _count = count;
  848. for (int i = 0; i < _currentSkill.enchsets1.length; i++)
  849. {
  850. try
  851. {
  852. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets1[i]));
  853. count++;
  854. }
  855. catch (Exception e)
  856. {
  857. _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);
  858. }
  859. }
  860. _count = count;
  861. for (int i = 0; i < _currentSkill.enchsets2.length; i++)
  862. {
  863. try
  864. {
  865. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets2[i]));
  866. count++;
  867. }
  868. catch (Exception e)
  869. {
  870. _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);
  871. }
  872. }
  873. _count = count;
  874. for (int i = 0; i < _currentSkill.enchsets3.length; i++)
  875. {
  876. try
  877. {
  878. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets3[i]));
  879. count++;
  880. }
  881. catch (Exception e)
  882. {
  883. _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);
  884. }
  885. }
  886. _count = count;
  887. for (int i = 0; i < _currentSkill.enchsets4.length; i++)
  888. {
  889. try
  890. {
  891. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets4[i]));
  892. count++;
  893. }
  894. catch (Exception e)
  895. {
  896. _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);
  897. }
  898. }
  899. _count = count;
  900. for (int i = 0; i < _currentSkill.enchsets5.length; i++)
  901. {
  902. try
  903. {
  904. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets5[i]));
  905. count++;
  906. }
  907. catch (Exception e)
  908. {
  909. _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);
  910. }
  911. }
  912. _count = count;
  913. for (int i = 0; i < _currentSkill.enchsets6.length; i++)
  914. {
  915. try
  916. {
  917. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets6[i]));
  918. count++;
  919. }
  920. catch (Exception e)
  921. {
  922. _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);
  923. }
  924. }
  925. _count = count;
  926. for (int i = 0; i < _currentSkill.enchsets7.length; i++)
  927. {
  928. try
  929. {
  930. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets7[i]));
  931. count++;
  932. }
  933. catch (Exception e)
  934. {
  935. _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);
  936. }
  937. }
  938. _count = count;
  939. for (int i = 0; i < _currentSkill.enchsets8.length; i++)
  940. {
  941. try
  942. {
  943. _currentSkill.currentSkills.add(_count + i, _currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY).makeSkill(_currentSkill.enchsets8[i]));
  944. count++;
  945. }
  946. catch (Exception e)
  947. {
  948. _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);
  949. }
  950. }
  951. }
  952. }