L2NpcTemplate.java 24 KB

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