L2NpcTemplate.java 23 KB

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