L2Skill.java 104 KB

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