L2Skill.java 104 KB

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