L2NpcTemplate.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.templates.chars;
  16. import java.util.List;
  17. import java.util.Map;
  18. import java.util.logging.Logger;
  19. import javolution.util.FastList;
  20. import javolution.util.FastMap;
  21. import com.l2jserver.gameserver.datatables.HerbDropTable;
  22. import com.l2jserver.gameserver.model.L2DropCategory;
  23. import com.l2jserver.gameserver.model.L2DropData;
  24. import com.l2jserver.gameserver.model.L2MinionData;
  25. import com.l2jserver.gameserver.model.L2NpcAIData;
  26. import com.l2jserver.gameserver.model.L2Skill;
  27. import com.l2jserver.gameserver.model.actor.instance.L2XmassTreeInstance;
  28. import com.l2jserver.gameserver.model.base.ClassId;
  29. import com.l2jserver.gameserver.model.quest.Quest;
  30. import com.l2jserver.gameserver.templates.StatsSet;
  31. /**
  32. * This cl contains all generic data of a L2Spawn object.<BR><BR>
  33. *
  34. * <B><U> Data</U> :</B><BR><BR>
  35. * <li>npcId, type, name, sex</li>
  36. * <li>rewardExp, rewardSp</li>
  37. * <li>aggroRange, factionId, factionRange</li>
  38. * <li>rhand, lhand</li>
  39. * <li>isUndead</li>
  40. * <li>_drops</li>
  41. * <li>_minions</li>
  42. * <li>_teachInfo</li>
  43. * <li>_skills</li>
  44. * <li>_questsStart</li><BR><BR>
  45. *
  46. * @version $Revision: 1.1.2.4 $ $Date: 2005/04/02 15:57:51 $
  47. */
  48. public final class L2NpcTemplate extends L2CharTemplate
  49. {
  50. protected static final Logger _log = Logger.getLogger(Quest.class.getName());
  51. public final int npcId;
  52. public final int idTemplate;
  53. public final String type;
  54. public final String name;
  55. public final boolean serverSideName;
  56. public final String title;
  57. public final boolean serverSideTitle;
  58. public final String sex;
  59. public final byte level;
  60. public final int rewardExp;
  61. public final int rewardSp;
  62. public final int aggroRange;
  63. public final int rhand;
  64. public final int lhand;
  65. public final int enchantEffect;
  66. public Race race;
  67. public final String jClass;
  68. public final int dropherbgroup;
  69. public boolean isQuestMonster; // doesn't include all mobs that are involved in
  70. // quests, just plain quest monsters for preventing champion spawn
  71. public final float baseVitalityDivider;
  72. //Skill AI
  73. public FastList<L2Skill> _buffskills;
  74. public FastList<L2Skill> _negativeskills;
  75. public FastList<L2Skill> _debuffskills;
  76. public FastList<L2Skill> _atkskills;
  77. public FastList<L2Skill> _rootskills;
  78. public FastList<L2Skill> _stunskills;
  79. public FastList<L2Skill> _sleepskills;
  80. public FastList<L2Skill> _paralyzeskills;
  81. public FastList<L2Skill> _fossilskills;
  82. public FastList<L2Skill> _floatskills;
  83. public FastList<L2Skill> _immobiliseskills;
  84. public FastList<L2Skill> _healskills;
  85. public FastList<L2Skill> _resskills;
  86. public FastList<L2Skill> _dotskills;
  87. public FastList<L2Skill> _cotskills;
  88. public FastList<L2Skill> _universalskills;
  89. public FastList<L2Skill> _manaskills;
  90. public FastList<L2Skill> _Lrangeskills;
  91. public FastList<L2Skill> _Srangeskills;
  92. public FastList<L2Skill> _generalskills;
  93. private boolean _hasbuffskills;
  94. private boolean _hasnegativeskills;
  95. private boolean _hasdebuffskills;
  96. private boolean _hasatkskills;
  97. private boolean _hasrootskills;
  98. private boolean _hasstunskills;
  99. private boolean _hassleepskills;
  100. private boolean _hasparalyzeskills;
  101. private boolean _hasfossilskills;
  102. private boolean _hasfloatskills;
  103. private boolean _hasimmobiliseskills;
  104. private boolean _hashealskills;
  105. private boolean _hasresskills;
  106. private boolean _hasdotskills;
  107. private boolean _hascotskills;
  108. private boolean _hasuniversalskills;
  109. private boolean _hasmanaskills;
  110. private boolean _hasLrangeskills;
  111. private boolean _hasSrangeskills;
  112. private boolean _hasgeneralskills;
  113. private L2NpcAIData _AIdataStatic = new L2NpcAIData();
  114. public static enum AIType
  115. {
  116. FIGHTER,
  117. ARCHER,
  118. BALANCED,
  119. MAGE,
  120. HEALER,
  121. CORPSE
  122. }
  123. public static enum Race
  124. {
  125. UNDEAD,
  126. MAGICCREATURE,
  127. BEAST,
  128. ANIMAL,
  129. PLANT,
  130. HUMANOID,
  131. SPIRIT,
  132. ANGEL,
  133. DEMON,
  134. DRAGON,
  135. GIANT,
  136. BUG,
  137. FAIRIE,
  138. HUMAN,
  139. ELVE,
  140. DARKELVE,
  141. ORC,
  142. DWARVE,
  143. OTHER,
  144. NONLIVING,
  145. SIEGEWEAPON,
  146. DEFENDINGARMY,
  147. MERCENARIE,
  148. UNKNOWN,
  149. KAMAEL,
  150. NONE
  151. }
  152. //private final StatsSet _npcStatsSet;
  153. /** The table containing all Item that can be dropped by L2NpcInstance using this L2NpcTemplate*/
  154. private FastList<L2DropCategory> _categories = null;
  155. /** The table containing all Minions that must be spawn with the L2NpcInstance using this L2NpcTemplate*/
  156. private List<L2MinionData> _minions = null;
  157. private List<ClassId> _teachInfo;
  158. private Map<Integer, L2Skill> _skills;
  159. //private Map<Stats, Double> _vulnerabilities;
  160. // contains a list of quests for each event type (questStart, questAttack, questKill, etc)
  161. private Map<Quest.QuestEventType, Quest[]> _questEvents;
  162. /**
  163. * Constructor of L2Character.<BR><BR>
  164. *
  165. * @param set The StatsSet object to transfer data to the method
  166. *
  167. */
  168. public L2NpcTemplate(StatsSet set)
  169. {
  170. super(set);
  171. npcId = set.getInteger("npcId");
  172. idTemplate = set.getInteger("idTemplate");
  173. type = set.getString("type");
  174. name = set.getString("name");
  175. serverSideName = set.getBool("serverSideName");
  176. title = set.getString("title");
  177. if (title.equalsIgnoreCase("Quest Monster"))
  178. isQuestMonster = true;
  179. else
  180. isQuestMonster = false;
  181. serverSideTitle = set.getBool("serverSideTitle");
  182. sex = set.getString("sex");
  183. level = set.getByte("level");
  184. rewardExp = set.getInteger("rewardExp");
  185. rewardSp = set.getInteger("rewardSp");
  186. aggroRange = set.getInteger("aggroRange");
  187. rhand = set.getInteger("rhand");
  188. lhand = set.getInteger("lhand");
  189. enchantEffect = set.getInteger("enchant");
  190. race = null;
  191. int herbGroup = set.getInteger("dropHerbGroup");
  192. if (herbGroup > 0 && HerbDropTable.getInstance().getHerbDroplist(herbGroup) == null)
  193. {
  194. _log.warning("Missing Herb Drop Group for npcId: " + npcId);
  195. dropherbgroup = 0;
  196. }
  197. else
  198. dropherbgroup = herbGroup;
  199. //_npcStatsSet = set;
  200. _teachInfo = null;
  201. jClass = set.getString("jClass");
  202. // can be loaded from db
  203. baseVitalityDivider = level > 0 && rewardExp > 0 ? baseHpMax * 9 * level * level /(100 * rewardExp) : 0;
  204. }
  205. public void addTeachInfo(ClassId classId)
  206. {
  207. if (_teachInfo == null)
  208. _teachInfo = new FastList<ClassId>();
  209. _teachInfo.add(classId);
  210. }
  211. public ClassId[] getTeachInfo()
  212. {
  213. if (_teachInfo == null)
  214. return null;
  215. return _teachInfo.toArray(new ClassId[_teachInfo.size()]);
  216. }
  217. public boolean canTeach(ClassId classId)
  218. {
  219. if (_teachInfo == null)
  220. return false;
  221. // If the player is on a third class, fetch the class teacher
  222. // information for its parent class.
  223. if (classId.level() == 3)
  224. return _teachInfo.contains(classId.getParent());
  225. return _teachInfo.contains(classId);
  226. }
  227. // add a drop to a given category. If the category does not exist, create it.
  228. public void addDropData(L2DropData drop, int categoryType)
  229. {
  230. if (drop.isQuestDrop())
  231. {
  232. // if (_questDrops == null)
  233. // _questDrops = new FastList<L2DropData>(0);
  234. // _questDrops.add(drop);
  235. }
  236. else
  237. {
  238. if (_categories == null)
  239. _categories = new FastList<L2DropCategory>();
  240. // if the category doesn't already exist, create it first
  241. synchronized (_categories)
  242. {
  243. boolean catExists = false;
  244. for (L2DropCategory cat : _categories)
  245. // if the category exists, add the drop to this category.
  246. if (cat.getCategoryType() == categoryType)
  247. {
  248. cat.addDropData(drop, type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss"));
  249. catExists = true;
  250. break;
  251. }
  252. // if the category doesn't exit, create it and add the drop
  253. if (!catExists)
  254. {
  255. L2DropCategory cat = new L2DropCategory(categoryType);
  256. cat.addDropData(drop, type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss"));
  257. _categories.add(cat);
  258. }
  259. }
  260. }
  261. }
  262. public void addRaidData(L2MinionData minion)
  263. {
  264. if (_minions == null)
  265. _minions = new FastList<L2MinionData>();
  266. _minions.add(minion);
  267. }
  268. /*public void addVulnerability(Stats id, double vuln)
  269. {
  270. if (_vulnerabilities == null)
  271. _vulnerabilities = new FastMap<Stats, Double>();
  272. _vulnerabilities.put(id, new Double(vuln));
  273. }
  274. public double getVulnerability(Stats id)
  275. {
  276. if (_vulnerabilities == null || _vulnerabilities.get(id) == null)
  277. return 1;
  278. return _vulnerabilities.get(id);
  279. }*/
  280. public void addSkill(L2Skill skill)
  281. {
  282. if (_skills == null)
  283. _skills = new FastMap<Integer, L2Skill>();
  284. if(!skill.isPassive())
  285. {
  286. addGeneralSkill(skill);
  287. switch(skill.getSkillType())
  288. {
  289. case BUFF:
  290. addBuffSkill(skill);
  291. break;
  292. case HEAL:
  293. case HOT:
  294. case HEAL_PERCENT:
  295. case HEAL_STATIC:
  296. case BALANCE_LIFE:
  297. addHealSkill(skill);
  298. break;
  299. case RESURRECT:
  300. addResSkill(skill);
  301. break;
  302. case DEBUFF:
  303. addDebuffSkill(skill);
  304. addCOTSkill(skill);
  305. addRangeSkill(skill);
  306. break;
  307. case ROOT:
  308. addRootSkill(skill);
  309. addImmobiliseSkill(skill);
  310. addRangeSkill(skill);
  311. break;
  312. case SLEEP:
  313. addSleepSkill(skill);
  314. addImmobiliseSkill(skill);
  315. break;
  316. case STUN:
  317. addRootSkill(skill);
  318. addImmobiliseSkill(skill);
  319. addRangeSkill(skill);
  320. break;
  321. case PARALYZE:
  322. addParalyzeSkill(skill);
  323. addImmobiliseSkill(skill);
  324. addRangeSkill(skill);
  325. break;
  326. case PDAM:
  327. case MDAM:
  328. case BLOW:
  329. case DRAIN:
  330. case CHARGEDAM:
  331. case FATAL:
  332. case DEATHLINK:
  333. case CPDAM:
  334. case MANADAM:
  335. case CPDAMPERCENT:
  336. addAtkSkill(skill);
  337. addUniversalSkill(skill);
  338. addRangeSkill(skill);
  339. break;
  340. case POISON:
  341. case DOT:
  342. case MDOT:
  343. case BLEED:
  344. addDOTSkill(skill);
  345. addRangeSkill(skill);
  346. break;
  347. case MUTE:
  348. case FEAR:
  349. addCOTSkill(skill);
  350. addRangeSkill(skill);
  351. break;
  352. case CANCEL:
  353. case NEGATE:
  354. addNegativeSkill(skill);
  355. addRangeSkill(skill);
  356. break;
  357. default :
  358. addUniversalSkill(skill);
  359. break;
  360. }
  361. }
  362. _skills.put(skill.getId(), skill);
  363. }
  364. /*public double removeVulnerability(Stats id)
  365. {
  366. return _vulnerabilities.remove(id);
  367. }*/
  368. /**
  369. * Return the list of all possible UNCATEGORIZED drops of this L2NpcTemplate.<BR><BR>
  370. */
  371. public FastList<L2DropCategory> getDropData()
  372. {
  373. return _categories;
  374. }
  375. /**
  376. * Return the list of all possible item drops of this L2NpcTemplate.<BR>
  377. * (ie full drops and part drops, mats, miscellaneous & UNCATEGORIZED)<BR><BR>
  378. */
  379. public List<L2DropData> getAllDropData()
  380. {
  381. if (_categories == null)
  382. return null;
  383. List<L2DropData> lst = new FastList<L2DropData>();
  384. for (L2DropCategory tmp : _categories)
  385. {
  386. lst.addAll(tmp.getAllDrops());
  387. }
  388. return lst;
  389. }
  390. /**
  391. * Empty all possible drops of this L2NpcTemplate.<BR><BR>
  392. */
  393. public synchronized void clearAllDropData()
  394. {
  395. if (_categories == null)
  396. return;
  397. while (!_categories.isEmpty())
  398. {
  399. _categories.getFirst().clearAllDrops();
  400. _categories.removeFirst();
  401. }
  402. _categories.clear();
  403. }
  404. /**
  405. * Return the list of all Minions that must be spawn with the L2NpcInstance using this L2NpcTemplate.<BR><BR>
  406. */
  407. public List<L2MinionData> getMinionData()
  408. {
  409. return _minions;
  410. }
  411. public Map<Integer, L2Skill> getSkills()
  412. {
  413. return _skills;
  414. }
  415. public void addQuestEvent(Quest.QuestEventType EventType, Quest q)
  416. {
  417. if (_questEvents == null)
  418. _questEvents = new FastMap<Quest.QuestEventType, Quest[]>();
  419. if (_questEvents.get(EventType) == null)
  420. {
  421. _questEvents.put(EventType, new Quest[]
  422. {
  423. q
  424. });
  425. }
  426. else
  427. {
  428. Quest[] _quests = _questEvents.get(EventType);
  429. int len = _quests.length;
  430. // if only one registration per npc is allowed for this event type
  431. // then only register this NPC if not already registered for the specified event.
  432. // if a quest allows multiple registrations, then register regardless of count
  433. // In all cases, check if this new registration is replacing an older copy of the SAME quest
  434. // Finally, check quest class hierarchy: a parent class should never replace a child class.
  435. // a child class should always replace a parent class.
  436. if (!EventType.isMultipleRegistrationAllowed())
  437. {
  438. // if it is the same quest (i.e. reload) or the existing is a superclass of the new one, replace the existing.
  439. if (_quests[0].getName().equals(q.getName()) || L2NpcTemplate.isAssignableTo(q, _quests[0].getClass()))
  440. {
  441. _quests[0] = q;
  442. }
  443. else
  444. {
  445. _log.warning("Quest event not allowed in multiple quests. Skipped addition of Event Type \"" + EventType + "\" for NPC \"" + name + "\" and quest \"" + q.getName() + "\".");
  446. }
  447. }
  448. else
  449. {
  450. // be ready to add a new quest to a new copy of the list, with larger size than previously.
  451. Quest[] tmp = new Quest[len + 1];
  452. // loop through the existing quests and copy them to the new list. While doing so, also
  453. // check if this new quest happens to be just a replacement for a previously loaded quest.
  454. // Replace existing if the new quest is the same (reload) or a child of the existing quest.
  455. // Do nothing if the new quest is a superclass of an existing quest.
  456. // Add the new quest in the end of the list otherwise.
  457. for (int i = 0; i < len; i++)
  458. {
  459. if (_quests[i].getName().equals(q.getName()) || L2NpcTemplate.isAssignableTo(q, _quests[i].getClass()))
  460. {
  461. _quests[i] = q;
  462. return;
  463. }
  464. else if (L2NpcTemplate.isAssignableTo(_quests[i], q.getClass()))
  465. {
  466. return;
  467. }
  468. tmp[i] = _quests[i];
  469. }
  470. tmp[len] = q;
  471. _questEvents.put(EventType, tmp);
  472. }
  473. }
  474. }
  475. /**
  476. * Checks if obj can be assigned to the Class represented by clazz.<br>
  477. * This is true if, and only if, obj is the same class represented by clazz,
  478. * or a subclass of it or obj implements the interface represented by clazz.
  479. *
  480. *
  481. * @param obj
  482. * @param clazz
  483. * @return
  484. */
  485. public static boolean isAssignableTo(Object obj, Class<?> clazz)
  486. {
  487. return L2NpcTemplate.isAssignableTo(obj.getClass(), clazz);
  488. }
  489. public static boolean isAssignableTo(Class<?> sub, Class<?> clazz)
  490. {
  491. // if clazz represents an interface
  492. if (clazz.isInterface())
  493. {
  494. // check if obj implements the clazz interface
  495. Class<?>[] interfaces = sub.getInterfaces();
  496. for (int i = 0; i < interfaces.length; i++)
  497. {
  498. if (clazz.getName().equals(interfaces[i].getName()))
  499. {
  500. return true;
  501. }
  502. }
  503. }
  504. else
  505. {
  506. do
  507. {
  508. if (sub.getName().equals(clazz.getName()))
  509. {
  510. return true;
  511. }
  512. sub = sub.getSuperclass();
  513. }
  514. while (sub != null);
  515. }
  516. return false;
  517. }
  518. public Quest[] getEventQuests(Quest.QuestEventType EventType)
  519. {
  520. if (_questEvents == null)
  521. {
  522. return null;
  523. }
  524. return _questEvents.get(EventType);
  525. }
  526. public void setRace(int raceId)
  527. {
  528. switch (raceId)
  529. {
  530. case 1:
  531. race = L2NpcTemplate.Race.UNDEAD;
  532. break;
  533. case 2:
  534. race = L2NpcTemplate.Race.MAGICCREATURE;
  535. break;
  536. case 3:
  537. race = L2NpcTemplate.Race.BEAST;
  538. break;
  539. case 4:
  540. race = L2NpcTemplate.Race.ANIMAL;
  541. break;
  542. case 5:
  543. race = L2NpcTemplate.Race.PLANT;
  544. break;
  545. case 6:
  546. race = L2NpcTemplate.Race.HUMANOID;
  547. break;
  548. case 7:
  549. race = L2NpcTemplate.Race.SPIRIT;
  550. break;
  551. case 8:
  552. race = L2NpcTemplate.Race.ANGEL;
  553. break;
  554. case 9:
  555. race = L2NpcTemplate.Race.DEMON;
  556. break;
  557. case 10:
  558. race = L2NpcTemplate.Race.DRAGON;
  559. break;
  560. case 11:
  561. race = L2NpcTemplate.Race.GIANT;
  562. break;
  563. case 12:
  564. race = L2NpcTemplate.Race.BUG;
  565. break;
  566. case 13:
  567. race = L2NpcTemplate.Race.FAIRIE;
  568. break;
  569. case 14:
  570. race = L2NpcTemplate.Race.HUMAN;
  571. break;
  572. case 15:
  573. race = L2NpcTemplate.Race.ELVE;
  574. break;
  575. case 16:
  576. race = L2NpcTemplate.Race.DARKELVE;
  577. break;
  578. case 17:
  579. race = L2NpcTemplate.Race.ORC;
  580. break;
  581. case 18:
  582. race = L2NpcTemplate.Race.DWARVE;
  583. break;
  584. case 19:
  585. race = L2NpcTemplate.Race.OTHER;
  586. break;
  587. case 20:
  588. race = L2NpcTemplate.Race.NONLIVING;
  589. break;
  590. case 21:
  591. race = L2NpcTemplate.Race.SIEGEWEAPON;
  592. break;
  593. case 22:
  594. race = L2NpcTemplate.Race.DEFENDINGARMY;
  595. break;
  596. case 23:
  597. race = L2NpcTemplate.Race.MERCENARIE;
  598. break;
  599. case 24:
  600. race = L2NpcTemplate.Race.UNKNOWN;
  601. break;
  602. case 25:
  603. race = L2NpcTemplate.Race.KAMAEL;
  604. break;
  605. default:
  606. race = L2NpcTemplate.Race.NONE;
  607. break;
  608. }
  609. }
  610. //-----------------------------------------------------------------------
  611. // Npc AI Data
  612. // By ShanSoft
  613. public void setAIData(L2NpcAIData aidata)
  614. {
  615. //_AIdataStatic = new L2NpcAIData(); // not needed to init object and in next line override with other reference. maybe other intention?
  616. _AIdataStatic = aidata;
  617. }
  618. //-----------------------------------------------------------------------
  619. public L2NpcAIData getAIDataStatic()
  620. {
  621. return _AIdataStatic;
  622. }
  623. public void addBuffSkill(L2Skill skill)
  624. {
  625. if (_buffskills == null)
  626. _buffskills = new FastList<L2Skill>();
  627. _buffskills.add(skill);
  628. _hasbuffskills=true;
  629. }
  630. public void addHealSkill(L2Skill skill)
  631. {
  632. if (_healskills == null)
  633. _healskills = new FastList<L2Skill>();
  634. _healskills.add(skill);
  635. _hashealskills=true;
  636. }
  637. public void addResSkill(L2Skill skill)
  638. {
  639. if (_resskills == null)
  640. _resskills = new FastList<L2Skill>();
  641. _resskills.add(skill);
  642. _hasresskills=true;
  643. }
  644. public void addAtkSkill(L2Skill skill)
  645. {
  646. if (_atkskills == null)
  647. _atkskills = new FastList<L2Skill>();
  648. _atkskills.add(skill);
  649. _hasatkskills=true;
  650. }
  651. public void addDebuffSkill(L2Skill skill)
  652. {
  653. if (_debuffskills == null)
  654. _debuffskills = new FastList<L2Skill>();
  655. _debuffskills.add(skill);
  656. _hasdebuffskills=true;
  657. }
  658. public void addRootSkill(L2Skill skill)
  659. {
  660. if (_rootskills == null)
  661. _rootskills = new FastList<L2Skill>();
  662. _rootskills.add(skill);
  663. _hasrootskills=true;
  664. }
  665. public void addSleepSkill(L2Skill skill)
  666. {
  667. if (_sleepskills == null)
  668. _sleepskills = new FastList<L2Skill>();
  669. _sleepskills.add(skill);
  670. _hassleepskills=true;
  671. }
  672. public void addStunSkill(L2Skill skill)
  673. {
  674. if (_stunskills == null)
  675. _stunskills = new FastList<L2Skill>();
  676. _stunskills.add(skill);
  677. _hasstunskills=true;
  678. }
  679. public void addParalyzeSkill(L2Skill skill)
  680. {
  681. if (_paralyzeskills == null)
  682. _paralyzeskills = new FastList<L2Skill>();
  683. _paralyzeskills.add(skill);
  684. _hasparalyzeskills=true;
  685. }
  686. public void addFloatSkill(L2Skill skill)
  687. {
  688. if (_floatskills == null)
  689. _floatskills = new FastList<L2Skill>();
  690. _floatskills.add(skill);
  691. _hasfloatskills=true;
  692. }
  693. public void addFossilSkill(L2Skill skill)
  694. {
  695. if (_fossilskills == null)
  696. _fossilskills = new FastList<L2Skill>();
  697. _fossilskills.add(skill);
  698. _hasfossilskills=true;
  699. }
  700. public void addNegativeSkill(L2Skill skill)
  701. {
  702. if (_negativeskills == null)
  703. _negativeskills = new FastList<L2Skill>();
  704. _negativeskills.add(skill);
  705. _hasnegativeskills=true;
  706. }
  707. public void addImmobiliseSkill(L2Skill skill)
  708. {
  709. if (_immobiliseskills == null)
  710. _immobiliseskills = new FastList<L2Skill>();
  711. _immobiliseskills.add(skill);
  712. _hasimmobiliseskills=true;
  713. }
  714. public void addDOTSkill(L2Skill skill)
  715. {
  716. if (_dotskills == null)
  717. _dotskills = new FastList<L2Skill>();
  718. _dotskills.add(skill);
  719. _hasdotskills=true;
  720. }
  721. public void addUniversalSkill(L2Skill skill)
  722. {
  723. if (_universalskills == null)
  724. _universalskills = new FastList<L2Skill>();
  725. _universalskills.add(skill);
  726. _hasuniversalskills=true;
  727. }
  728. public void addCOTSkill(L2Skill skill)
  729. {
  730. if (_cotskills == null)
  731. _cotskills = new FastList<L2Skill>();
  732. _cotskills.add(skill);
  733. _hascotskills=true;
  734. }
  735. public void addManaHealSkill(L2Skill skill)
  736. {
  737. if (_manaskills == null)
  738. _manaskills = new FastList<L2Skill>();
  739. _manaskills.add(skill);
  740. _hasmanaskills=true;
  741. }
  742. public void addGeneralSkill(L2Skill skill)
  743. {
  744. if (_generalskills == null)
  745. _generalskills = new FastList<L2Skill>();
  746. _generalskills.add(skill);
  747. _hasgeneralskills=true;
  748. }
  749. public void addRangeSkill(L2Skill skill)
  750. {
  751. if (skill.getCastRange() <= 150 && skill.getCastRange() > 0)
  752. {
  753. if (_Srangeskills == null)
  754. _Srangeskills = new FastList<L2Skill>();
  755. _Srangeskills.add(skill);
  756. _hasSrangeskills=true;
  757. }
  758. else if (skill.getCastRange() > 150)
  759. {
  760. if (_Lrangeskills == null)
  761. _Lrangeskills = new FastList<L2Skill>();
  762. _Lrangeskills.add(skill);
  763. _hasLrangeskills=true;
  764. }
  765. }
  766. //--------------------------------------------------------------------
  767. public boolean hasBuffSkill()
  768. {
  769. return _hasbuffskills;
  770. }
  771. public boolean hasHealSkill()
  772. {
  773. return _hashealskills;
  774. }
  775. public boolean hasResSkill()
  776. {
  777. return _hasresskills;
  778. }
  779. public boolean hasAtkSkill()
  780. {
  781. return _hasatkskills;
  782. }
  783. public boolean hasDebuffSkill()
  784. {
  785. return _hasdebuffskills;
  786. }
  787. public boolean hasRootSkill()
  788. {
  789. return _hasrootskills;
  790. }
  791. public boolean hasSleepSkill()
  792. {
  793. return _hassleepskills;
  794. }
  795. public boolean hasStunSkill()
  796. {
  797. return _hasstunskills;
  798. }
  799. public boolean hasParalyzeSkill()
  800. {
  801. return _hasparalyzeskills;
  802. }
  803. public boolean hasFloatSkill()
  804. {
  805. return _hasfloatskills;
  806. }
  807. public boolean hasFossilSkill()
  808. {
  809. return _hasfossilskills;
  810. }
  811. public boolean hasNegativeSkill()
  812. {
  813. return _hasnegativeskills;
  814. }
  815. public boolean hasImmobiliseSkill()
  816. {
  817. return _hasimmobiliseskills;
  818. }
  819. public boolean hasDOTSkill()
  820. {
  821. return _hasdotskills;
  822. }
  823. public boolean hasUniversalSkill()
  824. {
  825. return _hasuniversalskills;
  826. }
  827. public boolean hasCOTSkill()
  828. {
  829. return _hascotskills;
  830. }
  831. public boolean hasManaHealSkill()
  832. {
  833. return _hasmanaskills;
  834. }
  835. public boolean hasAutoLrangeSkill()
  836. {
  837. return _hasLrangeskills;
  838. }
  839. public boolean hasAutoSrangeSkill()
  840. {
  841. return _hasSrangeskills;
  842. }
  843. public boolean hasSkill()
  844. {
  845. return _hasgeneralskills;
  846. }
  847. public L2NpcTemplate.Race getRace()
  848. {
  849. if (race == null)
  850. race = L2NpcTemplate.Race.NONE;
  851. return race;
  852. }
  853. public boolean isCustom()
  854. {
  855. return npcId != idTemplate;
  856. }
  857. /**
  858. * @return name
  859. */
  860. public String getName()
  861. {
  862. return name;
  863. }
  864. public boolean isSpecialTree()
  865. {
  866. return npcId == L2XmassTreeInstance.SPECIAL_TREE_ID;
  867. }
  868. public boolean isUndead()
  869. {
  870. return (race == Race.UNDEAD);
  871. }
  872. }