L2NpcTemplate.java 24 KB

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