DocumentSkill.java 36 KB

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