L2Skill.java 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model;
  16. import java.util.ArrayList;
  17. import java.util.Collection;
  18. import java.util.List;
  19. import java.util.StringTokenizer;
  20. import java.util.logging.Logger;
  21. import javolution.util.FastList;
  22. import com.l2jserver.Config;
  23. import com.l2jserver.gameserver.GeoData;
  24. import com.l2jserver.gameserver.datatables.GMSkillTable;
  25. import com.l2jserver.gameserver.datatables.HeroSkillTable;
  26. import com.l2jserver.gameserver.datatables.ItemTable;
  27. import com.l2jserver.gameserver.datatables.SkillTable;
  28. import com.l2jserver.gameserver.datatables.SkillTreeTable;
  29. import com.l2jserver.gameserver.model.actor.L2Attackable;
  30. import com.l2jserver.gameserver.model.actor.L2Character;
  31. import com.l2jserver.gameserver.model.actor.L2Npc;
  32. import com.l2jserver.gameserver.model.actor.L2Playable;
  33. import com.l2jserver.gameserver.model.actor.L2Summon;
  34. import com.l2jserver.gameserver.model.actor.instance.L2ArtefactInstance;
  35. import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2CubicInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  38. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  39. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  40. import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
  41. import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
  42. import com.l2jserver.gameserver.model.entity.TvTEvent;
  43. import com.l2jserver.gameserver.network.SystemMessageId;
  44. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  45. import com.l2jserver.gameserver.skills.BaseStats;
  46. import com.l2jserver.gameserver.skills.Env;
  47. import com.l2jserver.gameserver.skills.Formulas;
  48. import com.l2jserver.gameserver.skills.Stats;
  49. import com.l2jserver.gameserver.skills.conditions.Condition;
  50. import com.l2jserver.gameserver.skills.funcs.Func;
  51. import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
  52. import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
  53. import com.l2jserver.gameserver.templates.StatsSet;
  54. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  55. import com.l2jserver.gameserver.templates.item.L2Armor;
  56. import com.l2jserver.gameserver.templates.item.L2ArmorType;
  57. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  58. import com.l2jserver.gameserver.util.Util;
  59. /**
  60. * This class...
  61. *
  62. * @version $Revision: 1.3.2.8.2.22 $ $Date: 2005/04/06 16:13:42 $
  63. */
  64. public abstract class L2Skill implements IChanceSkillTrigger
  65. {
  66. protected static final Logger _log = Logger.getLogger(L2Skill.class.getName());
  67. private static final L2Object[] _emptyTargetList = new L2Object[0];
  68. public static final int SKILL_LUCKY = 194;
  69. public static final int SKILL_CREATE_COMMON = 1320;
  70. public static final int SKILL_CREATE_DWARVEN = 172;
  71. public static final int SKILL_CRYSTALLIZE = 248;
  72. public static final int SKILL_DIVINE_INSPIRATION = 1405;
  73. public static final int SKILL_CLAN_LUCK = 390;
  74. public static final boolean geoEnabled = Config.GEODATA > 0;
  75. public static enum SkillOpType
  76. {
  77. OP_PASSIVE, OP_ACTIVE, OP_TOGGLE
  78. }
  79. /** Target types of skills : SELF, PARTY, CLAN, PET... */
  80. public static enum SkillTargetType
  81. {
  82. TARGET_NONE,
  83. TARGET_SELF,
  84. TARGET_ONE,
  85. TARGET_PARTY,
  86. TARGET_ALLY,
  87. TARGET_CLAN,
  88. TARGET_PET,
  89. TARGET_SUMMON,
  90. TARGET_AREA,
  91. TARGET_FRONT_AREA,
  92. TARGET_BEHIND_AREA,
  93. TARGET_AURA,
  94. TARGET_FRONT_AURA,
  95. TARGET_BEHIND_AURA,
  96. TARGET_CORPSE,
  97. TARGET_UNDEAD,
  98. TARGET_AREA_UNDEAD,
  99. TARGET_CORPSE_ALLY,
  100. TARGET_CORPSE_CLAN,
  101. TARGET_CORPSE_PLAYER,
  102. TARGET_CORPSE_PET,
  103. TARGET_AREA_CORPSE_MOB,
  104. TARGET_CORPSE_MOB,
  105. TARGET_UNLOCKABLE,
  106. TARGET_HOLY,
  107. TARGET_FLAGPOLE,
  108. TARGET_PARTY_MEMBER,
  109. TARGET_PARTY_OTHER,
  110. TARGET_PARTY_CLAN,
  111. TARGET_ENEMY_SUMMON,
  112. TARGET_OWNER_PET,
  113. TARGET_GROUND,
  114. TARGET_PARTY_NOTME,
  115. TARGET_AREA_SUMMON,
  116. TARGET_CLAN_MEMBER
  117. }
  118. //conditional values
  119. public final static int COND_RUNNING = 0x0001;
  120. public final static int COND_WALKING = 0x0002;
  121. public final static int COND_SIT = 0x0004;
  122. public final static int COND_BEHIND = 0x0008;
  123. public final static int COND_CRIT = 0x0010;
  124. public final static int COND_LOWHP = 0x0020;
  125. public final static int COND_ROBES = 0x0040;
  126. public final static int COND_CHARGES = 0x0080;
  127. public final static int COND_SHIELD = 0x0100;
  128. private static final Func[] _emptyFunctionSet = new Func[0];
  129. private static final L2Effect[] _emptyEffectSet = new L2Effect[0];
  130. // these two build the primary key
  131. private final int _id;
  132. private final int _level;
  133. /** Identifier for a skill that client can't display */
  134. private int _displayId;
  135. // not needed, just for easier debug
  136. private final String _name;
  137. private final SkillOpType _operateType;
  138. private final boolean _magic;
  139. private final boolean _staticReuse;
  140. private final boolean _staticHitTime;
  141. private final int _mpConsume;
  142. private final int _mpInitialConsume;
  143. private final int _hpConsume;
  144. private final int _cpConsume;
  145. private final int _targetConsume;
  146. private final int _targetConsumeId;
  147. private final int _itemConsume;
  148. private final int _itemConsumeId;
  149. private final int _castRange;
  150. private final int _effectRange;
  151. // Abnormal levels for skills and their canceling, e.g. poison vs negate
  152. private final int _abnormalLvl; // e.g. poison or bleed lvl 2
  153. // Note: see also _effectAbnormalLvl
  154. private final int _negateLvl; // abnormalLvl is negated with negateLvl
  155. private final int[] _negateId; // cancels the effect of skill ID
  156. private final L2SkillType[] _negateStats; // lists the effect types that are canceled
  157. private final int _maxNegatedEffects; // maximum number of effects to negate
  158. private final boolean _stayAfterDeath; // skill should stay after death
  159. // kill by damage over time
  160. private final boolean _killByDOT;
  161. private final int _refId;
  162. // all times in milliseconds
  163. private final int _hitTime;
  164. private final int[] _hitTimings;
  165. //private final int _skillInterruptTime;
  166. private final int _coolTime;
  167. private final int _reuseHashCode;
  168. private final int _reuseDelay;
  169. private final int _buffDuration;
  170. // for item skills delay on equip
  171. private final int _equipDelay;
  172. /** Target type of the skill : SELF, PARTY, CLAN, PET... */
  173. private final SkillTargetType _targetType;
  174. private final int _feed;
  175. // base success chance
  176. private final double _power;
  177. private final double _pvpPower;
  178. private final int _magicLevel;
  179. private final int _levelDepend;
  180. private final boolean _ignoreResists;
  181. private final int _minChance;
  182. private final int _maxChance;
  183. private final boolean _isNeutral;
  184. // Effecting area of the skill, in radius.
  185. // The radius center varies according to the _targetType:
  186. // "caster" if targetType = AURA/PARTY/CLAN or "target" if targetType = AREA
  187. private final int _skillRadius;
  188. private final L2SkillType _skillType;
  189. private final L2SkillType _effectType; // additional effect has a type
  190. private final int _effectAbnormalLvl; // abnormal level for the additional effect type, e.g. poison lvl 1
  191. private final int _effectId;
  192. private final int _effectLvl; // normal effect level
  193. private final boolean _nextActionIsAttack;
  194. private final boolean _removedOnAnyActionExceptMove;
  195. private final boolean _removedOnDamage;
  196. private final boolean _isPotion;
  197. private final byte _element;
  198. private final int _elementPower;
  199. private final Stats _stat;
  200. private final BaseStats _saveVs;
  201. private final int _condition;
  202. private final int _conditionValue;
  203. private final boolean _overhit;
  204. private final int _weaponsAllowed;
  205. private final int _armorsAllowed;
  206. private final int _minPledgeClass;
  207. private final boolean _isOffensive;
  208. private final int _maxCharges;
  209. private final int _numCharges;
  210. private final int _triggeredId;
  211. private final int _triggeredLevel;
  212. private final String _chanceType;
  213. private final int _soulMaxConsume;
  214. private final int _soulConsume;
  215. private final int _numSouls;
  216. private final int _expNeeded;
  217. private final int _critChance;
  218. private final float _dependOnTargetBuff;
  219. private final int _transformId;
  220. private final int _transformDuration;
  221. private final int _afterEffectId;
  222. private final int _afterEffectLvl;
  223. private final boolean _isHeroSkill; // If true the skill is a Hero Skill
  224. private final boolean _isGMSkill; // True if skill is GM skill
  225. private final int _baseCritRate; // percent of success for skill critical hit (especially for PDAM & BLOW - they're not affected by rCrit values or buffs). Default loads -1 for all other skills but 0 to PDAM & BLOW
  226. private final int _lethalEffect1; // percent of success for lethal 1st effect (hit cp to 1 or if mob hp to 50%) (only for PDAM skills)
  227. private final int _lethalEffect2; // percent of success for lethal 2nd effect (hit cp,hp to 1 or if mob hp to 1) (only for PDAM skills)
  228. private final boolean _directHpDmg; // If true then dmg is being make directly
  229. private final boolean _isDance; // If true then casting more dances will cost more MP
  230. private final int _nextDanceCost;
  231. private final float _sSBoost; //If true skill will have SoulShot boost (power*2)
  232. private final int _aggroPoints;
  233. protected List<Condition> _preCondition;
  234. protected List<Condition> _itemPreCondition;
  235. protected FuncTemplate[] _funcTemplates;
  236. protected EffectTemplate[] _effectTemplates;
  237. protected EffectTemplate[] _effectTemplatesSelf;
  238. protected ChanceCondition _chanceCondition = null;
  239. // Flying support
  240. private final String _flyType;
  241. private final int _flyRadius;
  242. private final float _flyCourse;
  243. private final boolean _isDebuff;
  244. private final String _attribute;
  245. private final boolean _ignoreShield;
  246. private final boolean _isSuicideAttack;
  247. private final boolean _canBeReflected;
  248. private final boolean _canBeDispeled;
  249. private final boolean _isClanSkill;
  250. private final boolean _excludedFromCheck;
  251. private final boolean _simultaneousCast;
  252. protected L2Skill(StatsSet set)
  253. {
  254. _id = set.getInteger("skill_id");
  255. _level = set.getInteger("level");
  256. _refId = set.getInteger("referenceId", 0);
  257. _displayId = set.getInteger("displayId", _id);
  258. _name = set.getString("name");
  259. _operateType = set.getEnum("operateType", SkillOpType.class);
  260. _magic = set.getBool("isMagic", false);
  261. _staticReuse = set.getBool("staticReuse", false);
  262. _staticHitTime = set.getBool("staticHitTime", false);
  263. _isPotion = set.getBool("isPotion", false);
  264. _mpConsume = set.getInteger("mpConsume", 0);
  265. _mpInitialConsume = set.getInteger("mpInitialConsume", 0);
  266. _hpConsume = set.getInteger("hpConsume", 0);
  267. _cpConsume = set.getInteger("cpConsume", 0);
  268. _targetConsume = set.getInteger("targetConsumeCount", 0);
  269. _targetConsumeId = set.getInteger("targetConsumeId", 0);
  270. _itemConsume = set.getInteger("itemConsumeCount", 0);
  271. _itemConsumeId = set.getInteger("itemConsumeId", 0);
  272. _afterEffectId = set.getInteger("afterEffectId", 0);
  273. _afterEffectLvl = set.getInteger("afterEffectLvl", 1);
  274. _castRange = set.getInteger("castRange", -1);
  275. _effectRange = set.getInteger("effectRange", -1);
  276. _abnormalLvl = set.getInteger("abnormalLvl", -1);
  277. _effectAbnormalLvl = set.getInteger("effectAbnormalLvl", -1); // support for a separate effect abnormal lvl, e.g. poison inside a different skill
  278. _negateLvl = set.getInteger("negateLvl", -1);
  279. _attribute = set.getString("attribute","");
  280. String str = set.getString("negateStats", "");
  281. if (str == "")
  282. _negateStats = new L2SkillType[0];
  283. else
  284. {
  285. String[] stats = str.split(" ");
  286. L2SkillType[] array = new L2SkillType[stats.length];
  287. for (int i = 0; i < stats.length; i++)
  288. {
  289. L2SkillType type = null;
  290. try
  291. {
  292. type = Enum.valueOf(L2SkillType.class, stats[i]);
  293. }
  294. catch (Exception e)
  295. {
  296. throw new IllegalArgumentException("SkillId: "+_id+"Enum value of type "+L2SkillType.class.getName()+"required, but found: "+stats[i]);
  297. }
  298. array[i] = type;
  299. }
  300. _negateStats = array;
  301. }
  302. String negateId = set.getString("negateId", null);
  303. if (negateId != null)
  304. {
  305. String[] valuesSplit = negateId.split(",");
  306. _negateId = new int[valuesSplit.length];
  307. for (int i = 0; i < valuesSplit.length;i++)
  308. {
  309. _negateId[i] = Integer.parseInt(valuesSplit[i]);
  310. }
  311. }
  312. else
  313. _negateId = new int[0];
  314. _maxNegatedEffects = set.getInteger("maxNegated", 0);
  315. _stayAfterDeath = set.getBool("stayAfterDeath", false);
  316. _killByDOT = set.getBool("killByDOT", false);
  317. _isNeutral = set.getBool("neutral",false);
  318. _hitTime = set.getInteger("hitTime", 0);
  319. String hitTimings = set.getString("hitTimings", null);
  320. if (hitTimings != null)
  321. {
  322. try
  323. {
  324. String [] valuesSplit = hitTimings.split(",");
  325. _hitTimings = new int[valuesSplit.length];
  326. for (int i = 0; i < valuesSplit.length; i++)
  327. _hitTimings[i] = Integer.parseInt(valuesSplit[i]);
  328. }
  329. catch (Exception e)
  330. {
  331. throw new IllegalArgumentException("SkillId: "+_id+" invalid hitTimings value: "+hitTimings+", \"percent,percent,...percent\" required");
  332. }
  333. }
  334. else
  335. _hitTimings = new int[0];
  336. _coolTime = set.getInteger("coolTime", 0);
  337. _isDebuff = set.getBool("isDebuff", false);
  338. _feed = set.getInteger("feed", 0);
  339. String reuseHash = set.getString("sharedReuse", null);
  340. if (reuseHash != null)
  341. {
  342. try
  343. {
  344. String[] valuesSplit = reuseHash.split("-");
  345. _reuseHashCode = SkillTable.getSkillHashCode(Integer.parseInt(valuesSplit[0]), Integer.parseInt(valuesSplit[1]));
  346. }
  347. catch (Exception e)
  348. {
  349. throw new IllegalArgumentException("SkillId: "+_id+" invalid sharedReuse value: "+reuseHash+", \"skillId-skillLvl\" required");
  350. }
  351. }
  352. else
  353. _reuseHashCode = SkillTable.getSkillHashCode(_id, _level);
  354. if (Config.ENABLE_MODIFY_SKILL_REUSE && Config.SKILL_REUSE_LIST.containsKey(_id))
  355. {
  356. if ( Config.DEBUG )
  357. _log.info("*** Skill " + _name + " (" + _level + ") changed reuse from " + set.getInteger("reuseDelay", 0) + " to " + Config.SKILL_REUSE_LIST.get(_id) + " seconds.");
  358. _reuseDelay = Config.SKILL_REUSE_LIST.get(_id);
  359. }
  360. else
  361. {
  362. _reuseDelay = set.getInteger("reuseDelay", 0);
  363. }
  364. _buffDuration = set.getInteger("buffDuration", 0);
  365. _equipDelay = set.getInteger("equipDelay", 0);
  366. _skillRadius = set.getInteger("skillRadius", 80);
  367. _targetType = set.getEnum("target", SkillTargetType.class);
  368. _power = set.getFloat("power", 0.f);
  369. _pvpPower = set.getFloat("pvpPower", (float)getPower());
  370. _magicLevel = set.getInteger("magicLvl", SkillTreeTable.getInstance().getMinSkillLevel(_id, _level));
  371. _levelDepend = set.getInteger("lvlDepend", 0);
  372. _ignoreResists = set.getBool("ignoreResists", false);
  373. _minChance = set.getInteger("minChance", 1);
  374. _maxChance = set.getInteger("maxChance", 99);
  375. _stat = set.getEnum("stat", Stats.class, null);
  376. _ignoreShield = set.getBool("ignoreShld", false);
  377. _skillType = set.getEnum("skillType", L2SkillType.class);
  378. _effectType = set.getEnum("effectType", L2SkillType.class, null);
  379. _effectId = set.getInteger("effectId", 0);
  380. _effectLvl = set.getInteger("effectLevel", 0);
  381. _nextActionIsAttack = set.getBool("nextActionAttack", false);
  382. _removedOnAnyActionExceptMove = set.getBool("removedOnAnyActionExceptMove", false);
  383. _removedOnDamage = set.getBool("removedOnDamage", _skillType == L2SkillType.SLEEP);
  384. _element = set.getByte("element", (byte)-1);
  385. _elementPower = set.getInteger("elementPower", 0);
  386. _saveVs = set.getEnum("saveVs", BaseStats.class, null);
  387. _condition = set.getInteger("condition", 0);
  388. _conditionValue = set.getInteger("conditionValue", 0);
  389. _overhit = set.getBool("overHit", false);
  390. _isSuicideAttack = set.getBool("isSuicideAttack", false);
  391. String weaponsAllowedString = set.getString("weaponsAllowed", null);
  392. if (weaponsAllowedString != null && !weaponsAllowedString.trim().isEmpty())
  393. {
  394. int mask = 0;
  395. StringTokenizer st = new StringTokenizer(weaponsAllowedString, ",");
  396. while (st.hasMoreTokens())
  397. {
  398. int old = mask;
  399. String item = st.nextToken().trim();
  400. if (ItemTable._weaponTypes.containsKey(item))
  401. mask |= ItemTable._weaponTypes.get(item).mask();
  402. if (ItemTable._armorTypes.containsKey(item)) // for shield
  403. mask |= ItemTable._armorTypes.get(item).mask();
  404. if (old == mask)
  405. _log.info("[weaponsAllowed] Unknown item type name: "+item);
  406. }
  407. _weaponsAllowed = mask;
  408. }
  409. else
  410. _weaponsAllowed = 0;
  411. _armorsAllowed = set.getInteger("armorsAllowed", 0);
  412. _minPledgeClass = set.getInteger("minPledgeClass", 0);
  413. _isOffensive = set.getBool("offensive", isSkillTypeOffensive());
  414. _maxCharges = set.getInteger("maxCharges", 0);
  415. _numCharges = set.getInteger("numCharges", 0);
  416. _triggeredId = set.getInteger("triggeredId", 0);
  417. _triggeredLevel = set.getInteger("triggeredLevel", 0);
  418. _chanceType = set.getString("chanceType", "");
  419. if (_chanceType != "" && !_chanceType.isEmpty())
  420. _chanceCondition = ChanceCondition.parse(set);
  421. _numSouls = set.getInteger("num_souls", 0);
  422. _soulMaxConsume = set.getInteger("soulMaxConsumeCount", 0);
  423. _soulConsume = set.getInteger("soulConsumeCount", 0);
  424. _expNeeded = set.getInteger("expNeeded", 0);
  425. _critChance = set.getInteger("critChance", 0);
  426. _transformId = set.getInteger("transformId", 0);
  427. _transformDuration = set.getInteger("transformDuration", 0);
  428. _isHeroSkill = HeroSkillTable.isHeroSkill(_id);
  429. _isGMSkill = GMSkillTable.isGMSkill(_id);
  430. _baseCritRate = set.getInteger("baseCritRate", (_skillType == L2SkillType.PDAM || _skillType == L2SkillType.BLOW) ? 0 : -1);
  431. _lethalEffect1 = set.getInteger("lethal1",0);
  432. _lethalEffect2 = set.getInteger("lethal2",0);
  433. _directHpDmg = set.getBool("dmgDirectlyToHp",false);
  434. _isDance = set.getBool("isDance",false);
  435. _nextDanceCost = set.getInteger("nextDanceCost", 0);
  436. _sSBoost = set.getFloat("SSBoost", 0.f);
  437. _aggroPoints = set.getInteger("aggroPoints", 0);
  438. _flyType = set.getString("flyType", null);
  439. _flyRadius = set.getInteger("flyRadius", 0);
  440. _flyCourse = set.getFloat("flyCourse", 0);
  441. _canBeReflected = set.getBool("canBeReflected", true);
  442. _canBeDispeled = set.getBool("canBeDispeled", true);
  443. _isClanSkill = set.getBool("isClanSkill", false);
  444. _excludedFromCheck = set.getBool("excludedFromCheck", false);
  445. _dependOnTargetBuff = set.getFloat("dependOnTargetBuff", 0);
  446. _simultaneousCast = set.getBool("simultaneousCast", false);
  447. }
  448. public abstract void useSkill(L2Character caster, L2Object[] targets);
  449. public final boolean isPotion()
  450. {
  451. return _isPotion;
  452. }
  453. public final int getArmorsAllowed()
  454. {
  455. return _armorsAllowed;
  456. }
  457. public final int getConditionValue()
  458. {
  459. return _conditionValue;
  460. }
  461. public final L2SkillType getSkillType()
  462. {
  463. return _skillType;
  464. }
  465. public final byte getElement()
  466. {
  467. return _element;
  468. }
  469. public final int getElementPower()
  470. {
  471. return _elementPower;
  472. }
  473. /**
  474. * Return the target type of the skill : SELF, PARTY, CLAN, PET...<BR><BR>
  475. *
  476. */
  477. public final SkillTargetType getTargetType()
  478. {
  479. return _targetType;
  480. }
  481. public final int getCondition()
  482. {
  483. return _condition;
  484. }
  485. public final boolean isOverhit()
  486. {
  487. return _overhit;
  488. }
  489. public final boolean killByDOT()
  490. {
  491. return _killByDOT;
  492. }
  493. public final boolean isSuicideAttack()
  494. {
  495. return _isSuicideAttack;
  496. }
  497. public final boolean allowOnTransform()
  498. {
  499. return isPassive();
  500. }
  501. /**
  502. * Return the power of the skill.<BR><BR>
  503. */
  504. public final double getPower(L2Character activeChar, L2Character target, boolean isPvP)
  505. {
  506. if (activeChar == null)
  507. return getPower(isPvP);
  508. switch (_skillType)
  509. {
  510. case DEATHLINK:
  511. {
  512. return getPower(isPvP) * Math.pow(1.7165 - activeChar.getCurrentHp() / activeChar.getMaxHp(), 2) * 0.577;
  513. /*
  514. * DrHouse:
  515. * Rolling back to old formula (look below) for DEATHLINK due to this one based on logarithm is not
  516. * accurate enough. Commented here because probably is a matter of just adjusting a constant
  517. if(activeChar.getCurrentHp() / activeChar.getMaxHp() > 0.005)
  518. return _power*(-0.45*Math.log(activeChar.getCurrentHp()/activeChar.getMaxHp())+1.);
  519. else
  520. return _power*(-0.45*Math.log(0.005)+1.);
  521. */
  522. }
  523. case FATAL:
  524. {
  525. return getPower(isPvP)*3.5*(1-target.getCurrentHp()/target.getMaxHp());
  526. }
  527. default:
  528. return getPower(isPvP);
  529. }
  530. }
  531. public final double getPower()
  532. {
  533. return _power;
  534. }
  535. public final double getPower(boolean isPvP)
  536. {
  537. return isPvP ? _pvpPower : _power;
  538. }
  539. public final L2SkillType[] getNegateStats()
  540. {
  541. return _negateStats;
  542. }
  543. public final int getAbnormalLvl()
  544. {
  545. return _abnormalLvl;
  546. }
  547. public final int getNegateLvl()
  548. {
  549. return _negateLvl;
  550. }
  551. public final int[] getNegateId()
  552. {
  553. return _negateId;
  554. }
  555. public final int getMagicLevel()
  556. {
  557. return _magicLevel;
  558. }
  559. public final int getMaxNegatedEffects()
  560. {
  561. return _maxNegatedEffects;
  562. }
  563. public final int getLevelDepend()
  564. {
  565. return _levelDepend;
  566. }
  567. /**
  568. * Return true if skill should ignore all resistances
  569. */
  570. public final boolean ignoreResists()
  571. {
  572. return _ignoreResists;
  573. }
  574. /**
  575. * Return minimum skill/effect land rate (default is 1).
  576. */
  577. public final int getMinChance()
  578. {
  579. return _minChance;
  580. }
  581. /**
  582. * Return maximum skill/effect land rate (default is 99).
  583. */
  584. public final int getMaxChance()
  585. {
  586. return _maxChance;
  587. }
  588. /**
  589. * Return true if skill effects should be removed on any action except movement
  590. */
  591. public final boolean isRemovedOnAnyActionExceptMove()
  592. {
  593. return _removedOnAnyActionExceptMove;
  594. }
  595. /**
  596. * Return true if skill effects should be removed on damage
  597. */
  598. public final boolean isRemovedOnDamage()
  599. {
  600. return _removedOnDamage;
  601. }
  602. /**
  603. * Return the additional effect Id.<BR><BR>
  604. */
  605. public final int getEffectId()
  606. {
  607. return _effectId;
  608. }
  609. /**
  610. * Return the additional effect level.<BR><BR>
  611. */
  612. public final int getEffectLvl()
  613. {
  614. return _effectLvl;
  615. }
  616. public final int getEffectAbnormalLvl()
  617. {
  618. return _effectAbnormalLvl;
  619. }
  620. /**
  621. * Return the additional effect skill type (ex : STUN, PARALYZE,...).<BR><BR>
  622. */
  623. public final L2SkillType getEffectType()
  624. {
  625. return _effectType;
  626. }
  627. /**
  628. * Return true if character should attack target after skill
  629. */
  630. public final boolean nextActionIsAttack()
  631. {
  632. return _nextActionIsAttack;
  633. }
  634. /**
  635. * @return Returns the buffDuration.
  636. */
  637. public final int getBuffDuration()
  638. {
  639. return _buffDuration;
  640. }
  641. /**
  642. * @return Returns the castRange.
  643. */
  644. public final int getCastRange()
  645. {
  646. return _castRange;
  647. }
  648. /**
  649. * @return Returns the cpConsume;
  650. */
  651. public final int getCpConsume()
  652. {
  653. return _cpConsume;
  654. }
  655. /**
  656. * @return Returns the effectRange.
  657. */
  658. public final int getEffectRange()
  659. {
  660. return _effectRange;
  661. }
  662. /**
  663. * @return Returns the hpConsume.
  664. */
  665. public final int getHpConsume()
  666. {
  667. return _hpConsume;
  668. }
  669. /**
  670. * @return Returns the id.
  671. */
  672. public final int getId()
  673. {
  674. return _id;
  675. }
  676. /**
  677. * @return Returns the boolean _isDebuff.
  678. */
  679. public final boolean isDebuff()
  680. {
  681. return _isDebuff;
  682. }
  683. public int getDisplayId()
  684. {
  685. return _displayId;
  686. }
  687. public void setDisplayId(int id)
  688. {
  689. _displayId = id;
  690. }
  691. public int getTriggeredId()
  692. {
  693. return _triggeredId;
  694. }
  695. public int getTriggeredLevel()
  696. {
  697. return _triggeredLevel;
  698. }
  699. public boolean triggerAnotherSkill()
  700. {
  701. return _triggeredId > 1;
  702. }
  703. /**
  704. * Return the skill type (ex : BLEED, SLEEP, WATER...).<BR><BR>
  705. */
  706. public final Stats getStat()
  707. {
  708. return _stat;
  709. }
  710. /**
  711. * Return skill saveVs base stat (STR, INT ...).<BR><BR>
  712. */
  713. public final BaseStats getSaveVs()
  714. {
  715. return _saveVs;
  716. }
  717. /**
  718. * @return Returns the _targetConsumeId.
  719. */
  720. public final int getTargetConsumeId()
  721. {
  722. return _targetConsumeId;
  723. }
  724. /**
  725. * @return Returns the targetConsume.
  726. */
  727. public final int getTargetConsume()
  728. {
  729. return _targetConsume;
  730. }
  731. /**
  732. * @return Returns the itemConsume.
  733. */
  734. public final int getItemConsume()
  735. {
  736. return _itemConsume;
  737. }
  738. /**
  739. * @return Returns the itemConsumeId.
  740. */
  741. public final int getItemConsumeId()
  742. {
  743. return _itemConsumeId;
  744. }
  745. /**
  746. * @return Returns the level.
  747. */
  748. public final int getLevel()
  749. {
  750. return _level;
  751. }
  752. /**
  753. * @return Returns the magic.
  754. */
  755. public final boolean isMagic()
  756. {
  757. return _magic;
  758. }
  759. /**
  760. * @return Returns true to set static reuse.
  761. */
  762. public final boolean isStaticReuse()
  763. {
  764. return _staticReuse;
  765. }
  766. /**
  767. * @return Returns true to set static hittime.
  768. */
  769. public final boolean isStaticHitTime()
  770. {
  771. return _staticHitTime;
  772. }
  773. /**
  774. * @return Returns the mpConsume.
  775. */
  776. public final int getMpConsume()
  777. {
  778. return _mpConsume;
  779. }
  780. /**
  781. * @return Returns the mpInitialConsume.
  782. */
  783. public final int getMpInitialConsume()
  784. {
  785. return _mpInitialConsume;
  786. }
  787. /**
  788. * @return Returns the name.
  789. */
  790. public final String getName()
  791. {
  792. return _name;
  793. }
  794. /**
  795. * @return Returns the reuseDelay.
  796. */
  797. public final int getReuseDelay()
  798. {
  799. return _reuseDelay;
  800. }
  801. public final int getReuseHashCode()
  802. {
  803. return _reuseHashCode;
  804. }
  805. public final int getEquipDelay()
  806. {
  807. return _equipDelay;
  808. }
  809. public final int getHitTime()
  810. {
  811. return _hitTime;
  812. }
  813. public final int getHitCounts()
  814. {
  815. return _hitTimings.length;
  816. }
  817. public final int[] getHitTimings()
  818. {
  819. return _hitTimings;
  820. }
  821. /**
  822. * @return Returns the coolTime.
  823. */
  824. public final int getCoolTime()
  825. {
  826. return _coolTime;
  827. }
  828. public final int getSkillRadius()
  829. {
  830. return _skillRadius;
  831. }
  832. public final boolean isActive()
  833. {
  834. return _operateType == SkillOpType.OP_ACTIVE;
  835. }
  836. public final boolean isPassive()
  837. {
  838. return _operateType == SkillOpType.OP_PASSIVE;
  839. }
  840. public final boolean isToggle()
  841. {
  842. return _operateType == SkillOpType.OP_TOGGLE;
  843. }
  844. public final boolean isChance()
  845. {
  846. return _chanceCondition != null && isPassive();
  847. }
  848. public final boolean isDance()
  849. {
  850. return _isDance;
  851. }
  852. public final int getNextDanceMpCost()
  853. {
  854. return _nextDanceCost;
  855. }
  856. public final float getSSBoost()
  857. {
  858. return _sSBoost;
  859. }
  860. public final int getAggroPoints()
  861. {
  862. return _aggroPoints;
  863. }
  864. public final boolean useSoulShot()
  865. {
  866. switch (getSkillType())
  867. {
  868. case PDAM:
  869. case CHARGEDAM:
  870. case BLOW:
  871. return true;
  872. default:
  873. return false;
  874. }
  875. }
  876. public final boolean useSpiritShot()
  877. {
  878. return isMagic();
  879. }
  880. public final boolean useFishShot()
  881. {
  882. return ((getSkillType() == L2SkillType.PUMPING) || (getSkillType() == L2SkillType.REELING) );
  883. }
  884. public final int getWeaponsAllowed()
  885. {
  886. return _weaponsAllowed;
  887. }
  888. public int getMinPledgeClass() { return _minPledgeClass; }
  889. public final boolean isPvpSkill()
  890. {
  891. switch (_skillType)
  892. {
  893. case DOT:
  894. case BLEED:
  895. case CONFUSION:
  896. case POISON:
  897. case DEBUFF:
  898. case AGGDEBUFF:
  899. case STUN:
  900. case ROOT:
  901. case FEAR:
  902. case SLEEP:
  903. case MDOT:
  904. case MUTE:
  905. case WEAKNESS:
  906. case PARALYZE:
  907. case CANCEL:
  908. case MAGE_BANE:
  909. case WARRIOR_BANE:
  910. case BETRAY:
  911. case DISARM:
  912. case AGGDAMAGE:
  913. case STEAL_BUFF:
  914. case AGGREDUCE_CHAR:
  915. case MANADAM:
  916. return true;
  917. default:
  918. return false;
  919. }
  920. }
  921. public final boolean isOffensive()
  922. {
  923. return _isOffensive;
  924. }
  925. public final boolean isNeutral()
  926. {
  927. return _isNeutral;
  928. }
  929. public final boolean isHeroSkill()
  930. {
  931. return _isHeroSkill;
  932. }
  933. public final boolean isGMSkill()
  934. {
  935. return _isGMSkill;
  936. }
  937. public final int getNumCharges()
  938. {
  939. return _numCharges;
  940. }
  941. public final int getNumSouls()
  942. {
  943. return _numSouls;
  944. }
  945. public final int getMaxSoulConsumeCount()
  946. {
  947. return _soulMaxConsume;
  948. }
  949. public final int getSoulConsumeCount()
  950. {
  951. return _soulConsume;
  952. }
  953. public final int getExpNeeded()
  954. {
  955. return _expNeeded;
  956. }
  957. public final int getCritChance()
  958. {
  959. return _critChance;
  960. }
  961. public final int getTransformId()
  962. {
  963. return _transformId;
  964. }
  965. public final int getTransformDuration()
  966. {
  967. return _transformDuration;
  968. }
  969. public final int getBaseCritRate()
  970. {
  971. return _baseCritRate;
  972. }
  973. public final int getLethalChance1()
  974. {
  975. return _lethalEffect1;
  976. }
  977. public final int getLethalChance2()
  978. {
  979. return _lethalEffect2;
  980. }
  981. public final boolean getDmgDirectlyToHP()
  982. {
  983. return _directHpDmg;
  984. }
  985. public final String getFlyType()
  986. {
  987. return _flyType;
  988. }
  989. public final int getFlyRadius()
  990. {
  991. return _flyRadius;
  992. }
  993. public final float getFlyCourse()
  994. {
  995. return _flyCourse;
  996. }
  997. public final boolean isSkillTypeOffensive()
  998. {
  999. switch (_skillType)
  1000. {
  1001. case PDAM:
  1002. case MDAM:
  1003. case CPDAM:
  1004. case DOT:
  1005. case CPDAMPERCENT:
  1006. case BLEED:
  1007. case POISON:
  1008. case AGGDAMAGE:
  1009. case DEBUFF:
  1010. case AGGDEBUFF:
  1011. case STUN:
  1012. case ROOT:
  1013. case CONFUSION:
  1014. case ERASE:
  1015. case BLOW:
  1016. case FATAL:
  1017. case FEAR:
  1018. case DRAIN:
  1019. case SLEEP:
  1020. case CHARGEDAM:
  1021. case CONFUSE_MOB_ONLY:
  1022. case DEATHLINK:
  1023. case DETECT_WEAKNESS:
  1024. case MANADAM:
  1025. case MDOT:
  1026. case MUTE:
  1027. case SOULSHOT:
  1028. case SPIRITSHOT:
  1029. case SPOIL:
  1030. case WEAKNESS:
  1031. case MANA_BY_LEVEL:
  1032. case SWEEP:
  1033. case PARALYZE:
  1034. case DRAIN_SOUL:
  1035. case AGGREDUCE:
  1036. case CANCEL:
  1037. case MAGE_BANE:
  1038. case WARRIOR_BANE:
  1039. case AGGREMOVE:
  1040. case AGGREDUCE_CHAR:
  1041. case BETRAY:
  1042. case DELUXE_KEY_UNLOCK:
  1043. case SOW:
  1044. case HARVEST:
  1045. case DISARM:
  1046. case STEAL_BUFF:
  1047. case INSTANT_JUMP:
  1048. return true;
  1049. default:
  1050. return this.isDebuff();
  1051. }
  1052. }
  1053. public final boolean is7Signs()
  1054. {
  1055. if (_id > 4360 && _id < 4367)
  1056. return true;
  1057. return false;
  1058. }
  1059. public final boolean isStayAfterDeath()
  1060. {
  1061. return _stayAfterDeath;
  1062. }
  1063. // int weapons[] = {L2Weapon.WEAPON_TYPE_ETC, L2Weapon.WEAPON_TYPE_BOW,
  1064. // L2Weapon.WEAPON_TYPE_POLE, L2Weapon.WEAPON_TYPE_DUALFIST,
  1065. // L2Weapon.WEAPON_TYPE_DUAL, L2Weapon.WEAPON_TYPE_BLUNT,
  1066. // L2Weapon.WEAPON_TYPE_SWORD, L2Weapon.WEAPON_TYPE_DAGGER};
  1067. public final boolean getWeaponDependancy(L2Character activeChar)
  1068. {
  1069. if(getWeaponDependancy(activeChar,false))
  1070. {
  1071. return true;
  1072. }
  1073. else
  1074. {
  1075. SystemMessage message = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  1076. message.addSkillName(this);
  1077. activeChar.sendPacket(message);
  1078. return false;
  1079. }
  1080. }
  1081. public final boolean getWeaponDependancy(L2Character activeChar,boolean chance)
  1082. {
  1083. int weaponsAllowed = getWeaponsAllowed();
  1084. //check to see if skill has a weapon dependency.
  1085. if (weaponsAllowed == 0)
  1086. return true;
  1087. int mask = 0;
  1088. if (activeChar.getActiveWeaponItem() != null)
  1089. mask |= activeChar.getActiveWeaponItem().getItemType().mask();
  1090. if (activeChar.getSecondaryWeaponItem() != null && activeChar.getSecondaryWeaponItem() instanceof L2Armor)
  1091. mask |= ((L2ArmorType) activeChar.getSecondaryWeaponItem().getItemType()).mask();
  1092. if ((mask & weaponsAllowed) != 0)
  1093. return true;
  1094. return false;
  1095. }
  1096. public boolean checkCondition(L2Character activeChar, L2Object target, boolean itemOrWeapon)
  1097. {
  1098. if (activeChar.isGM() && !Config.GM_SKILL_RESTRICTION)
  1099. return true;
  1100. if ((getCondition() & L2Skill.COND_SHIELD) != 0)
  1101. {
  1102. /*
  1103. L2Armor armorPiece;
  1104. L2ItemInstance dummy;
  1105. dummy = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  1106. armorPiece = (L2Armor) dummy.getItem();
  1107. */
  1108. //TODO add checks for shield here.
  1109. }
  1110. List<Condition> preCondition = _preCondition;
  1111. if(itemOrWeapon) preCondition = _itemPreCondition;
  1112. if (preCondition == null || preCondition.isEmpty()) return true;
  1113. for(Condition cond : preCondition)
  1114. {
  1115. Env env = new Env();
  1116. env.player = activeChar;
  1117. if (target instanceof L2Character) // TODO: object or char?
  1118. env.target = (L2Character)target;
  1119. env.skill = this;
  1120. if (!cond.test(env))
  1121. {
  1122. String msg = cond.getMessage();
  1123. int msgId = cond.getMessageId();
  1124. if (msgId != 0)
  1125. {
  1126. SystemMessage sm = SystemMessage.getSystemMessage(msgId);
  1127. if (cond.isAddName())
  1128. sm.addSkillName(_id);
  1129. activeChar.sendPacket(sm);
  1130. }
  1131. else if (msg != null)
  1132. {
  1133. activeChar.sendMessage(msg);
  1134. }
  1135. return false;
  1136. }
  1137. }
  1138. return true;
  1139. }
  1140. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst)
  1141. {
  1142. // Init to null the target of the skill
  1143. L2Character target = null;
  1144. // Get the L2Objcet targeted by the user of the skill at this moment
  1145. L2Object objTarget = activeChar.getTarget();
  1146. // If the L2Object targeted is a L2Character, it becomes the L2Character target
  1147. if (objTarget instanceof L2Character)
  1148. {
  1149. target = (L2Character) objTarget;
  1150. }
  1151. return getTargetList(activeChar, onlyFirst, target);
  1152. }
  1153. /**
  1154. * Return all targets of the skill in a table in function a the skill type.<BR><BR>
  1155. *
  1156. * <B><U> Values of skill type</U> :</B><BR><BR>
  1157. * <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>
  1158. * <li>SELF</li>
  1159. * <li>HOLY, UNDEAD</li>
  1160. * <li>PET</li>
  1161. * <li>AURA, AURA_CLOSE</li>
  1162. * <li>AREA</li>
  1163. * <li>MULTIFACE</li>
  1164. * <li>PARTY, CLAN</li>
  1165. * <li>CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN</li>
  1166. * <li>UNLOCKABLE</li>
  1167. * <li>ITEM</li><BR><BR>
  1168. *
  1169. * @param activeChar The L2Character who use the skill
  1170. *
  1171. */
  1172. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst, L2Character target)
  1173. {
  1174. List<L2Character> targetList = new FastList<L2Character>();
  1175. // Get the target type of the skill
  1176. // (ex : ONE, SELF, HOLY, PET, AURA, AURA_CLOSE, AREA, MULTIFACE, PARTY, CLAN, CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN, UNLOCKABLE, ITEM, UNDEAD)
  1177. SkillTargetType targetType = getTargetType();
  1178. // Get the type of the skill
  1179. // (ex : PDAM, MDAM, DOT, BLEED, POISON, HEAL, HOT, MANAHEAL, MANARECHARGE, AGGDAMAGE, BUFF, DEBUFF, STUN, ROOT, RESURRECT, PASSIVE...)
  1180. L2SkillType skillType = getSkillType();
  1181. switch (targetType)
  1182. {
  1183. // The skill can only be used on the L2Character targeted, or on the caster itself
  1184. case TARGET_ONE:
  1185. {
  1186. boolean canTargetSelf = false;
  1187. switch (skillType)
  1188. {
  1189. case BUFF:
  1190. case HEAL:
  1191. case HOT:
  1192. case HEAL_PERCENT:
  1193. case MANARECHARGE:
  1194. case MANAHEAL:
  1195. case NEGATE:
  1196. case CANCEL_DEBUFF:
  1197. case REFLECT:
  1198. case COMBATPOINTHEAL:
  1199. case BALANCE_LIFE:
  1200. case HPMPCPHEAL_PERCENT:
  1201. case HPMPHEAL_PERCENT:
  1202. case HPCPHEAL_PERCENT:
  1203. canTargetSelf = true;
  1204. break;
  1205. }
  1206. // Check for null target or any other invalid target
  1207. if (target == null || target.isDead() || (target == activeChar && !canTargetSelf))
  1208. {
  1209. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1210. return _emptyTargetList;
  1211. }
  1212. // If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
  1213. return new L2Character[] {target};
  1214. }
  1215. case TARGET_SELF:
  1216. case TARGET_GROUND:
  1217. {
  1218. return new L2Character[] {activeChar};
  1219. }
  1220. case TARGET_HOLY:
  1221. {
  1222. if (activeChar instanceof L2PcInstance)
  1223. {
  1224. if (target instanceof L2ArtefactInstance)
  1225. return new L2Character[] {target};
  1226. }
  1227. return _emptyTargetList;
  1228. }
  1229. case TARGET_FLAGPOLE:
  1230. {
  1231. return new L2Character[] {activeChar};
  1232. }
  1233. case TARGET_PET:
  1234. {
  1235. target = activeChar.getPet();
  1236. if (target != null && !target.isDead()) return new L2Character[] {target};
  1237. return _emptyTargetList;
  1238. }
  1239. case TARGET_SUMMON:
  1240. {
  1241. target = activeChar.getPet();
  1242. if (target != null && !target.isDead() && target instanceof L2SummonInstance) return new L2Character[] {target};
  1243. return _emptyTargetList;
  1244. }
  1245. case TARGET_OWNER_PET:
  1246. {
  1247. if (activeChar instanceof L2Summon)
  1248. {
  1249. target = ((L2Summon)activeChar).getOwner();
  1250. if (target != null && !target.isDead())
  1251. return new L2Character[]{target};
  1252. }
  1253. return _emptyTargetList;
  1254. }
  1255. case TARGET_CORPSE_PET:
  1256. {
  1257. if (activeChar instanceof L2PcInstance)
  1258. {
  1259. target = activeChar.getPet();
  1260. if (target != null && target.isDead())
  1261. return new L2Character[]{target};
  1262. }
  1263. return _emptyTargetList;
  1264. }
  1265. case TARGET_AURA:
  1266. case TARGET_FRONT_AURA:
  1267. case TARGET_BEHIND_AURA:
  1268. {
  1269. final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1270. final L2PcInstance sourcePlayer = activeChar.getActingPlayer();
  1271. // Go through the L2Character _knownList
  1272. final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharactersInRadius(getSkillRadius());
  1273. //synchronized (activeChar.getKnownList().getKnownObjects())
  1274. if (getSkillType() == L2SkillType.DUMMY)
  1275. {
  1276. if (onlyFirst)
  1277. return new L2Character[] { activeChar };
  1278. targetList.add(activeChar);
  1279. for (L2Character obj : objs)
  1280. {
  1281. if (!(obj == activeChar
  1282. || obj == sourcePlayer
  1283. || obj instanceof L2Npc
  1284. || obj instanceof L2Attackable))
  1285. continue;
  1286. targetList.add(obj);
  1287. }
  1288. }
  1289. else
  1290. {
  1291. for (L2Character obj : objs)
  1292. {
  1293. if (obj instanceof L2Attackable || obj instanceof L2Playable)
  1294. {
  1295. switch (targetType)
  1296. {
  1297. case TARGET_FRONT_AURA:
  1298. if (!obj.isInFrontOf(activeChar))
  1299. continue;
  1300. break;
  1301. case TARGET_BEHIND_AURA:
  1302. if(!obj.isBehind(activeChar))
  1303. continue;
  1304. break;
  1305. }
  1306. if (!checkForAreaOffensiveSkills(activeChar, obj, this, srcInArena))
  1307. continue;
  1308. if (onlyFirst)
  1309. return new L2Character[] { obj };
  1310. targetList.add(obj);
  1311. }
  1312. }
  1313. }
  1314. return targetList.toArray(new L2Character[targetList.size()]);
  1315. }
  1316. case TARGET_AREA_SUMMON:
  1317. {
  1318. target = activeChar.getPet();
  1319. if (target == null || !(target instanceof L2SummonInstance) || target.isDead())
  1320. return _emptyTargetList;
  1321. if(onlyFirst)
  1322. return new L2Character[]{target};
  1323. final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1324. final Collection<L2Character> objs = target.getKnownList().getKnownCharacters();
  1325. final int radius = getSkillRadius();
  1326. for (L2Character obj : objs)
  1327. {
  1328. if (obj == null || obj == target || obj == activeChar)
  1329. continue;
  1330. if (!Util.checkIfInRange(radius, target, obj, true))
  1331. continue;
  1332. if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  1333. continue;
  1334. if (!checkForAreaOffensiveSkills(activeChar, obj, this, srcInArena))
  1335. continue;
  1336. targetList.add(obj);
  1337. }
  1338. if (targetList.isEmpty())
  1339. return _emptyTargetList;
  1340. return targetList.toArray(new L2Character[targetList.size()]);
  1341. }
  1342. case TARGET_AREA:
  1343. case TARGET_FRONT_AREA:
  1344. case TARGET_BEHIND_AREA:
  1345. {
  1346. if (((target == null || target == activeChar || target.isAlikeDead()) && getCastRange() >= 0) ||
  1347. (!(target instanceof L2Attackable || target instanceof L2Playable)))
  1348. {
  1349. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1350. return _emptyTargetList;
  1351. }
  1352. final L2Character origin;
  1353. final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1354. final int radius = getSkillRadius();
  1355. if (getCastRange() >= 0)
  1356. {
  1357. if (!checkForAreaOffensiveSkills(activeChar, target, this, srcInArena))
  1358. return _emptyTargetList;
  1359. if(onlyFirst)
  1360. return new L2Character[]{target};
  1361. origin = target;
  1362. targetList.add(origin); // Add target to target list
  1363. }
  1364. else
  1365. origin = activeChar;
  1366. final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
  1367. //synchronized (activeChar.getKnownList().getKnownObjects())
  1368. {
  1369. for (L2Character obj : objs)
  1370. {
  1371. if (!(obj instanceof L2Attackable
  1372. || obj instanceof L2Playable))
  1373. continue;
  1374. if (obj == origin)
  1375. continue;
  1376. if (Util.checkIfInRange(radius, origin, obj, true))
  1377. {
  1378. switch (targetType)
  1379. {
  1380. case TARGET_FRONT_AREA:
  1381. if (!obj.isInFrontOf(activeChar))
  1382. continue;
  1383. break;
  1384. case TARGET_BEHIND_AREA:
  1385. if (!obj.isBehind(activeChar))
  1386. continue;
  1387. break;
  1388. }
  1389. if (!checkForAreaOffensiveSkills(activeChar, obj, this, srcInArena))
  1390. continue;
  1391. targetList.add(obj);
  1392. }
  1393. }
  1394. }
  1395. if (targetList.isEmpty())
  1396. return _emptyTargetList;
  1397. return targetList.toArray(new L2Character[targetList.size()]);
  1398. }
  1399. case TARGET_PARTY:
  1400. {
  1401. if (onlyFirst)
  1402. return new L2Character[]{activeChar};
  1403. targetList.add(activeChar);
  1404. final int radius = getSkillRadius();
  1405. L2PcInstance player = activeChar.getActingPlayer();
  1406. if (activeChar instanceof L2Summon)
  1407. {
  1408. if (addCharacter(activeChar, player, radius, false))
  1409. targetList.add(player);
  1410. }
  1411. else if (activeChar instanceof L2PcInstance)
  1412. {
  1413. if (addSummon(activeChar, player, radius, false))
  1414. targetList.add(player.getPet());
  1415. }
  1416. if (activeChar.isInParty())
  1417. {
  1418. // Get a list of Party Members
  1419. for(L2PcInstance partyMember : activeChar.getParty().getPartyMembers())
  1420. {
  1421. if (partyMember == null || partyMember == player)
  1422. continue;
  1423. if (addCharacter(activeChar, partyMember, radius, false))
  1424. targetList.add(partyMember);
  1425. if (addSummon(activeChar, partyMember, radius, false))
  1426. targetList.add(partyMember.getPet());
  1427. }
  1428. }
  1429. return targetList.toArray(new L2Character[targetList.size()]);
  1430. }
  1431. case TARGET_PARTY_MEMBER:
  1432. {
  1433. if ((target != null
  1434. && target == activeChar)
  1435. || (target != null
  1436. && activeChar.isInParty()
  1437. && target.isInParty()
  1438. && activeChar.getParty().getPartyLeaderOID() == target.getParty().getPartyLeaderOID())
  1439. || (target != null
  1440. && activeChar instanceof L2PcInstance
  1441. && target instanceof L2Summon
  1442. && activeChar.getPet() == target)
  1443. || (target != null
  1444. && activeChar instanceof L2Summon
  1445. && target instanceof L2PcInstance
  1446. && activeChar == target.getPet()))
  1447. {
  1448. if (!target.isDead())
  1449. {
  1450. // If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
  1451. return new L2Character[]{target};
  1452. }
  1453. else
  1454. return _emptyTargetList;
  1455. }
  1456. else
  1457. {
  1458. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1459. return _emptyTargetList;
  1460. }
  1461. }
  1462. case TARGET_PARTY_OTHER:
  1463. {
  1464. if (target != null && target != activeChar
  1465. && activeChar.isInParty() && target.isInParty()
  1466. && activeChar.getParty().getPartyLeaderOID() == target.getParty().getPartyLeaderOID())
  1467. {
  1468. if (!target.isDead())
  1469. {
  1470. if (target instanceof L2PcInstance)
  1471. {
  1472. switch (getId())
  1473. {
  1474. // FORCE BUFFS may cancel here but there should be a proper condition
  1475. case 426:
  1476. if (!((L2PcInstance)target).isMageClass())
  1477. return new L2Character[]{target};
  1478. else
  1479. return _emptyTargetList;
  1480. case 427:
  1481. if (((L2PcInstance)target).isMageClass())
  1482. return new L2Character[]{target};
  1483. else
  1484. return _emptyTargetList;
  1485. }
  1486. }
  1487. return new L2Character[]{target};
  1488. }
  1489. else
  1490. return _emptyTargetList;
  1491. }
  1492. else
  1493. {
  1494. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1495. return _emptyTargetList;
  1496. }
  1497. }
  1498. case TARGET_CORPSE_ALLY:
  1499. case TARGET_ALLY:
  1500. {
  1501. if (activeChar instanceof L2Playable)
  1502. {
  1503. final L2PcInstance player = activeChar.getActingPlayer();
  1504. if (player == null)
  1505. return _emptyTargetList;
  1506. if (player.isInOlympiadMode())
  1507. return new L2Character[] {player};
  1508. final boolean isCorpseType = targetType == SkillTargetType.TARGET_CORPSE_ALLY;
  1509. if (!isCorpseType)
  1510. {
  1511. if (onlyFirst)
  1512. return new L2Character[] {player};
  1513. targetList.add(player);
  1514. }
  1515. final int radius = getSkillRadius();
  1516. if (addSummon(activeChar, player, radius, isCorpseType))
  1517. targetList.add(player.getPet());
  1518. if (player.getClan() != null)
  1519. {
  1520. // Get all visible objects in a spherical area near the L2Character
  1521. final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
  1522. //synchronized (activeChar.getKnownList().getKnownObjects())
  1523. {
  1524. for (L2PcInstance obj : objs)
  1525. {
  1526. if (obj == null)
  1527. continue;
  1528. if ((obj.getAllyId() == 0 || obj.getAllyId() != player.getAllyId())
  1529. && (obj.getClan() == null || obj.getClanId() != player.getClanId()))
  1530. continue;
  1531. if (player.isInDuel())
  1532. {
  1533. if (player.getDuelId() != obj.getDuelId())
  1534. continue;
  1535. if (player.isInParty() && obj.isInParty() && player.getParty().getPartyLeaderOID() != obj.getParty().getPartyLeaderOID())
  1536. continue;
  1537. }
  1538. // Don't add this target if this is a Pc->Pc pvp
  1539. // casting and pvp condition not met
  1540. if (!player.checkPvpSkill(obj, this))
  1541. continue;
  1542. if (!TvTEvent.checkForTvTSkill(player, obj, this))
  1543. continue;
  1544. if (!onlyFirst && addSummon(activeChar, obj, radius, isCorpseType))
  1545. targetList.add(obj.getPet());
  1546. if (!addCharacter(activeChar, obj, radius, isCorpseType))
  1547. continue;
  1548. if (isCorpseType)
  1549. {
  1550. // Siege battlefield resurrect has been made possible for participants
  1551. if (getSkillType() == L2SkillType.RESURRECT)
  1552. {
  1553. if (obj.isInsideZone(L2Character.ZONE_SIEGE) && !obj.isInSiege())
  1554. continue;
  1555. }
  1556. }
  1557. if (onlyFirst)
  1558. return new L2Character[] { obj };
  1559. targetList.add(obj);
  1560. }
  1561. }
  1562. }
  1563. }
  1564. return targetList.toArray(new L2Character[targetList.size()]);
  1565. }
  1566. case TARGET_CORPSE_CLAN:
  1567. case TARGET_CLAN:
  1568. {
  1569. if (activeChar instanceof L2Playable)
  1570. {
  1571. final L2PcInstance player = activeChar.getActingPlayer();
  1572. if (player == null)
  1573. return _emptyTargetList;
  1574. if (player.isInOlympiadMode())
  1575. return new L2Character[] {player};
  1576. final boolean isCorpseType = targetType == SkillTargetType.TARGET_CORPSE_CLAN;
  1577. if (!isCorpseType)
  1578. {
  1579. if (onlyFirst)
  1580. return new L2Character[] {player};
  1581. targetList.add(player);
  1582. }
  1583. final int radius = getSkillRadius();
  1584. final L2Clan clan = player.getClan();
  1585. if (addSummon(activeChar, player, radius, isCorpseType))
  1586. targetList.add(player.getPet());
  1587. if (clan != null)
  1588. {
  1589. L2PcInstance obj;
  1590. // Get Clan Members
  1591. for (L2ClanMember member : clan.getMembers())
  1592. {
  1593. obj = member.getPlayerInstance();
  1594. if (obj == null || obj == player)
  1595. continue;
  1596. if (player.isInDuel())
  1597. {
  1598. if (player.getDuelId() != obj.getDuelId())
  1599. continue;
  1600. if (player.isInParty() && obj.isInParty() && player.getParty().getPartyLeaderOID() != obj.getParty().getPartyLeaderOID())
  1601. continue;
  1602. }
  1603. // Don't add this target if this is a Pc->Pc pvp casting and pvp condition not met
  1604. if (!player.checkPvpSkill(obj, this))
  1605. continue;
  1606. if (!TvTEvent.checkForTvTSkill(player, obj, this))
  1607. continue;
  1608. if (!onlyFirst && addSummon(activeChar, obj, radius, isCorpseType))
  1609. targetList.add(obj.getPet());
  1610. if (!addCharacter(activeChar, obj, radius, isCorpseType))
  1611. continue;
  1612. if (isCorpseType)
  1613. {
  1614. if (getSkillType() == L2SkillType.RESURRECT)
  1615. {
  1616. // check target is not in a active siege zone
  1617. if (obj.isInsideZone(L2Character.ZONE_SIEGE) && !obj.isInSiege())
  1618. continue;
  1619. }
  1620. }
  1621. if (onlyFirst)
  1622. return new L2Character[] {obj};
  1623. targetList.add(obj);
  1624. }
  1625. }
  1626. }
  1627. else if (activeChar instanceof L2Npc)
  1628. {
  1629. // for buff purposes, returns friendly mobs nearby and mob itself
  1630. final L2Npc npc = (L2Npc) activeChar;
  1631. if (npc.getFactionId() == null || npc.getFactionId().isEmpty())
  1632. {
  1633. return new L2Character[]{activeChar};
  1634. }
  1635. targetList.add(activeChar);
  1636. final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1637. //synchronized (activeChar.getKnownList().getKnownObjects())
  1638. {
  1639. for (L2Object newTarget : objs)
  1640. {
  1641. if (newTarget instanceof L2Npc
  1642. && npc.getFactionId().equals(((L2Npc) newTarget).getFactionId()))
  1643. {
  1644. if (!Util.checkIfInRange(getCastRange(), activeChar, newTarget, true))
  1645. continue;
  1646. targetList.add((L2Npc) newTarget);
  1647. }
  1648. }
  1649. }
  1650. }
  1651. return targetList.toArray(new L2Character[targetList.size()]);
  1652. }
  1653. case TARGET_PARTY_CLAN:
  1654. {
  1655. if (onlyFirst)
  1656. return new L2Character[]{activeChar};
  1657. final L2PcInstance player = activeChar.getActingPlayer();
  1658. if (player == null)
  1659. return _emptyTargetList;
  1660. targetList.add(player);
  1661. final int radius = getSkillRadius();
  1662. final boolean hasClan = player.getClan() != null;
  1663. final boolean hasParty = player.isInParty();
  1664. if (addSummon(activeChar, player, radius, false))
  1665. targetList.add(player.getPet());
  1666. // if player in clan and not in party
  1667. if (!(hasClan || hasParty))
  1668. return targetList.toArray(new L2Character[targetList.size()]);
  1669. // Get all visible objects in a spherical area near the L2Character
  1670. final Collection<L2PcInstance> objs = activeChar.getKnownList().getKnownPlayersInRadius(radius);
  1671. //synchronized (activeChar.getKnownList().getKnownObjects())
  1672. {
  1673. for (L2PcInstance obj : objs)
  1674. {
  1675. if (obj == null)
  1676. continue;
  1677. // olympiad mode - adding only own side
  1678. if (player.isInOlympiadMode())
  1679. {
  1680. if (!obj.isInOlympiadMode())
  1681. continue;
  1682. if (player.getOlympiadGameId() != obj.getOlympiadGameId())
  1683. continue;
  1684. if (player.getOlympiadSide() != obj.getOlympiadSide())
  1685. continue;
  1686. }
  1687. if (player.isInDuel())
  1688. {
  1689. if (player.getDuelId() != obj.getDuelId())
  1690. continue;
  1691. if (hasParty && obj.isInParty() && player.getParty().getPartyLeaderOID() != obj.getParty().getPartyLeaderOID())
  1692. continue;
  1693. }
  1694. if (!((hasClan && obj.getClanId() == player.getClanId())
  1695. || (hasParty && obj.isInParty() && player.getParty().getPartyLeaderOID() == obj.getParty().getPartyLeaderOID())))
  1696. continue;
  1697. // Don't add this target if this is a Pc->Pc pvp
  1698. // casting and pvp condition not met
  1699. if (!player.checkPvpSkill(obj, this))
  1700. continue;
  1701. if (!TvTEvent.checkForTvTSkill(player, obj, this))
  1702. continue;
  1703. if (!onlyFirst && addSummon(activeChar, obj, radius, false))
  1704. targetList.add(obj.getPet());
  1705. if (!addCharacter(activeChar, obj, radius, false))
  1706. continue;
  1707. if (onlyFirst)
  1708. return new L2Character[] { obj };
  1709. targetList.add(obj);
  1710. }
  1711. }
  1712. return targetList.toArray(new L2Character[targetList.size()]);
  1713. }
  1714. case TARGET_CORPSE_PLAYER:
  1715. {
  1716. if (target != null && target.isDead())
  1717. {
  1718. final L2PcInstance player;
  1719. if (activeChar instanceof L2PcInstance)
  1720. player = (L2PcInstance) activeChar;
  1721. else
  1722. player = null;
  1723. final L2PcInstance targetPlayer;
  1724. if (target instanceof L2PcInstance)
  1725. targetPlayer = (L2PcInstance) target;
  1726. else
  1727. targetPlayer = null;
  1728. final L2PetInstance targetPet;
  1729. if (target instanceof L2PetInstance)
  1730. targetPet = (L2PetInstance) target;
  1731. else
  1732. targetPet = null;
  1733. if (player != null && (targetPlayer != null || targetPet != null))
  1734. {
  1735. boolean condGood = true;
  1736. if (getSkillType() == L2SkillType.RESURRECT)
  1737. {
  1738. if (targetPlayer != null)
  1739. {
  1740. // check target is not in a active siege zone
  1741. if (targetPlayer.isInsideZone(L2Character.ZONE_SIEGE) && !targetPlayer.isInSiege())
  1742. {
  1743. condGood = false;
  1744. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE));
  1745. }
  1746. if (targetPlayer.isFestivalParticipant()) // Check to see if the current player target is in a festival.
  1747. {
  1748. condGood = false;
  1749. activeChar.sendMessage("You may not resurrect participants in a festival.");
  1750. }
  1751. if (targetPlayer.isReviveRequested())
  1752. {
  1753. if (targetPlayer.isRevivingPet())
  1754. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MASTER_CANNOT_RES)); // While a pet is attempting to resurrect, it cannot help in resurrecting its master.
  1755. else
  1756. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
  1757. condGood = false;
  1758. }
  1759. }
  1760. else if (targetPet != null)
  1761. {
  1762. if (targetPet.getOwner() != player)
  1763. {
  1764. if (targetPet.getOwner().isReviveRequested())
  1765. {
  1766. if (targetPet.getOwner().isRevivingPet())
  1767. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
  1768. else
  1769. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_RES_PET2)); // A pet cannot be resurrected while it's owner is in the process of resurrecting.
  1770. condGood = false;
  1771. }
  1772. }
  1773. }
  1774. }
  1775. if (condGood)
  1776. {
  1777. if (!onlyFirst)
  1778. {
  1779. targetList.add(target);
  1780. return targetList.toArray(new L2Object[targetList.size()]);
  1781. }
  1782. else
  1783. return new L2Character[] {target};
  1784. }
  1785. }
  1786. }
  1787. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1788. return _emptyTargetList;
  1789. }
  1790. case TARGET_CORPSE_MOB:
  1791. {
  1792. final boolean isSummon = target instanceof L2SummonInstance;
  1793. if (!(isSummon || target instanceof L2Attackable) || !target.isDead())
  1794. {
  1795. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1796. return _emptyTargetList;
  1797. }
  1798. // Corpse mob only available for half time
  1799. switch (getSkillType())
  1800. {
  1801. case SUMMON:
  1802. {
  1803. if (isSummon && ((L2SummonInstance)target).getOwner() != null
  1804. && ((L2SummonInstance)target).getOwner().getObjectId() == activeChar.getObjectId())
  1805. return _emptyTargetList;
  1806. }
  1807. case DRAIN:
  1808. {
  1809. if (DecayTaskManager.getInstance().getTasks().containsKey(target)
  1810. && (System.currentTimeMillis() - DecayTaskManager.getInstance().getTasks().get(target)) > DecayTaskManager.ATTACKABLE_DECAY_TIME / 2)
  1811. {
  1812. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CORPSE_TOO_OLD_SKILL_NOT_USED));
  1813. return _emptyTargetList;
  1814. }
  1815. }
  1816. }
  1817. if (!onlyFirst)
  1818. {
  1819. targetList.add(target);
  1820. return targetList.toArray(new L2Object[targetList.size()]);
  1821. }
  1822. else
  1823. return new L2Character[] {target};
  1824. }
  1825. case TARGET_AREA_CORPSE_MOB:
  1826. {
  1827. if ((!(target instanceof L2Attackable)) || !target.isDead())
  1828. {
  1829. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1830. return _emptyTargetList;
  1831. }
  1832. if (onlyFirst)
  1833. return new L2Character[] {target};
  1834. targetList.add(target);
  1835. final boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1836. final int radius = getSkillRadius();
  1837. final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
  1838. //synchronized (activeChar.getKnownList().getKnownObjects())
  1839. {
  1840. for (L2Character obj : objs)
  1841. {
  1842. if (!(obj instanceof L2Attackable || obj instanceof L2Playable)
  1843. || !Util.checkIfInRange(radius, target, obj, true))
  1844. continue;
  1845. if (!checkForAreaOffensiveSkills(activeChar, obj, this, srcInArena))
  1846. continue;
  1847. targetList.add(obj);
  1848. }
  1849. }
  1850. if (targetList.isEmpty())
  1851. return _emptyTargetList;
  1852. return targetList.toArray(new L2Character[targetList.size()]);
  1853. }
  1854. case TARGET_UNLOCKABLE:
  1855. {
  1856. if (!(target instanceof L2DoorInstance) && !(target instanceof L2ChestInstance))
  1857. {
  1858. //activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessage.TARGET_IS_INCORRECT));
  1859. return _emptyTargetList;
  1860. }
  1861. if (!onlyFirst)
  1862. {
  1863. targetList.add(target);
  1864. return targetList.toArray(new L2Object[targetList.size()]);
  1865. }
  1866. else return new L2Character[] {target};
  1867. }
  1868. case TARGET_UNDEAD:
  1869. {
  1870. if (target instanceof L2Npc || target instanceof L2SummonInstance)
  1871. {
  1872. if (!target.isUndead() || target.isDead())
  1873. {
  1874. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1875. return _emptyTargetList;
  1876. }
  1877. if (!onlyFirst)
  1878. targetList.add(target);
  1879. else
  1880. return new L2Character[] {target};
  1881. return targetList.toArray(new L2Object[targetList.size()]);
  1882. }
  1883. else
  1884. {
  1885. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1886. return _emptyTargetList;
  1887. }
  1888. }
  1889. case TARGET_AREA_UNDEAD:
  1890. {
  1891. final L2Character cha;
  1892. final int radius = getSkillRadius();
  1893. if (getCastRange() >= 0 && (target instanceof L2Npc || target instanceof L2SummonInstance)
  1894. && target.isUndead() && !target.isAlikeDead())
  1895. {
  1896. cha = target;
  1897. if (!onlyFirst)
  1898. targetList.add(cha); // Add target to target list
  1899. else
  1900. return new L2Character[] {cha};
  1901. }
  1902. else cha = activeChar;
  1903. final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
  1904. //synchronized (cha.getKnownList().getKnownObjects())
  1905. {
  1906. for (L2Character obj : objs)
  1907. {
  1908. if (!Util.checkIfInRange(radius, cha, obj, true))
  1909. continue;
  1910. if (obj instanceof L2Npc)
  1911. target = obj;
  1912. else if (obj instanceof L2SummonInstance)
  1913. target = obj;
  1914. else
  1915. continue;
  1916. if (!target.isAlikeDead()) // If target is not
  1917. // dead/fake death and not
  1918. // self
  1919. {
  1920. if (!target.isUndead())
  1921. continue;
  1922. if (geoEnabled && !GeoData.getInstance().canSeeTarget(activeChar, target))
  1923. continue;
  1924. if (!onlyFirst)
  1925. targetList.add(obj);
  1926. else
  1927. return new L2Character[] { obj };
  1928. }
  1929. }
  1930. }
  1931. if (targetList.isEmpty()) return _emptyTargetList;
  1932. return targetList.toArray(new L2Character[targetList.size()]);
  1933. }
  1934. case TARGET_ENEMY_SUMMON:
  1935. {
  1936. if(target instanceof L2Summon)
  1937. {
  1938. L2Summon targetSummon = (L2Summon)target;
  1939. if (activeChar instanceof L2PcInstance && activeChar.getPet() != targetSummon && !targetSummon.isDead()
  1940. && (targetSummon.getOwner().getPvpFlag() != 0 || targetSummon.getOwner().getKarma() > 0)
  1941. || (targetSummon.getOwner().isInsideZone(L2Character.ZONE_PVP) && ((L2PcInstance)activeChar).isInsideZone(L2Character.ZONE_PVP))
  1942. || (targetSummon.getOwner().isInDuel() && ((L2PcInstance)activeChar).isInDuel() && targetSummon.getOwner().getDuelId() == ((L2PcInstance)activeChar).getDuelId()))
  1943. return new L2Character[]{targetSummon};
  1944. }
  1945. return _emptyTargetList;
  1946. }
  1947. case TARGET_PARTY_NOTME:
  1948. {
  1949. //target all party members except yourself
  1950. if (onlyFirst)
  1951. return new L2Character[] { activeChar };
  1952. L2PcInstance player = null;
  1953. if (activeChar instanceof L2Summon)
  1954. {
  1955. player = ((L2Summon) activeChar).getOwner();
  1956. targetList.add(player);
  1957. }
  1958. else if (activeChar instanceof L2PcInstance)
  1959. {
  1960. player = (L2PcInstance) activeChar;
  1961. if (activeChar.getPet() != null)
  1962. targetList.add(activeChar.getPet());
  1963. }
  1964. if (activeChar.getParty() != null)
  1965. {
  1966. List<L2PcInstance> partyList = activeChar.getParty().getPartyMembers();
  1967. for (L2PcInstance partyMember : partyList)
  1968. {
  1969. if (partyMember == null)
  1970. continue;
  1971. if (partyMember == player)
  1972. continue;
  1973. if (!partyMember.isDead() && Util.checkIfInRange(getSkillRadius(), activeChar, partyMember, true))
  1974. {
  1975. targetList.add(partyMember);
  1976. if (partyMember.getPet() != null && !partyMember.getPet().isDead())
  1977. {
  1978. targetList.add(partyMember.getPet());
  1979. }
  1980. }
  1981. }
  1982. }
  1983. return targetList.toArray(new L2Character[targetList.size()]);
  1984. }
  1985. // npc only for now - untested
  1986. case TARGET_CLAN_MEMBER:
  1987. {
  1988. if (activeChar instanceof L2Npc)
  1989. {
  1990. // for buff purposes, returns friendly mobs nearby and mob itself
  1991. final L2Npc npc = (L2Npc) activeChar;
  1992. if (npc.getFactionId() == null || npc.getFactionId().isEmpty())
  1993. {
  1994. return new L2Character[]{activeChar};
  1995. }
  1996. final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1997. for (L2Object newTarget : objs)
  1998. {
  1999. if (newTarget instanceof L2Npc
  2000. && npc.getFactionId().equals(((L2Npc) newTarget).getFactionId()))
  2001. {
  2002. if (!Util.checkIfInRange(getCastRange(), activeChar, newTarget, true))
  2003. continue;
  2004. if (((L2Npc) newTarget).getFirstEffect(this) != null)
  2005. continue;
  2006. targetList.add((L2Npc) newTarget);
  2007. break; // found
  2008. }
  2009. }
  2010. if (targetList.isEmpty())
  2011. targetList.add(npc);
  2012. }
  2013. else
  2014. return _emptyTargetList;
  2015. return targetList.toArray(new L2Character[targetList.size()]);
  2016. }
  2017. default:
  2018. {
  2019. activeChar.sendMessage("Target type of skill is not currently handled");
  2020. return _emptyTargetList;
  2021. }
  2022. }//end switch
  2023. }
  2024. public final L2Object[] getTargetList(L2Character activeChar)
  2025. {
  2026. return getTargetList(activeChar, false);
  2027. }
  2028. public final L2Object getFirstOfTargetList(L2Character activeChar)
  2029. {
  2030. L2Object[] targets;
  2031. targets = getTargetList(activeChar, true);
  2032. if (targets.length == 0)
  2033. return null;
  2034. else
  2035. return targets[0];
  2036. }
  2037. /*
  2038. * Check if should be target added to the target list
  2039. * false if target is dead, target same as caster,
  2040. * target inside peace zone, target in the same party with caster,
  2041. * caster can see target
  2042. * Additional checks if not in PvP zones (arena, siege):
  2043. * target in not the same clan and alliance with caster,
  2044. * and usual skill PvP check.
  2045. * If TvT event is active - performing additional checks.
  2046. *
  2047. * Caution: distance is not checked.
  2048. */
  2049. public static final boolean checkForAreaOffensiveSkills(L2Character caster, L2Character target, L2Skill skill, boolean sourceInArena)
  2050. {
  2051. if (target == null || target.isDead() || target == caster)
  2052. return false;
  2053. final L2PcInstance player = caster.getActingPlayer();
  2054. final L2PcInstance targetPlayer = target.getActingPlayer();
  2055. if (player != null)
  2056. {
  2057. if (targetPlayer != null)
  2058. {
  2059. if (targetPlayer == caster || targetPlayer == player)
  2060. return false;
  2061. if (targetPlayer.inObserverMode())
  2062. return false;
  2063. if (skill.isOffensive() && player.getSiegeState() > 0 && player.isInsideZone(L2Character.ZONE_SIEGE)
  2064. && player.getSiegeState() == targetPlayer.getSiegeState()
  2065. && player.getSiegeSide() == targetPlayer.getSiegeSide())
  2066. return false;
  2067. if (target.isInsideZone(L2Character.ZONE_PEACE))
  2068. return false;
  2069. if (player.isInParty() && targetPlayer.isInParty())
  2070. {
  2071. // Same party
  2072. if (player.getParty().getPartyLeaderOID() == targetPlayer.getParty().getPartyLeaderOID())
  2073. return false;
  2074. // Same commandchannel
  2075. if (player.getParty().getCommandChannel() != null
  2076. && player.getParty().getCommandChannel() == targetPlayer.getParty().getCommandChannel())
  2077. return false;
  2078. }
  2079. if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
  2080. return false;
  2081. if (!sourceInArena && !(targetPlayer.isInsideZone(L2Character.ZONE_PVP) && !targetPlayer.isInsideZone(L2Character.ZONE_SIEGE)))
  2082. {
  2083. if (player.getAllyId() != 0 && player.getAllyId() == targetPlayer.getAllyId())
  2084. return false;
  2085. if (player.getClanId() != 0 && player.getClanId() == targetPlayer.getClanId())
  2086. return false;
  2087. if (!player.checkPvpSkill(targetPlayer, skill, (caster instanceof L2Summon)))
  2088. return false;
  2089. }
  2090. }
  2091. }
  2092. else
  2093. {
  2094. // source is not playable
  2095. if (caster instanceof L2Attackable)
  2096. {
  2097. // target is mob
  2098. if (targetPlayer == null)
  2099. {
  2100. if (target instanceof L2Attackable)
  2101. {
  2102. String casterEnemyClan = ((L2Attackable)caster).getEnemyClan();
  2103. if (casterEnemyClan == null || casterEnemyClan.isEmpty())
  2104. return false;
  2105. String targetClan = ((L2Attackable)target).getClan();
  2106. if (targetClan == null || targetClan.isEmpty())
  2107. return false;
  2108. if (!casterEnemyClan.equals(targetClan))
  2109. return false;
  2110. }
  2111. }
  2112. }
  2113. }
  2114. if (geoEnabled && !GeoData.getInstance().canSeeTarget(caster, target))
  2115. return false;
  2116. return true;
  2117. }
  2118. public static final boolean addSummon(L2Character caster, L2PcInstance owner, int radius, boolean isDead)
  2119. {
  2120. final L2Summon summon = owner.getPet();
  2121. if (summon == null)
  2122. return false;
  2123. return addCharacter(caster, summon, radius, isDead);
  2124. }
  2125. public static final boolean addCharacter(L2Character caster, L2Character target, int radius, boolean isDead)
  2126. {
  2127. if (isDead != target.isDead())
  2128. return false;
  2129. if (radius > 0 && !Util.checkIfInRange(radius, caster, target, true))
  2130. return false;
  2131. return true;
  2132. }
  2133. public final Func[] getStatFuncs(L2Effect effect, L2Character player)
  2134. {
  2135. if (_funcTemplates == null)
  2136. return _emptyFunctionSet;
  2137. if (!(player instanceof L2Playable) && !(player instanceof L2Attackable))
  2138. return _emptyFunctionSet;
  2139. ArrayList<Func> funcs = new ArrayList<Func>(_funcTemplates.length);
  2140. Env env = new Env();
  2141. env.player = player;
  2142. env.skill = this;
  2143. Func f;
  2144. for (FuncTemplate t : _funcTemplates)
  2145. {
  2146. f = t.getFunc(env, this); // skill is owner
  2147. if (f != null)
  2148. funcs.add(f);
  2149. }
  2150. if (funcs.isEmpty())
  2151. return _emptyFunctionSet;
  2152. return funcs.toArray(new Func[funcs.size()]);
  2153. }
  2154. public boolean hasEffects()
  2155. {
  2156. return (_effectTemplates != null && _effectTemplates.length > 0);
  2157. }
  2158. public EffectTemplate[] getEffectTemplates()
  2159. {
  2160. return _effectTemplates;
  2161. }
  2162. public boolean hasSelfEffects()
  2163. {
  2164. return (_effectTemplatesSelf != null && _effectTemplatesSelf.length > 0);
  2165. }
  2166. /**
  2167. * Env is used to pass parameters for secondary effects (shield and ss/bss/bsss)
  2168. *
  2169. * @return an array with the effects that have been added to effector
  2170. */
  2171. public final L2Effect[] getEffects(L2Character effector, L2Character effected, Env env)
  2172. {
  2173. if (!hasEffects() || isPassive())
  2174. return _emptyEffectSet;
  2175. // doors and siege flags cannot receive any effects
  2176. if (effected instanceof L2DoorInstance ||effected instanceof L2SiegeFlagInstance )
  2177. return _emptyEffectSet;
  2178. if (effector != effected)
  2179. {
  2180. if (isOffensive() || isDebuff())
  2181. {
  2182. if (effected.isInvul())
  2183. return _emptyEffectSet;
  2184. if (effector instanceof L2PcInstance && ((L2PcInstance)effector).isGM())
  2185. {
  2186. if (!((L2PcInstance)effector).getAccessLevel().canGiveDamage())
  2187. return _emptyEffectSet;
  2188. }
  2189. }
  2190. }
  2191. ArrayList<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplates.length);
  2192. if (env == null)
  2193. env = new Env();
  2194. env.skillMastery = Formulas.calcSkillMastery(effector, this);
  2195. env.player = effector;
  2196. env.target = effected;
  2197. env.skill = this;
  2198. for (EffectTemplate et : _effectTemplates)
  2199. {
  2200. boolean success = true;
  2201. if (et.effectPower > -1)
  2202. success = Formulas.calcEffectSuccess(effector, effected, et, this, env.shld, env.ss, env.sps, env.bss);
  2203. if (success)
  2204. {
  2205. L2Effect e = et.getEffect(env);
  2206. if (e != null)
  2207. {
  2208. e.scheduleEffect();
  2209. effects.add(e);
  2210. }
  2211. }
  2212. // display fail message only for effects with icons
  2213. else if (et.icon && effector instanceof L2PcInstance)
  2214. {
  2215. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
  2216. sm.addCharName(effected);
  2217. sm.addSkillName(this);
  2218. ((L2PcInstance)effector).sendPacket(sm);
  2219. }
  2220. }
  2221. if (effects.isEmpty()) return _emptyEffectSet;
  2222. return effects.toArray(new L2Effect[effects.size()]);
  2223. }
  2224. /**
  2225. * Warning: this method doesn't consider modifier (shield, ss, sps, bss) for secondary effects
  2226. *
  2227. */
  2228. public final L2Effect[] getEffects(L2Character effector, L2Character effected)
  2229. {
  2230. return getEffects(effector, effected, null);
  2231. }
  2232. /**
  2233. * This method has suffered some changes in CT2.2 ->CT2.3<br>
  2234. * Effect engine is now supporting secondary effects with independent
  2235. * success/fail calculus from effect skill. Env parameter has been added to
  2236. * pass parameters like soulshot, spiritshots, blessed spiritshots or shield deffence.
  2237. * Some other optimizations have been done
  2238. * <br><br>
  2239. * This new feature works following next rules:
  2240. * <li> To enable feature, effectPower must be over -1 (check DocumentSkill#attachEffect for further information)</li>
  2241. * <li> If main skill fails, secondary effect always fail</li>
  2242. */
  2243. public final L2Effect[] getEffects(L2CubicInstance effector, L2Character effected, Env env)
  2244. {
  2245. if (!hasEffects() || isPassive())
  2246. return _emptyEffectSet;
  2247. if (effector.getOwner() != effected)
  2248. {
  2249. if (isDebuff() || isOffensive())
  2250. {
  2251. if (effected.isInvul())
  2252. return _emptyEffectSet;
  2253. if (effector.getOwner().isGM() &&
  2254. !effector.getOwner().getAccessLevel().canGiveDamage())
  2255. {
  2256. return _emptyEffectSet;
  2257. }
  2258. }
  2259. }
  2260. ArrayList<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplates.length);
  2261. if (env == null)
  2262. env = new Env();
  2263. env.player = effector.getOwner();
  2264. env.cubic = effector;
  2265. env.target = effected;
  2266. env.skill = this;
  2267. for (EffectTemplate et : _effectTemplates)
  2268. {
  2269. boolean success = true;
  2270. if (et.effectPower > -1)
  2271. success = Formulas.calcEffectSuccess(effector.getOwner(), effected, et, this, env.shld, env.ss, env.sps, env.bss);
  2272. if (success)
  2273. {
  2274. L2Effect e = et.getEffect(env);
  2275. if (e != null)
  2276. {
  2277. e.scheduleEffect();
  2278. effects.add(e);
  2279. }
  2280. }
  2281. }
  2282. if (effects.isEmpty()) return _emptyEffectSet;
  2283. return effects.toArray(new L2Effect[effects.size()]);
  2284. }
  2285. public final L2Effect[] getEffectsSelf(L2Character effector)
  2286. {
  2287. if (!hasSelfEffects() || isPassive())
  2288. return _emptyEffectSet;
  2289. List<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplatesSelf.length);
  2290. for (EffectTemplate et : _effectTemplatesSelf)
  2291. {
  2292. Env env = new Env();
  2293. env.player = effector;
  2294. env.target = effector;
  2295. env.skill = this;
  2296. L2Effect e = et.getEffect(env);
  2297. if (e != null)
  2298. {
  2299. e.setSelfEffect();
  2300. e.scheduleEffect();
  2301. effects.add(e);
  2302. }
  2303. }
  2304. if (effects.isEmpty()) return _emptyEffectSet;
  2305. return effects.toArray(new L2Effect[effects.size()]);
  2306. }
  2307. public final void attach(FuncTemplate f)
  2308. {
  2309. if (_funcTemplates == null)
  2310. {
  2311. _funcTemplates = new FuncTemplate[] {f};
  2312. }
  2313. else
  2314. {
  2315. int len = _funcTemplates.length;
  2316. FuncTemplate[] tmp = new FuncTemplate[len + 1];
  2317. System.arraycopy(_funcTemplates, 0, tmp, 0, len);
  2318. tmp[len] = f;
  2319. _funcTemplates = tmp;
  2320. }
  2321. }
  2322. public final void attach(EffectTemplate effect)
  2323. {
  2324. if (_effectTemplates == null)
  2325. {
  2326. _effectTemplates = new EffectTemplate[] {effect};
  2327. }
  2328. else
  2329. {
  2330. int len = _effectTemplates.length;
  2331. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2332. System.arraycopy(_effectTemplates, 0, tmp, 0, len);
  2333. tmp[len] = effect;
  2334. _effectTemplates = tmp;
  2335. }
  2336. }
  2337. public final void attachSelf(EffectTemplate effect)
  2338. {
  2339. if (_effectTemplatesSelf == null)
  2340. {
  2341. _effectTemplatesSelf = new EffectTemplate[] {effect};
  2342. }
  2343. else
  2344. {
  2345. int len = _effectTemplatesSelf.length;
  2346. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2347. System.arraycopy(_effectTemplatesSelf, 0, tmp, 0, len);
  2348. tmp[len] = effect;
  2349. _effectTemplatesSelf = tmp;
  2350. }
  2351. }
  2352. public final void attach(Condition c, boolean itemOrWeapon)
  2353. {
  2354. if (itemOrWeapon)
  2355. {
  2356. if (_itemPreCondition == null)
  2357. _itemPreCondition = new FastList<Condition>();
  2358. _itemPreCondition.add(c);
  2359. }
  2360. else
  2361. {
  2362. if (_preCondition == null)
  2363. _preCondition = new FastList<Condition>();
  2364. _preCondition.add(c);
  2365. }
  2366. }
  2367. @Override
  2368. public String toString()
  2369. {
  2370. return "" + _name + "[id=" + _id + ",lvl=" + _level + "]";
  2371. }
  2372. /**
  2373. * @return pet food
  2374. */
  2375. public int getFeed()
  2376. {
  2377. return _feed;
  2378. }
  2379. /**
  2380. * used for tracking item id in case that item consume cannot be used
  2381. * @return reference item id
  2382. */
  2383. public int getReferenceItemId()
  2384. {
  2385. return _refId;
  2386. }
  2387. public final int getMaxCharges()
  2388. {
  2389. return _maxCharges;
  2390. }
  2391. public int getAfterEffectId()
  2392. {
  2393. return _afterEffectId;
  2394. }
  2395. public int getAfterEffectLvl()
  2396. {
  2397. return _afterEffectLvl;
  2398. }
  2399. @Override
  2400. public boolean triggersChanceSkill()
  2401. {
  2402. return _triggeredId > 0 && isChance();
  2403. }
  2404. @Override
  2405. public int getTriggeredChanceId()
  2406. {
  2407. return _triggeredId;
  2408. }
  2409. @Override
  2410. public int getTriggeredChanceLevel()
  2411. {
  2412. return _triggeredLevel;
  2413. }
  2414. @Override
  2415. public ChanceCondition getTriggeredChanceCondition()
  2416. {
  2417. return _chanceCondition;
  2418. }
  2419. public String getAttributeName()
  2420. {
  2421. return _attribute;
  2422. }
  2423. public boolean ignoreShield()
  2424. {
  2425. return _ignoreShield;
  2426. }
  2427. public boolean canBeReflected()
  2428. {
  2429. return _canBeReflected;
  2430. }
  2431. public boolean canBeDispeled()
  2432. {
  2433. return _canBeDispeled;
  2434. }
  2435. public boolean isClanSkill()
  2436. {
  2437. return _isClanSkill;
  2438. }
  2439. public boolean isExcludedFromCheck()
  2440. {
  2441. return _excludedFromCheck;
  2442. }
  2443. public float getDependOnTargetBuff()
  2444. {
  2445. return _dependOnTargetBuff;
  2446. }
  2447. public boolean isSimultaneousCast()
  2448. {
  2449. return _simultaneousCast;
  2450. }
  2451. }