L2Skill.java 80 KB

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