L2NpcTemplate.java 24 KB

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