L2Skill.java 103 KB

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