L2Skill.java 43 KB

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