2
0

L2Skill.java 103 KB

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