L2Skill.java 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015
  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 net.sf.l2j.gameserver.model;
  16. import java.util.Collection;
  17. import java.util.List;
  18. import java.util.StringTokenizer;
  19. import java.util.logging.Level;
  20. import java.util.logging.Logger;
  21. import javolution.util.FastList;
  22. import net.sf.l2j.Config;
  23. import net.sf.l2j.gameserver.GeoData;
  24. import net.sf.l2j.gameserver.datatables.HeroSkillTable;
  25. import net.sf.l2j.gameserver.datatables.SkillTable;
  26. import net.sf.l2j.gameserver.datatables.SkillTreeTable;
  27. import net.sf.l2j.gameserver.model.actor.instance.L2ArtefactInstance;
  28. import net.sf.l2j.gameserver.model.actor.instance.L2ChestInstance;
  29. import net.sf.l2j.gameserver.model.actor.instance.L2CubicInstance;
  30. import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
  31. import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  32. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  33. import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  34. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  35. import net.sf.l2j.gameserver.model.actor.instance.L2SiegeFlagInstance;
  36. import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
  37. import net.sf.l2j.gameserver.model.base.ClassId;
  38. import net.sf.l2j.gameserver.network.SystemMessageId;
  39. import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  40. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  41. import net.sf.l2j.gameserver.skills.Env;
  42. import net.sf.l2j.gameserver.skills.Stats;
  43. import net.sf.l2j.gameserver.skills.conditions.Condition;
  44. import net.sf.l2j.gameserver.skills.effects.EffectCharge;
  45. import net.sf.l2j.gameserver.skills.effects.EffectTemplate;
  46. import net.sf.l2j.gameserver.skills.funcs.Func;
  47. import net.sf.l2j.gameserver.skills.funcs.FuncTemplate;
  48. import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
  49. import net.sf.l2j.gameserver.templates.L2SkillType;
  50. import net.sf.l2j.gameserver.templates.L2WeaponType;
  51. import net.sf.l2j.gameserver.templates.StatsSet;
  52. import net.sf.l2j.gameserver.util.Util;
  53. /**
  54. * This class...
  55. *
  56. * @version $Revision: 1.3.2.8.2.22 $ $Date: 2005/04/06 16:13:42 $
  57. */
  58. public abstract class L2Skill
  59. {
  60. protected static final Logger _log = Logger.getLogger(L2Skill.class.getName());
  61. public static final int SKILL_CUBIC_MASTERY = 143;
  62. public static final int SKILL_LUCKY = 194;
  63. public static final int SKILL_CREATE_COMMON = 1320;
  64. public static final int SKILL_CREATE_DWARVEN = 172;
  65. public static final int SKILL_CRYSTALLIZE = 248;
  66. public static final int SKILL_DIVINE_INSPIRATION = 1405;
  67. public static final int SKILL_CLAN_LUCK = 390;
  68. public static final int SKILL_FAKE_INT = 9001;
  69. public static final int SKILL_FAKE_WIT = 9002;
  70. public static final int SKILL_FAKE_MEN = 9003;
  71. public static final int SKILL_FAKE_CON = 9004;
  72. public static final int SKILL_FAKE_DEX = 9005;
  73. public static final int SKILL_FAKE_STR = 9006;
  74. public static enum SkillOpType
  75. {
  76. OP_PASSIVE, OP_ACTIVE, OP_TOGGLE, OP_CHANCE
  77. }
  78. /** Target types of skills : SELF, PARTY, CLAN, PET... */
  79. public static enum SkillTargetType
  80. {
  81. TARGET_NONE,
  82. TARGET_SELF,
  83. TARGET_ONE,
  84. TARGET_PARTY,
  85. TARGET_ALLY,
  86. TARGET_CLAN,
  87. TARGET_PET,
  88. TARGET_AREA,
  89. TARGET_FRONT_AREA,
  90. TARGET_BEHIND_AREA,
  91. TARGET_AURA,
  92. TARGET_FRONT_AURA,
  93. TARGET_BEHIND_AURA,
  94. TARGET_CORPSE,
  95. TARGET_UNDEAD,
  96. TARGET_AREA_UNDEAD,
  97. TARGET_MULTIFACE,
  98. TARGET_CORPSE_ALLY,
  99. TARGET_CORPSE_CLAN,
  100. TARGET_CORPSE_PLAYER,
  101. TARGET_CORPSE_PET,
  102. TARGET_ITEM,
  103. TARGET_AREA_CORPSE_MOB,
  104. TARGET_CORPSE_MOB,
  105. TARGET_UNLOCKABLE,
  106. TARGET_HOLY,
  107. TARGET_FLAGPOLE,
  108. TARGET_PARTY_MEMBER,
  109. TARGET_PARTY_OTHER,
  110. TARGET_ENEMY_SUMMON,
  111. TARGET_OWNER_PET,
  112. TARGET_GROUND
  113. }
  114. //elements
  115. public final static int ELEMENT_WIND = 1;
  116. public final static int ELEMENT_FIRE = 2;
  117. public final static int ELEMENT_WATER = 3;
  118. public final static int ELEMENT_EARTH = 4;
  119. public final static int ELEMENT_HOLY = 5;
  120. public final static int ELEMENT_DARK = 6;
  121. //save vs
  122. public final static int SAVEVS_INT = 1;
  123. public final static int SAVEVS_WIT = 2;
  124. public final static int SAVEVS_MEN = 3;
  125. public final static int SAVEVS_CON = 4;
  126. public final static int SAVEVS_DEX = 5;
  127. public final static int SAVEVS_STR = 6;
  128. //stat effected
  129. public final static int STAT_PATK = 301; // pAtk
  130. public final static int STAT_PDEF = 302; // pDef
  131. public final static int STAT_MATK = 303; // mAtk
  132. public final static int STAT_MDEF = 304; // mDef
  133. public final static int STAT_MAXHP = 305; // maxHp
  134. public final static int STAT_MAXMP = 306; // maxMp
  135. public final static int STAT_CURHP = 307;
  136. public final static int STAT_CURMP = 308;
  137. public final static int STAT_HPREGEN = 309; // regHp
  138. public final static int STAT_MPREGEN = 310; // regMp
  139. public final static int STAT_CASTINGSPEED = 311; // sCast
  140. public final static int STAT_ATKSPD = 312; // sAtk
  141. public final static int STAT_CRITDAM = 313; // critDmg
  142. public final static int STAT_CRITRATE = 314; // critRate
  143. public final static int STAT_FIRERES = 315; // fireRes
  144. public final static int STAT_WINDRES = 316; // windRes
  145. public final static int STAT_WATERRES = 317; // waterRes
  146. public final static int STAT_EARTHRES = 318; // earthRes
  147. public final static int STAT_HOLYRES = 336; // holyRes
  148. public final static int STAT_DARKRES = 337; // darkRes
  149. public final static int STAT_ROOTRES = 319; // rootRes
  150. public final static int STAT_SLEEPRES = 320; // sleepRes
  151. public final static int STAT_CONFUSIONRES = 321; // confusRes
  152. public final static int STAT_BREATH = 322; // breath
  153. public final static int STAT_AGGRESSION = 323; // aggr
  154. public final static int STAT_BLEED = 324; // bleed
  155. public final static int STAT_POISON = 325; // poison
  156. public final static int STAT_STUN = 326; // stun
  157. public final static int STAT_ROOT = 327; // root
  158. public final static int STAT_MOVEMENT = 328; // move
  159. public final static int STAT_EVASION = 329; // evas
  160. public final static int STAT_ACCURACY = 330; // accu
  161. public final static int STAT_COMBAT_STRENGTH = 331;
  162. public final static int STAT_COMBAT_WEAKNESS = 332;
  163. public final static int STAT_ATTACK_RANGE = 333; // rAtk
  164. public final static int STAT_NOAGG = 334; // noagg
  165. public final static int STAT_SHIELDDEF = 335; // sDef
  166. public final static int STAT_MP_CONSUME_RATE = 336; // Rate of mp consume per skill use
  167. public final static int STAT_HP_CONSUME_RATE = 337; // Rate of hp consume per skill use
  168. public final static int STAT_MCRITRATE = 338; // Magic Crit Rate
  169. //COMBAT DAMAGE MODIFIER SKILLS...DETECT WEAKNESS AND WEAKNESS/STRENGTH
  170. public final static int COMBAT_MOD_ANIMAL = 200;
  171. public final static int COMBAT_MOD_BEAST = 201;
  172. public final static int COMBAT_MOD_BUG = 202;
  173. public final static int COMBAT_MOD_DRAGON = 203;
  174. public final static int COMBAT_MOD_MONSTER = 204;
  175. public final static int COMBAT_MOD_PLANT = 205;
  176. public final static int COMBAT_MOD_HOLY = 206;
  177. public final static int COMBAT_MOD_UNHOLY = 207;
  178. public final static int COMBAT_MOD_BOW = 208;
  179. public final static int COMBAT_MOD_BLUNT = 209;
  180. public final static int COMBAT_MOD_DAGGER = 210;
  181. public final static int COMBAT_MOD_FIST = 211;
  182. public final static int COMBAT_MOD_DUAL = 212;
  183. public final static int COMBAT_MOD_SWORD = 213;
  184. public final static int COMBAT_MOD_POISON = 214;
  185. public final static int COMBAT_MOD_BLEED = 215;
  186. public final static int COMBAT_MOD_FIRE = 216;
  187. public final static int COMBAT_MOD_WATER = 217;
  188. public final static int COMBAT_MOD_EARTH = 218;
  189. public final static int COMBAT_MOD_WIND = 219;
  190. public final static int COMBAT_MOD_ROOT = 220;
  191. public final static int COMBAT_MOD_STUN = 221;
  192. public final static int COMBAT_MOD_CONFUSION = 222;
  193. public final static int COMBAT_MOD_DARK = 223;
  194. //conditional values
  195. public final static int COND_RUNNING = 0x0001;
  196. public final static int COND_WALKING = 0x0002;
  197. public final static int COND_SIT = 0x0004;
  198. public final static int COND_BEHIND = 0x0008;
  199. public final static int COND_CRIT = 0x0010;
  200. public final static int COND_LOWHP = 0x0020;
  201. public final static int COND_ROBES = 0x0040;
  202. public final static int COND_CHARGES = 0x0080;
  203. public final static int COND_SHIELD = 0x0100;
  204. public final static int COND_GRADEA = 0x010000;
  205. public final static int COND_GRADEB = 0x020000;
  206. public final static int COND_GRADEC = 0x040000;
  207. public final static int COND_GRADED = 0x080000;
  208. public final static int COND_GRADES = 0x100000;
  209. private static final Func[] _emptyFunctionSet = new Func[0];
  210. private static final L2Effect[] _emptyEffectSet = new L2Effect[0];
  211. // these two build the primary key
  212. private final int _id;
  213. private final int _level;
  214. /** Identifier for a skill that client can't display */
  215. private int _displayId;
  216. // not needed, just for easier debug
  217. private final String _name;
  218. private final SkillOpType _operateType;
  219. private final boolean _magic;
  220. private final int _mpConsume;
  221. private final int _mpInitialConsume;
  222. private final int _hpConsume;
  223. private final int _cpConsume;
  224. private final int _targetConsume;
  225. private final int _targetConsumeId;
  226. private final int _itemConsume;
  227. private final int _itemConsumeId;
  228. // item consume count over time
  229. private final int _itemConsumeOT;
  230. // item consume id over time
  231. private final int _itemConsumeIdOT;
  232. // how many times to consume an item
  233. private final int _itemConsumeSteps;
  234. // for summon spells:
  235. // a) What is the total lifetime of summons (in millisecs)
  236. private final int _summonTotalLifeTime;
  237. // b) how much lifetime is lost per second of idleness (non-fighting)
  238. private final int _summonTimeLostIdle;
  239. // c) how much time is lost per second of activity (fighting)
  240. private final int _summonTimeLostActive;
  241. private final boolean _isCubic;
  242. // cubic AI
  243. private final int _activationtime;
  244. private final int _activationchance;
  245. // item consume time in milliseconds
  246. private final int _itemConsumeTime;
  247. private final int _castRange;
  248. private final int _effectRange;
  249. // Remove Skill Effect
  250. private final int _cancelEffect;
  251. // kill by damage over time
  252. private final boolean _killByDOT;
  253. // all times in milliseconds
  254. private final int _hitTime;
  255. //private final int _skillInterruptTime;
  256. private final int _coolTime;
  257. private final int _reuseDelay;
  258. private final int _buffDuration;
  259. /** Target type of the skill : SELF, PARTY, CLAN, PET... */
  260. private final SkillTargetType _targetType;
  261. private final double _power;
  262. private final int _effectPoints;
  263. private final int _magicLevel;
  264. private final String[] _negateStats;
  265. private final float _negatePower;
  266. private final int _negateId;
  267. private final int _maxNegatedEffect;
  268. private final int _levelDepend;
  269. // Effecting area of the skill, in radius.
  270. // The radius center varies according to the _targetType:
  271. // "caster" if targetType = AURA/PARTY/CLAN or "target" if targetType = AREA
  272. private final int _skillRadius;
  273. private final L2SkillType _skillType;
  274. private final L2SkillType _effectType;
  275. private final int _effectPower;
  276. private final int _effectId;
  277. private final int _effectLvl;
  278. private final boolean _ispotion;
  279. private final int _element;
  280. private final int _savevs;
  281. private final boolean _isSuicideAttack;
  282. private final Stats _stat;
  283. private final int _condition;
  284. private final int _conditionValue;
  285. private final boolean _overhit;
  286. private final int _weaponsAllowed;
  287. private final int _armorsAllowed;
  288. private final int _addCrossLearn; // -1 disable, otherwice SP price for others classes, default 1000
  289. private final float _mulCrossLearn; // multiplay for others classes, default 2
  290. private final float _mulCrossLearnRace; // multiplay for others races, default 2
  291. private final float _mulCrossLearnProf; // multiplay for fighter/mage missmatch, default 3
  292. private final List<ClassId> _canLearn; // which classes can learn
  293. private final List<Integer> _teachers; // which NPC teaches
  294. private final int _minPledgeClass;
  295. private final boolean _isOffensive;
  296. private final int _numCharges;
  297. private final int _triggeredId;
  298. private final int _triggeredLevel;
  299. private final int _soulMaxConsume;
  300. private final int _soulConsume;
  301. private final int _numSouls;
  302. private final int _expNeeded;
  303. private final int _critChance;
  304. private final int _transformId;
  305. private final int _transformDuration;
  306. private final boolean _isHeroSkill; // If true the skill is a Hero Skill
  307. 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
  308. 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)
  309. 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)
  310. private final boolean _directHpDmg; // If true then dmg is being make directly
  311. private final boolean _isDance; // If true then casting more dances will cost more MP
  312. private final int _nextDanceCost;
  313. private final float _sSBoost; //If true skill will have SoulShot boost (power*2)
  314. private final int _aggroPoints;
  315. protected Condition _preCondition;
  316. protected Condition _itemPreCondition;
  317. protected FuncTemplate[] _funcTemplates;
  318. protected EffectTemplate[] _effectTemplates;
  319. protected EffectTemplate[] _effectTemplatesSelf;
  320. protected ChanceCondition _chanceCondition = null;
  321. // Flying support
  322. private final String _flyType;
  323. private final int _flyRadius;
  324. private final float _flyCourse;
  325. private final boolean _isDebuff;
  326. protected L2Skill(StatsSet set)
  327. {
  328. _id = set.getInteger("skill_id");
  329. _level = set.getInteger("level");
  330. _displayId = set.getInteger("displayId", _id);
  331. _name = set.getString("name");
  332. _operateType = set.getEnum("operateType", SkillOpType.class);
  333. _magic = set.getBool("isMagic", false);
  334. _ispotion = set.getBool("isPotion", false);
  335. _mpConsume = set.getInteger("mpConsume", 0);
  336. _mpInitialConsume = set.getInteger("mpInitialConsume", 0);
  337. _hpConsume = set.getInteger("hpConsume", 0);
  338. _cpConsume = set.getInteger("cpConsume", 0);
  339. _targetConsume = set.getInteger("targetConsumeCount", 0);
  340. _targetConsumeId = set.getInteger("targetConsumeId", 0);
  341. _itemConsume = set.getInteger("itemConsumeCount", 0);
  342. _itemConsumeId = set.getInteger("itemConsumeId", 0);
  343. _itemConsumeOT = set.getInteger("itemConsumeCountOT", 0);
  344. _itemConsumeIdOT = set.getInteger("itemConsumeIdOT", 0);
  345. _itemConsumeTime = set.getInteger("itemConsumeTime", 0);
  346. _itemConsumeSteps = set.getInteger("itemConsumeSteps", 0);
  347. _summonTotalLifeTime= set.getInteger("summonTotalLifeTime", 1200000); // 20 minutes default
  348. _summonTimeLostIdle= set.getInteger("summonTimeLostIdle", 0);
  349. _summonTimeLostActive= set.getInteger("summonTimeLostActive", 0);
  350. _isCubic = set.getBool("isCubic", false);
  351. _activationtime= set.getInteger("activationtime", 8);
  352. _activationchance= set.getInteger("activationchance", 30);
  353. _castRange = set.getInteger("castRange", 0);
  354. _effectRange = set.getInteger("effectRange", -1);
  355. _cancelEffect = set.getInteger("cancelEffect", 0);
  356. _killByDOT = set.getBool("killByDOT", false);
  357. _hitTime = set.getInteger("hitTime", 0);
  358. _coolTime = set.getInteger("coolTime", 0);
  359. _isDebuff = set.getBool("isDebuff", false);
  360. if (Config.ENABLE_MODIFY_SKILL_REUSE && Config.SKILL_REUSE_LIST.containsKey(_id))
  361. {
  362. if ( Config.DEBUG )
  363. _log.info("*** Skill " + _name + " (" + _level + ") changed reuse from " + set.getInteger("reuseDelay", 0) + " to " + Config.SKILL_REUSE_LIST.get(_id) + " seconds.");
  364. _reuseDelay = Config.SKILL_REUSE_LIST.get(_id);
  365. }
  366. else
  367. {
  368. _reuseDelay = set.getInteger("reuseDelay", 0);
  369. }
  370. _buffDuration = set.getInteger("buffDuration", 0);
  371. _skillRadius = set.getInteger("skillRadius", 80);
  372. _targetType = set.getEnum("target", SkillTargetType.class);
  373. _power = set.getFloat("power", 0.f);
  374. _effectPoints = set.getInteger("effectPoints", 0);
  375. _negateStats = set.getString("negateStats", "").split(" ");
  376. _negatePower = set.getFloat("negatePower", 0.f);
  377. _negateId = set.getInteger("negateId", 0);
  378. _maxNegatedEffect = set.getInteger("maxNegated", 0);
  379. _magicLevel = set.getInteger("magicLvl", SkillTreeTable.getInstance().getMinSkillLevel(_id, _level));
  380. _levelDepend = set.getInteger("lvlDepend", 0);
  381. _stat = set.getEnum("stat", Stats.class, null);
  382. _skillType = set.getEnum("skillType", L2SkillType.class);
  383. _effectType = set.getEnum("effectType", L2SkillType.class, null);
  384. _effectPower = set.getInteger("effectPower", 0);
  385. _effectId = set.getInteger("effectId", 0);
  386. _effectLvl = set.getInteger("effectLevel", 0);
  387. _element = set.getInteger("element", 0);
  388. _savevs = set.getInteger("save", 0);
  389. _condition = set.getInteger("condition", 0);
  390. _conditionValue = set.getInteger("conditionValue", 0);
  391. _overhit = set.getBool("overHit", false);
  392. _isSuicideAttack = set.getBool("isSuicideAttack", false);
  393. _weaponsAllowed = set.getInteger("weaponsAllowed", 0);
  394. _armorsAllowed = set.getInteger("armorsAllowed", 0);
  395. _addCrossLearn = set.getInteger("addCrossLearn", 1000);
  396. _mulCrossLearn = set.getFloat("mulCrossLearn", 2.f);
  397. _mulCrossLearnRace = set.getFloat("mulCrossLearnRace", 2.f);
  398. _mulCrossLearnProf = set.getFloat("mulCrossLearnProf", 3.f);
  399. _minPledgeClass = set.getInteger("minPledgeClass", 0);
  400. _isOffensive = set.getBool("offensive", isSkillTypeOffensive());
  401. _numCharges = set.getInteger("num_charges", getLevel());
  402. _triggeredId = set.getInteger("triggeredId", 0);
  403. _triggeredLevel = set.getInteger("triggeredLevel", 0);
  404. if (_operateType == SkillOpType.OP_CHANCE)
  405. _chanceCondition = ChanceCondition.parse(set);
  406. _numSouls = set.getInteger("num_souls", 0);
  407. _soulMaxConsume = set.getInteger("soulMaxConsumeCount", 0);
  408. _soulConsume = set.getInteger("soulConsumeCount", 0);
  409. _expNeeded = set.getInteger("expNeeded", 0);
  410. _critChance = set.getInteger("critChance", 0);
  411. _transformId = set.getInteger("transformId", 0);
  412. _transformDuration = set.getInteger("transformDuration", 0);
  413. _isHeroSkill = HeroSkillTable.isHeroSkill(_id);
  414. _baseCritRate = set.getInteger("baseCritRate", (_skillType == L2SkillType.PDAM || _skillType == L2SkillType.BLOW) ? 0 : -1);
  415. _lethalEffect1 = set.getInteger("lethal1",0);
  416. _lethalEffect2 = set.getInteger("lethal2",0);
  417. _directHpDmg = set.getBool("dmgDirectlyToHp",false);
  418. _isDance = set.getBool("isDance",false);
  419. _nextDanceCost = set.getInteger("nextDanceCost", 0);
  420. _sSBoost = set.getFloat("SSBoost", 0.f);
  421. _aggroPoints = set.getInteger("aggroPoints", 0);
  422. _flyType = set.getString("flyType", null);
  423. _flyRadius = set.getInteger("flyRadius", 200);
  424. _flyCourse = set.getFloat("flyCourse", 0);
  425. String canLearn = set.getString("canLearn", null);
  426. if (canLearn == null)
  427. {
  428. _canLearn = null;
  429. }
  430. else
  431. {
  432. _canLearn = new FastList<ClassId>();
  433. StringTokenizer st = new StringTokenizer(canLearn, " \r\n\t,;");
  434. while (st.hasMoreTokens())
  435. {
  436. String cls = st.nextToken();
  437. try
  438. {
  439. _canLearn.add(ClassId.valueOf(cls));
  440. }
  441. catch (Throwable t)
  442. {
  443. _log.log(Level.SEVERE, "Bad class " + cls + " to learn skill", t);
  444. }
  445. }
  446. }
  447. String teachers = set.getString("teachers", null);
  448. if (teachers == null)
  449. {
  450. _teachers = null;
  451. }
  452. else
  453. {
  454. _teachers = new FastList<Integer>();
  455. StringTokenizer st = new StringTokenizer(teachers, " \r\n\t,;");
  456. while (st.hasMoreTokens())
  457. {
  458. String npcid = st.nextToken();
  459. try
  460. {
  461. _teachers.add(Integer.parseInt(npcid));
  462. }
  463. catch (Throwable t)
  464. {
  465. _log.log(Level.SEVERE, "Bad teacher id " + npcid + " to teach skill", t);
  466. }
  467. }
  468. }
  469. }
  470. public abstract void useSkill(L2Character caster, L2Object[] targets);
  471. public final boolean isPotion()
  472. {
  473. return _ispotion;
  474. }
  475. public final int getArmorsAllowed()
  476. {
  477. return _armorsAllowed;
  478. }
  479. public final int getConditionValue()
  480. {
  481. return _conditionValue;
  482. }
  483. public final L2SkillType getSkillType()
  484. {
  485. return _skillType;
  486. }
  487. public final int getSavevs()
  488. {
  489. return _savevs;
  490. }
  491. public final int getElement()
  492. {
  493. return _element;
  494. }
  495. /**
  496. * Return the target type of the skill : SELF, PARTY, CLAN, PET...<BR><BR>
  497. *
  498. */
  499. public final SkillTargetType getTargetType()
  500. {
  501. return _targetType;
  502. }
  503. public final int getCondition()
  504. {
  505. return _condition;
  506. }
  507. public final boolean isOverhit()
  508. {
  509. return _overhit;
  510. }
  511. public final boolean killByDOT()
  512. {
  513. return _killByDOT;
  514. }
  515. public final int cancelEffect()
  516. {
  517. return _cancelEffect;
  518. }
  519. public final boolean isSuicideAttack()
  520. {
  521. return _isSuicideAttack;
  522. }
  523. /**
  524. * Return the power of the skill.<BR><BR>
  525. */
  526. public final double getPower(L2Character activeChar)
  527. {
  528. if (_skillType == L2SkillType.DEATHLINK && activeChar != null) return _power
  529. * Math.pow(1.7165 - activeChar.getCurrentHp() / activeChar.getMaxHp(), 2) * 0.577;
  530. else return _power;
  531. }
  532. public final double getPower()
  533. {
  534. return _power;
  535. }
  536. public final int getEffectPoints()
  537. {
  538. return _effectPoints;
  539. }
  540. public final String[] getNegateStats()
  541. {
  542. return _negateStats;
  543. }
  544. public final float getNegatePower()
  545. {
  546. return _negatePower;
  547. }
  548. public final int getNegateId()
  549. {
  550. return _negateId;
  551. }
  552. public final int getMagicLevel()
  553. {
  554. return _magicLevel;
  555. }
  556. public final int getMaxNegatedEffects()
  557. {
  558. return _maxNegatedEffect;
  559. }
  560. public final int getLevelDepend()
  561. {
  562. return _levelDepend;
  563. }
  564. /**
  565. * Return the additional effect power or base probability.<BR><BR>
  566. */
  567. public final int getEffectPower()
  568. {
  569. return _effectPower;
  570. }
  571. /**
  572. * Return the additional effect Id.<BR><BR>
  573. */
  574. public final int getEffectId()
  575. {
  576. return _effectId;
  577. }
  578. /**
  579. * Return the additional effect level.<BR><BR>
  580. */
  581. public final int getEffectLvl()
  582. {
  583. return _effectLvl;
  584. }
  585. /**
  586. * Return the additional effect skill type (ex : STUN, PARALYZE,...).<BR><BR>
  587. */
  588. public final L2SkillType getEffectType()
  589. {
  590. return _effectType;
  591. }
  592. /**
  593. * @return Returns the buffDuration.
  594. */
  595. public final int getBuffDuration()
  596. {
  597. return _buffDuration;
  598. }
  599. /**
  600. * @return Returns the castRange.
  601. */
  602. public final int getCastRange()
  603. {
  604. return _castRange;
  605. }
  606. /**
  607. * @return Returns the cpConsume;
  608. */
  609. public final int getCpConsume()
  610. {
  611. return _cpConsume;
  612. }
  613. /**
  614. * @return Returns the effectRange.
  615. */
  616. public final int getEffectRange()
  617. {
  618. return _effectRange;
  619. }
  620. /**
  621. * @return Returns the hpConsume.
  622. */
  623. public final int getHpConsume()
  624. {
  625. return _hpConsume;
  626. }
  627. /**
  628. * @return Returns the id.
  629. */
  630. public final int getId()
  631. {
  632. return _id;
  633. }
  634. /**
  635. * @return Returns the boolean _isDebuff.
  636. */
  637. public final boolean isDebuff()
  638. {
  639. return _isDebuff;
  640. }
  641. public int getDisplayId()
  642. {
  643. return _displayId;
  644. }
  645. public void setDisplayId(int id)
  646. {
  647. _displayId = id;
  648. }
  649. public int getTriggeredId()
  650. {
  651. return _triggeredId;
  652. }
  653. public int getTriggeredLevel()
  654. {
  655. return _triggeredLevel;
  656. }
  657. /**
  658. * Return the skill type (ex : BLEED, SLEEP, WATER...).<BR><BR>
  659. */
  660. public final Stats getStat()
  661. {
  662. return _stat;
  663. }
  664. /**
  665. * @return Returns the _targetConsumeId.
  666. */
  667. public final int getTargetConsumeId()
  668. {
  669. return _targetConsumeId;
  670. }
  671. /**
  672. * @return Returns the targetConsume.
  673. */
  674. public final int getTargetConsume()
  675. {
  676. return _targetConsume;
  677. }
  678. /**
  679. * @return Returns the itemConsume.
  680. */
  681. public final int getItemConsume()
  682. {
  683. return _itemConsume;
  684. }
  685. /**
  686. * @return Returns the itemConsumeId.
  687. */
  688. public final int getItemConsumeId()
  689. {
  690. return _itemConsumeId;
  691. }
  692. /**
  693. * @return Returns the itemConsume count over time.
  694. */
  695. public final int getItemConsumeOT()
  696. {
  697. return _itemConsumeOT;
  698. }
  699. /**
  700. * @return Returns the itemConsumeId over time.
  701. */
  702. public final int getItemConsumeIdOT()
  703. {
  704. return _itemConsumeIdOT;
  705. }
  706. /**
  707. * @return Returns the itemConsume count over time.
  708. */
  709. public final int getItemConsumeSteps()
  710. {
  711. return _itemConsumeSteps;
  712. }
  713. /**
  714. * @return Returns the itemConsume count over time.
  715. */
  716. public final int getTotalLifeTime()
  717. {
  718. return _summonTotalLifeTime;
  719. }
  720. /**
  721. * @return Returns the itemConsume count over time.
  722. */
  723. public final int getTimeLostIdle()
  724. {
  725. return _summonTimeLostIdle;
  726. }
  727. /**
  728. * @return Returns the itemConsumeId over time.
  729. */
  730. public final int getTimeLostActive()
  731. {
  732. return _summonTimeLostActive;
  733. }
  734. public final boolean isCubic()
  735. {
  736. return _isCubic;
  737. }
  738. /**
  739. * @return Returns the itemConsume time in milliseconds.
  740. */
  741. public final int getItemConsumeTime()
  742. {
  743. return _itemConsumeTime;
  744. }
  745. /**
  746. * @return Returns the activation time for a cubic.
  747. */
  748. public final int getActivationTime()
  749. {
  750. return _activationtime;
  751. }
  752. /**
  753. * @return Returns the activation chance for a cubic.
  754. */
  755. public final int getActivationChance()
  756. {
  757. return _activationchance;
  758. }
  759. /**
  760. * @return Returns the level.
  761. */
  762. public final int getLevel()
  763. {
  764. return _level;
  765. }
  766. /**
  767. * @return Returns the magic.
  768. */
  769. public final boolean isMagic()
  770. {
  771. return _magic;
  772. }
  773. /**
  774. * @return Returns the mpConsume.
  775. */
  776. public final int getMpConsume()
  777. {
  778. return _mpConsume;
  779. }
  780. /**
  781. * @return Returns the mpInitialConsume.
  782. */
  783. public final int getMpInitialConsume()
  784. {
  785. return _mpInitialConsume;
  786. }
  787. /**
  788. * @return Returns the name.
  789. */
  790. public final String getName()
  791. {
  792. return _name;
  793. }
  794. /**
  795. * @return Returns the reuseDelay.
  796. */
  797. public final int getReuseDelay()
  798. {
  799. return _reuseDelay;
  800. }
  801. public final int getHitTime()
  802. {
  803. return _hitTime;
  804. }
  805. /**
  806. * @return Returns the coolTime.
  807. */
  808. public final int getCoolTime()
  809. {
  810. return _coolTime;
  811. }
  812. public final int getSkillRadius()
  813. {
  814. return _skillRadius;
  815. }
  816. public final boolean isActive()
  817. {
  818. return _operateType == SkillOpType.OP_ACTIVE;
  819. }
  820. public final boolean isPassive()
  821. {
  822. return _operateType == SkillOpType.OP_PASSIVE;
  823. }
  824. public final boolean isToggle()
  825. {
  826. return _operateType == SkillOpType.OP_TOGGLE;
  827. }
  828. public final boolean isChance()
  829. {
  830. return _operateType == SkillOpType.OP_CHANCE;
  831. }
  832. public ChanceCondition getChanceCondition()
  833. {
  834. return _chanceCondition;
  835. }
  836. public final boolean isDance()
  837. {
  838. return _isDance;
  839. }
  840. public final int getNextDanceMpCost()
  841. {
  842. return _nextDanceCost;
  843. }
  844. public final float getSSBoost()
  845. {
  846. return _sSBoost;
  847. }
  848. public final int getAggroPoints()
  849. {
  850. return _aggroPoints;
  851. }
  852. public final boolean useSoulShot()
  853. {
  854. return ((getSkillType() == L2SkillType.PDAM) || (getSkillType() == L2SkillType.STUN) || (getSkillType() == L2SkillType.CHARGEDAM));
  855. }
  856. public final boolean useSpiritShot()
  857. {
  858. return isMagic();
  859. }
  860. public final boolean useFishShot()
  861. {
  862. return ((getSkillType() == L2SkillType.PUMPING) || (getSkillType() == L2SkillType.REELING) );
  863. }
  864. public final int getWeaponsAllowed()
  865. {
  866. return _weaponsAllowed;
  867. }
  868. public final int getCrossLearnAdd()
  869. {
  870. return _addCrossLearn;
  871. }
  872. public final float getCrossLearnMul()
  873. {
  874. return _mulCrossLearn;
  875. }
  876. public final float getCrossLearnRace()
  877. {
  878. return _mulCrossLearnRace;
  879. }
  880. public final float getCrossLearnProf()
  881. {
  882. return _mulCrossLearnProf;
  883. }
  884. public final boolean getCanLearn(ClassId cls)
  885. {
  886. return _canLearn == null || _canLearn.contains(cls);
  887. }
  888. public final boolean canTeachBy(int npcId)
  889. {
  890. return _teachers == null || _teachers.contains(npcId);
  891. }
  892. public int getMinPledgeClass() { return _minPledgeClass; }
  893. public final boolean isPvpSkill()
  894. {
  895. switch (_skillType)
  896. {
  897. case DOT:
  898. case BLEED:
  899. case CONFUSION:
  900. case POISON:
  901. case DEBUFF:
  902. case AGGDEBUFF:
  903. case STUN:
  904. case ROOT:
  905. case FEAR:
  906. case SLEEP:
  907. case MDOT:
  908. case MUTE:
  909. case WEAKNESS:
  910. case PARALYZE:
  911. case CANCEL:
  912. case MAGE_BANE:
  913. case WARRIOR_BANE:
  914. case BETRAY:
  915. case DISARM:
  916. case AGGDAMAGE:
  917. return true;
  918. default:
  919. return false;
  920. }
  921. }
  922. public final boolean isOffensive()
  923. {
  924. return _isOffensive;
  925. }
  926. public final boolean isHeroSkill()
  927. {
  928. return _isHeroSkill;
  929. }
  930. public final int getNumCharges()
  931. {
  932. return _numCharges;
  933. }
  934. public final int getNumSouls()
  935. {
  936. return _numSouls;
  937. }
  938. public final int getMaxSoulConsumeCount()
  939. {
  940. return _soulMaxConsume;
  941. }
  942. public final int getSoulConsumeCount()
  943. {
  944. return _soulConsume;
  945. }
  946. public final int getExpNeeded()
  947. {
  948. return _expNeeded;
  949. }
  950. public final int getCritChance()
  951. {
  952. return _critChance;
  953. }
  954. public final int getTransformId()
  955. {
  956. return _transformId;
  957. }
  958. public final int getTransformDuration()
  959. {
  960. return _transformDuration;
  961. }
  962. public final int getBaseCritRate()
  963. {
  964. return _baseCritRate;
  965. }
  966. public final int getLethalChance1()
  967. {
  968. return _lethalEffect1;
  969. }
  970. public final int getLethalChance2()
  971. {
  972. return _lethalEffect2;
  973. }
  974. public final boolean getDmgDirectlyToHP()
  975. {
  976. return _directHpDmg;
  977. }
  978. public final String getFlyType()
  979. {
  980. return _flyType;
  981. }
  982. public final int getFlyRadius()
  983. {
  984. return _flyRadius;
  985. }
  986. public final float getFlyCourse()
  987. {
  988. return _flyCourse;
  989. }
  990. public final boolean isSkillTypeOffensive()
  991. {
  992. switch (_skillType)
  993. {
  994. case PDAM:
  995. case MDAM:
  996. case CPDAM:
  997. case DOT:
  998. case BLEED:
  999. case POISON:
  1000. case AGGDAMAGE:
  1001. case DEBUFF:
  1002. case AGGDEBUFF:
  1003. case STUN:
  1004. case ROOT:
  1005. case CONFUSION:
  1006. case ERASE:
  1007. case BLOW:
  1008. case FEAR:
  1009. case DRAIN:
  1010. case SLEEP:
  1011. case CHARGEDAM:
  1012. case CONFUSE_MOB_ONLY:
  1013. case DEATHLINK:
  1014. case DETECT_WEAKNESS:
  1015. case MANADAM:
  1016. case MDOT:
  1017. case MUTE:
  1018. case SOULSHOT:
  1019. case SPIRITSHOT:
  1020. case SPOIL:
  1021. case WEAKNESS:
  1022. case MANA_BY_LEVEL:
  1023. case SWEEP:
  1024. case PARALYZE:
  1025. case DRAIN_SOUL:
  1026. case AGGREDUCE:
  1027. case CANCEL:
  1028. case MAGE_BANE:
  1029. case WARRIOR_BANE:
  1030. case AGGREMOVE:
  1031. case AGGREDUCE_CHAR:
  1032. case BETRAY:
  1033. case DELUXE_KEY_UNLOCK:
  1034. case SOW:
  1035. case HARVEST:
  1036. case DISARM:
  1037. return true;
  1038. default:
  1039. return false;
  1040. }
  1041. }
  1042. // int weapons[] = {L2Weapon.WEAPON_TYPE_ETC, L2Weapon.WEAPON_TYPE_BOW,
  1043. // L2Weapon.WEAPON_TYPE_POLE, L2Weapon.WEAPON_TYPE_DUALFIST,
  1044. // L2Weapon.WEAPON_TYPE_DUAL, L2Weapon.WEAPON_TYPE_BLUNT,
  1045. // L2Weapon.WEAPON_TYPE_SWORD, L2Weapon.WEAPON_TYPE_DAGGER};
  1046. public final boolean getWeaponDependancy(L2Character activeChar)
  1047. {
  1048. int weaponsAllowed = getWeaponsAllowed();
  1049. //check to see if skill has a weapon dependency.
  1050. if (weaponsAllowed == 0) return true;
  1051. if (activeChar.getActiveWeaponItem() != null)
  1052. {
  1053. L2WeaponType playerWeapon;
  1054. playerWeapon = activeChar.getActiveWeaponItem().getItemType();
  1055. int mask = playerWeapon.mask();
  1056. if ((mask & weaponsAllowed) != 0) return true;
  1057. // can be on the secondary weapon
  1058. if (activeChar.getSecondaryWeaponItem() != null)
  1059. {
  1060. playerWeapon = activeChar.getSecondaryWeaponItem().getItemType();
  1061. mask = playerWeapon.mask();
  1062. if ((mask & weaponsAllowed) != 0) return true;
  1063. }
  1064. }
  1065. SystemMessage message = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  1066. message.addSkillName(this);
  1067. activeChar.sendPacket(message);
  1068. return false;
  1069. }
  1070. public boolean checkCondition(L2Character activeChar, L2Object target, boolean itemOrWeapon)
  1071. {
  1072. if ((getCondition() & L2Skill.COND_SHIELD) != 0)
  1073. {
  1074. /*
  1075. L2Armor armorPiece;
  1076. L2ItemInstance dummy;
  1077. dummy = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  1078. armorPiece = (L2Armor) dummy.getItem();
  1079. */
  1080. //TODO add checks for shield here.
  1081. }
  1082. Condition preCondition = _preCondition;
  1083. if(itemOrWeapon) preCondition = _itemPreCondition;
  1084. if (preCondition == null) return true;
  1085. Env env = new Env();
  1086. env.player = activeChar;
  1087. if (target instanceof L2Character) // TODO: object or char?
  1088. env.target = (L2Character)target;
  1089. env.skill = this;
  1090. if (!preCondition.test(env))
  1091. {
  1092. String msg = preCondition.getMessage();
  1093. if (msg != null)
  1094. {
  1095. activeChar.sendMessage(msg);
  1096. }
  1097. return false;
  1098. }
  1099. return true;
  1100. }
  1101. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst)
  1102. {
  1103. // Init to null the target of the skill
  1104. L2Character target = null;
  1105. // Get the L2Objcet targeted by the user of the skill at this moment
  1106. L2Object objTarget = activeChar.getTarget();
  1107. // If the L2Object targeted is a L2Character, it becomes the L2Character target
  1108. if (objTarget instanceof L2Character)
  1109. {
  1110. target = (L2Character) objTarget;
  1111. }
  1112. return getTargetList(activeChar, onlyFirst, target);
  1113. }
  1114. /**
  1115. * Return all targets of the skill in a table in function a the skill type.<BR><BR>
  1116. *
  1117. * <B><U> Values of skill type</U> :</B><BR><BR>
  1118. * <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>
  1119. * <li>SELF</li>
  1120. * <li>HOLY, UNDEAD</li>
  1121. * <li>PET</li>
  1122. * <li>AURA, AURA_CLOSE</li>
  1123. * <li>AREA</li>
  1124. * <li>MULTIFACE</li>
  1125. * <li>PARTY, CLAN</li>
  1126. * <li>CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN</li>
  1127. * <li>UNLOCKABLE</li>
  1128. * <li>ITEM</li><BR><BR>
  1129. *
  1130. * @param activeChar The L2Character who use the skill
  1131. *
  1132. */
  1133. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst, L2Character target)
  1134. {
  1135. List<L2Character> targetList = new FastList<L2Character>();
  1136. // Get the target type of the skill
  1137. // (ex : ONE, SELF, HOLY, PET, AURA, AURA_CLOSE, AREA, MULTIFACE, PARTY, CLAN, CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN, UNLOCKABLE, ITEM, UNDEAD)
  1138. SkillTargetType targetType = getTargetType();
  1139. // Get the type of the skill
  1140. // (ex : PDAM, MDAM, DOT, BLEED, POISON, HEAL, HOT, MANAHEAL, MANARECHARGE, AGGDAMAGE, BUFF, DEBUFF, STUN, ROOT, RESURRECT, PASSIVE...)
  1141. L2SkillType skillType = getSkillType();
  1142. switch (targetType)
  1143. {
  1144. // The skill can only be used on the L2Character targeted, or on the caster itself
  1145. case TARGET_ONE:
  1146. {
  1147. boolean canTargetSelf = false;
  1148. switch (skillType)
  1149. {
  1150. case BUFF:
  1151. case HEAL:
  1152. case HOT:
  1153. case HEAL_PERCENT:
  1154. case MANARECHARGE:
  1155. case MANAHEAL:
  1156. case NEGATE:
  1157. case CANCEL:
  1158. case CANCEL_DEBUFF:
  1159. case REFLECT:
  1160. case UNBLEED:
  1161. case UNPOISON:
  1162. case COMBATPOINTHEAL:
  1163. case MAGE_BANE:
  1164. case WARRIOR_BANE:
  1165. case BETRAY:
  1166. case BALANCE_LIFE:
  1167. case FORCE_BUFF:
  1168. canTargetSelf = true;
  1169. break;
  1170. }
  1171. // Check for null target or any other invalid target
  1172. if (target == null || target.isDead() || (target == activeChar && !canTargetSelf))
  1173. {
  1174. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1175. return null;
  1176. }
  1177. // If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
  1178. return new L2Character[] {target};
  1179. }
  1180. case TARGET_SELF:
  1181. case TARGET_GROUND:
  1182. {
  1183. return new L2Character[] {activeChar};
  1184. }
  1185. case TARGET_HOLY:
  1186. {
  1187. if (activeChar instanceof L2PcInstance)
  1188. {
  1189. if (target instanceof L2ArtefactInstance)
  1190. return new L2Character[] {target};
  1191. }
  1192. return null;
  1193. }
  1194. case TARGET_FLAGPOLE:
  1195. {
  1196. return new L2Character[] {activeChar};
  1197. }
  1198. case TARGET_PET:
  1199. {
  1200. target = activeChar.getPet();
  1201. if (target != null && !target.isDead()) return new L2Character[] {target};
  1202. return null;
  1203. }
  1204. case TARGET_OWNER_PET:
  1205. {
  1206. if (activeChar instanceof L2Summon)
  1207. {
  1208. target = ((L2Summon)activeChar).getOwner();
  1209. if (target != null && !target.isDead())
  1210. return new L2Character[]{target};
  1211. }
  1212. return null;
  1213. }
  1214. case TARGET_CORPSE_PET:
  1215. {
  1216. if (activeChar instanceof L2PcInstance)
  1217. {
  1218. target = activeChar.getPet();
  1219. if (target != null && target.isDead())
  1220. return new L2Character[]{target};
  1221. }
  1222. return null;
  1223. }
  1224. case TARGET_AURA:
  1225. {
  1226. int radius = getSkillRadius();
  1227. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1228. L2PcInstance src = null;
  1229. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1230. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1231. else if (activeChar instanceof L2Decoy) src = ((L2Decoy)activeChar).getOwner();
  1232. else if (activeChar instanceof L2Trap) src = ((L2Trap)activeChar).getOwner();
  1233. // Go through the L2Character _knownList
  1234. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1235. //synchronized (activeChar.getKnownList().getKnownObjects())
  1236. {
  1237. for (L2Object obj : objs)
  1238. {
  1239. if (obj instanceof L2Attackable
  1240. || obj instanceof L2PlayableInstance)
  1241. {
  1242. // Don't add this target if this is a Pc->Pc pvp
  1243. // casting and pvp condition not met
  1244. if (obj == activeChar || obj == src
  1245. || ((L2Character) obj).isDead())
  1246. continue;
  1247. if (src != null)
  1248. {
  1249. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1250. continue;
  1251. // check if both attacker and target are
  1252. // L2PcInstances and if they are in same party
  1253. if (obj instanceof L2PcInstance)
  1254. {
  1255. if (!src.checkPvpSkill(obj, this))
  1256. continue;
  1257. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1258. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1259. continue;
  1260. if (!srcInArena
  1261. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1262. {
  1263. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1264. && src.getAllyId() != 0)
  1265. continue;
  1266. if (src.getClanId() != 0
  1267. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1268. continue;
  1269. }
  1270. }
  1271. if (obj instanceof L2Summon)
  1272. {
  1273. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1274. if (trg == src)
  1275. continue;
  1276. if (!src.checkPvpSkill(trg, this))
  1277. continue;
  1278. if ((src.getParty() != null && trg.getParty() != null)
  1279. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1280. continue;
  1281. if (!srcInArena
  1282. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1283. {
  1284. if (src.getAllyId() == trg.getAllyId()
  1285. && src.getAllyId() != 0)
  1286. continue;
  1287. if (src.getClanId() != 0
  1288. && src.getClanId() == trg.getClanId())
  1289. continue;
  1290. }
  1291. }
  1292. }
  1293. else
  1294. // Skill user is not L2PlayableInstance
  1295. {
  1296. if (!(obj instanceof L2PlayableInstance) // Target
  1297. // is
  1298. // not
  1299. // L2PlayableInstance
  1300. && !activeChar.isConfused()) // and
  1301. // caster
  1302. // not
  1303. // confused
  1304. // (?)
  1305. continue;
  1306. }
  1307. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1308. continue;
  1309. if (onlyFirst == false)
  1310. targetList.add((L2Character) obj);
  1311. else
  1312. return new L2Character[] { (L2Character) obj };
  1313. }
  1314. }
  1315. }
  1316. return targetList.toArray(new L2Character[targetList.size()]);
  1317. }
  1318. case TARGET_FRONT_AURA:
  1319. {
  1320. int radius = getSkillRadius();
  1321. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1322. L2PcInstance src = null;
  1323. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1324. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1325. else if (activeChar instanceof L2Trap) src = ((L2Trap)activeChar).getOwner();
  1326. // Go through the L2Character _knownList
  1327. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1328. //synchronized (activeChar.getKnownList().getKnownObjects())
  1329. {
  1330. for (L2Object obj : objs)
  1331. {
  1332. if (obj instanceof L2Attackable
  1333. || obj instanceof L2PlayableInstance)
  1334. {
  1335. // Don't add this target if this is a Pc->Pc pvp
  1336. // casting and pvp condition not met
  1337. if (obj == activeChar || obj == src
  1338. || ((L2Character) obj).isDead())
  1339. continue;
  1340. if (src != null)
  1341. {
  1342. if (!((L2Character) obj).isInFrontOf(activeChar))
  1343. continue;
  1344. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1345. continue;
  1346. // check if both attacker and target are
  1347. // L2PcInstances and if they are in same party
  1348. if (obj instanceof L2PcInstance)
  1349. {
  1350. if (!src.checkPvpSkill(obj, this))
  1351. continue;
  1352. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1353. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1354. continue;
  1355. if (!srcInArena
  1356. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1357. {
  1358. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1359. && src.getAllyId() != 0)
  1360. continue;
  1361. if (src.getClanId() != 0
  1362. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1363. continue;
  1364. }
  1365. }
  1366. if (obj instanceof L2Summon)
  1367. {
  1368. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1369. if (trg == src)
  1370. continue;
  1371. if (!src.checkPvpSkill(trg, this))
  1372. continue;
  1373. if ((src.getParty() != null && trg.getParty() != null)
  1374. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1375. continue;
  1376. if (!srcInArena
  1377. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1378. {
  1379. if (src.getAllyId() == trg.getAllyId()
  1380. && src.getAllyId() != 0)
  1381. continue;
  1382. if (src.getClanId() != 0
  1383. && src.getClanId() == trg.getClanId())
  1384. continue;
  1385. }
  1386. }
  1387. }
  1388. else
  1389. // Skill user is not L2PlayableInstance
  1390. {
  1391. if (!(obj instanceof L2PlayableInstance) // Target
  1392. // is
  1393. // not
  1394. // L2PlayableInstance
  1395. && !activeChar.isConfused()) // and
  1396. // caster
  1397. // not
  1398. // confused
  1399. // (?)
  1400. continue;
  1401. }
  1402. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1403. continue;
  1404. if (onlyFirst == false)
  1405. targetList.add((L2Character) obj);
  1406. else
  1407. return new L2Character[] { (L2Character) obj };
  1408. }
  1409. }
  1410. }
  1411. return targetList.toArray(new L2Character[targetList.size()]);
  1412. }
  1413. case TARGET_BEHIND_AURA:
  1414. {
  1415. int radius = getSkillRadius();
  1416. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1417. L2PcInstance src = null;
  1418. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1419. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1420. else if (activeChar instanceof L2Trap) src = ((L2Trap)activeChar).getOwner();
  1421. // Go through the L2Character _knownList
  1422. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1423. //synchronized (activeChar.getKnownList().getKnownObjects())
  1424. {
  1425. for (L2Object obj : objs)
  1426. {
  1427. if (obj instanceof L2Attackable
  1428. || obj instanceof L2PlayableInstance)
  1429. {
  1430. // Don't add this target if this is a Pc->Pc pvp
  1431. // casting and pvp condition not met
  1432. if (obj == activeChar || obj == src
  1433. || ((L2Character) obj).isDead())
  1434. continue;
  1435. if (src != null)
  1436. {
  1437. if (!((L2Character) obj).isBehind(activeChar))
  1438. continue;
  1439. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1440. continue;
  1441. // check if both attacker and target are
  1442. // L2PcInstances and if they are in same party
  1443. if (obj instanceof L2PcInstance)
  1444. {
  1445. if (!src.checkPvpSkill(obj, this))
  1446. continue;
  1447. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1448. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1449. continue;
  1450. if (!srcInArena
  1451. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1452. {
  1453. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1454. && src.getAllyId() != 0)
  1455. continue;
  1456. if (src.getClanId() != 0
  1457. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1458. continue;
  1459. }
  1460. }
  1461. if (obj instanceof L2Summon)
  1462. {
  1463. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1464. if (trg == src)
  1465. continue;
  1466. if (!src.checkPvpSkill(trg, this))
  1467. continue;
  1468. if ((src.getParty() != null && trg.getParty() != null)
  1469. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1470. continue;
  1471. if (!srcInArena
  1472. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1473. {
  1474. if (src.getAllyId() == trg.getAllyId()
  1475. && src.getAllyId() != 0)
  1476. continue;
  1477. if (src.getClanId() != 0
  1478. && src.getClanId() == trg.getClanId())
  1479. continue;
  1480. }
  1481. }
  1482. }
  1483. else
  1484. // Skill user is not L2PlayableInstance
  1485. {
  1486. if (!(obj instanceof L2PlayableInstance) // Target
  1487. // is
  1488. // not
  1489. // L2PlayableInstance
  1490. && !activeChar.isConfused()) // and
  1491. // caster
  1492. // not
  1493. // confused
  1494. // (?)
  1495. continue;
  1496. }
  1497. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1498. continue;
  1499. if (onlyFirst == false)
  1500. targetList.add((L2Character) obj);
  1501. else
  1502. return new L2Character[] { (L2Character) obj };
  1503. }
  1504. }
  1505. }
  1506. return targetList.toArray(new L2Character[targetList.size()]);
  1507. }
  1508. case TARGET_AREA:
  1509. {
  1510. if ((!(target instanceof L2Attackable || target instanceof L2PlayableInstance)) || // Target
  1511. // is
  1512. // not
  1513. // L2Attackable
  1514. // or
  1515. // L2PlayableInstance
  1516. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1517. // is
  1518. // null
  1519. // or
  1520. // self
  1521. // or
  1522. // dead/faking
  1523. {
  1524. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1525. return null;
  1526. }
  1527. L2Character cha;
  1528. if (getCastRange() >= 0)
  1529. {
  1530. cha = target;
  1531. if(!onlyFirst) targetList.add(cha); // Add target to target list
  1532. else return new L2Character[]{cha};
  1533. }
  1534. else cha = activeChar;
  1535. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2PlayableInstance);
  1536. L2PcInstance src = null;
  1537. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1538. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1539. int radius = getSkillRadius();
  1540. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1541. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1542. //synchronized (activeChar.getKnownList().getKnownObjects())
  1543. {
  1544. for (L2Object obj : objs)
  1545. {
  1546. if (!(obj instanceof L2Attackable || obj instanceof L2PlayableInstance))
  1547. continue;
  1548. if (obj == cha)
  1549. continue;
  1550. target = (L2Character) obj;
  1551. if (!GeoData.getInstance().canSeeTarget(activeChar, target))
  1552. continue;
  1553. if (!target.isDead() && (target != activeChar))
  1554. {
  1555. if (!Util.checkIfInRange(radius, obj, cha, true))
  1556. continue;
  1557. if (src != null) // caster is l2playableinstance
  1558. // and exists
  1559. {
  1560. if (obj instanceof L2PcInstance)
  1561. {
  1562. L2PcInstance trg = (L2PcInstance) obj;
  1563. if (trg == src)
  1564. continue;
  1565. if ((src.getParty() != null && trg.getParty() != null)
  1566. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1567. continue;
  1568. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  1569. continue;
  1570. if (!srcInArena
  1571. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1572. {
  1573. if (src.getAllyId() == trg.getAllyId()
  1574. && src.getAllyId() != 0)
  1575. continue;
  1576. if (src.getClan() != null
  1577. && trg.getClan() != null)
  1578. {
  1579. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1580. continue;
  1581. }
  1582. if (!src.checkPvpSkill(obj, this))
  1583. continue;
  1584. }
  1585. }
  1586. if (obj instanceof L2Summon)
  1587. {
  1588. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1589. if (trg == src)
  1590. continue;
  1591. if ((src.getParty() != null && trg.getParty() != null)
  1592. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1593. continue;
  1594. if (!srcInArena
  1595. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1596. {
  1597. if (src.getAllyId() == trg.getAllyId()
  1598. && src.getAllyId() != 0)
  1599. continue;
  1600. if (src.getClan() != null
  1601. && trg.getClan() != null)
  1602. {
  1603. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1604. continue;
  1605. }
  1606. if (!src.checkPvpSkill(trg, this))
  1607. continue;
  1608. }
  1609. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  1610. continue;
  1611. }
  1612. }
  1613. else
  1614. // Skill user is not L2PlayableInstance
  1615. {
  1616. if (effectOriginIsL2PlayableInstance && // If
  1617. // effect
  1618. // starts
  1619. // at
  1620. // L2PlayableInstance
  1621. // and
  1622. !(obj instanceof L2PlayableInstance)) // Object
  1623. // is
  1624. // not
  1625. // L2PlayableInstance
  1626. continue;
  1627. }
  1628. targetList.add((L2Character) obj);
  1629. }
  1630. }
  1631. }
  1632. if (targetList.size() == 0)
  1633. return null;
  1634. return targetList.toArray(new L2Character[targetList.size()]);
  1635. }
  1636. case TARGET_FRONT_AREA:
  1637. {
  1638. if ((!(target instanceof L2Attackable || target instanceof L2PlayableInstance)) || // Target
  1639. // is
  1640. // not
  1641. // L2Attackable
  1642. // or
  1643. // L2PlayableInstance
  1644. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1645. // is
  1646. // null
  1647. // or
  1648. // self
  1649. // or
  1650. // dead/faking
  1651. {
  1652. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1653. return null;
  1654. }
  1655. L2Character cha;
  1656. if (getCastRange() >= 0)
  1657. {
  1658. cha = target;
  1659. if(!onlyFirst) targetList.add(cha); // Add target to target
  1660. // list
  1661. else return new L2Character[]{cha};
  1662. }
  1663. else cha = activeChar;
  1664. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2PlayableInstance);
  1665. L2PcInstance src = null;
  1666. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1667. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1668. int radius = getSkillRadius();
  1669. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1670. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1671. //synchronized (activeChar.getKnownList().getKnownObjects())
  1672. {
  1673. for (L2Object obj : objs)
  1674. {
  1675. if (obj == cha)
  1676. continue;
  1677. if (!(obj instanceof L2Attackable || obj instanceof L2PlayableInstance))
  1678. continue;
  1679. target = (L2Character) obj;
  1680. if (!target.isDead() && (target != activeChar))
  1681. {
  1682. if (!Util.checkIfInRange(radius, obj, activeChar, true))
  1683. continue;
  1684. if (!((L2Character) obj).isInFrontOf(activeChar))
  1685. continue;
  1686. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1687. continue;
  1688. if (src != null) // caster is l2playableinstance
  1689. // and exists
  1690. {
  1691. if (obj instanceof L2PcInstance)
  1692. {
  1693. L2PcInstance trg = (L2PcInstance) obj;
  1694. if (trg == src)
  1695. continue;
  1696. if ((src.getParty() != null && trg.getParty() != null)
  1697. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1698. continue;
  1699. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  1700. continue;
  1701. if (!srcInArena
  1702. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1703. {
  1704. if (src.getAllyId() == trg.getAllyId()
  1705. && src.getAllyId() != 0)
  1706. continue;
  1707. if (src.getClan() != null
  1708. && trg.getClan() != null)
  1709. {
  1710. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1711. continue;
  1712. }
  1713. if (!src.checkPvpSkill(obj, this))
  1714. continue;
  1715. }
  1716. }
  1717. if (obj instanceof L2Summon)
  1718. {
  1719. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1720. if (trg == src)
  1721. continue;
  1722. if ((src.getParty() != null && trg.getParty() != null)
  1723. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1724. continue;
  1725. if (!srcInArena
  1726. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1727. {
  1728. if (src.getAllyId() == trg.getAllyId()
  1729. && src.getAllyId() != 0)
  1730. continue;
  1731. if (src.getClan() != null
  1732. && trg.getClan() != null)
  1733. {
  1734. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1735. continue;
  1736. }
  1737. if (!src.checkPvpSkill(trg, this))
  1738. continue;
  1739. }
  1740. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  1741. continue;
  1742. }
  1743. }
  1744. else
  1745. // Skill user is not L2PlayableInstance
  1746. {
  1747. if (effectOriginIsL2PlayableInstance && // If
  1748. // effect
  1749. // starts
  1750. // at
  1751. // L2PlayableInstance
  1752. // and
  1753. !(obj instanceof L2PlayableInstance)) // Object
  1754. // is
  1755. // not
  1756. // L2PlayableInstance
  1757. continue;
  1758. }
  1759. targetList.add((L2Character) obj);
  1760. }
  1761. }
  1762. }
  1763. if (targetList.size() == 0)
  1764. return null;
  1765. return targetList.toArray(new L2Character[targetList.size()]);
  1766. }
  1767. case TARGET_BEHIND_AREA:
  1768. {
  1769. if ((!(target instanceof L2Attackable || target instanceof L2PlayableInstance)) || // Target
  1770. // is
  1771. // not
  1772. // L2Attackable
  1773. // or
  1774. // L2PlayableInstance
  1775. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1776. // is
  1777. // null
  1778. // or
  1779. // self
  1780. // or
  1781. // dead/faking
  1782. {
  1783. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1784. return null;
  1785. }
  1786. L2Character cha;
  1787. if (getCastRange() >= 0)
  1788. {
  1789. cha = target;
  1790. if(!onlyFirst) targetList.add(cha); // Add target to target
  1791. // list
  1792. else return new L2Character[]{cha};
  1793. }
  1794. else cha = activeChar;
  1795. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2PlayableInstance);
  1796. L2PcInstance src = null;
  1797. if (activeChar instanceof L2PcInstance) src = (L2PcInstance)activeChar;
  1798. else if (activeChar instanceof L2Summon) src = ((L2Summon)activeChar).getOwner();
  1799. int radius = getSkillRadius();
  1800. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1801. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1802. //synchronized (activeChar.getKnownList().getKnownObjects())
  1803. {
  1804. for (L2Object obj : objs)
  1805. {
  1806. if (!(obj instanceof L2Attackable || obj instanceof L2PlayableInstance))
  1807. continue;
  1808. if (obj == cha)
  1809. continue;
  1810. target = (L2Character) obj;
  1811. if (!target.isDead() && (target != activeChar))
  1812. {
  1813. if (!Util.checkIfInRange(radius, obj, activeChar, true))
  1814. continue;
  1815. if (!((L2Character) obj).isBehind(activeChar))
  1816. continue;
  1817. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1818. continue;
  1819. if (src != null) // caster is l2playableinstance
  1820. // and exists
  1821. {
  1822. if (obj instanceof L2PcInstance)
  1823. {
  1824. L2PcInstance trg = (L2PcInstance) obj;
  1825. if (trg == src)
  1826. continue;
  1827. if ((src.getParty() != null && trg.getParty() != null)
  1828. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1829. continue;
  1830. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  1831. continue;
  1832. if (!srcInArena
  1833. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1834. {
  1835. if (src.getAllyId() == trg.getAllyId()
  1836. && src.getAllyId() != 0)
  1837. continue;
  1838. if (src.getClan() != null
  1839. && trg.getClan() != null)
  1840. {
  1841. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1842. continue;
  1843. }
  1844. if (!src.checkPvpSkill(obj, this))
  1845. continue;
  1846. }
  1847. }
  1848. if (obj instanceof L2Summon)
  1849. {
  1850. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1851. if (trg == src)
  1852. continue;
  1853. if ((src.getParty() != null && trg.getParty() != null)
  1854. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1855. continue;
  1856. if (!srcInArena
  1857. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1858. {
  1859. if (src.getAllyId() == trg.getAllyId()
  1860. && src.getAllyId() != 0)
  1861. continue;
  1862. if (src.getClan() != null
  1863. && trg.getClan() != null)
  1864. {
  1865. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1866. continue;
  1867. }
  1868. if (!src.checkPvpSkill(trg, this))
  1869. continue;
  1870. }
  1871. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  1872. continue;
  1873. }
  1874. }
  1875. else
  1876. // Skill user is not L2PlayableInstance
  1877. {
  1878. if (effectOriginIsL2PlayableInstance && // If
  1879. // effect
  1880. // starts
  1881. // at
  1882. // L2PlayableInstance
  1883. // and
  1884. !(obj instanceof L2PlayableInstance)) // Object
  1885. // is
  1886. // not
  1887. // L2PlayableInstance
  1888. continue;
  1889. }
  1890. targetList.add((L2Character) obj);
  1891. }
  1892. }
  1893. }
  1894. if (targetList.size() == 0)
  1895. return null;
  1896. return targetList.toArray(new L2Character[targetList.size()]);
  1897. }
  1898. case TARGET_MULTIFACE:
  1899. {
  1900. if ((!(target instanceof L2Attackable) && !(target instanceof L2PcInstance)))
  1901. {
  1902. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1903. return null;
  1904. }
  1905. if (onlyFirst == false) targetList.add(target);
  1906. else return new L2Character[] {target};
  1907. int radius = getSkillRadius();
  1908. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1909. //synchronized (activeChar.getKnownList().getKnownObjects())
  1910. {
  1911. for (L2Object obj : objs)
  1912. {
  1913. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1914. continue;
  1915. if (obj instanceof L2Attackable && obj != target)
  1916. targetList.add((L2Character) obj);
  1917. if (targetList.size() == 0)
  1918. {
  1919. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_CANT_FOUND));
  1920. return null;
  1921. }
  1922. }
  1923. }
  1924. return targetList.toArray(new L2Character[targetList.size()]);
  1925. //TODO multiface targets all around right now. need it to just get targets
  1926. //the character is facing.
  1927. }
  1928. case TARGET_PARTY:
  1929. {
  1930. if (onlyFirst)
  1931. return new L2Character[]{activeChar};
  1932. targetList.add(activeChar);
  1933. L2PcInstance player = null;
  1934. if (activeChar instanceof L2Summon)
  1935. {
  1936. player = ((L2Summon)activeChar).getOwner();
  1937. targetList.add(player);
  1938. }
  1939. else if (activeChar instanceof L2PcInstance)
  1940. {
  1941. player = (L2PcInstance)activeChar;
  1942. if (activeChar.getPet() != null)
  1943. targetList.add(activeChar.getPet());
  1944. }
  1945. if (activeChar.getParty() != null)
  1946. {
  1947. // Get all visible objects in a spherical area near the L2Character
  1948. // Get a list of Party Members
  1949. List<L2PcInstance> partyList = activeChar.getParty().getPartyMembers();
  1950. for(L2PcInstance partyMember : partyList)
  1951. {
  1952. if (partyMember == null) continue;
  1953. if (partyMember == player) continue;
  1954. if (!partyMember.isDead()
  1955. && Util.checkIfInRange(getSkillRadius(), activeChar, partyMember, true))
  1956. {
  1957. targetList.add(partyMember);
  1958. if (partyMember.getPet() != null && !partyMember.getPet().isDead())
  1959. {
  1960. targetList.add(partyMember.getPet());
  1961. }
  1962. }
  1963. }
  1964. }
  1965. return targetList.toArray(new L2Character[targetList.size()]);
  1966. }
  1967. case TARGET_PARTY_MEMBER:
  1968. {
  1969. if ((target != null
  1970. && target == activeChar)
  1971. || (target != null
  1972. && activeChar.getParty() != null
  1973. && target.getParty() != null
  1974. && activeChar.getParty().getPartyLeaderOID() == target.getParty().getPartyLeaderOID())
  1975. || (target != null
  1976. && activeChar instanceof L2PcInstance
  1977. && target instanceof L2Summon
  1978. && activeChar.getPet() == target)
  1979. || (target != null
  1980. && activeChar instanceof L2Summon
  1981. && target instanceof L2PcInstance
  1982. && activeChar == target.getPet()))
  1983. {
  1984. if (!target.isDead())
  1985. {
  1986. // If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
  1987. return new L2Character[]{target};
  1988. }
  1989. else
  1990. return null;
  1991. }
  1992. else
  1993. {
  1994. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1995. return null;
  1996. }
  1997. }
  1998. case TARGET_PARTY_OTHER:
  1999. {
  2000. if (target != null && target != activeChar
  2001. && activeChar.getParty() != null && target.getParty() != null
  2002. && activeChar.getParty().getPartyLeaderOID() == target.getParty().getPartyLeaderOID())
  2003. {
  2004. if (!target.isDead())
  2005. {
  2006. if (target instanceof L2PcInstance)
  2007. {
  2008. L2PcInstance player = (L2PcInstance)target;
  2009. switch (getId())
  2010. {
  2011. // FORCE BUFFS may cancel here but there should be a proper condition
  2012. case 426:
  2013. if (!player.isMageClass())
  2014. return new L2Character[]{target};
  2015. else
  2016. return null;
  2017. case 427:
  2018. if (player.isMageClass())
  2019. return new L2Character[]{target};
  2020. else
  2021. return null;
  2022. }
  2023. }
  2024. return new L2Character[]{target};
  2025. }
  2026. else
  2027. return null;
  2028. }
  2029. else
  2030. {
  2031. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2032. return null;
  2033. }
  2034. }
  2035. case TARGET_CORPSE_ALLY:
  2036. case TARGET_ALLY:
  2037. {
  2038. if (activeChar instanceof L2PcInstance)
  2039. {
  2040. int radius = getSkillRadius();
  2041. L2PcInstance player = (L2PcInstance) activeChar;
  2042. L2Clan clan = player.getClan();
  2043. if (player.isInOlympiadMode())
  2044. return new L2Character[] {player};
  2045. if (targetType != SkillTargetType.TARGET_CORPSE_ALLY)
  2046. {
  2047. if (onlyFirst == false) targetList.add(player);
  2048. else return new L2Character[] {player};
  2049. }
  2050. if (activeChar.getPet() != null)
  2051. {
  2052. if ((targetType != SkillTargetType.TARGET_CORPSE_ALLY) && !(activeChar.getPet().isDead()))
  2053. targetList.add(activeChar.getPet());
  2054. }
  2055. if (clan != null)
  2056. {
  2057. // Get all visible objects in a spherical area near the L2Character
  2058. // Get Clan Members
  2059. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  2060. //synchronized (activeChar.getKnownList().getKnownObjects())
  2061. {
  2062. for (L2Object newTarget : objs)
  2063. {
  2064. if (!(newTarget instanceof L2PcInstance))
  2065. continue;
  2066. if ((((L2PcInstance) newTarget).getAllyId() == 0 || ((L2PcInstance) newTarget).getAllyId() != player.getAllyId())
  2067. && (((L2PcInstance) newTarget).getClan() == null || ((L2PcInstance) newTarget).getClanId() != player.getClanId()))
  2068. continue;
  2069. if (player.isInDuel()
  2070. && (player.getDuelId() != ((L2PcInstance) newTarget).getDuelId() || (player.getParty() != null && !player.getParty().getPartyMembers().contains(newTarget))))
  2071. continue;
  2072. if (((L2PcInstance) newTarget).getPet() != null)
  2073. if (Util.checkIfInRange(radius, activeChar, ((L2PcInstance) newTarget).getPet(), true))
  2074. if ((targetType != SkillTargetType.TARGET_CORPSE_ALLY)
  2075. && !(((L2PcInstance) newTarget).getPet().isDead())
  2076. && player.checkPvpSkill(newTarget, this)
  2077. && onlyFirst == false)
  2078. targetList.add(((L2PcInstance) newTarget).getPet());
  2079. if (targetType == SkillTargetType.TARGET_CORPSE_ALLY)
  2080. {
  2081. if (!((L2PcInstance) newTarget).isDead())
  2082. continue;
  2083. if (getSkillType() == L2SkillType.RESURRECT)
  2084. {
  2085. // check target is not in a active siege
  2086. // zone
  2087. if (((L2PcInstance) newTarget).isInsideZone(L2Character.ZONE_SIEGE))
  2088. continue;
  2089. }
  2090. }
  2091. if (!Util.checkIfInRange(radius, activeChar, newTarget, true))
  2092. continue;
  2093. // Don't add this target if this is a Pc->Pc pvp
  2094. // casting and pvp condition not met
  2095. if (!player.checkPvpSkill(newTarget, this))
  2096. continue;
  2097. if (onlyFirst == false) targetList.add((L2Character) newTarget);
  2098. else return new L2Character[] { (L2Character) newTarget };
  2099. }
  2100. }
  2101. }
  2102. }
  2103. return targetList.toArray(new L2Character[targetList.size()]);
  2104. }
  2105. case TARGET_CORPSE_CLAN:
  2106. case TARGET_CLAN:
  2107. {
  2108. if (activeChar instanceof L2PlayableInstance)
  2109. {
  2110. int radius = getSkillRadius();
  2111. L2PcInstance player = null;
  2112. if (activeChar instanceof L2Summon)
  2113. player = ((L2Summon)activeChar).getOwner();
  2114. else
  2115. player = (L2PcInstance) activeChar;
  2116. if (player == null) return null;
  2117. L2Clan clan = player.getClan();
  2118. if (player.isInOlympiadMode())
  2119. return new L2Character[] {player};
  2120. if (targetType != SkillTargetType.TARGET_CORPSE_CLAN)
  2121. {
  2122. if (onlyFirst == false) targetList.add(player);
  2123. else return new L2Character[] {player};
  2124. }
  2125. if (activeChar.getPet() != null)
  2126. {
  2127. if ((targetType != SkillTargetType.TARGET_CORPSE_CLAN) && !(activeChar.getPet().isDead()))
  2128. targetList.add(activeChar.getPet());
  2129. }
  2130. if (clan != null)
  2131. {
  2132. // Get all visible objects in a spheric area near the L2Character
  2133. // Get Clan Members
  2134. for (L2ClanMember member : clan.getMembers())
  2135. {
  2136. L2PcInstance newTarget = member.getPlayerInstance();
  2137. if (newTarget == null || newTarget == player) continue;
  2138. if (player.isInDuel() && (player.getDuelId() != newTarget.getDuelId() || (player.getParty() != null
  2139. && !player.getParty().getPartyMembers().contains(newTarget))))
  2140. continue;
  2141. if (newTarget.getPet() != null)
  2142. if (Util.checkIfInRange(radius, activeChar, newTarget.getPet(), true))
  2143. if ((targetType != SkillTargetType.TARGET_CORPSE_CLAN) && !(newTarget.getPet().isDead())
  2144. && player.checkPvpSkill(newTarget, this)
  2145. && onlyFirst == false)
  2146. targetList.add(newTarget.getPet());
  2147. if (targetType == SkillTargetType.TARGET_CORPSE_CLAN)
  2148. {
  2149. if (!newTarget.isDead())
  2150. continue;
  2151. if (getSkillType() == L2SkillType.RESURRECT)
  2152. {
  2153. // check target is not in a active siege zone
  2154. if (newTarget.isInsideZone(L2Character.ZONE_SIEGE))
  2155. continue;
  2156. }
  2157. }
  2158. if (!Util.checkIfInRange(radius, activeChar, newTarget, true)) continue;
  2159. // Don't add this target if this is a Pc->Pc pvp casting and pvp condition not met
  2160. if (!player.checkPvpSkill(newTarget, this)) continue;
  2161. if (onlyFirst == false) targetList.add(newTarget);
  2162. else return new L2Character[] {newTarget};
  2163. }
  2164. }
  2165. }
  2166. else if (activeChar instanceof L2NpcInstance)
  2167. {
  2168. // for buff purposes, returns one unbuffed friendly mob nearby or mob itself?
  2169. L2NpcInstance npc = (L2NpcInstance) activeChar;
  2170. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  2171. //synchronized (activeChar.getKnownList().getKnownObjects())
  2172. {
  2173. for (L2Object newTarget : objs)
  2174. {
  2175. if (newTarget instanceof L2NpcInstance
  2176. && ((L2NpcInstance) newTarget).getFactionId() == npc.getFactionId())
  2177. {
  2178. if (!Util.checkIfInRange(getCastRange(), activeChar, newTarget, true))
  2179. continue;
  2180. if (((L2NpcInstance) newTarget).getFirstEffect(this) != null)
  2181. {
  2182. targetList.add((L2NpcInstance) newTarget);
  2183. break;
  2184. }
  2185. }
  2186. }
  2187. }
  2188. if (targetList.isEmpty())
  2189. {
  2190. targetList.add(activeChar);
  2191. }
  2192. }
  2193. return targetList.toArray(new L2Character[targetList.size()]);
  2194. }
  2195. case TARGET_CORPSE_PLAYER:
  2196. {
  2197. if (target != null && target.isDead())
  2198. {
  2199. L2PcInstance player = null;
  2200. if (activeChar instanceof L2PcInstance) player = (L2PcInstance) activeChar;
  2201. L2PcInstance targetPlayer = null;
  2202. if (target instanceof L2PcInstance) targetPlayer = (L2PcInstance) target;
  2203. L2PetInstance targetPet = null;
  2204. if (target instanceof L2PetInstance) targetPet = (L2PetInstance) target;
  2205. if (player != null && (targetPlayer != null || targetPet != null))
  2206. {
  2207. boolean condGood = true;
  2208. if (getSkillType() == L2SkillType.RESURRECT)
  2209. {
  2210. // check target is not in a active siege zone
  2211. if (target.isInsideZone(L2Character.ZONE_SIEGE))
  2212. {
  2213. condGood = false;
  2214. player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE));
  2215. }
  2216. if (targetPlayer != null)
  2217. {
  2218. if (targetPlayer.isReviveRequested())
  2219. {
  2220. if (targetPlayer.isRevivingPet())
  2221. player.sendPacket(new SystemMessage(SystemMessageId.MASTER_CANNOT_RES)); // While a pet is attempting to resurrect, it cannot help in resurrecting its master.
  2222. else
  2223. player.sendPacket(new SystemMessage(SystemMessageId.RES_HAS_ALREADY_BEEN_PROPOSED)); // Resurrection is already been proposed.
  2224. condGood = false;
  2225. }
  2226. }
  2227. else if (targetPet != null)
  2228. {
  2229. if (targetPet.getOwner() != player)
  2230. {
  2231. condGood = false;
  2232. player.sendMessage("You are not the owner of this pet");
  2233. }
  2234. }
  2235. }
  2236. if (condGood)
  2237. {
  2238. if (onlyFirst == false)
  2239. {
  2240. targetList.add(target);
  2241. return targetList.toArray(new L2Object[targetList.size()]);
  2242. }
  2243. else return new L2Character[] {target};
  2244. }
  2245. }
  2246. }
  2247. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2248. return null;
  2249. }
  2250. case TARGET_CORPSE_MOB:
  2251. {
  2252. if (!(target instanceof L2Attackable) || !target.isDead())
  2253. {
  2254. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2255. return null;
  2256. }
  2257. // Corpse mob only available for half time
  2258. switch (getSkillType())
  2259. {
  2260. case DRAIN:
  2261. case SUMMON:
  2262. {
  2263. if (DecayTaskManager.getInstance().getTasks().containsKey(target)
  2264. && (System.currentTimeMillis() - DecayTaskManager.getInstance().getTasks().get(target)) > DecayTaskManager.ATTACKABLE_DECAY_TIME / 2)
  2265. {
  2266. activeChar.sendPacket(new SystemMessage(SystemMessageId.CORPSE_TOO_OLD_SKILL_NOT_USED));
  2267. return null;
  2268. }
  2269. }
  2270. }
  2271. if (onlyFirst == false)
  2272. {
  2273. targetList.add(target);
  2274. return targetList.toArray(new L2Object[targetList.size()]);
  2275. }
  2276. else return new L2Character[] {target};
  2277. }
  2278. case TARGET_AREA_CORPSE_MOB:
  2279. {
  2280. if ((!(target instanceof L2Attackable)) || !target.isDead())
  2281. {
  2282. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2283. return null;
  2284. }
  2285. if (onlyFirst == false) targetList.add(target);
  2286. else return new L2Character[] {target};
  2287. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  2288. L2PcInstance src = null;
  2289. if (activeChar instanceof L2PcInstance)
  2290. src = (L2PcInstance)activeChar;
  2291. L2PcInstance trg = null;
  2292. int radius = getSkillRadius();
  2293. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  2294. //synchronized (activeChar.getKnownList().getKnownObjects())
  2295. {
  2296. for (L2Object obj : objs)
  2297. {
  2298. if (!(obj instanceof L2Attackable || obj instanceof L2PlayableInstance)
  2299. || ((L2Character) obj).isDead()
  2300. || ((L2Character) obj) == activeChar)
  2301. continue;
  2302. if (!Util.checkIfInRange(radius, target, obj, true))
  2303. continue;
  2304. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  2305. continue;
  2306. if (obj instanceof L2PcInstance && src != null)
  2307. {
  2308. trg = (L2PcInstance) obj;
  2309. if ((src.getParty() != null && trg.getParty() != null)
  2310. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  2311. continue;
  2312. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  2313. continue;
  2314. if (!srcInArena
  2315. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  2316. {
  2317. if (src.getAllyId() == trg.getAllyId()
  2318. && src.getAllyId() != 0)
  2319. continue;
  2320. if (src.getClan() != null
  2321. && trg.getClan() != null)
  2322. {
  2323. if (src.getClan().getClanId() == trg.getClan().getClanId())
  2324. continue;
  2325. }
  2326. if (!src.checkPvpSkill(obj, this))
  2327. continue;
  2328. }
  2329. }
  2330. if (obj instanceof L2Summon && src != null)
  2331. {
  2332. trg = ((L2Summon) obj).getOwner();
  2333. if ((src.getParty() != null && trg.getParty() != null)
  2334. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  2335. continue;
  2336. if (!srcInArena
  2337. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  2338. {
  2339. if (src.getAllyId() == trg.getAllyId()
  2340. && src.getAllyId() != 0)
  2341. continue;
  2342. if (src.getClan() != null
  2343. && trg.getClan() != null)
  2344. {
  2345. if (src.getClan().getClanId() == trg.getClan().getClanId())
  2346. continue;
  2347. }
  2348. if (!src.checkPvpSkill(trg, this))
  2349. continue;
  2350. }
  2351. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  2352. continue;
  2353. }
  2354. targetList.add((L2Character) obj);
  2355. }
  2356. }
  2357. if (targetList.size() == 0) return null;
  2358. return targetList.toArray(new L2Character[targetList.size()]);
  2359. }
  2360. case TARGET_UNLOCKABLE:
  2361. {
  2362. if (!(target instanceof L2DoorInstance) && !(target instanceof L2ChestInstance))
  2363. {
  2364. //activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
  2365. return null;
  2366. }
  2367. if (onlyFirst == false)
  2368. {
  2369. targetList.add(target);
  2370. return targetList.toArray(new L2Object[targetList.size()]);
  2371. }
  2372. else return new L2Character[] {target};
  2373. }
  2374. case TARGET_ITEM:
  2375. {
  2376. activeChar.sendMessage("Target type of skill is not currently handled");
  2377. return null;
  2378. }
  2379. case TARGET_UNDEAD:
  2380. {
  2381. if (target instanceof L2NpcInstance || target instanceof L2SummonInstance)
  2382. {
  2383. if (!target.isUndead() || target.isDead())
  2384. {
  2385. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2386. return null;
  2387. }
  2388. if (onlyFirst == false) targetList.add(target);
  2389. else return new L2Character[] {target};
  2390. return targetList.toArray(new L2Object[targetList.size()]);
  2391. }
  2392. else
  2393. {
  2394. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2395. return null;
  2396. }
  2397. }
  2398. case TARGET_AREA_UNDEAD:
  2399. {
  2400. L2Character cha;
  2401. int radius = getSkillRadius();
  2402. if (getCastRange() >= 0 && (target instanceof L2NpcInstance || target instanceof L2SummonInstance)
  2403. && target.isUndead() && !target.isAlikeDead())
  2404. {
  2405. cha = target;
  2406. if (onlyFirst == false) targetList.add(cha); // Add target to target list
  2407. else return new L2Character[] {cha};
  2408. }
  2409. else cha = activeChar;
  2410. Collection<L2Object> objs = cha.getKnownList().getKnownObjects().values();
  2411. //synchronized (cha.getKnownList().getKnownObjects())
  2412. {
  2413. for (L2Object obj : objs)
  2414. {
  2415. if (obj instanceof L2NpcInstance)
  2416. target = (L2NpcInstance) obj;
  2417. else if (obj instanceof L2SummonInstance)
  2418. target = (L2SummonInstance) obj;
  2419. else
  2420. continue;
  2421. if (!GeoData.getInstance().canSeeTarget(activeChar, target))
  2422. continue;
  2423. if (!target.isAlikeDead()) // If target is not
  2424. // dead/fake death and not
  2425. // self
  2426. {
  2427. if (!target.isUndead())
  2428. continue;
  2429. if (!Util.checkIfInRange(radius, cha, obj, true))
  2430. continue;
  2431. if (onlyFirst == false)
  2432. targetList.add((L2Character) obj);
  2433. else
  2434. return new L2Character[] { (L2Character) obj };
  2435. }
  2436. }
  2437. }
  2438. if (targetList.size() == 0) return null;
  2439. return targetList.toArray(new L2Character[targetList.size()]);
  2440. }
  2441. case TARGET_ENEMY_SUMMON:
  2442. {
  2443. if(target instanceof L2Summon)
  2444. {
  2445. L2Summon targetSummon = (L2Summon)target;
  2446. if (activeChar instanceof L2PcInstance && activeChar.getPet() != targetSummon && !targetSummon.isDead()
  2447. && (targetSummon.getOwner().getPvpFlag() != 0 || targetSummon.getOwner().getKarma() > 0)
  2448. || (targetSummon.getOwner().isInsideZone(L2Character.ZONE_PVP) && ((L2PcInstance)activeChar).isInsideZone(L2Character.ZONE_PVP)))
  2449. return new L2Character[]{targetSummon};
  2450. }
  2451. return null;
  2452. }
  2453. default:
  2454. {
  2455. activeChar.sendMessage("Target type of skill is not currently handled");
  2456. return null;
  2457. }
  2458. }//end switch
  2459. }
  2460. public final L2Object[] getTargetList(L2Character activeChar)
  2461. {
  2462. return getTargetList(activeChar, false);
  2463. }
  2464. public final L2Object getFirstOfTargetList(L2Character activeChar)
  2465. {
  2466. L2Object[] targets;
  2467. targets = getTargetList(activeChar, true);
  2468. if (targets == null || targets.length == 0) return null;
  2469. else return targets[0];
  2470. }
  2471. public final Func[] getStatFuncs(L2Effect effect, L2Character player)
  2472. {
  2473. if (!(player instanceof L2PcInstance) && !(player instanceof L2Attackable)
  2474. && !(player instanceof L2Summon)) return _emptyFunctionSet;
  2475. if (_funcTemplates == null) return _emptyFunctionSet;
  2476. List<Func> funcs = new FastList<Func>();
  2477. for (FuncTemplate t : _funcTemplates)
  2478. {
  2479. Env env = new Env();
  2480. env.player = player;
  2481. env.skill = this;
  2482. Func f = t.getFunc(env, this); // skill is owner
  2483. if (f != null) funcs.add(f);
  2484. }
  2485. if (funcs.size() == 0) return _emptyFunctionSet;
  2486. return funcs.toArray(new Func[funcs.size()]);
  2487. }
  2488. public boolean hasEffects()
  2489. {
  2490. return (_effectTemplates != null && _effectTemplates.length > 0);
  2491. }
  2492. public final L2Effect[] getEffects(L2Character effector, L2Character effected)
  2493. {
  2494. if (isPassive()) return _emptyEffectSet;
  2495. if (_effectTemplates == null)
  2496. return _emptyEffectSet;
  2497. // doors and siege flags cannot receive any effects
  2498. if (effected instanceof L2DoorInstance ||effected instanceof L2SiegeFlagInstance )
  2499. return _emptyEffectSet;
  2500. if ((effector != effected) && effected.isInvul())
  2501. return _emptyEffectSet;
  2502. List<L2Effect> effects = new FastList<L2Effect>();
  2503. for (EffectTemplate et : _effectTemplates)
  2504. {
  2505. Env env = new Env();
  2506. env.player = effector;
  2507. env.target = effected;
  2508. env.skill = this;
  2509. L2Effect e = et.getEffect(env);
  2510. if (e != null) effects.add(e);
  2511. }
  2512. if (effects.size() == 0) return _emptyEffectSet;
  2513. return effects.toArray(new L2Effect[effects.size()]);
  2514. }
  2515. public final L2Effect[] getEffects(L2CubicInstance effector, L2Character effected)
  2516. {
  2517. if (isPassive()) return _emptyEffectSet;
  2518. if (_effectTemplates == null)
  2519. return _emptyEffectSet;
  2520. if ((!effector.equals(effected)) && effected.isInvul())
  2521. return _emptyEffectSet;
  2522. List<L2Effect> effects = new FastList<L2Effect>();
  2523. for (EffectTemplate et : _effectTemplates)
  2524. {
  2525. Env env = new Env();
  2526. env.player = effector.getOwner();
  2527. env.cubic = effector;
  2528. env.target = effected;
  2529. env.skill = this;
  2530. L2Effect e = et.getEffect(env);
  2531. if (e != null) effects.add(e);
  2532. }
  2533. if (effects.size() == 0) return _emptyEffectSet;
  2534. return effects.toArray(new L2Effect[effects.size()]);
  2535. }
  2536. public final L2Effect[] getEffectsSelf(L2Character effector)
  2537. {
  2538. if (isPassive()) return _emptyEffectSet;
  2539. if (_effectTemplatesSelf == null) return _emptyEffectSet;
  2540. List<L2Effect> effects = new FastList<L2Effect>();
  2541. for (EffectTemplate et : _effectTemplatesSelf)
  2542. {
  2543. Env env = new Env();
  2544. env.player = effector;
  2545. env.target = effector;
  2546. env.skill = this;
  2547. L2Effect e = et.getEffect(env);
  2548. if (e != null)
  2549. {
  2550. //Implements effect charge
  2551. if (e.getEffectType()== L2Effect.EffectType.CHARGE)
  2552. {
  2553. env.skill = SkillTable.getInstance().getInfo(8, effector.getSkillLevel(8));
  2554. EffectCharge effect = (EffectCharge) env.target.getFirstEffect(L2Effect.EffectType.CHARGE);
  2555. if (effect != null)
  2556. {
  2557. int effectcharge = effect.getLevel();
  2558. if (effectcharge < _numCharges)
  2559. {
  2560. effectcharge++;
  2561. effect.addNumCharges(effectcharge);
  2562. if (env.target instanceof L2PcInstance)
  2563. {
  2564. env.target.sendPacket(new EtcStatusUpdate((L2PcInstance)env.target));
  2565. SystemMessage sm = new SystemMessage(SystemMessageId.FORCE_INCREASED_TO_S1);
  2566. sm.addNumber(effectcharge);
  2567. env.target.sendPacket(sm);
  2568. }
  2569. }
  2570. }
  2571. else effects.add(e);
  2572. }
  2573. else effects.add(e);
  2574. }
  2575. }
  2576. if (effects.size() == 0) return _emptyEffectSet;
  2577. return effects.toArray(new L2Effect[effects.size()]);
  2578. }
  2579. public final void attach(FuncTemplate f)
  2580. {
  2581. if (_funcTemplates == null)
  2582. {
  2583. _funcTemplates = new FuncTemplate[] {f};
  2584. }
  2585. else
  2586. {
  2587. int len = _funcTemplates.length;
  2588. FuncTemplate[] tmp = new FuncTemplate[len + 1];
  2589. System.arraycopy(_funcTemplates, 0, tmp, 0, len);
  2590. tmp[len] = f;
  2591. _funcTemplates = tmp;
  2592. }
  2593. }
  2594. public final void attach(EffectTemplate effect)
  2595. {
  2596. if (_effectTemplates == null)
  2597. {
  2598. _effectTemplates = new EffectTemplate[] {effect};
  2599. }
  2600. else
  2601. {
  2602. int len = _effectTemplates.length;
  2603. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2604. System.arraycopy(_effectTemplates, 0, tmp, 0, len);
  2605. tmp[len] = effect;
  2606. _effectTemplates = tmp;
  2607. }
  2608. }
  2609. public final void attachSelf(EffectTemplate effect)
  2610. {
  2611. if (_effectTemplatesSelf == null)
  2612. {
  2613. _effectTemplatesSelf = new EffectTemplate[] {effect};
  2614. }
  2615. else
  2616. {
  2617. int len = _effectTemplatesSelf.length;
  2618. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2619. System.arraycopy(_effectTemplatesSelf, 0, tmp, 0, len);
  2620. tmp[len] = effect;
  2621. _effectTemplatesSelf = tmp;
  2622. }
  2623. }
  2624. public final void attach(Condition c, boolean itemOrWeapon)
  2625. {
  2626. if(itemOrWeapon) _itemPreCondition = c;
  2627. else _preCondition = c;
  2628. }
  2629. @Override
  2630. public String toString()
  2631. {
  2632. return "" + _name + "[id=" + _id + ",lvl=" + _level + "]";
  2633. }
  2634. }