L2Skill.java 103 KB

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