L2Skill.java 105 KB

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