Advertisement
Nik

CharTemplatesTable rework

Nik
Apr 26th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 39.69 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/GameServer.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/GameServer.java   (revision 4587)
  4. +++ java/com/l2jserver/gameserver/GameServer.java   (working copy)
  5. @@ -150,7 +150,7 @@
  6.     private final DeadLockDetector _deadDetectThread;
  7.     private final IdFactory _idFactory;
  8.     public static GameServer gameServer;
  9. -   private LoginServerThread _loginThread;
  10. +   private final LoginServerThread _loginThread;
  11.     private static Status _statusServer;
  12.     public static final Calendar dateTimeServerStarted = Calendar.getInstance();
  13.    
  14. @@ -241,7 +241,7 @@
  15.         SkillSpellbookTable.getInstance();
  16.        
  17.         printSection("Characters");
  18. -       CharTemplateTable.getInstance();
  19. +       CharTemplateTable.getInstance().init();
  20.         CharNameTable.getInstance();
  21.         LevelUpData.getInstance();
  22.         AccessLevels.getInstance();
  23. Index: java/com/l2jserver/gameserver/datatables/CharTemplateTable.java
  24. ===================================================================
  25. --- java/com/l2jserver/gameserver/datatables/CharTemplateTable.java (revision 4587)
  26. +++ java/com/l2jserver/gameserver/datatables/CharTemplateTable.java (working copy)
  27. @@ -14,21 +14,80 @@
  28.   */
  29.  package com.l2jserver.gameserver.datatables;
  30.  
  31. +import java.io.File;
  32.  import java.sql.Connection;
  33.  import java.sql.PreparedStatement;
  34.  import java.sql.ResultSet;
  35.  import java.sql.SQLException;
  36. +import java.util.Map;
  37.  import java.util.logging.Level;
  38.  import java.util.logging.Logger;
  39.  
  40. +import javax.xml.parsers.DocumentBuilderFactory;
  41. +
  42. +import javolution.util.FastMap;
  43. +
  44. +import org.w3c.dom.Document;
  45. +import org.w3c.dom.NamedNodeMap;
  46. +import org.w3c.dom.Node;
  47. +
  48. +import com.l2jserver.Config;
  49.  import com.l2jserver.L2DatabaseFactory;
  50.  import com.l2jserver.gameserver.model.base.ClassId;
  51.  import com.l2jserver.gameserver.templates.StatsSet;
  52.  import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
  53.  
  54.  /**
  55. + * Values that are set though StatsSet
  56.   *
  57. - * @author Unknown, Forsaiken
  58. + * [CharTemplates]:
  59. + * baseSTR
  60. + * baseDEX
  61. + * baseCON
  62. + * baseINT
  63. + * baseWIT
  64. + * baseMEN
  65. + * baseHpMax
  66. + * lvlHpAdd
  67. + * lvlHpMod
  68. + * baseMpMax
  69. + * baseCpMax
  70. + * lvlCpAdd
  71. + * lvlCpMod
  72. + * lvlMpAdd
  73. + * lvlMpMod
  74. + * baseHpReg
  75. + * baseMpReg
  76. + * baseMAtkSpd
  77. + * baseRunSpd
  78. + * baseWalkSpd
  79. + * baseShldDef
  80. + * baseShldRate
  81. + *
  82. + * [PcBaseStats]:
  83. + * basePAtk
  84. + * baseRcrit
  85. + * baseAtkType
  86. + * baseAtkSpd
  87. + * basePDef
  88. + * baseMAtk
  89. + * baseMDef
  90. + * baseCanPenetrate
  91. + * baseAtkRange
  92. + * baseDamRange
  93. + * baseRndDam
  94. + *
  95. + * [PcBreathBonus]:
  96. + * pcBreathBonus
  97. + *
  98. + * [PcCollision]:
  99. + * collision_radius
  100. + * collision_height
  101. + *
  102. + * [PcSafeFallHeight]:
  103. + * safeFallHeight
  104. + *
  105. + * @author Unknown, Forsaiken, reworked by Nik
  106.   *
  107.   */
  108.  public final class CharTemplateTable
  109. @@ -41,88 +100,36 @@
  110.     }
  111.    
  112.     private final L2PcTemplate[] _templates;
  113. +   Map<Integer, StatsSet> _ssMap; // Temp map sith StatsSet that we use until finalazing the current StatsSet that we are going to use to create L2PcTemplate
  114.    
  115.     private CharTemplateTable()
  116.     {
  117.         _templates = new L2PcTemplate[ClassId.values().length];
  118. -      
  119. -       Connection con = null;
  120. +       _ssMap = new FastMap<Integer, StatsSet>();
  121. +   }
  122. +  
  123. +   public void init()
  124. +   {
  125. +       // Load the PCs stats
  126. +       loadCharTemplates();
  127. +       loadPcBaseStats();
  128. +       loadPcBreathBonus();
  129. +       loadPcCollision();
  130. +       loadPcSafeFallHeight();
  131.        
  132. -       try
  133. -       {
  134. -           con = L2DatabaseFactory.getInstance().getConnection();
  135. -           PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list, char_templates, lvlupgain"
  136. -                   + " WHERE class_list.id = char_templates.classId" + " AND class_list.id = lvlupgain.classId"
  137. -                   + " ORDER BY class_list.id");
  138. -           ResultSet rset = statement.executeQuery();
  139. -          
  140. -           int count = 0;
  141. -           while (rset.next())
  142. -           {
  143. -               StatsSet set = new StatsSet();
  144. -               set.set("classId", rset.getInt("id"));
  145. -               set.set("className", rset.getString("className"));
  146. -               set.set("raceId", rset.getInt("raceId"));
  147. -               set.set("baseSTR", rset.getInt("STR"));
  148. -               set.set("baseCON", rset.getInt("CON"));
  149. -               set.set("baseDEX", rset.getInt("DEX"));
  150. -               set.set("baseINT", rset.getInt("_INT"));
  151. -               set.set("baseWIT", rset.getInt("WIT"));
  152. -               set.set("baseMEN", rset.getInt("MEN"));
  153. -               set.set("baseHpMax", rset.getFloat("defaultHpBase"));
  154. -               set.set("lvlHpAdd", rset.getFloat("defaultHpAdd"));
  155. -               set.set("lvlHpMod", rset.getFloat("defaultHpMod"));
  156. -               set.set("baseMpMax", rset.getFloat("defaultMpBase"));
  157. -               set.set("baseCpMax", rset.getFloat("defaultCpBase"));
  158. -               set.set("lvlCpAdd", rset.getFloat("defaultCpAdd"));
  159. -               set.set("lvlCpMod", rset.getFloat("defaultCpMod"));
  160. -               set.set("lvlMpAdd", rset.getFloat("defaultMpAdd"));
  161. -               set.set("lvlMpMod", rset.getFloat("defaultMpMod"));
  162. -               set.set("baseHpReg", 1.5);
  163. -               set.set("baseMpReg", 0.9);
  164. -               set.set("basePAtk", rset.getInt("p_atk"));
  165. -               set.set("basePDef", /*classId.isMage()? 77 : 129*/rset.getInt("p_def"));
  166. -               set.set("baseMAtk", rset.getInt("m_atk"));
  167. -               set.set("baseMDef", rset.getInt("char_templates.m_def"));
  168. -               set.set("classBaseLevel", rset.getInt("class_lvl"));
  169. -               set.set("basePAtkSpd", rset.getInt("p_spd"));
  170. -               set.set("baseMAtkSpd", /*classId.isMage()? 166 : 333*/rset.getInt("char_templates.m_spd"));
  171. -               set.set("baseCritRate", rset.getInt("char_templates.critical") / 10);
  172. -               set.set("baseRunSpd", rset.getInt("move_spd"));
  173. -               set.set("baseWalkSpd", 0);
  174. -               set.set("baseShldDef", 0);
  175. -               set.set("baseShldRate", 0);
  176. -               set.set("baseAtkRange", 40);
  177. -              
  178. -               set.set("spawnX", rset.getInt("x"));
  179. -               set.set("spawnY", rset.getInt("y"));
  180. -               set.set("spawnZ", rset.getInt("z"));
  181. -              
  182. -               L2PcTemplate ct;
  183. -              
  184. -               set.set("collision_radius", rset.getDouble("m_col_r"));
  185. -               set.set("collision_height", rset.getDouble("m_col_h"));
  186. -               set.set("collision_radius_female", rset.getDouble("f_col_r"));
  187. -               set.set("collision_height_female", rset.getDouble("f_col_h"));
  188. -               ct = new L2PcTemplate(set);
  189. -              
  190. -               _templates[ct.classId.getId()] = ct;
  191. -               ++count;
  192. -           }
  193. -          
  194. -           rset.close();
  195. -           statement.close();
  196. -          
  197. -           _log.info("CharTemplateTable: Loaded " + count + " Character Templates.");
  198. -       }
  199. -       catch (SQLException e)
  200. +       // Now since everything is loaded, the StatsSet are ready, now we can generate the _templates
  201. +       for (StatsSet set : _ssMap.values())
  202.         {
  203. -           _log.log(Level.SEVERE, "Failed loading char templates", e);
  204. +           _log.info("CharTemplates: Loading " + set.getInteger("classId") + " class...");
  205. +           L2PcTemplate ct = new L2PcTemplate(set);
  206. +           _templates[ct.classId.getId()] = ct;
  207. +           _log.info("CharTemplates: Loaded " + ct.classId.getId() + " class.");
  208.         }
  209. -       finally
  210. -       {
  211. -           L2DatabaseFactory.close(con);
  212. -       }
  213. +       _log.info("CharTemplates: Loaded " + _ssMap.size() + " character templates.");
  214. +       _ssMap.clear();
  215. +      
  216. +      
  217. +       Connection con = null;
  218.        
  219.         try
  220.         {
  221. @@ -178,6 +185,428 @@
  222.         }
  223.     }
  224.    
  225. +   private void loadCharTemplates()
  226. +   {
  227. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  228. +       factory.setValidating(false);
  229. +       factory.setIgnoringComments(true);
  230. +       factory.setIgnoringElementContentWhitespace(true);
  231. +       File file = new File(Config.DATAPACK_ROOT, "data/CharTemplates.xml");
  232. +       Document doc = null;
  233. +      
  234. +       if (file.exists())
  235. +       {
  236. +           try
  237. +           {
  238. +               doc = factory.newDocumentBuilder().parse(file);
  239. +           }
  240. +           catch (Exception e)
  241. +           {
  242. +               _log.log(Level.WARNING, "Could not parse CharTemplates.xml file: " + e.getMessage(), e);
  243. +           }
  244. +          
  245. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  246. +           {
  247. +               StringBuilder spawnXarr = new StringBuilder();
  248. +               StringBuilder spawnYarr = new StringBuilder();
  249. +               StringBuilder spawnZarr = new StringBuilder();
  250. +
  251. +               if ("list".equalsIgnoreCase(n.getNodeName()))
  252. +               {
  253. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  254. +                   {
  255. +                       if ("class".equalsIgnoreCase(d.getNodeName()))
  256. +                       {
  257. +                           StatsSet set = new StatsSet();
  258. +                           String className;
  259. +                           int classId;
  260. +                           NamedNodeMap attrs = d.getAttributes();
  261. +                           Node att;
  262. +
  263. +                           att = attrs.getNamedItem("name");
  264. +                           if (att == null)
  265. +                           {
  266. +                               _log.severe("[CharTemplates.xml] Missing name, skipping");
  267. +                               continue;
  268. +                           }
  269. +                           className = att.getNodeValue();
  270. +                           set.set("className", className);
  271. +                          
  272. +                           att = attrs.getNamedItem("id");
  273. +                           if (att == null)
  274. +                           {
  275. +                               _log.severe("[CharTemplates.xml] Missing id for name:"+className+", skipping");
  276. +                               continue;
  277. +                           }
  278. +                           classId = Integer.parseInt(att.getNodeValue());
  279. +                           set.set("classId", classId);
  280. +                          
  281. +                           /*att = attrs.getNamedItem("parentId");
  282. +                           if (att == null)
  283. +                           {
  284. +                               _log.severe("[CharTemplates.xml] Missing parentId for name:"+className+", skipping");
  285. +                               continue;
  286. +                           }
  287. +                           parentClassId = Integer.parseInt(att.getNodeValue());*/
  288. +                          
  289. +                           att = attrs.getNamedItem("classBaseLevel");
  290. +                           if (att == null)
  291. +                           {
  292. +                               _log.severe("[CharTemplates.xml] Missing classLvl for name:"+className+", skipping");
  293. +                               continue;
  294. +                           }
  295. +                           set.set("classBaseLevel", Integer.parseInt(att.getNodeValue()));
  296. +                          
  297. +                           att = attrs.getNamedItem("raceId");
  298. +                           if (att == null)
  299. +                           {
  300. +                               _log.severe("[CharTemplates.xml] Missing raceId for name:"+className+", skipping");
  301. +                               continue;
  302. +                           }
  303. +                           set.set("raceId", Integer.parseInt(att.getNodeValue()));
  304. +                          
  305. +                           for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
  306. +                           {
  307. +                               if ("set".equalsIgnoreCase(cd.getNodeName()))
  308. +                               {
  309. +                                   String stat = null;
  310. +                                   double value = 0;
  311. +                                   try
  312. +                                   {
  313. +                                       stat = cd.getAttributes().getNamedItem("name").getNodeValue();
  314. +                                       value = Double.parseDouble(cd.getAttributes().getNamedItem("val").getNodeValue());
  315. +                                   }
  316. +                                   catch(NullPointerException npe)
  317. +                                   {
  318. +                                       npe.printStackTrace();
  319. +                                   }
  320. +                                   catch(NumberFormatException nfe)
  321. +                                   {
  322. +                                       _log.severe("[CharTemplates.xml] at "+stat+","+cd.getAttributes().getNamedItem("val").getNodeValue()+" is not a number! "+nfe.getMessage());
  323. +                                   }
  324. +                                   finally
  325. +                                   {
  326. +                                      
  327. +                                       if (stat.equals("baseSTR")
  328. +                                               || stat.equals("baseDEX")
  329. +                                               || stat.equals("baseCON")
  330. +                                               || stat.equals("baseINT")
  331. +                                               || stat.equals("baseWIT")
  332. +                                               || stat.equals("baseMEN")
  333. +                                               || stat.equals("baseHpMax")
  334. +                                               || stat.equals("lvlHpAdd")
  335. +                                               || stat.equals("lvlHpMod")
  336. +                                               || stat.equals("baseMpMax")
  337. +                                               || stat.equals("baseCpMax")
  338. +                                               || stat.equals("lvlCpAdd")
  339. +                                               || stat.equals("lvlCpMod")
  340. +                                               || stat.equals("lvlMpAdd")
  341. +                                               || stat.equals("lvlMpMod")
  342. +                                               || stat.equals("baseHpReg")
  343. +                                               || stat.equals("baseMpReg")
  344. +                                               || stat.equals("baseMAtkSpd")
  345. +                                               || stat.equals("baseRunSpd")
  346. +                                               || stat.equals("baseWalkSpd")
  347. +                                               || stat.equals("baseShldDef")
  348. +                                               || stat.equals("baseShldRate"))
  349. +                                           set.set(stat, value);
  350. +                                   }
  351. +                               }
  352. +                               else if ("spawn".equalsIgnoreCase(cd.getNodeName()))
  353. +                               {
  354. +                                   attrs = cd.getAttributes();
  355. +                                   try
  356. +                                   {
  357. +                                       spawnXarr.append(attrs.getNamedItem("X").getNodeValue()+";");
  358. +                                       spawnYarr.append(attrs.getNamedItem("Y").getNodeValue()+";");
  359. +                                       spawnZarr.append(attrs.getNamedItem("Z").getNodeValue()+";");
  360. +                                   }
  361. +                                   catch (NumberFormatException nfe)
  362. +                                   {
  363. +                                       _log.severe("[CharTemplates.xml] invalid spawn location: "+nfe.getMessage());
  364. +                                   }
  365. +                               }
  366. +                           }
  367. +                           set.set("spawnsX", spawnXarr.toString());
  368. +                           set.set("spawnsY", spawnYarr.toString());
  369. +                           set.set("spawnsZ", spawnZarr.toString());
  370. +                          
  371. +                           // The CharTemplate is ready, put the StatsSet in the map, we will need it to add more values to this set
  372. +                           _ssMap.put(classId, set);
  373. +                       }
  374. +                   }
  375. +               }
  376. +           }
  377. +       }
  378. +   }
  379. +  
  380. +   private void loadPcBaseStats()
  381. +   {
  382. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  383. +       factory.setValidating(false);
  384. +       factory.setIgnoringComments(true);
  385. +       factory.setIgnoringElementContentWhitespace(true);
  386. +       File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcBaseStats.xml");
  387. +       Document doc = null;
  388. +      
  389. +       if (file.exists())
  390. +       {      
  391. +           try
  392. +           {
  393. +               doc = factory.newDocumentBuilder().parse(file);
  394. +           }
  395. +           catch (Exception e)
  396. +           {
  397. +               _log.log(Level.WARNING, "Could not parse pcBaseStats.xml file: " + e.getMessage(), e);
  398. +           }
  399. +          
  400. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  401. +           {
  402. +               if ("pcBaseStats".equalsIgnoreCase(n.getNodeName()))
  403. +               {
  404. +                   String[] nodeNames = {
  405. +                           "basePAtk",
  406. +                           "baseRcrit",
  407. +                           "baseAtkType",
  408. +                           "baseAtkSpd",
  409. +                           "basePDef",
  410. +                           "baseMAtk",
  411. +                           "baseMDef",
  412. +                           "baseCanPenetrate",
  413. +                           "baseAtkRange",
  414. +                           "baseDamRange",
  415. +                           "baseRndDam"
  416. +                           };
  417. +                  
  418. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  419. +                   {
  420. +                       for (String nn : nodeNames)
  421. +                       {
  422. +                           if (nn.equalsIgnoreCase(d.getNodeName()))
  423. +                           {
  424. +                               Object[] properties = getProperties(file.getName(), d);
  425. +                               if (properties == null)
  426. +                                   break;
  427. +                              
  428. +                               _ssMap.get(properties[0]).set((Boolean) properties[1] ? nn+"_female" : nn, (String)properties[2]);
  429. +                           }
  430. +                       }
  431. +                   }
  432. +               }
  433. +           }
  434. +       }
  435. +       else
  436. +           _log.severe("CharTemplates: data/stats/chars/pcBaseStats.xml not found!");
  437. +   }
  438. +   private void loadPcBreathBonus()
  439. +   {
  440. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  441. +       factory.setValidating(false);
  442. +       factory.setIgnoringComments(true);
  443. +       factory.setIgnoringElementContentWhitespace(true);
  444. +       File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcBreathBonus.xml");
  445. +       Document doc = null;
  446. +      
  447. +       if (file.exists())
  448. +       {      
  449. +           try
  450. +           {
  451. +               doc = factory.newDocumentBuilder().parse(file);
  452. +           }
  453. +           catch (Exception e)
  454. +           {
  455. +               _log.log(Level.WARNING, "Could not parse pcBreathBonus.xml file: " + e.getMessage(), e);
  456. +           }
  457. +          
  458. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  459. +           {
  460. +               if ("pcBreathBonus".equalsIgnoreCase(n.getNodeName()))
  461. +               {
  462. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  463. +                   {
  464. +                       if ("breathBonus".equalsIgnoreCase(d.getNodeName()))
  465. +                       {
  466. +                           Object[] properties = getProperties(file.getName(), d);
  467. +                           if (properties == null)
  468. +                               break;
  469. +                          
  470. +                           _ssMap.get(properties[0]).set((Boolean) properties[1] ? "pcBreathBonus_female" : "pcBreathBonus", (String) properties[2]);
  471. +                       }
  472. +                   }
  473. +               }
  474. +           }
  475. +       }
  476. +       else
  477. +           _log.severe("CharTemplates: data/stats/chars/pcBreathBonus.xml not found!");
  478. +   }
  479. +  
  480. +   private void loadPcCollision()
  481. +   {
  482. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  483. +       factory.setValidating(false);
  484. +       factory.setIgnoringComments(true);
  485. +       factory.setIgnoringElementContentWhitespace(true);
  486. +       File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcCollision.xml");
  487. +       Document doc = null;
  488. +      
  489. +       if (file.exists())
  490. +       {      
  491. +           try
  492. +           {
  493. +               doc = factory.newDocumentBuilder().parse(file);
  494. +           }
  495. +           catch (Exception e)
  496. +           {
  497. +               _log.log(Level.WARNING, "Could not parse pcCollision.xml file: " + e.getMessage(), e);
  498. +           }
  499. +          
  500. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  501. +           {
  502. +               if ("pcCollision".equalsIgnoreCase(n.getNodeName()))
  503. +               {
  504. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  505. +                   {
  506. +                       if ("collision".equalsIgnoreCase(d.getNodeName()))
  507. +                       {
  508. +                           NamedNodeMap attrs = d.getAttributes();
  509. +                           Node att;
  510. +                           int classId = 0;
  511. +                           boolean isFemale = false;
  512. +                           double radius = 0;
  513. +                           double height = 0;
  514. +                          
  515. +                           att = attrs.getNamedItem("classId");
  516. +                           if (att == null)
  517. +                           {
  518. +                               _log.severe("["+file.getName()+"] Missing classId, skipping");
  519. +                               continue;
  520. +                           }
  521. +                           classId = Integer.parseInt(att.getNodeValue());
  522. +                          
  523. +                           att = attrs.getNamedItem("sex");
  524. +                           if (att == null)
  525. +                           {
  526. +                               _log.severe("["+file.getName()+"] Missing sex, skipping");
  527. +                               continue;
  528. +                           }
  529. +                           if ("female".equals(att.getNodeValue()))
  530. +                               isFemale = true;
  531. +                          
  532. +                           att = attrs.getNamedItem("radius");
  533. +                           if (att == null)
  534. +                           {
  535. +                               _log.severe("["+file.getName()+"] Missing radius, skipping");
  536. +                               continue;
  537. +                           }
  538. +                           radius = Double.parseDouble(att.getNodeValue());
  539. +                          
  540. +                           att = attrs.getNamedItem("height");
  541. +                           if (att == null)
  542. +                           {
  543. +                               _log.severe("["+file.getName()+"] Missing height, skipping");
  544. +                               continue;
  545. +                           }
  546. +                           height = Double.parseDouble(att.getNodeValue());
  547. +                          
  548. +                          
  549. +                           _ssMap.get(classId).set(isFemale ? "collision_radius_female" : "collision_radius", radius);
  550. +                           _ssMap.get(classId).set(isFemale ? "collision_height_female" : "collision_height", height);
  551. +                       }
  552. +                   }
  553. +               }
  554. +           }
  555. +       }
  556. +       else
  557. +           _log.severe("CharTemplates: data/stats/chars/pcCollision.xml not found!");
  558. +   }
  559. +  
  560. +   private void loadPcSafeFallHeight()
  561. +   {
  562. +       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  563. +       factory.setValidating(false);
  564. +       factory.setIgnoringComments(true);
  565. +       factory.setIgnoringElementContentWhitespace(true);
  566. +       File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcSafeFallHeight.xml");
  567. +       Document doc = null;
  568. +      
  569. +       if (file.exists())
  570. +       {      
  571. +           try
  572. +           {
  573. +               doc = factory.newDocumentBuilder().parse(file);
  574. +           }
  575. +           catch (Exception e)
  576. +           {
  577. +               _log.log(Level.WARNING, "Could not parse pcSafeFallHeight.xml file: " + e.getMessage(), e);
  578. +           }
  579. +          
  580. +           for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  581. +           {
  582. +               if ("pcSafeFallHeight".equalsIgnoreCase(n.getNodeName()))
  583. +               {
  584. +                   for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  585. +                   {
  586. +                       if ("safeFallHeight".equalsIgnoreCase(d.getNodeName()))
  587. +                       {
  588. +                           Object[] properties = getProperties(file.getName(), d);
  589. +                           if (properties == null)
  590. +                               break;
  591. +                          
  592. +                           _ssMap.get(properties[0]).set((Boolean) properties[1] ? "safeFallHeight_female" : "safeFallHeight", (String) properties[2]);
  593. +                       }
  594. +                   }
  595. +               }
  596. +           }
  597. +       }
  598. +       else
  599. +           _log.severe("CharTemplates: data/stats/chars/pcSafeFallHeight.xml not found!");
  600. +   }
  601. +  
  602. +   /**
  603. +    *
  604. +    * @param docName - the file's name (used for logging)
  605. +    * @param d - the node we use to get the values
  606. +    * @return Object[0] = classId(int)<BR>
  607. +    * Object[1] = isFemale(boolean)<BR>
  608. +    * Object[2] = value(String)<BR>
  609. +    */
  610. +   private Object[] getProperties(String docName, Node d)
  611. +   {
  612. +       Object[] toReturn = new Object[3];
  613. +      
  614. +       NamedNodeMap attrs = d.getAttributes();
  615. +       Node att;
  616. +      
  617. +       att = attrs.getNamedItem("classId");
  618. +       if (att == null)
  619. +       {
  620. +           _log.severe("["+docName+"] Missing classId, skipping");
  621. +           return null;
  622. +       }
  623. +       toReturn[0] = Integer.parseInt(att.getNodeValue());
  624. +      
  625. +       att = attrs.getNamedItem("sex");
  626. +       if (att == null)
  627. +       {
  628. +           _log.severe("["+docName+"] Missing sex, skipping");
  629. +           return null;
  630. +       }
  631. +       if ("female".equals(att.getNodeValue()))
  632. +           toReturn[1] = true;
  633. +       else
  634. +           toReturn[1] = false;
  635. +      
  636. +       att = attrs.getNamedItem("val");
  637. +       if (att == null)
  638. +       {
  639. +           _log.severe("["+docName+"] Missing val, skipping");
  640. +           return null;
  641. +       }
  642. +       toReturn[2] = att.getNodeValue();
  643. +      
  644. +       return toReturn;
  645. +   }
  646. +  
  647.     public L2PcTemplate getTemplate(ClassId classId)
  648.     {
  649.         return this.getTemplate(classId.getId());
  650. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  651. ===================================================================
  652. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 4587)
  653. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  654. @@ -523,11 +523,11 @@
  655.     private int _transformationId = 0;
  656.    
  657.     /** The table containing all L2RecipeList of the L2PcInstance */
  658. -   private Map<Integer, L2RecipeList> _dwarvenRecipeBook = new FastMap<Integer, L2RecipeList>();
  659. -   private Map<Integer, L2RecipeList> _commonRecipeBook = new FastMap<Integer, L2RecipeList>();
  660. +   private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new FastMap<Integer, L2RecipeList>();
  661. +   private final Map<Integer, L2RecipeList> _commonRecipeBook = new FastMap<Integer, L2RecipeList>();
  662.    
  663.     /** Premium Items */
  664. -   private Map<Integer, L2PremiumItem> _premiumItems = new FastMap<Integer, L2PremiumItem>();
  665. +   private final Map<Integer, L2PremiumItem> _premiumItems = new FastMap<Integer, L2PremiumItem>();
  666.    
  667.     /** True if the L2PcInstance is sitting */
  668.     private boolean _waitTypeSitting;
  669. @@ -539,7 +539,7 @@
  670.     private boolean _observerMode = false;
  671.    
  672.     /** Stored from last ValidatePosition **/
  673. -   private Point3D _lastServerPosition = new Point3D(0, 0, 0);
  674. +   private final Point3D _lastServerPosition = new Point3D(0, 0, 0);
  675.    
  676.     /** The number of recommendation obtained by the L2PcInstance */
  677.     private int _recomHave; // how much I was recommended by others
  678. @@ -552,7 +552,7 @@
  679.     /** Recommendation Two Hours bonus **/
  680.     private boolean _recoTwoHoursGiven = false;
  681.    
  682. -   private PcInventory _inventory = new PcInventory(this);
  683. +   private final PcInventory _inventory = new PcInventory(this);
  684.     private PcWarehouse _warehouse;
  685.     private PcRefund _refund;
  686.    
  687. @@ -581,16 +581,16 @@
  688.     private int _questNpcObject = 0;
  689.    
  690.     /** The table containing all Quests began by the L2PcInstance */
  691. -   private Map<String, QuestState> _quests = new FastMap<String, QuestState>();
  692. +   private final Map<String, QuestState> _quests = new FastMap<String, QuestState>();
  693.    
  694.     /** The list containing all shortCuts of this L2PcInstance */
  695. -   private ShortCuts _shortCuts = new ShortCuts(this);
  696. +   private final ShortCuts _shortCuts = new ShortCuts(this);
  697.    
  698.     /** The list containing all macroses of this L2PcInstance */
  699. -   private MacroList _macroses = new MacroList(this);
  700. +   private final MacroList _macroses = new MacroList(this);
  701.    
  702. -   private List<L2PcInstance> _snoopListener = new FastList<L2PcInstance>();
  703. -   private List<L2PcInstance> _snoopedPlayer = new FastList<L2PcInstance>();
  704. +   private final List<L2PcInstance> _snoopListener = new FastList<L2PcInstance>();
  705. +   private final List<L2PcInstance> _snoopedPlayer = new FastList<L2PcInstance>();
  706.    
  707.     private ClassId _skillLearningClassId;
  708.    
  709. @@ -656,7 +656,7 @@
  710.     private int _deathPenaltyBuffLevel = 0;
  711.    
  712.     // charges
  713. -   private AtomicInteger _charges = new AtomicInteger();
  714. +   private final AtomicInteger _charges = new AtomicInteger();
  715.     private ScheduledFuture<?> _chargeTask = null;
  716.    
  717.     // Absorbed Souls
  718. @@ -681,7 +681,7 @@
  719.     // there can only be one active party request at once
  720.     private L2PcInstance _activeRequester;
  721.     private long _requestExpireTime = 0;
  722. -   private L2Request _request = new L2Request(this);
  723. +   private final L2Request _request = new L2Request(this);
  724.     private L2ItemInstance _arrowItem;
  725.     private L2ItemInstance _boltItem;
  726.    
  727. @@ -737,10 +737,10 @@
  728.     private byte _handysBlockCheckerEventArena = -1;
  729.    
  730.     /** new loto ticket **/
  731. -   private int _loto[] = new int[5];
  732. +   private final int _loto[] = new int[5];
  733.     //public static int _loto_nums[] = {0,1,2,3,4,5,6,7,8,9,};
  734.     /** new race ticket **/
  735. -   private int _race[] = new int[2];
  736. +   private final int _race[] = new int[2];
  737.    
  738.     private final BlockList _blockList = new BlockList(this);
  739.    
  740. @@ -762,8 +762,8 @@
  741.     private ScheduledFuture<?> _taskWater;
  742.    
  743.     /** Bypass validations */
  744. -   private List<String> _validBypass = new FastList<String>();
  745. -   private List<String> _validBypass2 = new FastList<String>();
  746. +   private final List<String> _validBypass = new FastList<String>();
  747. +   private final List<String> _validBypass2 = new FastList<String>();
  748.    
  749.     private Forum _forumMail;
  750.     private Forum _forumMemo;
  751. @@ -896,11 +896,11 @@
  752.    
  753.     private class HerbTask implements Runnable
  754.     {
  755. -       private String _process;
  756. -       private int _itemId;
  757. -       private long _count;
  758. -       private L2Object _reference;
  759. -       private boolean _sendMessage;
  760. +       private final String _process;
  761. +       private final int _itemId;
  762. +       private final long _count;
  763. +       private final L2Object _reference;
  764. +       private final boolean _sendMessage;
  765.        
  766.         HerbTask(String process, int itemId, long count, L2Object reference, boolean sendMessage)
  767.         {
  768. @@ -951,9 +951,9 @@
  769.     /** Skill casting information (used to queue when several skills are cast in a short time) **/
  770.     public static class SkillDat
  771.     {
  772. -       private L2Skill _skill;
  773. -       private boolean _ctrlPressed;
  774. -       private boolean _shiftPressed;
  775. +       private final L2Skill _skill;
  776. +       private final boolean _ctrlPressed;
  777. +       private final boolean _shiftPressed;
  778.        
  779.         protected SkillDat(L2Skill skill, boolean ctrlPressed, boolean shiftPressed)
  780.         {
  781. @@ -984,7 +984,7 @@
  782.     }
  783.    
  784.     //summon friend
  785. -   private SummonRequest _summonRequest = new SummonRequest();
  786. +   private final SummonRequest _summonRequest = new SummonRequest();
  787.    
  788.     private static class SummonRequest
  789.     {
  790. @@ -1009,7 +1009,7 @@
  791.     }
  792.    
  793.     // open/close gates
  794. -   private GatesRequest _gatesRequest = new GatesRequest();
  795. +   private final GatesRequest _gatesRequest = new GatesRequest();
  796.    
  797.     private static class GatesRequest
  798.     {
  799. @@ -12997,7 +12997,7 @@
  800.             addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
  801.     }
  802.    
  803. -   private FastMap<Integer, TimeStamp> _reuseTimeStamps = new FastMap<Integer, TimeStamp>().shared();
  804. +   private final FastMap<Integer, TimeStamp> _reuseTimeStamps = new FastMap<Integer, TimeStamp>().shared();
  805.     private boolean _canFeed;
  806.     private int _eventEffectId = 0;
  807.     private boolean _isInSiege;
  808. @@ -14330,7 +14330,7 @@
  809.      * list of character friends
  810.      *
  811.      */
  812. -   private List<Integer> _friendList = new FastList<Integer>();
  813. +   private final List<Integer> _friendList = new FastList<Integer>();
  814.    
  815.     public List<Integer> getFriendList()
  816.     {
  817. @@ -14543,7 +14543,7 @@
  818.             return true;
  819.        
  820.         final int deltaZ = getZ() - z;
  821. -       if (deltaZ <= getBaseTemplate().getFallHeight())
  822. +       if (deltaZ <= getBaseTemplate().safeFallHeight)
  823.             return false;
  824.        
  825.         final int damage = (int)Formulas.calcFallDam(this, deltaZ);
  826. Index: java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java
  827. ===================================================================
  828. --- java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java    (revision 4587)
  829. +++ java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java    (working copy)
  830. @@ -44,6 +44,7 @@
  831.  import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
  832.  import com.l2jserver.gameserver.templates.chars.L2PcTemplate.PcTemplateItem;
  833.  import com.l2jserver.gameserver.util.Util;
  834. +import com.l2jserver.util.Rnd;
  835.  
  836.  
  837.  @SuppressWarnings("unused")
  838. @@ -233,7 +234,8 @@
  839.        
  840.         newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
  841.        
  842. -       newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
  843. +       int rnd = Rnd.get(template.spawnsX.length);
  844. +       newChar.setXYZInvisible(template.spawnsX[rnd], template.spawnsY[rnd], template.spawnsZ[rnd]);
  845.         newChar.setTitle("");
  846.        
  847.         if (Config.ENABLE_VITALITY)
  848. Index: java/com/l2jserver/gameserver/templates/StatsSet.java
  849. ===================================================================
  850. --- java/com/l2jserver/gameserver/templates/StatsSet.java   (revision 4587)
  851. +++ java/com/l2jserver/gameserver/templates/StatsSet.java   (working copy)
  852. @@ -349,7 +349,7 @@
  853.      * @param deflt : float designating the default value if value associated with the key is null
  854.      * @return double : value associated to the key
  855.      */
  856. -   public double getDouble(String name, float deflt)
  857. +   public double getDouble(String name, double deflt)
  858.     {
  859.         Object val = _set.get(name);
  860.         if (val == null)
  861. Index: java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java
  862. ===================================================================
  863. --- java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java   (revision 4587)
  864. +++ java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java   (working copy)
  865. @@ -40,23 +40,23 @@
  866.     /** MP Regen base */
  867.     public final float baseMpReg;
  868.    
  869. -   public final int basePAtk;
  870. -   public final int baseMAtk;
  871. -   public final int basePDef;
  872. -   public final int baseMDef;
  873. -   public final int basePAtkSpd;
  874. +   public int basePAtk;
  875. +   public int baseMAtk;
  876. +   public int basePDef;
  877. +   public int baseMDef;
  878. +   public int basePAtkSpd;
  879.     public final int baseMAtkSpd;
  880.     public final float baseMReuseRate;
  881.     public final int baseShldDef;
  882. -   public final int baseAtkRange;
  883. +   public int baseAtkRange;
  884.     public final int baseShldRate;
  885. -   public final int baseCritRate;
  886. +   public int baseCritRate;
  887.     public final int baseMCritRate;
  888.     public final int baseWalkSpd;
  889.     public final int baseRunSpd;
  890.    
  891.     // SpecialStats
  892. -   public final int baseBreath;
  893. +   public int baseBreath;
  894.     public final int baseAggression;
  895.     public final int baseBleed;
  896.     public final int basePoison;
  897. @@ -96,17 +96,17 @@
  898.      * For client info use {@link fCollisionRadius}
  899.      * </B></FONT><BR><BR>
  900.      */
  901. -   public final int collisionRadius;
  902. +   public int collisionRadius;
  903.    
  904.     /**
  905.      * <FONT COLOR=#FF0000><B> <U>Caution</U> :
  906.      * For client info use {@link fCollisionHeight}
  907.      * </B></FONT><BR><BR>
  908.      */
  909. -   public final int collisionHeight;
  910. +   public int collisionHeight;
  911.    
  912. -   public final double fCollisionRadius;
  913. -   public final double fCollisionHeight;
  914. +   public double fCollisionRadius;
  915. +   public double fCollisionHeight;
  916.    
  917.     public L2CharTemplate(StatsSet set)
  918.     {
  919. @@ -122,23 +122,58 @@
  920.         baseMpMax = set.getFloat("baseMpMax");
  921.         baseHpReg = set.getFloat("baseHpReg");
  922.         baseMpReg = set.getFloat("baseMpReg");
  923. -       basePAtk = set.getInteger("basePAtk");
  924. -       baseMAtk = set.getInteger("baseMAtk");
  925. -       basePDef = set.getInteger("basePDef");
  926. -       baseMDef = set.getInteger("baseMDef");
  927. -       basePAtkSpd = set.getInteger("basePAtkSpd");
  928. +       basePAtk = set.getInteger("basePAtk", -1);
  929. +       baseMAtk = set.getInteger("baseMAtk", -1);
  930. +       try
  931. +       {
  932. +           basePDef = set.getInteger("basePDef", -1);
  933. +       }
  934. +       catch(IllegalArgumentException iae)
  935. +       {
  936. +           try
  937. +           {
  938. +               basePDef = calcIntArray(set.getIntegerArray("basePDef"));
  939. +           }
  940. +           catch(IllegalArgumentException iae2)
  941. +           {
  942. +               basePDef = -1;
  943. +           }
  944. +       }
  945. +       try
  946. +       {
  947. +           baseMDef = set.getInteger("baseMDef", -1);
  948. +       }
  949. +       catch(IllegalArgumentException iae)
  950. +       {
  951. +           try
  952. +           {
  953. +               baseMDef = calcIntArray(set.getIntegerArray("baseMDef"));
  954. +           }
  955. +           catch(IllegalArgumentException iae2)
  956. +           {
  957. +               baseMDef = -1;
  958. +           }
  959. +       }
  960. +       basePAtkSpd = set.getInteger("basePAtkSpd", -1);
  961.         baseMAtkSpd = set.getInteger("baseMAtkSpd");
  962.         baseMReuseRate = set.getFloat("baseMReuseDelay", 1.f);
  963.         baseShldDef = set.getInteger("baseShldDef");
  964. -       baseAtkRange = set.getInteger("baseAtkRange");
  965. +       baseAtkRange = set.getInteger("baseAtkRange", -1);
  966.         baseShldRate = set.getInteger("baseShldRate");
  967. -       baseCritRate = set.getInteger("baseCritRate");
  968. +       baseCritRate = set.getInteger("baseCritRate", -1);
  969.         baseMCritRate = set.getInteger("baseMCritRate", 80); // CT2: The magic critical rate has been increased to 10 times.
  970.         baseWalkSpd = set.getInteger("baseWalkSpd");
  971.         baseRunSpd = set.getInteger("baseRunSpd");
  972.        
  973.         // SpecialStats
  974. -       baseBreath = set.getInteger("baseBreath", 100);
  975. +       try
  976. +       {
  977. +           baseBreath = set.getInteger("baseBreath", 100);
  978. +       }
  979. +       catch(IllegalArgumentException iae)
  980. +       {
  981. +           baseBreath = set.getInteger("pcBreathBonus", 100);
  982. +       }
  983.         baseAggression = set.getInteger("baseAggression", 0);
  984.         baseBleed = set.getInteger("baseBleed", 0);
  985.         basePoison = set.getInteger("basePoison", 0);
  986. @@ -174,9 +209,17 @@
  987.         baseHpConsumeRate = set.getInteger("baseHpConsumeRate", 0);
  988.        
  989.         // Geometry
  990. -       fCollisionHeight = set.getDouble("collision_height");
  991. -       fCollisionRadius = set.getDouble("collision_radius");
  992. +       fCollisionHeight = set.getDouble("collision_height", -1);
  993. +       fCollisionRadius = set.getDouble("collision_radius", -1);
  994.         collisionRadius = (int) fCollisionRadius;
  995.         collisionHeight = (int) fCollisionHeight;
  996.     }
  997. +  
  998. +   protected int calcIntArray(int[] val)
  999. +   {
  1000. +       int toReturn = 0;
  1001. +       for (int i = 0; i < val.length; i++)
  1002. +           toReturn += val[i];
  1003. +       return toReturn;
  1004. +   }
  1005.  }
  1006. Index: java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java
  1007. ===================================================================
  1008. --- java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java (revision 4587)
  1009. +++ java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java (working copy)
  1010. @@ -18,6 +18,7 @@
  1011.  
  1012.  import javolution.util.FastList;
  1013.  
  1014. +import com.l2jserver.gameserver.datatables.CharTemplateTable;
  1015.  import com.l2jserver.gameserver.model.base.ClassId;
  1016.  import com.l2jserver.gameserver.model.base.Race;
  1017.  import com.l2jserver.gameserver.templates.StatsSet;
  1018. @@ -33,9 +34,9 @@
  1019.     public final Race race;
  1020.     public final String className;
  1021.    
  1022. -   public final int spawnX;
  1023. -   public final int spawnY;
  1024. -   public final int spawnZ;
  1025. +   public final int[] spawnsX;
  1026. +   public final int[] spawnsY;
  1027. +   public final int[] spawnsZ;
  1028.    
  1029.     public final int classBaseLevel;
  1030.     public final float lvlHpAdd;
  1031. @@ -45,10 +46,25 @@
  1032.     public final float lvlMpAdd;
  1033.     public final float lvlMpMod;
  1034.    
  1035. -   public final double fCollisionHeight_female;
  1036. -   public final double fCollisionRadius_female;
  1037. +   public int basePAtk_female;
  1038. +   public int baseMAtk_female;
  1039. +   public int basePDef_female;
  1040. +   public int baseMDef_female;
  1041. +   public int basePAtkSpd_female;
  1042. +   public int baseAtkRange_female;
  1043. +   public int baseCritRate_female;
  1044. +  
  1045. +   public int baseBreath_female;
  1046.    
  1047. -   private List<PcTemplateItem> _items = new FastList<PcTemplateItem>();
  1048. +   public double fCollisionHeight_female;
  1049. +   public double fCollisionRadius_female;
  1050. +   public double collisionHeight_female;
  1051. +   public double collisionRadius_female;
  1052. +  
  1053. +   public int safeFallHeight;
  1054. +   public int safeFallHeight_female;
  1055. +  
  1056. +   private final List<PcTemplateItem> _items = new FastList<PcTemplateItem>();
  1057.    
  1058.     public L2PcTemplate(StatsSet set)
  1059.     {
  1060. @@ -57,9 +73,9 @@
  1061.         race = Race.values()[set.getInteger("raceId")];
  1062.         className = set.getString("className");
  1063.        
  1064. -       spawnX = set.getInteger("spawnX");
  1065. -       spawnY = set.getInteger("spawnY");
  1066. -       spawnZ = set.getInteger("spawnZ");
  1067. +       spawnsX = set.getIntegerArray("spawnsX");
  1068. +       spawnsY = set.getIntegerArray("spawnsY");
  1069. +       spawnsZ = set.getIntegerArray("spawnsZ");
  1070.        
  1071.         classBaseLevel = set.getInteger("classBaseLevel");
  1072.         lvlHpAdd = set.getFloat("lvlHpAdd");
  1073. @@ -69,8 +85,67 @@
  1074.         lvlMpAdd = set.getFloat("lvlMpAdd");
  1075.         lvlMpMod = set.getFloat("lvlMpMod");
  1076.        
  1077. -       fCollisionRadius_female = set.getDouble("collision_radius_female");
  1078. -       fCollisionHeight_female = set.getDouble("collision_height_female");
  1079. +       if (basePAtk == -1)
  1080. +           basePAtk = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtk;
  1081. +       if (baseMAtk == -1)
  1082. +           baseMAtk = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMAtk;
  1083. +       if (basePDef == -1)
  1084. +           basePDef = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef;
  1085. +       if (baseMDef == -1)
  1086. +           baseMDef = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef;
  1087. +       if (basePAtkSpd == -1)
  1088. +           basePAtkSpd = set.getInteger("baseAtkSpd", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtkSpd);
  1089. +       if (baseAtkRange == -1)
  1090. +           baseAtkRange = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseAtkRange;
  1091. +       if (baseCritRate == -1)
  1092. +           baseCritRate = set.getInteger("baseRcrit", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseCritRate);
  1093. +       if (fCollisionRadius == -1)
  1094. +           fCollisionRadius = set.getDouble("collision_radius", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionRadius);
  1095. +       if (fCollisionHeight == -1)
  1096. +           fCollisionHeight = set.getDouble("collision_height", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionHeight);
  1097. +      
  1098. +       basePAtk_female = set.getInteger("basePAtk_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtk_female);
  1099. +       baseMAtk_female = set.getInteger("baseMAtk_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMAtk_female);
  1100. +       // Since we dont have support for base p.def per seperate armor piece, we get the total
  1101. +       try
  1102. +       {
  1103. +           basePDef_female = calcIntArray(set.getIntegerArray("basePDef_female"));
  1104. +       }
  1105. +       catch(IllegalArgumentException iae)
  1106. +       {
  1107. +           basePDef_female = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef_female;
  1108. +       }
  1109. +       try
  1110. +       {
  1111. +           baseMDef_female = calcIntArray(set.getIntegerArray("baseMDef_female"));
  1112. +       }
  1113. +       catch(IllegalArgumentException iae)
  1114. +       {
  1115. +           baseMDef_female = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMDef_female;
  1116. +       }
  1117. +       basePAtkSpd_female = set.getInteger("baseAtkSpd_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtkSpd_female);
  1118. +       baseAtkRange_female = set.getInteger("baseAtkRange_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseAtkRange_female);
  1119. +       baseCritRate_female = set.getInteger("baseRcrit_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseCritRate_female);
  1120. +      
  1121. +       baseBreath = set.getInteger("pcBreathBonus", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseBreath);
  1122. +       baseBreath_female = set.getInteger("pcBreathBonus_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseBreath_female);
  1123. +      
  1124. +       safeFallHeight = set.getInteger("safeFallHeight", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).safeFallHeight);
  1125. +       safeFallHeight_female = set.getInteger("safeFallHeight_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).safeFallHeight_female);
  1126. +      
  1127. +       fCollisionRadius_female = set.getDouble("collision_radius_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionRadius_female);
  1128. +       fCollisionHeight_female = set.getDouble("collision_height_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionHeight_female);
  1129. +      
  1130. +       collisionRadius = (int) fCollisionRadius;
  1131. +       collisionHeight = (int) fCollisionHeight;
  1132. +       collisionRadius_female = (int) fCollisionRadius_female;
  1133. +       collisionHeight_female = (int) fCollisionHeight_female;
  1134. +       /* TODO: Unimplemented values:
  1135. +        * baseAtkType
  1136. +        * baseCanPenetrate
  1137. +        * baseDamRange
  1138. +        * baseRndDam
  1139. +        */
  1140.     }
  1141.    
  1142.     /**
  1143. @@ -132,9 +207,4 @@
  1144.             return _equipped;
  1145.         }
  1146.     }
  1147. -  
  1148. -   public final int getFallHeight()
  1149. -   {
  1150. -       return 333; // TODO: unhardcode it
  1151. -   }
  1152.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement