DocumentSkill.java 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  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.EnchantGroupsTable;
  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 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. enchantLevels1 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 1, Integer.parseInt(attrs.getNamedItem("enchantGroup1").getNodeValue()));
  139. if (attrs.getNamedItem("enchantGroup2") != null)
  140. enchantLevels2 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 2, Integer.parseInt(attrs.getNamedItem("enchantGroup2").getNodeValue()));
  141. if (attrs.getNamedItem("enchantGroup3") != null)
  142. enchantLevels3 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 3, Integer.parseInt(attrs.getNamedItem("enchantGroup3").getNodeValue()));
  143. if (attrs.getNamedItem("enchantGroup4") != null)
  144. enchantLevels4 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 4, Integer.parseInt(attrs.getNamedItem("enchantGroup4").getNodeValue()));
  145. if (attrs.getNamedItem("enchantGroup5") != null)
  146. enchantLevels5 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 5, Integer.parseInt(attrs.getNamedItem("enchantGroup5").getNodeValue()));
  147. if (attrs.getNamedItem("enchantGroup6") != null)
  148. enchantLevels6 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 6, Integer.parseInt(attrs.getNamedItem("enchantGroup6").getNodeValue()));
  149. if (attrs.getNamedItem("enchantGroup7") != null)
  150. enchantLevels7 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 7, Integer.parseInt(attrs.getNamedItem("enchantGroup7").getNodeValue()));
  151. if (attrs.getNamedItem("enchantGroup8") != null)
  152. enchantLevels8 = EnchantGroupsTable.getInstance().addNewRouteForSkill(skillId, lastLvl, 8, Integer.parseInt(attrs.getNamedItem("enchantGroup8").getNodeValue()));
  153. _currentSkill.id = skillId;
  154. _currentSkill.name = skillName;
  155. _currentSkill.sets = new StatsSet[lastLvl];
  156. _currentSkill.enchsets1 = new StatsSet[enchantLevels1];
  157. _currentSkill.enchsets2 = new StatsSet[enchantLevels2];
  158. _currentSkill.enchsets3 = new StatsSet[enchantLevels3];
  159. _currentSkill.enchsets4 = new StatsSet[enchantLevels4];
  160. _currentSkill.enchsets5 = new StatsSet[enchantLevels5];
  161. _currentSkill.enchsets6 = new StatsSet[enchantLevels6];
  162. _currentSkill.enchsets7 = new StatsSet[enchantLevels7];
  163. _currentSkill.enchsets8 = new StatsSet[enchantLevels8];
  164. for (int i=0; i < lastLvl; i++)
  165. {
  166. _currentSkill.sets[i] = new StatsSet();
  167. _currentSkill.sets[i].set("skill_id", _currentSkill.id);
  168. _currentSkill.sets[i].set("level", i+1);
  169. _currentSkill.sets[i].set("name", _currentSkill.name);
  170. }
  171. if (_currentSkill.sets.length != lastLvl)
  172. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+lastLvl+" levels expected");
  173. Node first = n.getFirstChild();
  174. for (n=first; n != null; n = n.getNextSibling())
  175. {
  176. if ("table".equalsIgnoreCase(n.getNodeName()))
  177. parseTable(n);
  178. }
  179. for (int i=1; i <= lastLvl; i++)
  180. {
  181. for (n=first; n != null; n = n.getNextSibling())
  182. {
  183. if ("set".equalsIgnoreCase(n.getNodeName()))
  184. {
  185. //Extractable item skills by Zoey76
  186. if ("capsuled_items_skill".equalsIgnoreCase(n.getAttributes().getNamedItem("name").getNodeValue()))
  187. setExtractableSkillData(_currentSkill.sets[i-1], getTableValue("#extractableItems", i));
  188. else
  189. parseBeanSet(n, _currentSkill.sets[i-1], i);
  190. }
  191. }
  192. }
  193. for (int i=0; i < enchantLevels1; i++)
  194. {
  195. _currentSkill.enchsets1[i] = new StatsSet();
  196. _currentSkill.enchsets1[i].set("skill_id", _currentSkill.id);
  197. //currentSkill.enchsets1[i] = currentSkill.sets[currentSkill.sets.length-1];
  198. _currentSkill.enchsets1[i].set("level", i+101);
  199. _currentSkill.enchsets1[i].set("name", _currentSkill.name);
  200. //currentSkill.enchsets1[i].set("skillType", "NOTDONE");
  201. for (n=first; n != null; n = n.getNextSibling())
  202. {
  203. if ("set".equalsIgnoreCase(n.getNodeName()))
  204. parseBeanSet(n, _currentSkill.enchsets1[i], _currentSkill.sets.length);
  205. }
  206. for (n=first; n != null; n = n.getNextSibling())
  207. {
  208. if ("enchant1".equalsIgnoreCase(n.getNodeName()))
  209. parseBeanSet(n, _currentSkill.enchsets1[i], i+1);
  210. }
  211. }
  212. if (_currentSkill.enchsets1.length != enchantLevels1)
  213. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels1+" levels expected");
  214. for (int i=0; i < enchantLevels2; i++)
  215. {
  216. _currentSkill.enchsets2[i] = new StatsSet();
  217. //currentSkill.enchsets2[i] = currentSkill.sets[currentSkill.sets.length-1];
  218. _currentSkill.enchsets2[i].set("skill_id", _currentSkill.id);
  219. _currentSkill.enchsets2[i].set("level", i+201);
  220. _currentSkill.enchsets2[i].set("name", _currentSkill.name);
  221. //currentSkill.enchsets2[i].set("skillType", "NOTDONE");
  222. for (n=first; n != null; n = n.getNextSibling())
  223. {
  224. if ("set".equalsIgnoreCase(n.getNodeName()))
  225. parseBeanSet(n, _currentSkill.enchsets2[i], _currentSkill.sets.length);
  226. }
  227. for (n=first; n != null; n = n.getNextSibling())
  228. {
  229. if ("enchant2".equalsIgnoreCase(n.getNodeName()))
  230. parseBeanSet(n, _currentSkill.enchsets2[i], i+1);
  231. }
  232. }
  233. if (_currentSkill.enchsets2.length != enchantLevels2)
  234. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels2+" levels expected");
  235. for (int i=0; i < enchantLevels3; i++)
  236. {
  237. _currentSkill.enchsets3[i] = new StatsSet();
  238. _currentSkill.enchsets3[i].set("skill_id", _currentSkill.id);
  239. _currentSkill.enchsets3[i].set("level", i+301);
  240. _currentSkill.enchsets3[i].set("name", _currentSkill.name);
  241. for (n=first; n != null; n = n.getNextSibling())
  242. {
  243. if ("set".equalsIgnoreCase(n.getNodeName()))
  244. parseBeanSet(n, _currentSkill.enchsets3[i], _currentSkill.sets.length);
  245. }
  246. for (n=first; n != null; n = n.getNextSibling())
  247. {
  248. if ("enchant3".equalsIgnoreCase(n.getNodeName()))
  249. parseBeanSet(n, _currentSkill.enchsets3[i], i+1);
  250. }
  251. }
  252. if (_currentSkill.enchsets3.length != enchantLevels3)
  253. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels3+" levels expected");
  254. for (int i=0; i < enchantLevels4; i++)
  255. {
  256. _currentSkill.enchsets4[i] = new StatsSet();
  257. _currentSkill.enchsets4[i].set("skill_id", _currentSkill.id);
  258. _currentSkill.enchsets4[i].set("level", i+401);
  259. _currentSkill.enchsets4[i].set("name", _currentSkill.name);
  260. for (n=first; n != null; n = n.getNextSibling())
  261. {
  262. if ("set".equalsIgnoreCase(n.getNodeName()))
  263. parseBeanSet(n, _currentSkill.enchsets4[i], _currentSkill.sets.length);
  264. }
  265. for (n=first; n != null; n = n.getNextSibling())
  266. {
  267. if ("enchant4".equalsIgnoreCase(n.getNodeName()))
  268. parseBeanSet(n, _currentSkill.enchsets4[i], i+1);
  269. }
  270. }
  271. if (_currentSkill.enchsets4.length != enchantLevels4)
  272. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels4+" levels expected");
  273. for (int i=0; i < enchantLevels5; i++)
  274. {
  275. _currentSkill.enchsets5[i] = new StatsSet();
  276. _currentSkill.enchsets5[i].set("skill_id", _currentSkill.id);
  277. _currentSkill.enchsets5[i].set("level", i+501);
  278. _currentSkill.enchsets5[i].set("name", _currentSkill.name);
  279. for (n=first; n != null; n = n.getNextSibling())
  280. {
  281. if ("set".equalsIgnoreCase(n.getNodeName()))
  282. parseBeanSet(n, _currentSkill.enchsets5[i], _currentSkill.sets.length);
  283. }
  284. for (n=first; n != null; n = n.getNextSibling())
  285. {
  286. if ("enchant5".equalsIgnoreCase(n.getNodeName()))
  287. parseBeanSet(n, _currentSkill.enchsets5[i], i+1);
  288. }
  289. }
  290. if (_currentSkill.enchsets5.length != enchantLevels5)
  291. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels5+" levels expected");
  292. for (int i=0; i < enchantLevels6; i++)
  293. {
  294. _currentSkill.enchsets6[i] = new StatsSet();
  295. _currentSkill.enchsets6[i].set("skill_id", _currentSkill.id);
  296. _currentSkill.enchsets6[i].set("level", i+601);
  297. _currentSkill.enchsets6[i].set("name", _currentSkill.name);
  298. for (n=first; n != null; n = n.getNextSibling())
  299. {
  300. if ("set".equalsIgnoreCase(n.getNodeName()))
  301. parseBeanSet(n, _currentSkill.enchsets6[i], _currentSkill.sets.length);
  302. }
  303. for (n=first; n != null; n = n.getNextSibling())
  304. {
  305. if ("enchant6".equalsIgnoreCase(n.getNodeName()))
  306. parseBeanSet(n, _currentSkill.enchsets6[i], i+1);
  307. }
  308. }
  309. if (_currentSkill.enchsets6.length != enchantLevels6)
  310. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels6+" levels expected");
  311. for (int i=0; i < enchantLevels7; i++)
  312. {
  313. _currentSkill.enchsets7[i] = new StatsSet();
  314. _currentSkill.enchsets7[i].set("skill_id", _currentSkill.id);
  315. _currentSkill.enchsets7[i].set("level", i+701);
  316. _currentSkill.enchsets7[i].set("name", _currentSkill.name);
  317. for (n=first; n != null; n = n.getNextSibling())
  318. {
  319. if ("set".equalsIgnoreCase(n.getNodeName()))
  320. parseBeanSet(n, _currentSkill.enchsets7[i], _currentSkill.sets.length);
  321. }
  322. for (n=first; n != null; n = n.getNextSibling())
  323. {
  324. if ("enchant7".equalsIgnoreCase(n.getNodeName()))
  325. parseBeanSet(n, _currentSkill.enchsets7[i], i+1);
  326. }
  327. }
  328. if (_currentSkill.enchsets7.length != enchantLevels7)
  329. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels7+" levels expected");
  330. for (int i=0; i < enchantLevels8; i++)
  331. {
  332. _currentSkill.enchsets8[i] = new StatsSet();
  333. _currentSkill.enchsets8[i].set("skill_id", _currentSkill.id);
  334. _currentSkill.enchsets8[i].set("level", i+801);
  335. _currentSkill.enchsets8[i].set("name", _currentSkill.name);
  336. for (n=first; n != null; n = n.getNextSibling())
  337. {
  338. if ("set".equalsIgnoreCase(n.getNodeName()))
  339. parseBeanSet(n, _currentSkill.enchsets8[i], _currentSkill.sets.length);
  340. }
  341. for (n=first; n != null; n = n.getNextSibling())
  342. {
  343. if ("enchant8".equalsIgnoreCase(n.getNodeName()))
  344. parseBeanSet(n, _currentSkill.enchsets8[i], i+1);
  345. }
  346. }
  347. if (_currentSkill.enchsets8.length != enchantLevels8)
  348. throw new RuntimeException("Skill id="+skillId+" number of levels missmatch, "+enchantLevels8+" levels expected");
  349. makeSkills();
  350. for (int i=0; i < lastLvl; i++)
  351. {
  352. _currentSkill.currentLevel = i;
  353. for (n=first; n != null; n = n.getNextSibling())
  354. {
  355. if ("cond".equalsIgnoreCase(n.getNodeName()))
  356. {
  357. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  358. Node msg = n.getAttributes().getNamedItem("msg");
  359. Node msgId = n.getAttributes().getNamedItem("msgId");
  360. if (condition != null && msg != null)
  361. condition.setMessage(msg.getNodeValue());
  362. else if (condition != null && msgId != null)
  363. {
  364. condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
  365. Node addName = n.getAttributes().getNamedItem("addName");
  366. if (addName != null && Integer.decode(getValue(msgId.getNodeValue(), null)) > 0)
  367. condition.addName();
  368. }
  369. _currentSkill.currentSkills.get(i).attach(condition, false);
  370. }
  371. else if ("for".equalsIgnoreCase(n.getNodeName()))
  372. {
  373. parseTemplate(n, _currentSkill.currentSkills.get(i));
  374. }
  375. }
  376. }
  377. for (int i=lastLvl; i < lastLvl+enchantLevels1; i++)
  378. {
  379. _currentSkill.currentLevel = i-lastLvl;
  380. boolean foundCond = false, foundFor = false;
  381. for (n=first; n != null; n = n.getNextSibling())
  382. {
  383. if ("enchant1cond".equalsIgnoreCase(n.getNodeName()))
  384. {
  385. foundCond = true;
  386. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  387. Node msg = n.getAttributes().getNamedItem("msg");
  388. if (condition != null && msg != null)
  389. condition.setMessage(msg.getNodeValue());
  390. _currentSkill.currentSkills.get(i).attach(condition,false);
  391. }
  392. else if ("enchant1for".equalsIgnoreCase(n.getNodeName()))
  393. {
  394. foundFor = true;
  395. parseTemplate(n, _currentSkill.currentSkills.get(i));
  396. }
  397. }
  398. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  399. if (!foundCond || !foundFor)
  400. {
  401. _currentSkill.currentLevel = lastLvl-1;
  402. for (n=first; n != null; n = n.getNextSibling())
  403. {
  404. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  405. {
  406. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  407. Node msg = n.getAttributes().getNamedItem("msg");
  408. if (condition != null && msg != null)
  409. condition.setMessage(msg.getNodeValue());
  410. _currentSkill.currentSkills.get(i).attach(condition,false);
  411. }
  412. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  413. {
  414. parseTemplate(n, _currentSkill.currentSkills.get(i));
  415. }
  416. }
  417. }
  418. }
  419. for (int i=lastLvl+enchantLevels1; i < lastLvl+enchantLevels1+enchantLevels2; i++)
  420. {
  421. boolean foundCond = false, foundFor = false;
  422. _currentSkill.currentLevel = i-lastLvl-enchantLevels1;
  423. for (n=first; n != null; n = n.getNextSibling())
  424. {
  425. if ("enchant2cond".equalsIgnoreCase(n.getNodeName()))
  426. {
  427. foundCond = true;
  428. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  429. Node msg = n.getAttributes().getNamedItem("msg");
  430. if (condition != null && msg != null)
  431. condition.setMessage(msg.getNodeValue());
  432. _currentSkill.currentSkills.get(i).attach(condition,false);
  433. }
  434. else if ("enchant2for".equalsIgnoreCase(n.getNodeName()))
  435. {
  436. foundFor = true;
  437. parseTemplate(n, _currentSkill.currentSkills.get(i));
  438. }
  439. }
  440. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  441. if(!foundCond || !foundFor)
  442. {
  443. _currentSkill.currentLevel = lastLvl-1;
  444. for (n=first; n != null; n = n.getNextSibling())
  445. {
  446. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  447. {
  448. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  449. Node msg = n.getAttributes().getNamedItem("msg");
  450. if (condition != null && msg != null)
  451. condition.setMessage(msg.getNodeValue());
  452. _currentSkill.currentSkills.get(i).attach(condition,false);
  453. }
  454. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  455. {
  456. parseTemplate(n, _currentSkill.currentSkills.get(i));
  457. }
  458. }
  459. }
  460. }
  461. for (int i=lastLvl+enchantLevels1+enchantLevels2; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3; i++)
  462. {
  463. boolean foundCond = false, foundFor = false;
  464. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2;
  465. for (n=first; n != null; n = n.getNextSibling())
  466. {
  467. if ("enchant3cond".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. condition.setMessage(msg.getNodeValue());
  474. _currentSkill.currentSkills.get(i).attach(condition,false);
  475. }
  476. else if ("enchant3for".equalsIgnoreCase(n.getNodeName()))
  477. {
  478. foundFor = true;
  479. parseTemplate(n, _currentSkill.currentSkills.get(i));
  480. }
  481. }
  482. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  483. if(!foundCond || !foundFor)
  484. {
  485. _currentSkill.currentLevel = lastLvl-1;
  486. for (n=first; n != null; n = n.getNextSibling())
  487. {
  488. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  489. {
  490. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  491. Node msg = n.getAttributes().getNamedItem("msg");
  492. if (condition != null && msg != null)
  493. condition.setMessage(msg.getNodeValue());
  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+enchantLevels2+enchantLevels3; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4; i++)
  504. {
  505. boolean foundCond = false, foundFor = false;
  506. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2-enchantLevels3;
  507. for (n=first; n != null; n = n.getNextSibling())
  508. {
  509. if ("enchant4cond".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. condition.setMessage(msg.getNodeValue());
  516. _currentSkill.currentSkills.get(i).attach(condition,false);
  517. }
  518. else if ("enchant4for".equalsIgnoreCase(n.getNodeName()))
  519. {
  520. foundFor = true;
  521. parseTemplate(n, _currentSkill.currentSkills.get(i));
  522. }
  523. }
  524. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  525. if(!foundCond || !foundFor)
  526. {
  527. _currentSkill.currentLevel = lastLvl-1;
  528. for (n=first; n != null; n = n.getNextSibling())
  529. {
  530. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  531. {
  532. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  533. Node msg = n.getAttributes().getNamedItem("msg");
  534. if (condition != null && msg != null)
  535. condition.setMessage(msg.getNodeValue());
  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+enchantLevels3+enchantLevels4; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5; i++)
  546. {
  547. boolean foundCond = false, foundFor = false;
  548. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2-enchantLevels3-enchantLevels4;
  549. for (n=first; n != null; n = n.getNextSibling())
  550. {
  551. if ("enchant5cond".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. condition.setMessage(msg.getNodeValue());
  558. _currentSkill.currentSkills.get(i).attach(condition,false);
  559. }
  560. else if ("enchant5for".equalsIgnoreCase(n.getNodeName()))
  561. {
  562. foundFor = true;
  563. parseTemplate(n, _currentSkill.currentSkills.get(i));
  564. }
  565. }
  566. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  567. if(!foundCond || !foundFor)
  568. {
  569. _currentSkill.currentLevel = lastLvl-1;
  570. for (n=first; n != null; n = n.getNextSibling())
  571. {
  572. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  573. {
  574. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  575. Node msg = n.getAttributes().getNamedItem("msg");
  576. if (condition != null && msg != null)
  577. condition.setMessage(msg.getNodeValue());
  578. _currentSkill.currentSkills.get(i).attach(condition,false);
  579. }
  580. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  581. {
  582. parseTemplate(n, _currentSkill.currentSkills.get(i));
  583. }
  584. }
  585. }
  586. }
  587. for (int i=lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5+enchantLevels6; i++)
  588. {
  589. boolean foundCond = false, foundFor = false;
  590. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2-enchantLevels3-enchantLevels4-enchantLevels5;
  591. for (n=first; n != null; n = n.getNextSibling())
  592. {
  593. if ("enchant6cond".equalsIgnoreCase(n.getNodeName()))
  594. {
  595. foundCond = true;
  596. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  597. Node msg = n.getAttributes().getNamedItem("msg");
  598. if (condition != null && msg != null)
  599. condition.setMessage(msg.getNodeValue());
  600. _currentSkill.currentSkills.get(i).attach(condition,false);
  601. }
  602. else if ("enchant6for".equalsIgnoreCase(n.getNodeName()))
  603. {
  604. foundFor = true;
  605. parseTemplate(n, _currentSkill.currentSkills.get(i));
  606. }
  607. }
  608. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  609. if(!foundCond || !foundFor)
  610. {
  611. _currentSkill.currentLevel = lastLvl-1;
  612. for (n=first; n != null; n = n.getNextSibling())
  613. {
  614. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  615. {
  616. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  617. Node msg = n.getAttributes().getNamedItem("msg");
  618. if (condition != null && msg != null)
  619. condition.setMessage(msg.getNodeValue());
  620. _currentSkill.currentSkills.get(i).attach(condition,false);
  621. }
  622. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  623. {
  624. parseTemplate(n, _currentSkill.currentSkills.get(i));
  625. }
  626. }
  627. }
  628. }
  629. for (int i=lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5+enchantLevels6; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5+enchantLevels6+enchantLevels7; i++)
  630. {
  631. boolean foundCond = false, foundFor = false;
  632. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2-enchantLevels3-enchantLevels4-enchantLevels5-enchantLevels6;
  633. for (n=first; n != null; n = n.getNextSibling())
  634. {
  635. if ("enchant7cond".equalsIgnoreCase(n.getNodeName()))
  636. {
  637. foundCond = true;
  638. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  639. Node msg = n.getAttributes().getNamedItem("msg");
  640. if (condition != null && msg != null)
  641. condition.setMessage(msg.getNodeValue());
  642. _currentSkill.currentSkills.get(i).attach(condition,false);
  643. }
  644. else if ("enchant7for".equalsIgnoreCase(n.getNodeName()))
  645. {
  646. foundFor = true;
  647. parseTemplate(n, _currentSkill.currentSkills.get(i));
  648. }
  649. }
  650. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  651. if(!foundCond || !foundFor)
  652. {
  653. _currentSkill.currentLevel = lastLvl-1;
  654. for (n=first; n != null; n = n.getNextSibling())
  655. {
  656. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  657. {
  658. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  659. Node msg = n.getAttributes().getNamedItem("msg");
  660. if (condition != null && msg != null)
  661. condition.setMessage(msg.getNodeValue());
  662. _currentSkill.currentSkills.get(i).attach(condition,false);
  663. }
  664. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  665. {
  666. parseTemplate(n, _currentSkill.currentSkills.get(i));
  667. }
  668. }
  669. }
  670. }
  671. for (int i=lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5+enchantLevels6+enchantLevels7; i < lastLvl+enchantLevels1+enchantLevels2+enchantLevels3+enchantLevels4+enchantLevels5+enchantLevels6+enchantLevels7+enchantLevels8; i++)
  672. {
  673. boolean foundCond = false, foundFor = false;
  674. _currentSkill.currentLevel = i-lastLvl-enchantLevels1-enchantLevels2-enchantLevels3-enchantLevels4-enchantLevels5-enchantLevels6-enchantLevels7;
  675. for (n=first; n != null; n = n.getNextSibling())
  676. {
  677. if ("enchant8cond".equalsIgnoreCase(n.getNodeName()))
  678. {
  679. foundCond = true;
  680. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  681. Node msg = n.getAttributes().getNamedItem("msg");
  682. if (condition != null && msg != null)
  683. condition.setMessage(msg.getNodeValue());
  684. _currentSkill.currentSkills.get(i).attach(condition,false);
  685. }
  686. else if ("enchant8for".equalsIgnoreCase(n.getNodeName()))
  687. {
  688. foundFor = true;
  689. parseTemplate(n, _currentSkill.currentSkills.get(i));
  690. }
  691. }
  692. // If none found, the enchanted skill will take effects from maxLvL of norm skill
  693. if(!foundCond || !foundFor)
  694. {
  695. _currentSkill.currentLevel = lastLvl-1;
  696. for (n=first; n != null; n = n.getNextSibling())
  697. {
  698. if (!foundCond && "cond".equalsIgnoreCase(n.getNodeName()))
  699. {
  700. Condition condition = parseCondition(n.getFirstChild(), _currentSkill.currentSkills.get(i));
  701. Node msg = n.getAttributes().getNamedItem("msg");
  702. if (condition != null && msg != null)
  703. condition.setMessage(msg.getNodeValue());
  704. _currentSkill.currentSkills.get(i).attach(condition,false);
  705. }
  706. else if (!foundFor && "for".equalsIgnoreCase(n.getNodeName()))
  707. {
  708. parseTemplate(n, _currentSkill.currentSkills.get(i));
  709. }
  710. }
  711. }
  712. }
  713. _currentSkill.skills.addAll(_currentSkill.currentSkills);
  714. }
  715. private void makeSkills()
  716. {
  717. int count = 0;
  718. _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);
  719. for (int i=0; i < _currentSkill.sets.length; i++)
  720. {
  721. try
  722. {
  723. _currentSkill.currentSkills.add(i, _currentSkill.sets[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.sets[i]));
  724. count++;
  725. }
  726. catch (Exception e)
  727. {
  728. _log.log(Level.SEVERE, "Skill id="+_currentSkill.sets[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.sets[i]).getDisplayId()+"level"+_currentSkill.sets[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.sets[i]).getLevel(), e);
  729. }
  730. }
  731. int _count = count;
  732. for (int i=0; i < _currentSkill.enchsets1.length; i++)
  733. {
  734. try
  735. {
  736. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets1[i]));
  737. count++;
  738. }
  739. catch (Exception e)
  740. {
  741. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets1[i]).getDisplayId()+" level="+_currentSkill.enchsets1[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets1[i]).getLevel(), e);
  742. }
  743. }
  744. _count = count;
  745. for (int i=0; i < _currentSkill.enchsets2.length; i++)
  746. {
  747. try
  748. {
  749. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets2[i]));
  750. count++;
  751. }
  752. catch (Exception e)
  753. {
  754. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets2[i]).getDisplayId()+" level="+_currentSkill.enchsets2[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets2[i]).getLevel(), e);
  755. }
  756. }
  757. _count = count;
  758. for (int i=0; i < _currentSkill.enchsets3.length; i++)
  759. {
  760. try
  761. {
  762. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets3[i]));
  763. count++;
  764. }
  765. catch (Exception e)
  766. {
  767. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets3[i]).getDisplayId()+" level="+_currentSkill.enchsets3[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets3[i]).getLevel(), e);
  768. }
  769. }
  770. _count = count;
  771. for (int i=0; i < _currentSkill.enchsets4.length; i++)
  772. {
  773. try
  774. {
  775. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets4[i]));
  776. count++;
  777. }
  778. catch (Exception e)
  779. {
  780. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets4[i]).getDisplayId()+" level="+_currentSkill.enchsets4[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets4[i]).getLevel(), e);
  781. }
  782. }
  783. _count = count;
  784. for (int i=0; i < _currentSkill.enchsets5.length; i++)
  785. {
  786. try
  787. {
  788. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets5[i]));
  789. count++;
  790. }
  791. catch (Exception e)
  792. {
  793. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets5[i]).getDisplayId()+" level="+_currentSkill.enchsets5[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets5[i]).getLevel(), e);
  794. }
  795. }
  796. _count = count;
  797. for (int i=0; i < _currentSkill.enchsets6.length; i++)
  798. {
  799. try
  800. {
  801. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets6[i]));
  802. count++;
  803. }
  804. catch (Exception e)
  805. {
  806. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets6[i]).getDisplayId()+" level="+_currentSkill.enchsets6[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets6[i]).getLevel(), e);
  807. }
  808. }
  809. _count = count;
  810. for (int i=0; i < _currentSkill.enchsets7.length; i++)
  811. {
  812. try
  813. {
  814. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets7[i]));
  815. count++;
  816. }
  817. catch (Exception e)
  818. {
  819. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets7[i]).getDisplayId()+" level="+_currentSkill.enchsets7[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets7[i]).getLevel(), e);
  820. }
  821. }
  822. _count = count;
  823. for (int i=0; i < _currentSkill.enchsets8.length; i++)
  824. {
  825. try
  826. {
  827. _currentSkill.currentSkills.add(_count+i, _currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets8[i]));
  828. count++;
  829. }
  830. catch (Exception e)
  831. {
  832. _log.log(Level.SEVERE, "Skill id="+_currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets8[i]).getDisplayId()+" level="+_currentSkill.enchsets8[i].getEnum("skillType", L2SkillType.class).makeSkill(_currentSkill.enchsets8[i]).getLevel(), e);
  833. }
  834. }
  835. }
  836. }