2
0

L2Skill.java 101 KB

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