2
0

DocumentSkill.java 42 KB

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