L2Skill.java 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708
  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. * Method overload for {@link L2Skill#applyEffects(L2Character, L2CubicInstance, L2Character, boolean, boolean, boolean, int)}.<br>
  1063. * Simplify the calls.
  1064. * @param effector the caster of the skill
  1065. * @param effected the target of the effect
  1066. */
  1067. public void applyEffects(L2Character effector, L2Character effected)
  1068. {
  1069. applyEffects(effector, null, effected, false, false, true, 0);
  1070. }
  1071. /**
  1072. * Method overload for {@link L2Skill#applyEffects(L2Character, L2CubicInstance, L2Character, boolean, boolean, boolean, int)}.<br>
  1073. * Simplify the calls, allowing abnormal time time customization.
  1074. * @param effector the caster of the skill
  1075. * @param effected the target of the effect
  1076. * @param instant if {@code true} instant effects will be applied to the effected
  1077. * @param abnormalTime custom abnormal time, if equal or lesser than zero will be ignored
  1078. */
  1079. public void applyEffects(L2Character effector, L2Character effected, boolean instant, int abnormalTime)
  1080. {
  1081. applyEffects(effector, null, effected, false, false, instant, abnormalTime);
  1082. }
  1083. /**
  1084. * Applies the effects from this skill to the target.
  1085. * @param effector the caster of the skill
  1086. * @param cubic the cubic that cast the skill, can be {@code null}
  1087. * @param effected the target of the effect
  1088. * @param self if {@code true} self-effects will be casted on the caster
  1089. * @param passive if {@code true} passive effects will be applied to the effector
  1090. * @param instant if {@code true} instant effects will be applied to the effected
  1091. * @param abnormalTime custom abnormal time, if equal or lesser than zero will be ignored
  1092. */
  1093. public void applyEffects(L2Character effector, L2CubicInstance cubic, L2Character effected, boolean self, boolean passive, boolean instant, int abnormalTime)
  1094. {
  1095. // Null targets, doors and siege flags cannot receive any effects.
  1096. if ((effected == null) || effected.isDoor() || (effected instanceof L2SiegeFlagInstance))
  1097. {
  1098. return;
  1099. }
  1100. // Check bad skills against target.
  1101. if ((effector != effected) && isBad() && (effected.isInvul() || (effector.isGM() && !effector.getAccessLevel().canGiveDamage())))
  1102. {
  1103. return;
  1104. }
  1105. final Env env = new Env();
  1106. env.setSkillMastery(Formulas.calcSkillMastery(effector, this));
  1107. env.setCharacter(effector);
  1108. env.setCubic(cubic);
  1109. env.setTarget(effected);
  1110. env.setSkill(this);
  1111. final boolean addContinuousEffects = !passive && (_operateType.isToggle() || (_operateType.isContinuous() && Formulas.calcEffectSuccess(env)));
  1112. if (!self && !passive && hasEffects())
  1113. {
  1114. final BuffInfo info = new BuffInfo(env);
  1115. if (addContinuousEffects && (abnormalTime > 0))
  1116. {
  1117. info.setAbnormalTime(abnormalTime);
  1118. }
  1119. for (AbstractEffect effect : _effects)
  1120. {
  1121. if (effect != null)
  1122. {
  1123. if (effect.isInstant())
  1124. {
  1125. if (instant && effect.calcSuccess(info))
  1126. {
  1127. effect.onStart(info);
  1128. }
  1129. }
  1130. else if (addContinuousEffects)
  1131. {
  1132. if (effect.canStart(info))
  1133. {
  1134. info.addEffect(effect);
  1135. }
  1136. }
  1137. }
  1138. }
  1139. effected.getEffectList().add(info);
  1140. // Support for buff sharing feature.
  1141. if (addContinuousEffects && effected.isPlayer() && effected.hasServitor() && isContinuous() && !isDebuff())
  1142. {
  1143. applyEffects(effector, effected.getSummon(), false, 0);
  1144. }
  1145. }
  1146. if (self && hasSelfEffects())
  1147. {
  1148. env.setTarget(effector);
  1149. final BuffInfo info = new BuffInfo(env);
  1150. if (addContinuousEffects && (abnormalTime > 0))
  1151. {
  1152. info.setAbnormalTime(abnormalTime);
  1153. }
  1154. for (AbstractEffect effect : _effectSelf)
  1155. {
  1156. if (effect != null)
  1157. {
  1158. if (effect.isInstant())
  1159. {
  1160. if (instant && effect.calcSuccess(info))
  1161. {
  1162. effect.onStart(info);
  1163. }
  1164. }
  1165. else if (addContinuousEffects)
  1166. {
  1167. if (effect.canStart(info))
  1168. {
  1169. info.addEffect(effect);
  1170. }
  1171. }
  1172. }
  1173. }
  1174. effector.getEffectList().add(info);
  1175. // Support for buff sharing feature.
  1176. if (addContinuousEffects && effected.isPlayer() && effected.hasSummon() && isContinuous() && !isDebuff())
  1177. {
  1178. applyEffects(effector, effected.getSummon(), false, 0);
  1179. }
  1180. }
  1181. if (passive && hasPassiveEffects())
  1182. {
  1183. env.setTarget(effector);
  1184. final BuffInfo info = new BuffInfo(env);
  1185. for (AbstractEffect effect : _effectPassive)
  1186. {
  1187. if (effect != null)
  1188. {
  1189. if (effect.canStart(info))
  1190. {
  1191. info.addEffect(effect);
  1192. }
  1193. }
  1194. }
  1195. effector.getEffectList().add(info);
  1196. }
  1197. if (!self && !passive && hasChannelingEffects())
  1198. {
  1199. env.setTarget(effected);
  1200. final BuffInfo info = new BuffInfo(env);
  1201. if (addContinuousEffects && (abnormalTime > 0))
  1202. {
  1203. info.setAbnormalTime(abnormalTime);
  1204. }
  1205. for (AbstractEffect effect : _effectChanneling)
  1206. {
  1207. if (effect != null)
  1208. {
  1209. if (effect.isInstant())
  1210. {
  1211. if (instant && effect.calcSuccess(info))
  1212. {
  1213. effect.onStart(info);
  1214. }
  1215. }
  1216. else if (addContinuousEffects)
  1217. {
  1218. if (effect.canStart(info))
  1219. {
  1220. info.addEffect(effect);
  1221. }
  1222. }
  1223. }
  1224. }
  1225. effector.getEffectList().add(info);
  1226. // Support for buff sharing feature.
  1227. if (addContinuousEffects && effected.isPlayer() && effected.hasSummon() && isContinuous() && !isDebuff())
  1228. {
  1229. applyEffects(effector, effected.getSummon(), false, 0);
  1230. }
  1231. }
  1232. }
  1233. public final void attach(FuncTemplate f)
  1234. {
  1235. if (_funcTemplates == null)
  1236. {
  1237. _funcTemplates = new ArrayList<>(1);
  1238. }
  1239. _funcTemplates.add(f);
  1240. }
  1241. public final void attach(AbstractEffect effect)
  1242. {
  1243. if (_effects == null)
  1244. {
  1245. _effects = new ArrayList<>(1);
  1246. }
  1247. _effects.add(effect);
  1248. }
  1249. public final void attachSelf(AbstractEffect effect)
  1250. {
  1251. if (_effectSelf == null)
  1252. {
  1253. _effectSelf = new ArrayList<>(1);
  1254. }
  1255. _effectSelf.add(effect);
  1256. }
  1257. public final void attachPassive(AbstractEffect effect)
  1258. {
  1259. if (_effectPassive == null)
  1260. {
  1261. _effectPassive = new ArrayList<>(1);
  1262. }
  1263. _effectPassive.add(effect);
  1264. }
  1265. public final void attachChanneling(AbstractEffect effectTemplate)
  1266. {
  1267. if (_effectChanneling == null)
  1268. {
  1269. _effectChanneling = new ArrayList<>(1);
  1270. }
  1271. _effectChanneling.add(effectTemplate);
  1272. }
  1273. public final void attach(Condition c, boolean itemOrWeapon)
  1274. {
  1275. if (itemOrWeapon)
  1276. {
  1277. if (_itemPreCondition == null)
  1278. {
  1279. _itemPreCondition = new ArrayList<>();
  1280. }
  1281. _itemPreCondition.add(c);
  1282. }
  1283. else
  1284. {
  1285. if (_preCondition == null)
  1286. {
  1287. _preCondition = new ArrayList<>();
  1288. }
  1289. _preCondition.add(c);
  1290. }
  1291. }
  1292. @Override
  1293. public String toString()
  1294. {
  1295. return "Skill " + _name + "(" + _id + "," + _level + ")";
  1296. }
  1297. /**
  1298. * @return pet food
  1299. */
  1300. public int getFeed()
  1301. {
  1302. return _feed;
  1303. }
  1304. /**
  1305. * used for tracking item id in case that item consume cannot be used
  1306. * @return reference item id
  1307. */
  1308. public int getReferenceItemId()
  1309. {
  1310. return _refId;
  1311. }
  1312. @Override
  1313. public boolean triggersChanceSkill()
  1314. {
  1315. return (_triggeredId > 0) && isChance();
  1316. }
  1317. @Override
  1318. public int getTriggeredChanceId()
  1319. {
  1320. return _triggeredId;
  1321. }
  1322. @Override
  1323. public int getTriggeredChanceLevel()
  1324. {
  1325. return _triggeredLevel;
  1326. }
  1327. @Override
  1328. public ChanceCondition getTriggeredChanceCondition()
  1329. {
  1330. return _chanceCondition;
  1331. }
  1332. public String getAttributeName()
  1333. {
  1334. return _attribute;
  1335. }
  1336. /**
  1337. * @return the _blowChance
  1338. */
  1339. public int getBlowChance()
  1340. {
  1341. return _blowChance;
  1342. }
  1343. public boolean ignoreShield()
  1344. {
  1345. return _ignoreShield;
  1346. }
  1347. public boolean canBeDispeled()
  1348. {
  1349. return _canBeDispeled;
  1350. }
  1351. /**
  1352. * Verify if the skill can be stolen.
  1353. * @return {@code true} if skill can be stolen, {@code false} otherwise
  1354. */
  1355. public boolean canBeStolen()
  1356. {
  1357. return !isPassive() && !isToggle() && !isDebuff() && !isHeroSkill() && !isGMSkill() && !(isStatic() && (getId() != SKILL_CARAVANS_SECRET_MEDICINE)) && canBeDispeled() && (getId() != SKILL_SERVITOR_SHARE);
  1358. }
  1359. public boolean isClanSkill()
  1360. {
  1361. return _isClanSkill;
  1362. }
  1363. public boolean isExcludedFromCheck()
  1364. {
  1365. return _excludedFromCheck;
  1366. }
  1367. public boolean getDependOnTargetBuff()
  1368. {
  1369. return _dependOnTargetBuff;
  1370. }
  1371. public boolean isSimultaneousCast()
  1372. {
  1373. return _simultaneousCast;
  1374. }
  1375. /**
  1376. * Parse an extractable skill.
  1377. * @param skillId the skill Id
  1378. * @param skillLvl the skill level
  1379. * @param values the values to parse
  1380. * @return the parsed extractable skill
  1381. * @author Zoey76
  1382. */
  1383. private L2ExtractableSkill parseExtractableSkill(int skillId, int skillLvl, String values)
  1384. {
  1385. final String[] prodLists = values.split(";");
  1386. final List<L2ExtractableProductItem> products = new ArrayList<>();
  1387. String[] prodData;
  1388. for (String prodList : prodLists)
  1389. {
  1390. prodData = prodList.split(",");
  1391. if (prodData.length < 3)
  1392. {
  1393. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> wrong seperator!");
  1394. }
  1395. List<ItemHolder> items = null;
  1396. double chance = 0;
  1397. int prodId = 0;
  1398. int quantity = 0;
  1399. final int lenght = prodData.length - 1;
  1400. try
  1401. {
  1402. items = new ArrayList<>(lenght / 2);
  1403. for (int j = 0; j < lenght; j++)
  1404. {
  1405. prodId = Integer.parseInt(prodData[j]);
  1406. quantity = Integer.parseInt(prodData[j += 1]);
  1407. if ((prodId <= 0) || (quantity <= 0))
  1408. {
  1409. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " wrong production Id: " + prodId + " or wrond quantity: " + quantity + "!");
  1410. }
  1411. items.add(new ItemHolder(prodId, quantity));
  1412. }
  1413. chance = Double.parseDouble(prodData[lenght]);
  1414. }
  1415. catch (Exception e)
  1416. {
  1417. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> incomplete/invalid production data or wrong seperator!");
  1418. }
  1419. products.add(new L2ExtractableProductItem(items, chance));
  1420. }
  1421. if (products.isEmpty())
  1422. {
  1423. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> There are no production items!");
  1424. }
  1425. return new L2ExtractableSkill(SkillTable.getSkillHashCode(skillId, skillLvl), products);
  1426. }
  1427. public L2ExtractableSkill getExtractableSkill()
  1428. {
  1429. return _extractableItems;
  1430. }
  1431. /**
  1432. * @return the _npcId
  1433. */
  1434. public int getNpcId()
  1435. {
  1436. return _npcId;
  1437. }
  1438. /**
  1439. * @param types
  1440. * @return {@code true} if at least one of specified {@link L2EffectType} types present on the current skill's effects, {@code false} otherwise.
  1441. */
  1442. public boolean hasEffectType(L2EffectType... types)
  1443. {
  1444. if (hasEffects() && (types != null) && (types.length > 0))
  1445. {
  1446. if (_effectTypes == null)
  1447. {
  1448. _effectTypes = new byte[_effects.size()];
  1449. final Env env = new Env();
  1450. env.setSkill(this);
  1451. int i = 0;
  1452. for (AbstractEffect effect : _effects)
  1453. {
  1454. if (effect == null)
  1455. {
  1456. continue;
  1457. }
  1458. _effectTypes[i++] = (byte) effect.getEffectType().ordinal();
  1459. }
  1460. Arrays.sort(_effectTypes);
  1461. }
  1462. for (L2EffectType type : types)
  1463. {
  1464. if (Arrays.binarySearch(_effectTypes, (byte) type.ordinal()) >= 0)
  1465. {
  1466. return true;
  1467. }
  1468. }
  1469. }
  1470. return false;
  1471. }
  1472. /**
  1473. * @return icon of the current skill.
  1474. */
  1475. public String getIcon()
  1476. {
  1477. return _icon;
  1478. }
  1479. public int getChannelingTickInterval()
  1480. {
  1481. return _channelingTickInterval;
  1482. }
  1483. public int getChannelingTickInitialDelay()
  1484. {
  1485. return _channelingTickInitialDelay;
  1486. }
  1487. }