DocumentSkill.java 35 KB

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