L2Skill.java 102 KB

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