L2Skill.java 80 KB

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