L2Skill.java 103 KB

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