L2Skill.java 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.skills;
  20. import java.util.ArrayList;
  21. import java.util.Arrays;
  22. import java.util.Collections;
  23. import java.util.List;
  24. import java.util.logging.Level;
  25. import java.util.logging.Logger;
  26. import com.l2jserver.Config;
  27. import com.l2jserver.gameserver.GeoData;
  28. import com.l2jserver.gameserver.datatables.SkillTable;
  29. import com.l2jserver.gameserver.datatables.SkillTreesData;
  30. import com.l2jserver.gameserver.handler.ITargetTypeHandler;
  31. import com.l2jserver.gameserver.handler.TargetHandler;
  32. import com.l2jserver.gameserver.model.ChanceCondition;
  33. import com.l2jserver.gameserver.model.L2ExtractableProductItem;
  34. import com.l2jserver.gameserver.model.L2ExtractableSkill;
  35. import com.l2jserver.gameserver.model.L2Object;
  36. import com.l2jserver.gameserver.model.PcCondOverride;
  37. import com.l2jserver.gameserver.model.StatsSet;
  38. import com.l2jserver.gameserver.model.actor.L2Attackable;
  39. import com.l2jserver.gameserver.model.actor.L2Character;
  40. import com.l2jserver.gameserver.model.actor.L2Playable;
  41. import com.l2jserver.gameserver.model.actor.L2Summon;
  42. import com.l2jserver.gameserver.model.actor.instance.L2CubicInstance;
  43. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  44. import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
  45. import com.l2jserver.gameserver.model.conditions.Condition;
  46. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  47. import com.l2jserver.gameserver.model.effects.L2EffectType;
  48. import com.l2jserver.gameserver.model.entity.TvTEvent;
  49. import com.l2jserver.gameserver.model.holders.ItemHolder;
  50. import com.l2jserver.gameserver.model.interfaces.IChanceSkillTrigger;
  51. import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
  52. import com.l2jserver.gameserver.model.skills.funcs.Func;
  53. import com.l2jserver.gameserver.model.skills.funcs.FuncTemplate;
  54. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  55. import com.l2jserver.gameserver.model.stats.BaseStats;
  56. import com.l2jserver.gameserver.model.stats.Env;
  57. import com.l2jserver.gameserver.model.stats.Formulas;
  58. import com.l2jserver.gameserver.model.stats.TraitType;
  59. import com.l2jserver.gameserver.model.zone.ZoneId;
  60. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  61. import com.l2jserver.gameserver.util.Util;
  62. import com.l2jserver.util.Rnd;
  63. public abstract class L2Skill implements IChanceSkillTrigger, IIdentifiable
  64. {
  65. protected static final Logger _log = Logger.getLogger(L2Skill.class.getName());
  66. private static final L2Object[] EMPTY_TARGET_LIST = new L2Object[0];
  67. public static final int SKILL_CUBIC_MASTERY = 143;
  68. public static final int SKILL_CREATE_DWARVEN = 172;
  69. public static final int SKILL_LUCKY = 194;
  70. public static final int SKILL_EXPERTISE = 239;
  71. public static final int SKILL_CRYSTALLIZE = 248;
  72. public static final int SKILL_CLAN_LUCK = 390;
  73. public static final int SKILL_ONYX_BEAST_TRANSFORMATION = 617;
  74. public static final int SKILL_CREATE_COMMON = 1320;
  75. public static final int SKILL_DIVINE_INSPIRATION = 1405;
  76. public static final int SKILL_SERVITOR_SHARE = 1557;
  77. public static final int SKILL_CARAVANS_SECRET_MEDICINE = 2341;
  78. public static final int SKILL_NPC_RACE = 4416;
  79. /** Skill Id. */
  80. private final int _id;
  81. /** Skill level. */
  82. private final int _level;
  83. /** Custom skill ID displayed by the client. */
  84. private final int _displayId;
  85. /** Custom skill level displayed by the client. */
  86. private final int _displayLevel;
  87. /** Skill client's name. */
  88. private final String _name;
  89. /** Operative type: passive, active, toggle. */
  90. private final L2SkillOpType _operateType;
  91. private final int _magic;
  92. private final TraitType _traitType;
  93. private final boolean _staticReuse;
  94. /** MP consumption. */
  95. private final int _mpConsume;
  96. /** Initial MP consumption. */
  97. private final int _mpInitialConsume;
  98. private final int _mpPerChanneling;
  99. /** HP consumption. */
  100. private final int _hpConsume;
  101. /** Amount of items consumed by this skill from caster. */
  102. private final int _itemConsumeCount;
  103. /** Id of item consumed by this skill from caster. */
  104. private final int _itemConsumeId;
  105. /** Cast range: how far can be the target. */
  106. private final int _castRange;
  107. /** Effect range: how far the skill affect the target. */
  108. private final int _effectRange;
  109. /** Abnormal instant, used for herbs mostly. */
  110. private final boolean _isAbnormalInstant;
  111. /** Abnormal level, global effect level. */
  112. private final int _abnormalLvl;
  113. /** Abnormal type: global effect "group". */
  114. private final AbnormalType _abnormalType;
  115. /** Abnormal time: global effect duration time. */
  116. private final int _abnormalTime;
  117. /** If {@code true} this skill's effect should stay after death. */
  118. private final boolean _stayAfterDeath;
  119. /** If {@code true} this skill's effect should stay after class-subclass change. */
  120. private final boolean _stayOnSubclassChange;
  121. private final int _refId;
  122. // all times in milliseconds
  123. private final int _hitTime;
  124. // private final int _skillInterruptTime;
  125. private final int _coolTime;
  126. private final int _reuseHashCode;
  127. private final int _reuseDelay;
  128. /** Target type of the skill : SELF, PARTY, CLAN, PET... */
  129. private final L2TargetType _targetType;
  130. private final int _feed;
  131. // base success chance
  132. private final double _power;
  133. private final double _pvpPower;
  134. private final double _pvePower;
  135. private final int _magicLevel;
  136. private final int _lvlBonusRate;
  137. private final int _activateRate;
  138. private final int _minChance;
  139. private final int _maxChance;
  140. private final int _blowChance;
  141. // Effecting area of the skill, in radius.
  142. // The radius center varies according to the _targetType:
  143. // "caster" if targetType = AURA/PARTY/CLAN or "target" if targetType = AREA
  144. private final int _affectRange;
  145. private final int[] _affectLimit = new int[2];
  146. private final L2SkillType _skillType;
  147. private final boolean _nextActionIsAttack;
  148. private final boolean _removedOnAnyActionExceptMove;
  149. private final boolean _removedOnDamage;
  150. private final byte _element;
  151. private final int _elementPower;
  152. private final BaseStats _saveVs;
  153. private final boolean _overhit;
  154. private final int _minPledgeClass;
  155. private final int _chargeConsume;
  156. private final int _triggeredId;
  157. private final int _triggeredLevel;
  158. private final String _chanceType;
  159. private final int _soulMaxConsume;
  160. private final boolean _dependOnTargetBuff;
  161. private final boolean _isHeroSkill; // If true the skill is a Hero Skill
  162. private final boolean _isGMSkill; // True if skill is GM skill
  163. private final boolean _isSevenSigns;
  164. private final int _baseCritRate; // percent of success for skill critical hit (especially for PhysicalAttack & Blow - they're not affected by rCrit values or buffs).
  165. private final boolean _directHpDmg; // If true then damage is being make directly
  166. private final boolean _isTriggeredSkill; // If true the skill will take activation buff slot instead of a normal buff slot
  167. private final int _effectPoint;
  168. // Condition lists
  169. private List<Condition> _preCondition;
  170. private List<Condition> _itemPreCondition;
  171. // Function lists
  172. private List<FuncTemplate> _funcTemplates;
  173. // Effect lists
  174. private List<AbstractEffect> _effects;
  175. private List<AbstractEffect> _effectSelf;
  176. private List<AbstractEffect> _effectPassive;
  177. private List<AbstractEffect> _effectChanneling;
  178. protected ChanceCondition _chanceCondition = null;
  179. // Flying support
  180. private final String _flyType;
  181. private final int _flyRadius;
  182. private final float _flyCourse;
  183. private final boolean _isDebuff;
  184. private final String _attribute;
  185. private final boolean _ignoreShield;
  186. private final boolean _isSuicideAttack;
  187. private final boolean _canBeDispeled;
  188. private final boolean _isClanSkill;
  189. private final boolean _excludedFromCheck;
  190. private final boolean _simultaneousCast;
  191. private L2ExtractableSkill _extractableItems = null;
  192. private int _npcId = 0;
  193. private final String _icon;
  194. private byte[] _effectTypes;
  195. // Channeling data
  196. private final int _channelingSkillId;
  197. private final int _channelingTickInitialDelay;
  198. private final int _channelingTickInterval;
  199. protected L2Skill(StatsSet set)
  200. {
  201. _isAbnormalInstant = set.getBoolean("abnormalInstant", false);
  202. _id = set.getInt("skill_id");
  203. _level = set.getInt("level");
  204. _refId = set.getInt("referenceId", 0);
  205. _displayId = set.getInt("displayId", _id);
  206. _displayLevel = set.getInt("displayLevel", _level);
  207. _name = set.getString("name", "");
  208. _operateType = set.getEnum("operateType", L2SkillOpType.class);
  209. _magic = set.getInt("isMagic", 0);
  210. _traitType = set.getEnum("trait", TraitType.class, TraitType.NONE);
  211. _staticReuse = set.getBoolean("staticReuse", false);
  212. _mpConsume = set.getInt("mpConsume", 0);
  213. _mpInitialConsume = set.getInt("mpInitialConsume", 0);
  214. _mpPerChanneling = set.getInt("mpPerChanneling", _mpConsume);
  215. _hpConsume = set.getInt("hpConsume", 0);
  216. _itemConsumeCount = set.getInt("itemConsumeCount", 0);
  217. _itemConsumeId = set.getInt("itemConsumeId", 0);
  218. _castRange = set.getInt("castRange", -1);
  219. _effectRange = set.getInt("effectRange", -1);
  220. _abnormalLvl = set.getInt("abnormalLvl", 0);
  221. _abnormalType = set.getEnum("abnormalType", AbnormalType.class, AbnormalType.NONE);
  222. int abnormalTime = set.getInt("abnormalTime", 0);
  223. if (Config.ENABLE_MODIFY_SKILL_DURATION && Config.SKILL_DURATION_LIST.containsKey(getId()))
  224. {
  225. if ((getLevel() < 100) || (getLevel() > 140))
  226. {
  227. abnormalTime = Config.SKILL_DURATION_LIST.get(getId());
  228. }
  229. else if ((getLevel() >= 100) && (getLevel() < 140))
  230. {
  231. abnormalTime += Config.SKILL_DURATION_LIST.get(getId());
  232. }
  233. }
  234. _abnormalTime = abnormalTime;
  235. _attribute = set.getString("attribute", "");
  236. _stayAfterDeath = set.getBoolean("stayAfterDeath", false);
  237. _stayOnSubclassChange = set.getBoolean("stayOnSubclassChange", true);
  238. _hitTime = set.getInt("hitTime", 0);
  239. _coolTime = set.getInt("coolTime", 0);
  240. _isDebuff = set.getBoolean("isDebuff", false);
  241. _feed = set.getInt("feed", 0);
  242. _reuseHashCode = SkillTable.getSkillHashCode(_id, _level);
  243. if (Config.ENABLE_MODIFY_SKILL_REUSE && Config.SKILL_REUSE_LIST.containsKey(_id))
  244. {
  245. if (Config.DEBUG)
  246. {
  247. _log.info("*** Skill " + _name + " (" + _level + ") changed reuse from " + set.getInt("reuseDelay", 0) + " to " + Config.SKILL_REUSE_LIST.get(_id) + " seconds.");
  248. }
  249. _reuseDelay = Config.SKILL_REUSE_LIST.get(_id);
  250. }
  251. else
  252. {
  253. _reuseDelay = set.getInt("reuseDelay", 0);
  254. }
  255. _affectRange = set.getInt("affectRange", 0);
  256. final String affectLimit = set.getString("affectLimit", null);
  257. if (affectLimit != null)
  258. {
  259. try
  260. {
  261. String[] valuesSplit = affectLimit.split("-");
  262. _affectLimit[0] = Integer.parseInt(valuesSplit[0]);
  263. _affectLimit[1] = Integer.parseInt(valuesSplit[1]);
  264. }
  265. catch (Exception e)
  266. {
  267. throw new IllegalArgumentException("SkillId: " + _id + " invalid affectLimit value: " + affectLimit + ", \"percent-percent\" required");
  268. }
  269. }
  270. _targetType = set.getEnum("targetType", L2TargetType.class);
  271. _power = set.getFloat("power", 0.f);
  272. _pvpPower = set.getFloat("pvpPower", (float) getPower());
  273. _pvePower = set.getFloat("pvePower", (float) getPower());
  274. _magicLevel = set.getInt("magicLvl", 0);
  275. _lvlBonusRate = set.getInt("lvlBonusRate", 0);
  276. _activateRate = set.getInt("activateRate", -1);
  277. _minChance = set.getInt("minChance", Config.MIN_ABNORMAL_STATE_SUCCESS_RATE);
  278. _maxChance = set.getInt("maxChance", Config.MAX_ABNORMAL_STATE_SUCCESS_RATE);
  279. _ignoreShield = set.getBoolean("ignoreShld", false);
  280. _skillType = set.getEnum("skillType", L2SkillType.class, L2SkillType.DUMMY);
  281. _nextActionIsAttack = set.getBoolean("nextActionAttack", false);
  282. _removedOnAnyActionExceptMove = set.getBoolean("removedOnAnyActionExceptMove", false);
  283. _removedOnDamage = set.getBoolean("removedOnDamage", false);
  284. _element = set.getByte("element", (byte) -1);
  285. _elementPower = set.getInt("elementPower", 0);
  286. _saveVs = set.getEnum("saveVs", BaseStats.class, BaseStats.NULL);
  287. _overhit = set.getBoolean("overHit", false);
  288. _isSuicideAttack = set.getBoolean("isSuicideAttack", false);
  289. _minPledgeClass = set.getInt("minPledgeClass", 0);
  290. _chargeConsume = set.getInt("chargeConsume", 0);
  291. _triggeredId = set.getInt("triggeredId", 0);
  292. _triggeredLevel = set.getInt("triggeredLevel", 1);
  293. _chanceType = set.getString("chanceType", "");
  294. if (!_chanceType.isEmpty())
  295. {
  296. _chanceCondition = ChanceCondition.parse(set);
  297. }
  298. _soulMaxConsume = set.getInt("soulMaxConsumeCount", 0);
  299. _blowChance = set.getInt("blowChance", 0);
  300. _isHeroSkill = SkillTreesData.getInstance().isHeroSkill(_id, _level);
  301. _isGMSkill = SkillTreesData.getInstance().isGMSkill(_id, _level);
  302. _isSevenSigns = (_id > 4360) && (_id < 4367);
  303. _isClanSkill = SkillTreesData.getInstance().isClanSkill(_id, _level);
  304. _baseCritRate = set.getInt("baseCritRate", 0);
  305. _directHpDmg = set.getBoolean("dmgDirectlyToHp", false);
  306. _isTriggeredSkill = set.getBoolean("isTriggeredSkill", false);
  307. _effectPoint = set.getInt("effectPoint", 0);
  308. _flyType = set.getString("flyType", null);
  309. _flyRadius = set.getInt("flyRadius", 0);
  310. _flyCourse = set.getFloat("flyCourse", 0);
  311. _canBeDispeled = set.getBoolean("canBeDispeled", true);
  312. _excludedFromCheck = set.getBoolean("excludedFromCheck", false);
  313. _dependOnTargetBuff = set.getBoolean("dependOnTargetBuff", false);
  314. _simultaneousCast = set.getBoolean("simultaneousCast", false);
  315. String capsuled_items = set.getString("capsuled_items_skill", null);
  316. if (capsuled_items != null)
  317. {
  318. if (capsuled_items.isEmpty())
  319. {
  320. _log.warning("Empty Extractable Item Skill data in Skill Id: " + _id);
  321. }
  322. _extractableItems = parseExtractableSkill(_id, _level, capsuled_items);
  323. }
  324. _npcId = set.getInt("npcId", 0);
  325. _icon = set.getString("icon", "icon.skill0000");
  326. _channelingSkillId = set.getInt("channelingSkillId", 0);
  327. _channelingTickInterval = set.getInt("channelingTickInterval", 2) * 1000;
  328. _channelingTickInitialDelay = set.getInt("channelingTickInitialDelay", _channelingTickInterval / 1000) * 1000;
  329. }
  330. public abstract void useSkill(L2Character caster, L2Object[] targets);
  331. public final L2SkillType getSkillType()
  332. {
  333. return _skillType;
  334. }
  335. public final TraitType getTraitType()
  336. {
  337. return _traitType;
  338. }
  339. public final byte getElement()
  340. {
  341. return _element;
  342. }
  343. public final int getElementPower()
  344. {
  345. return _elementPower;
  346. }
  347. /**
  348. * Return the target type of the skill : SELF, PARTY, CLAN, PET...
  349. * @return
  350. */
  351. public final L2TargetType getTargetType()
  352. {
  353. return _targetType;
  354. }
  355. public final boolean isOverhit()
  356. {
  357. return _overhit;
  358. }
  359. public final boolean isSuicideAttack()
  360. {
  361. return _isSuicideAttack;
  362. }
  363. public final boolean allowOnTransform()
  364. {
  365. return isPassive();
  366. }
  367. /**
  368. * Return the power of the skill.
  369. * @param activeChar
  370. * @param target
  371. * @param isPvP
  372. * @param isPvE
  373. * @return
  374. */
  375. public final double getPower(L2Character activeChar, L2Character target, boolean isPvP, boolean isPvE)
  376. {
  377. if (activeChar == null)
  378. {
  379. return getPower(isPvP, isPvE);
  380. }
  381. if (hasEffectType(L2EffectType.DEATH_LINK))
  382. {
  383. return getPower(isPvP, isPvE) * (-((activeChar.getCurrentHp() * 2) / activeChar.getMaxHp()) + 2);
  384. }
  385. if (hasEffectType(L2EffectType.PHYSICAL_ATTACK_HP_LINK))
  386. {
  387. return getPower(isPvP, isPvE) * (-((target.getCurrentHp() * 2) / target.getMaxHp()) + 2);
  388. }
  389. return getPower(isPvP, isPvE);
  390. }
  391. public final double getPower()
  392. {
  393. return _power;
  394. }
  395. public final double getPower(boolean isPvP, boolean isPvE)
  396. {
  397. return isPvE ? _pvePower : isPvP ? _pvpPower : _power;
  398. }
  399. /**
  400. * @return {@code true} if the skill is abnormal instant, {@code false} otherwise
  401. */
  402. public final boolean isAbnormalInstant()
  403. {
  404. return _isAbnormalInstant;
  405. }
  406. public final int getAbnormalLvl()
  407. {
  408. return _abnormalLvl;
  409. }
  410. public final AbnormalType getAbnormalType()
  411. {
  412. return _abnormalType;
  413. }
  414. public final int getAbnormalTime()
  415. {
  416. return _abnormalTime;
  417. }
  418. public final int getMagicLevel()
  419. {
  420. return _magicLevel;
  421. }
  422. public final int getLvlBonusRate()
  423. {
  424. return _lvlBonusRate;
  425. }
  426. public final int getActivateRate()
  427. {
  428. return _activateRate;
  429. }
  430. /**
  431. * Return custom minimum skill/effect chance.
  432. * @return
  433. */
  434. public final int getMinChance()
  435. {
  436. return _minChance;
  437. }
  438. /**
  439. * Return custom maximum skill/effect chance.
  440. * @return
  441. */
  442. public final int getMaxChance()
  443. {
  444. return _maxChance;
  445. }
  446. /**
  447. * Return true if skill effects should be removed on any action except movement
  448. * @return
  449. */
  450. public final boolean isRemovedOnAnyActionExceptMove()
  451. {
  452. return _removedOnAnyActionExceptMove;
  453. }
  454. /**
  455. * @return {@code true} if skill effects should be removed on damage
  456. */
  457. public final boolean isRemovedOnDamage()
  458. {
  459. return _removedOnDamage;
  460. }
  461. /**
  462. * Return the additional effect Id.
  463. * @return
  464. */
  465. public final int getChannelingSkillId()
  466. {
  467. return _channelingSkillId;
  468. }
  469. /**
  470. * Return true if character should attack target after skill
  471. * @return
  472. */
  473. public final boolean nextActionIsAttack()
  474. {
  475. return _nextActionIsAttack;
  476. }
  477. /**
  478. * @return Returns the castRange.
  479. */
  480. public final int getCastRange()
  481. {
  482. return _castRange;
  483. }
  484. /**
  485. * @return Returns the effectRange.
  486. */
  487. public final int getEffectRange()
  488. {
  489. return _effectRange;
  490. }
  491. /**
  492. * @return Returns the hpConsume.
  493. */
  494. public final int getHpConsume()
  495. {
  496. return _hpConsume;
  497. }
  498. /**
  499. * Gets the skill ID.
  500. * @return the skill ID
  501. */
  502. @Override
  503. public final int getId()
  504. {
  505. return _id;
  506. }
  507. /**
  508. * @return Returns the boolean _isDebuff.
  509. */
  510. public final boolean isDebuff()
  511. {
  512. return _isDebuff;
  513. }
  514. public int getDisplayId()
  515. {
  516. return _displayId;
  517. }
  518. public int getDisplayLevel()
  519. {
  520. return _displayLevel;
  521. }
  522. public int getTriggeredId()
  523. {
  524. return _triggeredId;
  525. }
  526. public int getTriggeredLevel()
  527. {
  528. return _triggeredLevel;
  529. }
  530. public boolean triggerAnotherSkill()
  531. {
  532. return _triggeredId > 1;
  533. }
  534. /**
  535. * Return skill saveVs base stat (STR, INT ...).
  536. * @return
  537. */
  538. public final BaseStats getSaveVs()
  539. {
  540. return _saveVs;
  541. }
  542. /**
  543. * @return Returns the itemConsume.
  544. */
  545. public final int getItemConsume()
  546. {
  547. return _itemConsumeCount;
  548. }
  549. /**
  550. * @return Returns the itemConsumeId.
  551. */
  552. public final int getItemConsumeId()
  553. {
  554. return _itemConsumeId;
  555. }
  556. /**
  557. * @return Returns the level.
  558. */
  559. public final int getLevel()
  560. {
  561. return _level;
  562. }
  563. /**
  564. * @return Returns true to set physical skills.
  565. */
  566. public final boolean isPhysical()
  567. {
  568. return _magic == 0;
  569. }
  570. /**
  571. * @return Returns true to set magic skills.
  572. */
  573. public final boolean isMagic()
  574. {
  575. return _magic == 1;
  576. }
  577. /**
  578. * @return Returns true to set static skills.
  579. */
  580. public final boolean isStatic()
  581. {
  582. return _magic == 2;
  583. }
  584. /**
  585. * @return Returns true to set dance skills.
  586. */
  587. public final boolean isDance()
  588. {
  589. return _magic == 3;
  590. }
  591. /**
  592. * @return Returns true to set static reuse.
  593. */
  594. public final boolean isStaticReuse()
  595. {
  596. return _staticReuse;
  597. }
  598. /**
  599. * @return Returns the mpConsume.
  600. */
  601. public final int getMpConsume()
  602. {
  603. return _mpConsume;
  604. }
  605. /**
  606. * @return Returns the mpInitialConsume.
  607. */
  608. public final int getMpInitialConsume()
  609. {
  610. return _mpInitialConsume;
  611. }
  612. /**
  613. * @return Mana consumption per channeling tick.
  614. */
  615. public final int getMpPerChanneling()
  616. {
  617. return _mpPerChanneling;
  618. }
  619. /**
  620. * @return the skill name
  621. */
  622. public final String getName()
  623. {
  624. return _name;
  625. }
  626. /**
  627. * @return the reuse delay
  628. */
  629. public final int getReuseDelay()
  630. {
  631. return _reuseDelay;
  632. }
  633. public final int getReuseHashCode()
  634. {
  635. return _reuseHashCode;
  636. }
  637. public final int getHitTime()
  638. {
  639. return _hitTime;
  640. }
  641. /**
  642. * @return the cool time
  643. */
  644. public final int getCoolTime()
  645. {
  646. return _coolTime;
  647. }
  648. public final int getAffectRange()
  649. {
  650. return _affectRange;
  651. }
  652. public final int getAffectLimit()
  653. {
  654. return (_affectLimit[0] + Rnd.get(_affectLimit[1]));
  655. }
  656. public final boolean isActive()
  657. {
  658. return (_operateType != null) && _operateType.isActive();
  659. }
  660. public final boolean isPassive()
  661. {
  662. return (_operateType != null) && _operateType.isPassive();
  663. }
  664. public final boolean isToggle()
  665. {
  666. return (_operateType != null) && _operateType.isToggle();
  667. }
  668. public final boolean isContinuous()
  669. {
  670. return (_operateType != null) && _operateType.isContinuous();
  671. }
  672. public final boolean isChance()
  673. {
  674. return (_chanceCondition != null) && isPassive();
  675. }
  676. public final boolean isChanneling()
  677. {
  678. return (_operateType != null) && _operateType.isChanneling();
  679. }
  680. public final boolean isTriggeredSkill()
  681. {
  682. return _isTriggeredSkill;
  683. }
  684. /**
  685. * Verify if the skill is a transformation skill.
  686. * @return {@code true} if the skill is a transformation, {@code false} otherwise
  687. */
  688. public boolean isTransformation()
  689. {
  690. return _abnormalType == AbnormalType.TRANSFORM;
  691. }
  692. public final int getEffectPoint()
  693. {
  694. return _effectPoint;
  695. }
  696. public final boolean useSoulShot()
  697. {
  698. return (hasEffectType(L2EffectType.PHYSICAL_ATTACK, L2EffectType.PHYSICAL_ATTACK_HP_LINK, L2EffectType.FATAL_BLOW, L2EffectType.ENERGY_ATTACK));
  699. }
  700. public final boolean useSpiritShot()
  701. {
  702. return _magic == 1;
  703. }
  704. public final boolean useFishShot()
  705. {
  706. return ((getSkillType() == L2SkillType.PUMPING) || (getSkillType() == L2SkillType.REELING));
  707. }
  708. public int getMinPledgeClass()
  709. {
  710. return _minPledgeClass;
  711. }
  712. public final boolean isHeroSkill()
  713. {
  714. return _isHeroSkill;
  715. }
  716. public final boolean isGMSkill()
  717. {
  718. return _isGMSkill;
  719. }
  720. public final boolean is7Signs()
  721. {
  722. return _isSevenSigns;
  723. }
  724. /**
  725. * Verify if this is a healing potion skill.
  726. * @return {@code true} if this is a healing potion skill, {@code false} otherwise
  727. */
  728. public final boolean isHealingPotionSkill()
  729. {
  730. switch (getId())
  731. {
  732. case 2031: // Lesser Healing Potion
  733. case 2032: // Healing Potion
  734. case 2037: // Greater Healing Potion
  735. case 2863: // Highest Power Healing Potion
  736. case 26025: // Powerful Healing Potion
  737. case 26026: // High-grade Healing Potion
  738. {
  739. return true;
  740. }
  741. }
  742. return false;
  743. }
  744. public final int getChargeConsume()
  745. {
  746. return _chargeConsume;
  747. }
  748. public final int getMaxSoulConsumeCount()
  749. {
  750. return _soulMaxConsume;
  751. }
  752. public final int getBaseCritRate()
  753. {
  754. return _baseCritRate;
  755. }
  756. public final boolean getDmgDirectlyToHP()
  757. {
  758. return _directHpDmg;
  759. }
  760. public final String getFlyType()
  761. {
  762. return _flyType;
  763. }
  764. public final int getFlyRadius()
  765. {
  766. return _flyRadius;
  767. }
  768. public final float getFlyCourse()
  769. {
  770. return _flyCourse;
  771. }
  772. public final boolean isStayAfterDeath()
  773. {
  774. return _stayAfterDeath;
  775. }
  776. public final boolean isStayOnSubclassChange()
  777. {
  778. return _stayOnSubclassChange;
  779. }
  780. public final boolean isBad()
  781. {
  782. return _effectPoint < 0;
  783. }
  784. public boolean checkCondition(L2Character activeChar, L2Object target, boolean itemOrWeapon)
  785. {
  786. if (activeChar.canOverrideCond(PcCondOverride.SKILL_CONDITIONS) && !Config.GM_SKILL_RESTRICTION)
  787. {
  788. return true;
  789. }
  790. final List<Condition> preCondition = itemOrWeapon ? _itemPreCondition : _preCondition;
  791. if ((preCondition == null) || preCondition.isEmpty())
  792. {
  793. return true;
  794. }
  795. final Env env = new Env();
  796. env.setCharacter(activeChar);
  797. if (target instanceof L2Character)
  798. {
  799. env.setTarget((L2Character) target);
  800. }
  801. env.setSkill(this);
  802. for (Condition cond : preCondition)
  803. {
  804. if (!cond.test(env))
  805. {
  806. final String msg = cond.getMessage();
  807. final int msgId = cond.getMessageId();
  808. if (msgId != 0)
  809. {
  810. final SystemMessage sm = SystemMessage.getSystemMessage(msgId);
  811. if (cond.isAddName())
  812. {
  813. sm.addSkillName(_id);
  814. }
  815. activeChar.sendPacket(sm);
  816. }
  817. else if (msg != null)
  818. {
  819. activeChar.sendMessage(msg);
  820. }
  821. return false;
  822. }
  823. }
  824. return true;
  825. }
  826. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst)
  827. {
  828. // Init to null the target of the skill
  829. L2Character target = null;
  830. // Get the L2Objcet targeted by the user of the skill at this moment
  831. L2Object objTarget = activeChar.getTarget();
  832. // If the L2Object targeted is a L2Character, it becomes the L2Character target
  833. if (objTarget instanceof L2Character)
  834. {
  835. target = (L2Character) objTarget;
  836. }
  837. return getTargetList(activeChar, onlyFirst, target);
  838. }
  839. /**
  840. * Return all targets of the skill in a table in function a the skill type.<br>
  841. * <B><U>Values of skill type</U>:</B>
  842. * <ul>
  843. * <li>ONE : The skill can only be used on the L2PcInstance targeted, or on the caster if it's a L2PcInstance and no L2PcInstance targeted</li>
  844. * <li>SELF</li>
  845. * <li>HOLY, UNDEAD</li>
  846. * <li>PET</li>
  847. * <li>AURA, AURA_CLOSE</li>
  848. * <li>AREA</li>
  849. * <li>MULTIFACE</li>
  850. * <li>PARTY, CLAN</li>
  851. * <li>CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN</li>
  852. * <li>UNLOCKABLE</li>
  853. * <li>ITEM</li>
  854. * <ul>
  855. * @param activeChar The L2Character who use the skill
  856. * @param onlyFirst
  857. * @param target
  858. * @return
  859. */
  860. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst, L2Character target)
  861. {
  862. final ITargetTypeHandler handler = TargetHandler.getInstance().getHandler(getTargetType());
  863. if (handler != null)
  864. {
  865. try
  866. {
  867. return handler.getTargetList(this, activeChar, onlyFirst, target);
  868. }
  869. catch (Exception e)
  870. {
  871. _log.log(Level.WARNING, "Exception in L2Skill.getTargetList(): " + e.getMessage(), e);
  872. }
  873. }
  874. activeChar.sendMessage("Target type of skill is not currently handled.");
  875. return EMPTY_TARGET_LIST;
  876. }
  877. public final L2Object[] getTargetList(L2Character activeChar)
  878. {
  879. return getTargetList(activeChar, false);
  880. }
  881. public final L2Object getFirstOfTargetList(L2Character activeChar)
  882. {
  883. L2Object[] targets = getTargetList(activeChar, true);
  884. if (targets.length == 0)
  885. {
  886. return null;
  887. }
  888. return targets[0];
  889. }
  890. /**
  891. * Check if should be target added to the target list false if target is dead, target same as caster,<br>
  892. * target inside peace zone, target in the same party with caster, caster can see target Additional checks if not in PvP zones (arena, siege):<br>
  893. * target in not the same clan and alliance with caster, and usual skill PvP check. If TvT event is active - performing additional checks. Caution: distance is not checked.
  894. * @param caster
  895. * @param target
  896. * @param skill
  897. * @param sourceInArena
  898. * @return
  899. */
  900. public static final boolean checkForAreaOffensiveSkills(L2Character caster, L2Character target, L2Skill skill, boolean sourceInArena)
  901. {
  902. if ((target == null) || target.isDead() || (target == caster))
  903. {
  904. return false;
  905. }
  906. final L2PcInstance player = caster.getActingPlayer();
  907. final L2PcInstance targetPlayer = target.getActingPlayer();
  908. if (player != null)
  909. {
  910. if (targetPlayer != null)
  911. {
  912. if ((targetPlayer == caster) || (targetPlayer == player))
  913. {
  914. return false;
  915. }
  916. if (targetPlayer.inObserverMode())
  917. {
  918. return false;
  919. }
  920. if (skill.isBad() && (player.getSiegeState() > 0) && player.isInsideZone(ZoneId.SIEGE) && (player.getSiegeState() == targetPlayer.getSiegeState()) && (player.getSiegeSide() == targetPlayer.getSiegeSide()))
  921. {
  922. return false;
  923. }
  924. if (skill.isBad() && target.isInsideZone(ZoneId.PEACE))
  925. {
  926. return false;
  927. }
  928. if (player.isInParty() && targetPlayer.isInParty())
  929. {
  930. // Same party
  931. if (player.getParty().getLeaderObjectId() == targetPlayer.getParty().getLeaderObjectId())
  932. {
  933. return false;
  934. }
  935. // Same command channel
  936. if (player.getParty().isInCommandChannel() && (player.getParty().getCommandChannel() == targetPlayer.getParty().getCommandChannel()))
  937. {
  938. return false;
  939. }
  940. }
  941. if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
  942. {
  943. return false;
  944. }
  945. if (!sourceInArena && !(targetPlayer.isInsideZone(ZoneId.PVP) && !targetPlayer.isInsideZone(ZoneId.SIEGE)))
  946. {
  947. if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
  948. {
  949. return false;
  950. }
  951. if ((player.getClanId() != 0) && (player.getClanId() == targetPlayer.getClanId()))
  952. {
  953. return false;
  954. }
  955. if (!player.checkPvpSkill(targetPlayer, skill, (caster instanceof L2Summon)))
  956. {
  957. return false;
  958. }
  959. }
  960. }
  961. }
  962. else
  963. {
  964. // target is mob
  965. if ((targetPlayer == null) && (target instanceof L2Attackable) && (caster instanceof L2Attackable))
  966. {
  967. String casterEnemyClan = ((L2Attackable) caster).getEnemyClan();
  968. if ((casterEnemyClan == null) || casterEnemyClan.isEmpty())
  969. {
  970. return false;
  971. }
  972. String targetClan = ((L2Attackable) target).getClan();
  973. if ((targetClan == null) || targetClan.isEmpty())
  974. {
  975. return false;
  976. }
  977. if (!casterEnemyClan.equals(targetClan))
  978. {
  979. return false;
  980. }
  981. }
  982. }
  983. if ((Config.GEODATA > 0) && !GeoData.getInstance().canSeeTarget(caster, target))
  984. {
  985. return false;
  986. }
  987. return true;
  988. }
  989. public static final boolean addSummon(L2Character caster, L2PcInstance owner, int radius, boolean isDead)
  990. {
  991. if (!owner.hasSummon())
  992. {
  993. return false;
  994. }
  995. return addCharacter(caster, owner.getSummon(), radius, isDead);
  996. }
  997. public static final boolean addCharacter(L2Character caster, L2Character target, int radius, boolean isDead)
  998. {
  999. if (isDead != target.isDead())
  1000. {
  1001. return false;
  1002. }
  1003. if ((radius > 0) && !Util.checkIfInRange(radius, caster, target, true))
  1004. {
  1005. return false;
  1006. }
  1007. return true;
  1008. }
  1009. public final List<Func> getStatFuncs(AbstractEffect effect, L2Character player)
  1010. {
  1011. if (_funcTemplates == null)
  1012. {
  1013. return Collections.<Func> emptyList();
  1014. }
  1015. if (!(player instanceof L2Playable) && !(player instanceof L2Attackable))
  1016. {
  1017. return Collections.<Func> emptyList();
  1018. }
  1019. final List<Func> funcs = new ArrayList<>(_funcTemplates.size());
  1020. final Env env = new Env();
  1021. env.setCharacter(player);
  1022. env.setSkill(this);
  1023. for (FuncTemplate t : _funcTemplates)
  1024. {
  1025. Func f = t.getFunc(env, this); // skill is owner
  1026. if (f != null)
  1027. {
  1028. funcs.add(f);
  1029. }
  1030. }
  1031. return funcs;
  1032. }
  1033. public boolean hasEffects()
  1034. {
  1035. return (_effects != null) && !_effects.isEmpty();
  1036. }
  1037. public List<AbstractEffect> getEffectTemplates()
  1038. {
  1039. return _effects;
  1040. }
  1041. public boolean hasPassiveEffects()
  1042. {
  1043. return (_effectPassive != null) && !_effectPassive.isEmpty();
  1044. }
  1045. public List<AbstractEffect> getEffectTemplatesPassive()
  1046. {
  1047. return _effectPassive;
  1048. }
  1049. public List<AbstractEffect> getEffectTemplateChanneling()
  1050. {
  1051. return _effectChanneling;
  1052. }
  1053. public boolean hasSelfEffects()
  1054. {
  1055. return (_effectSelf != null) && !_effectSelf.isEmpty();
  1056. }
  1057. public boolean hasChannelingEffects()
  1058. {
  1059. return (_effectChanneling != null) && !_effectChanneling.isEmpty();
  1060. }
  1061. /**
  1062. * Applies the effects from this skill to the target.
  1063. * @param effector the caster of the skill
  1064. * @param cubic the cubic that cast the skill, can be {@code null}
  1065. * @param effected the target of the effect
  1066. * @param env
  1067. * @param self if {@code true} self-effects will be casted on the caster
  1068. * @param passive if {@code true} passive effects will be applied to the caster
  1069. */
  1070. public final void applyEffects(L2Character effector, L2CubicInstance cubic, L2Character effected, Env env, boolean self, boolean passive)
  1071. {
  1072. // Null targets, doors and siege flags cannot receive any effects.
  1073. if ((effected == null) || effected.isDoor() || (effected instanceof L2SiegeFlagInstance))
  1074. {
  1075. return;
  1076. }
  1077. // Check bad skills against target.
  1078. if ((effector != effected) && isBad() && (effected.isInvul() || (effector.isGM() && !effector.getAccessLevel().canGiveDamage())))
  1079. {
  1080. return;
  1081. }
  1082. if (env == null)
  1083. {
  1084. env = new Env();
  1085. }
  1086. env.setSkillMastery(Formulas.calcSkillMastery(effector, this));
  1087. env.setCharacter(effector);
  1088. env.setCubic(cubic);
  1089. env.setTarget(effected);
  1090. env.setSkill(this);
  1091. final boolean addContinuousEffects = _operateType.isToggle() || (_operateType.isContinuous() && Formulas.calcEffectSuccess(env));
  1092. if (!self && !passive && hasEffects())
  1093. {
  1094. final BuffInfo info = new BuffInfo(env);
  1095. for (AbstractEffect effect : _effects)
  1096. {
  1097. if (effect != null)
  1098. {
  1099. if (effect.isInstant())
  1100. {
  1101. if (effect.calcSuccess(info))
  1102. {
  1103. effect.onStart(info);
  1104. }
  1105. }
  1106. else if (addContinuousEffects)
  1107. {
  1108. if (effect.onStart(info))
  1109. {
  1110. info.addEffect(effect);
  1111. }
  1112. }
  1113. }
  1114. }
  1115. effected.getEffectList().add(info);
  1116. }
  1117. if (self && hasSelfEffects())
  1118. {
  1119. env.setTarget(effector);
  1120. final BuffInfo info = new BuffInfo(env);
  1121. for (AbstractEffect effect : _effectSelf)
  1122. {
  1123. if (effect != null)
  1124. {
  1125. if (effect.isInstant())
  1126. {
  1127. if (effect.calcSuccess(info))
  1128. {
  1129. effect.onStart(info);
  1130. }
  1131. }
  1132. else if (addContinuousEffects)
  1133. {
  1134. if (effect.onStart(info))
  1135. {
  1136. info.addEffect(effect);
  1137. }
  1138. }
  1139. }
  1140. }
  1141. effector.getEffectList().add(info);
  1142. }
  1143. if (passive && hasPassiveEffects())
  1144. {
  1145. env.setTarget(effector);
  1146. final BuffInfo info = new BuffInfo(env);
  1147. for (AbstractEffect effect : _effectPassive)
  1148. {
  1149. if (effect != null)
  1150. {
  1151. if (effect.onStart(info))
  1152. {
  1153. info.addEffect(effect);
  1154. }
  1155. }
  1156. }
  1157. effector.getEffectList().add(info);
  1158. }
  1159. if (!self && !passive && hasChannelingEffects())
  1160. {
  1161. env.setTarget(effected);
  1162. final BuffInfo info = new BuffInfo(env);
  1163. for (AbstractEffect effect : _effectChanneling)
  1164. {
  1165. if (effect != null)
  1166. {
  1167. if ((effect.isInstant() && effect.calcSuccess(info)) || (!effect.isInstant() && addContinuousEffects))
  1168. {
  1169. if (effect.onStart(info))
  1170. {
  1171. info.addEffect(effect);
  1172. }
  1173. }
  1174. }
  1175. }
  1176. effector.getEffectList().add(info);
  1177. }
  1178. }
  1179. public final void attach(FuncTemplate f)
  1180. {
  1181. if (_funcTemplates == null)
  1182. {
  1183. _funcTemplates = new ArrayList<>(1);
  1184. }
  1185. _funcTemplates.add(f);
  1186. }
  1187. public final void attach(AbstractEffect effect)
  1188. {
  1189. if (_effects == null)
  1190. {
  1191. _effects = new ArrayList<>(1);
  1192. }
  1193. _effects.add(effect);
  1194. }
  1195. public final void attachSelf(AbstractEffect effect)
  1196. {
  1197. if (_effectSelf == null)
  1198. {
  1199. _effectSelf = new ArrayList<>(1);
  1200. }
  1201. _effectSelf.add(effect);
  1202. }
  1203. public final void attachPassive(AbstractEffect effect)
  1204. {
  1205. if (_effectPassive == null)
  1206. {
  1207. _effectPassive = new ArrayList<>(1);
  1208. }
  1209. _effectPassive.add(effect);
  1210. }
  1211. public final void attachChanneling(AbstractEffect effectTemplate)
  1212. {
  1213. if (_effectChanneling == null)
  1214. {
  1215. _effectChanneling = new ArrayList<>(1);
  1216. }
  1217. _effectChanneling.add(effectTemplate);
  1218. }
  1219. public final void attach(Condition c, boolean itemOrWeapon)
  1220. {
  1221. if (itemOrWeapon)
  1222. {
  1223. if (_itemPreCondition == null)
  1224. {
  1225. _itemPreCondition = new ArrayList<>();
  1226. }
  1227. _itemPreCondition.add(c);
  1228. }
  1229. else
  1230. {
  1231. if (_preCondition == null)
  1232. {
  1233. _preCondition = new ArrayList<>();
  1234. }
  1235. _preCondition.add(c);
  1236. }
  1237. }
  1238. @Override
  1239. public String toString()
  1240. {
  1241. return "Skill " + _name + "(" + _id + "," + _level + ")";
  1242. }
  1243. /**
  1244. * @return pet food
  1245. */
  1246. public int getFeed()
  1247. {
  1248. return _feed;
  1249. }
  1250. /**
  1251. * used for tracking item id in case that item consume cannot be used
  1252. * @return reference item id
  1253. */
  1254. public int getReferenceItemId()
  1255. {
  1256. return _refId;
  1257. }
  1258. @Override
  1259. public boolean triggersChanceSkill()
  1260. {
  1261. return (_triggeredId > 0) && isChance();
  1262. }
  1263. @Override
  1264. public int getTriggeredChanceId()
  1265. {
  1266. return _triggeredId;
  1267. }
  1268. @Override
  1269. public int getTriggeredChanceLevel()
  1270. {
  1271. return _triggeredLevel;
  1272. }
  1273. @Override
  1274. public ChanceCondition getTriggeredChanceCondition()
  1275. {
  1276. return _chanceCondition;
  1277. }
  1278. public String getAttributeName()
  1279. {
  1280. return _attribute;
  1281. }
  1282. /**
  1283. * @return the _blowChance
  1284. */
  1285. public int getBlowChance()
  1286. {
  1287. return _blowChance;
  1288. }
  1289. public boolean ignoreShield()
  1290. {
  1291. return _ignoreShield;
  1292. }
  1293. public boolean canBeDispeled()
  1294. {
  1295. return _canBeDispeled;
  1296. }
  1297. /**
  1298. * Verify if the skill can be stolen.
  1299. * @return {@code true} if skill can be stolen, {@code false} otherwise
  1300. */
  1301. public boolean canBeStolen()
  1302. {
  1303. return !isPassive() && !isToggle() && !isDebuff() && !isHeroSkill() && !isGMSkill() && !(isStatic() && (getId() != SKILL_CARAVANS_SECRET_MEDICINE)) && canBeDispeled() && (getId() != SKILL_SERVITOR_SHARE);
  1304. }
  1305. public boolean isClanSkill()
  1306. {
  1307. return _isClanSkill;
  1308. }
  1309. public boolean isExcludedFromCheck()
  1310. {
  1311. return _excludedFromCheck;
  1312. }
  1313. public boolean getDependOnTargetBuff()
  1314. {
  1315. return _dependOnTargetBuff;
  1316. }
  1317. public boolean isSimultaneousCast()
  1318. {
  1319. return _simultaneousCast;
  1320. }
  1321. /**
  1322. * Parse an extractable skill.
  1323. * @param skillId the skill Id
  1324. * @param skillLvl the skill level
  1325. * @param values the values to parse
  1326. * @return the parsed extractable skill
  1327. * @author Zoey76
  1328. */
  1329. private L2ExtractableSkill parseExtractableSkill(int skillId, int skillLvl, String values)
  1330. {
  1331. final String[] prodLists = values.split(";");
  1332. final List<L2ExtractableProductItem> products = new ArrayList<>();
  1333. String[] prodData;
  1334. for (String prodList : prodLists)
  1335. {
  1336. prodData = prodList.split(",");
  1337. if (prodData.length < 3)
  1338. {
  1339. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> wrong seperator!");
  1340. }
  1341. List<ItemHolder> items = null;
  1342. double chance = 0;
  1343. int prodId = 0;
  1344. int quantity = 0;
  1345. final int lenght = prodData.length - 1;
  1346. try
  1347. {
  1348. items = new ArrayList<>(lenght / 2);
  1349. for (int j = 0; j < lenght; j++)
  1350. {
  1351. prodId = Integer.parseInt(prodData[j]);
  1352. quantity = Integer.parseInt(prodData[j += 1]);
  1353. if ((prodId <= 0) || (quantity <= 0))
  1354. {
  1355. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " wrong production Id: " + prodId + " or wrond quantity: " + quantity + "!");
  1356. }
  1357. items.add(new ItemHolder(prodId, quantity));
  1358. }
  1359. chance = Double.parseDouble(prodData[lenght]);
  1360. }
  1361. catch (Exception e)
  1362. {
  1363. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> incomplete/invalid production data or wrong seperator!");
  1364. }
  1365. products.add(new L2ExtractableProductItem(items, chance));
  1366. }
  1367. if (products.isEmpty())
  1368. {
  1369. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> There are no production items!");
  1370. }
  1371. return new L2ExtractableSkill(SkillTable.getSkillHashCode(skillId, skillLvl), products);
  1372. }
  1373. public L2ExtractableSkill getExtractableSkill()
  1374. {
  1375. return _extractableItems;
  1376. }
  1377. /**
  1378. * @return the _npcId
  1379. */
  1380. public int getNpcId()
  1381. {
  1382. return _npcId;
  1383. }
  1384. /**
  1385. * @param types
  1386. * @return {@code true} if at least one of specified {@link L2EffectType} types present on the current skill's effects, {@code false} otherwise.
  1387. */
  1388. public boolean hasEffectType(L2EffectType... types)
  1389. {
  1390. if (hasEffects() && (types != null) && (types.length > 0))
  1391. {
  1392. if (_effectTypes == null)
  1393. {
  1394. _effectTypes = new byte[_effects.size()];
  1395. final Env env = new Env();
  1396. env.setSkill(this);
  1397. int i = 0;
  1398. for (AbstractEffect effect : _effects)
  1399. {
  1400. if (effect == null)
  1401. {
  1402. continue;
  1403. }
  1404. _effectTypes[i++] = (byte) effect.getEffectType().ordinal();
  1405. }
  1406. Arrays.sort(_effectTypes);
  1407. }
  1408. for (L2EffectType type : types)
  1409. {
  1410. if (Arrays.binarySearch(_effectTypes, (byte) type.ordinal()) >= 0)
  1411. {
  1412. return true;
  1413. }
  1414. }
  1415. }
  1416. return false;
  1417. }
  1418. /**
  1419. * @return icon of the current skill.
  1420. */
  1421. public String getIcon()
  1422. {
  1423. return _icon;
  1424. }
  1425. public int getChannelingTickInterval()
  1426. {
  1427. return _channelingTickInterval;
  1428. }
  1429. public int getChannelingTickInitialDelay()
  1430. {
  1431. return _channelingTickInitialDelay;
  1432. }
  1433. }