L2Skill.java 101 KB

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