L2Skill.java 106 KB

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