L2Skill.java 43 KB

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