DocumentSkill.java 40 KB

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