L2Skill.java 102 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. // kill by damage over time
  173. private final boolean _killByDOT;
  174. private final int _refId;
  175. // all times in milliseconds
  176. private final int _hitTime;
  177. //private final int _skillInterruptTime;
  178. private final int _coolTime;
  179. private final int _reuseDelay;
  180. private final int _buffDuration;
  181. // for item skills delay on equip
  182. private final int _equipDelay;
  183. /** Target type of the skill : SELF, PARTY, CLAN, PET... */
  184. private final SkillTargetType _targetType;
  185. private int _feed;
  186. // base success chance
  187. private final double _power;
  188. private final int _magicLevel;
  189. private final int _levelDepend;
  190. private final boolean _ignoreResists;
  191. private final boolean _isNeutral;
  192. // Effecting area of the skill, in radius.
  193. // The radius center varies according to the _targetType:
  194. // "caster" if targetType = AURA/PARTY/CLAN or "target" if targetType = AREA
  195. private final int _skillRadius;
  196. private final L2SkillType _skillType;
  197. private final L2SkillType _effectType; // additional effect has a type
  198. private final int _effectAbnormalLvl; // abnormal level for the additional effect type, e.g. poison lvl 1
  199. private final int _effectId;
  200. private final int _effectLvl; // normal effect level
  201. private final boolean _ispotion;
  202. private final int _element;
  203. private final Stats _stat;
  204. private final int _condition;
  205. private final int _conditionValue;
  206. private final boolean _overhit;
  207. private final int _weaponsAllowed;
  208. private final int _armorsAllowed;
  209. private final int _minPledgeClass;
  210. private final int[] _teleportCoords;
  211. private final String _recallType;
  212. private final boolean _isOffensive;
  213. private final int _requiredCharges;
  214. private final int _maxCharges;
  215. private final int _numCharges;
  216. private final int _triggeredId;
  217. private final int _triggeredLevel;
  218. private final String _chanceType;
  219. private final int _soulMaxConsume;
  220. private final int _soulConsume;
  221. private final int _numSouls;
  222. private final int _expNeeded;
  223. private final int _critChance;
  224. private final int _transformId;
  225. private final int _transformDuration;
  226. private final int _afterEffectId;
  227. private final int _afterEffectLvl;
  228. private final boolean _isHeroSkill; // If true the skill is a Hero Skill
  229. private final int _baseCritRate; // percent of success for skill critical hit (especially for PDAM & BLOW - they're not affected by rCrit values or buffs). Default loads -1 for all other skills but 0 to PDAM & BLOW
  230. private final int _lethalEffect1; // percent of success for lethal 1st effect (hit cp to 1 or if mob hp to 50%) (only for PDAM skills)
  231. private final int _lethalEffect2; // percent of success for lethal 2nd effect (hit cp,hp to 1 or if mob hp to 1) (only for PDAM skills)
  232. private final boolean _directHpDmg; // If true then dmg is being make directly
  233. private final boolean _isDance; // If true then casting more dances will cost more MP
  234. private final int _nextDanceCost;
  235. private final float _sSBoost; //If true skill will have SoulShot boost (power*2)
  236. private final int _aggroPoints;
  237. protected Condition _preCondition;
  238. protected Condition _itemPreCondition;
  239. protected FuncTemplate[] _funcTemplates;
  240. protected EffectTemplate[] _effectTemplates;
  241. protected EffectTemplate[] _effectTemplatesSelf;
  242. protected ChanceCondition _chanceCondition = null;
  243. // Flying support
  244. private final String _flyType;
  245. private final int _flyRadius;
  246. private final float _flyCourse;
  247. private final boolean _isDebuff;
  248. private boolean _isAdvancedFlag;
  249. private String _attribute;
  250. private int _afroId;
  251. private int _learnSkillId;
  252. private int _learnSkillLvl;
  253. private boolean _useShield;
  254. private boolean _isSuicideAttack;
  255. protected L2Skill(StatsSet set)
  256. {
  257. _id = set.getInteger("skill_id");
  258. _level = set.getInteger("level");
  259. _refId = set.getInteger("referenceId", set.getInteger("itemConsumeId", 0));
  260. _afroId = set.getInteger("afroId",0);
  261. _displayId = set.getInteger("displayId", _id);
  262. _name = set.getString("name");
  263. _operateType = set.getEnum("operateType", SkillOpType.class);
  264. _magic = set.getBool("isMagic", false);
  265. _staticReuse = set.getBool("staticReuse", false);
  266. _staticHitTime = set.getBool("staticHitTime", false);
  267. _ispotion = set.getBool("isPotion", false);
  268. _mpConsume = set.getInteger("mpConsume", 0);
  269. _mpInitialConsume = set.getInteger("mpInitialConsume", 0);
  270. _hpConsume = set.getInteger("hpConsume", 0);
  271. _cpConsume = set.getInteger("cpConsume", 0);
  272. _targetConsume = set.getInteger("targetConsumeCount", 0);
  273. _targetConsumeId = set.getInteger("targetConsumeId", 0);
  274. _itemConsume = set.getInteger("itemConsumeCount", 0);
  275. _itemConsumeId = set.getInteger("itemConsumeId", 0);
  276. _itemConsumeOT = set.getInteger("itemConsumeCountOT", 0);
  277. _itemConsumeIdOT = set.getInteger("itemConsumeIdOT", 0);
  278. _itemConsumeTime = set.getInteger("itemConsumeTime", 0);
  279. _itemConsumeSteps = set.getInteger("itemConsumeSteps", 0);
  280. _summonTotalLifeTime= set.getInteger("summonTotalLifeTime", 1200000); // 20 minutes default
  281. _summonTimeLostIdle= set.getInteger("summonTimeLostIdle", 0);
  282. _summonTimeLostActive= set.getInteger("summonTimeLostActive", 0);
  283. _afterEffectId = set.getInteger("afterEffectId", 0);
  284. _afterEffectLvl = set.getInteger("afterEffectLvl", 1);
  285. _isCubic = set.getBool("isCubic", false);
  286. String coords = set.getString("teleCoords", null);
  287. if (coords != null)
  288. {
  289. String[] valuesSplit = coords.split(",");
  290. _teleportCoords = new int[valuesSplit.length];
  291. for (int i = 0; i < valuesSplit.length;i++)
  292. _teleportCoords[i] = Integer.valueOf(valuesSplit[i]);
  293. }
  294. else
  295. _teleportCoords = null;
  296. _recallType = set.getString("recallType", "");
  297. _isAdvancedFlag = set.getBool("isAdvancedFlag", false);
  298. _activationtime= set.getInteger("activationtime", 8);
  299. _activationchance= set.getInteger("activationchance", 30);
  300. _castRange = set.getInteger("castRange", -1);
  301. _effectRange = set.getInteger("effectRange", -1);
  302. _abnormalLvl = set.getInteger("abnormalLvl", -1);
  303. _effectAbnormalLvl = set.getInteger("effectAbnormalLvl", -1); // support for a separate effect abnormal lvl, e.g. poison inside a different skill
  304. _negateLvl = set.getInteger("negateLvl", -1);
  305. _learnSkillId = set.getInteger("learnSkillId",0);
  306. _learnSkillLvl = set.getInteger("learnSkillLvl",1);
  307. _attribute = set.getString("attribute","");
  308. String str = set.getString("negateStats", "");
  309. if (str == "")
  310. _negateStats = new L2SkillType[0];
  311. else
  312. {
  313. String[] stats = str.split(" ");
  314. L2SkillType[] array = new L2SkillType[stats.length];
  315. for (int i = 0; i < stats.length; i++)
  316. {
  317. L2SkillType type = null;
  318. try
  319. {
  320. type = Enum.valueOf(L2SkillType.class, stats[i]);
  321. }
  322. catch (Exception e)
  323. {
  324. throw new IllegalArgumentException("SkillId: "+_id+"Enum value of type "+L2SkillType.class.getName()+"required, but found: "+stats[i]);
  325. }
  326. array[i] = type;
  327. }
  328. _negateStats = array;
  329. }
  330. String negateId = set.getString("negateId", null);
  331. if (negateId != null)
  332. {
  333. String[] valuesSplit = negateId.split(",");
  334. _negateId = new int[valuesSplit.length];
  335. for (int i = 0; i < valuesSplit.length;i++)
  336. {
  337. _negateId[i] = Integer.valueOf(valuesSplit[i]);
  338. }
  339. }
  340. else
  341. _negateId = new int[0];
  342. _maxNegatedEffects = set.getInteger("maxNegated", 0);
  343. _killByDOT = set.getBool("killByDOT", false);
  344. _isNeutral = set.getBool("neutral",false);
  345. _hitTime = set.getInteger("hitTime", 0);
  346. _coolTime = set.getInteger("coolTime", 0);
  347. _isDebuff = set.getBool("isDebuff", false);
  348. _feed = set.getInteger("feed", 0);
  349. if (Config.ENABLE_MODIFY_SKILL_REUSE && Config.SKILL_REUSE_LIST.containsKey(_id))
  350. {
  351. if ( Config.DEBUG )
  352. _log.info("*** Skill " + _name + " (" + _level + ") changed reuse from " + set.getInteger("reuseDelay", 0) + " to " + Config.SKILL_REUSE_LIST.get(_id) + " seconds.");
  353. _reuseDelay = Config.SKILL_REUSE_LIST.get(_id);
  354. }
  355. else
  356. {
  357. _reuseDelay = set.getInteger("reuseDelay", 0);
  358. }
  359. _buffDuration = set.getInteger("buffDuration", 0);
  360. _equipDelay = set.getInteger("equipDelay", 0);
  361. _skillRadius = set.getInteger("skillRadius", 80);
  362. _targetType = set.getEnum("target", SkillTargetType.class);
  363. _power = set.getFloat("power", 0.f);
  364. _magicLevel = set.getInteger("magicLvl", SkillTreeTable.getInstance().getMinSkillLevel(_id, _level));
  365. _levelDepend = set.getInteger("lvlDepend", 0);
  366. _ignoreResists = set.getBool("ignoreResists", false);
  367. _stat = set.getEnum("stat", Stats.class, null);
  368. _useShield = set.getBool("useShield", false);
  369. _skillType = set.getEnum("skillType", L2SkillType.class);
  370. _effectType = set.getEnum("effectType", L2SkillType.class, null);
  371. _effectId = set.getInteger("effectId", 0);
  372. _effectLvl = set.getInteger("effectLevel", 0);
  373. _element = set.getInteger("element", 0);
  374. _condition = set.getInteger("condition", 0);
  375. _conditionValue = set.getInteger("conditionValue", 0);
  376. _overhit = set.getBool("overHit", false);
  377. _isSuicideAttack = set.getBool("isSuicideAttack", false);
  378. _weaponsAllowed = set.getInteger("weaponsAllowed", 0);
  379. _armorsAllowed = set.getInteger("armorsAllowed", 0);
  380. _minPledgeClass = set.getInteger("minPledgeClass", 0);
  381. _isOffensive = set.getBool("offensive", isSkillTypeOffensive());
  382. _maxCharges = set.getInteger("maxCharges", 0);
  383. _numCharges = set.getInteger("numCharges", 0);
  384. _requiredCharges = set.getInteger("requiredCharges", 0);
  385. _triggeredId = set.getInteger("triggeredId", 0);
  386. _triggeredLevel = set.getInteger("triggeredLevel", 0);
  387. _chanceType = set.getString("chanceType", "");
  388. if (_chanceType != "" && !_chanceType.isEmpty())
  389. _chanceCondition = ChanceCondition.parse(set);
  390. _numSouls = set.getInteger("num_souls", 0);
  391. _soulMaxConsume = set.getInteger("soulMaxConsumeCount", 0);
  392. _soulConsume = set.getInteger("soulConsumeCount", 0);
  393. _expNeeded = set.getInteger("expNeeded", 0);
  394. _critChance = set.getInteger("critChance", 0);
  395. _transformId = set.getInteger("transformId", 0);
  396. _transformDuration = set.getInteger("transformDuration", 0);
  397. _isHeroSkill = HeroSkillTable.isHeroSkill(_id);
  398. _baseCritRate = set.getInteger("baseCritRate", (_skillType == L2SkillType.PDAM || _skillType == L2SkillType.BLOW) ? 0 : -1);
  399. _lethalEffect1 = set.getInteger("lethal1",0);
  400. _lethalEffect2 = set.getInteger("lethal2",0);
  401. _directHpDmg = set.getBool("dmgDirectlyToHp",false);
  402. _isDance = set.getBool("isDance",false);
  403. _nextDanceCost = set.getInteger("nextDanceCost", 0);
  404. _sSBoost = set.getFloat("SSBoost", 0.f);
  405. _aggroPoints = set.getInteger("aggroPoints", 0);
  406. _flyType = set.getString("flyType", null);
  407. _flyRadius = set.getInteger("flyRadius", 200);
  408. _flyCourse = set.getFloat("flyCourse", 0);
  409. }
  410. public abstract void useSkill(L2Character caster, L2Object[] targets);
  411. public final boolean isPotion()
  412. {
  413. return _ispotion;
  414. }
  415. public final int getArmorsAllowed()
  416. {
  417. return _armorsAllowed;
  418. }
  419. public final int getConditionValue()
  420. {
  421. return _conditionValue;
  422. }
  423. public final L2SkillType getSkillType()
  424. {
  425. return _skillType;
  426. }
  427. public final int getElement()
  428. {
  429. return _element;
  430. }
  431. /**
  432. * Return the target type of the skill : SELF, PARTY, CLAN, PET...<BR><BR>
  433. *
  434. */
  435. public final SkillTargetType getTargetType()
  436. {
  437. return _targetType;
  438. }
  439. public final int getCondition()
  440. {
  441. return _condition;
  442. }
  443. public final boolean isOverhit()
  444. {
  445. return _overhit;
  446. }
  447. public final boolean killByDOT()
  448. {
  449. return _killByDOT;
  450. }
  451. public final boolean isSuicideAttack()
  452. {
  453. return _isSuicideAttack;
  454. }
  455. public final boolean allowOnTransform()
  456. {
  457. return isPassive();
  458. }
  459. /**
  460. * Return the power of the skill.<BR><BR>
  461. */
  462. public final double getPower(L2Character activeChar)
  463. {
  464. if (activeChar == null)
  465. return _power;
  466. switch (_skillType)
  467. {
  468. case DEATHLINK:
  469. {
  470. return _power * Math.pow(1.7165 - activeChar.getCurrentHp() / activeChar.getMaxHp(), 2) * 0.577;
  471. /*
  472. * DrHouse:
  473. * Rolling back to old formula (look below) for DEATHLINK due to this one based on logarithm is not
  474. * accurate enough. Commented here because probably is a matter of just adjusting a constant
  475. if(activeChar.getCurrentHp() / activeChar.getMaxHp() > 0.005)
  476. return _power*(-0.45*Math.log(activeChar.getCurrentHp()/activeChar.getMaxHp())+1.);
  477. else
  478. return _power*(-0.45*Math.log(0.005)+1.);
  479. */
  480. }
  481. case FATAL:
  482. {
  483. return _power*3.5*(1-activeChar.getCurrentHp()/activeChar.getMaxHp());
  484. }
  485. default:
  486. return _power;
  487. }
  488. }
  489. public final double getPower()
  490. {
  491. return _power;
  492. }
  493. public final L2SkillType[] getNegateStats()
  494. {
  495. return _negateStats;
  496. }
  497. public final int getAbnormalLvl()
  498. {
  499. return _abnormalLvl;
  500. }
  501. public final int getNegateLvl()
  502. {
  503. return _negateLvl;
  504. }
  505. public final int[] getNegateId()
  506. {
  507. return _negateId;
  508. }
  509. public final int getMagicLevel()
  510. {
  511. return _magicLevel;
  512. }
  513. public final int getMaxNegatedEffects()
  514. {
  515. return _maxNegatedEffects;
  516. }
  517. public final int getLevelDepend()
  518. {
  519. return _levelDepend;
  520. }
  521. /**
  522. * Return true if skill should ignore all resistances
  523. */
  524. public final boolean ignoreResists()
  525. {
  526. return _ignoreResists;
  527. }
  528. /**
  529. * Return the additional effect Id.<BR><BR>
  530. */
  531. public final int getEffectId()
  532. {
  533. return _effectId;
  534. }
  535. /**
  536. * Return the additional effect level.<BR><BR>
  537. */
  538. public final int getEffectLvl()
  539. {
  540. return _effectLvl;
  541. }
  542. public final int getEffectAbnormalLvl()
  543. {
  544. return _effectAbnormalLvl;
  545. }
  546. /**
  547. * Return the additional effect skill type (ex : STUN, PARALYZE,...).<BR><BR>
  548. */
  549. public final L2SkillType getEffectType()
  550. {
  551. return _effectType;
  552. }
  553. /**
  554. * @return Returns the buffDuration.
  555. */
  556. public final int getBuffDuration()
  557. {
  558. return _buffDuration;
  559. }
  560. /**
  561. * @return Returns the castRange.
  562. */
  563. public final int getCastRange()
  564. {
  565. return _castRange;
  566. }
  567. /**
  568. * @return Returns the cpConsume;
  569. */
  570. public final int getCpConsume()
  571. {
  572. return _cpConsume;
  573. }
  574. /**
  575. * @return Returns the effectRange.
  576. */
  577. public final int getEffectRange()
  578. {
  579. return _effectRange;
  580. }
  581. /**
  582. * @return Returns the hpConsume.
  583. */
  584. public final int getHpConsume()
  585. {
  586. return _hpConsume;
  587. }
  588. /**
  589. * @return Returns the id.
  590. */
  591. public final int getId()
  592. {
  593. return _id;
  594. }
  595. /**
  596. * @return Returns the boolean _isDebuff.
  597. */
  598. public final boolean isDebuff()
  599. {
  600. return _isDebuff;
  601. }
  602. public int getDisplayId()
  603. {
  604. return _displayId;
  605. }
  606. public void setDisplayId(int id)
  607. {
  608. _displayId = id;
  609. }
  610. public int getTriggeredId()
  611. {
  612. return _triggeredId;
  613. }
  614. public int getTriggeredLevel()
  615. {
  616. return _triggeredLevel;
  617. }
  618. public boolean triggerAnotherSkill()
  619. {
  620. return _triggeredId > 1;
  621. }
  622. /**
  623. * Return the skill type (ex : BLEED, SLEEP, WATER...).<BR><BR>
  624. */
  625. public final Stats getStat()
  626. {
  627. return _stat;
  628. }
  629. /**
  630. * @return Returns the _targetConsumeId.
  631. */
  632. public final int getTargetConsumeId()
  633. {
  634. return _targetConsumeId;
  635. }
  636. /**
  637. * @return Returns the targetConsume.
  638. */
  639. public final int getTargetConsume()
  640. {
  641. return _targetConsume;
  642. }
  643. /**
  644. * @return Returns the itemConsume.
  645. */
  646. public final int getItemConsume()
  647. {
  648. return _itemConsume;
  649. }
  650. /**
  651. * @return Returns the itemConsumeId.
  652. */
  653. public final int getItemConsumeId()
  654. {
  655. return _itemConsumeId;
  656. }
  657. /**
  658. * @return Returns the itemConsume count over time.
  659. */
  660. public final int getItemConsumeOT()
  661. {
  662. return _itemConsumeOT;
  663. }
  664. /**
  665. * @return Returns the itemConsumeId over time.
  666. */
  667. public final int getItemConsumeIdOT()
  668. {
  669. return _itemConsumeIdOT;
  670. }
  671. /**
  672. * @return Returns the itemConsume count over time.
  673. */
  674. public final int getItemConsumeSteps()
  675. {
  676. return _itemConsumeSteps;
  677. }
  678. /**
  679. * @return Returns the itemConsume count over time.
  680. */
  681. public final int getTotalLifeTime()
  682. {
  683. return _summonTotalLifeTime;
  684. }
  685. /**
  686. * @return Returns the itemConsume count over time.
  687. */
  688. public final int getTimeLostIdle()
  689. {
  690. return _summonTimeLostIdle;
  691. }
  692. /**
  693. * @return Returns the itemConsumeId over time.
  694. */
  695. public final int getTimeLostActive()
  696. {
  697. return _summonTimeLostActive;
  698. }
  699. public final boolean isCubic()
  700. {
  701. return _isCubic;
  702. }
  703. /**
  704. * @return Returns the itemConsume time in milliseconds.
  705. */
  706. public final int getItemConsumeTime()
  707. {
  708. return _itemConsumeTime;
  709. }
  710. /**
  711. * @return Returns the activation time for a cubic.
  712. */
  713. public final int getActivationTime()
  714. {
  715. return _activationtime;
  716. }
  717. /**
  718. * @return Returns the activation chance for a cubic.
  719. */
  720. public final int getActivationChance()
  721. {
  722. return _activationchance;
  723. }
  724. /**
  725. * @return Returns the level.
  726. */
  727. public final int getLevel()
  728. {
  729. return _level;
  730. }
  731. /**
  732. * @return Returns the magic.
  733. */
  734. public final boolean isMagic()
  735. {
  736. return _magic;
  737. }
  738. /**
  739. * @return Returns true to set static reuse.
  740. */
  741. public final boolean isStaticReuse()
  742. {
  743. return _staticReuse;
  744. }
  745. /**
  746. * @return Returns true to set static hittime.
  747. */
  748. public final boolean isStaticHitTime()
  749. {
  750. return _staticHitTime;
  751. }
  752. /**
  753. * @return Returns the mpConsume.
  754. */
  755. public final int getMpConsume()
  756. {
  757. return _mpConsume;
  758. }
  759. /**
  760. * @return Returns the mpInitialConsume.
  761. */
  762. public final int getMpInitialConsume()
  763. {
  764. return _mpInitialConsume;
  765. }
  766. /**
  767. * @return Returns the name.
  768. */
  769. public final String getName()
  770. {
  771. return _name;
  772. }
  773. /**
  774. * @return Returns the reuseDelay.
  775. */
  776. public final int getReuseDelay()
  777. {
  778. return _reuseDelay;
  779. }
  780. public final int getEquipDelay()
  781. {
  782. return _equipDelay;
  783. }
  784. public final int getHitTime()
  785. {
  786. return _hitTime;
  787. }
  788. /**
  789. * @return Returns the coolTime.
  790. */
  791. public final int getCoolTime()
  792. {
  793. return _coolTime;
  794. }
  795. public final int getSkillRadius()
  796. {
  797. return _skillRadius;
  798. }
  799. public final boolean isActive()
  800. {
  801. return _operateType == SkillOpType.OP_ACTIVE;
  802. }
  803. public final boolean isPassive()
  804. {
  805. return _operateType == SkillOpType.OP_PASSIVE;
  806. }
  807. public final boolean isToggle()
  808. {
  809. return _operateType == SkillOpType.OP_TOGGLE;
  810. }
  811. public final boolean isChance()
  812. {
  813. return _chanceCondition != null && isPassive();
  814. }
  815. public ChanceCondition getChanceCondition()
  816. {
  817. return _chanceCondition;
  818. }
  819. public final boolean isDance()
  820. {
  821. return _isDance;
  822. }
  823. public final int getNextDanceMpCost()
  824. {
  825. return _nextDanceCost;
  826. }
  827. public final float getSSBoost()
  828. {
  829. return _sSBoost;
  830. }
  831. public final int getAggroPoints()
  832. {
  833. return _aggroPoints;
  834. }
  835. public final boolean useSoulShot()
  836. {
  837. switch (getSkillType())
  838. {
  839. case PDAM:
  840. case STUN:
  841. case CHARGEDAM:
  842. case BLOW:
  843. return true;
  844. default:
  845. return false;
  846. }
  847. }
  848. public final boolean useSpiritShot()
  849. {
  850. return isMagic();
  851. }
  852. public final boolean useFishShot()
  853. {
  854. return ((getSkillType() == L2SkillType.PUMPING) || (getSkillType() == L2SkillType.REELING) );
  855. }
  856. public final int getWeaponsAllowed()
  857. {
  858. return _weaponsAllowed;
  859. }
  860. public int getMinPledgeClass() { return _minPledgeClass; }
  861. public final boolean isPvpSkill()
  862. {
  863. switch (_skillType)
  864. {
  865. case DOT:
  866. case BLEED:
  867. case CONFUSION:
  868. case POISON:
  869. case DEBUFF:
  870. case AGGDEBUFF:
  871. case STUN:
  872. case ROOT:
  873. case FEAR:
  874. case SLEEP:
  875. case MDOT:
  876. case MUTE:
  877. case WEAKNESS:
  878. case PARALYZE:
  879. case CANCEL:
  880. case MAGE_BANE:
  881. case WARRIOR_BANE:
  882. case BETRAY:
  883. case DISARM:
  884. case AGGDAMAGE:
  885. return true;
  886. default:
  887. return false;
  888. }
  889. }
  890. public final boolean isOffensive()
  891. {
  892. return _isOffensive;
  893. }
  894. public final boolean isNeutral()
  895. {
  896. return _isNeutral;
  897. }
  898. public final boolean isHeroSkill()
  899. {
  900. return _isHeroSkill;
  901. }
  902. public final int getNumCharges()
  903. {
  904. return _numCharges;
  905. }
  906. public final int getNumSouls()
  907. {
  908. return _numSouls;
  909. }
  910. public final int getMaxSoulConsumeCount()
  911. {
  912. return _soulMaxConsume;
  913. }
  914. public final int getSoulConsumeCount()
  915. {
  916. return _soulConsume;
  917. }
  918. public final int getExpNeeded()
  919. {
  920. return _expNeeded;
  921. }
  922. public final int getCritChance()
  923. {
  924. return _critChance;
  925. }
  926. public final int getTransformId()
  927. {
  928. return _transformId;
  929. }
  930. public final int getTransformDuration()
  931. {
  932. return _transformDuration;
  933. }
  934. public final int getBaseCritRate()
  935. {
  936. return _baseCritRate;
  937. }
  938. public final int getLethalChance1()
  939. {
  940. return _lethalEffect1;
  941. }
  942. public final int getLethalChance2()
  943. {
  944. return _lethalEffect2;
  945. }
  946. public final boolean getDmgDirectlyToHP()
  947. {
  948. return _directHpDmg;
  949. }
  950. public final String getFlyType()
  951. {
  952. return _flyType;
  953. }
  954. public final int getFlyRadius()
  955. {
  956. return _flyRadius;
  957. }
  958. public final float getFlyCourse()
  959. {
  960. return _flyCourse;
  961. }
  962. public final boolean isSkillTypeOffensive()
  963. {
  964. switch (_skillType)
  965. {
  966. case PDAM:
  967. case MDAM:
  968. case CPDAM:
  969. case DOT:
  970. case BLEED:
  971. case POISON:
  972. case AGGDAMAGE:
  973. case DEBUFF:
  974. case AGGDEBUFF:
  975. case STUN:
  976. case ROOT:
  977. case CONFUSION:
  978. case ERASE:
  979. case BLOW:
  980. case FATAL:
  981. case FEAR:
  982. case DRAIN:
  983. case SLEEP:
  984. case CHARGEDAM:
  985. case CONFUSE_MOB_ONLY:
  986. case DEATHLINK:
  987. case DETECT_WEAKNESS:
  988. case MANADAM:
  989. case MDOT:
  990. case MUTE:
  991. case SOULSHOT:
  992. case SPIRITSHOT:
  993. case SPOIL:
  994. case WEAKNESS:
  995. case MANA_BY_LEVEL:
  996. case SWEEP:
  997. case PARALYZE:
  998. case DRAIN_SOUL:
  999. case AGGREDUCE:
  1000. case CANCEL:
  1001. case MAGE_BANE:
  1002. case WARRIOR_BANE:
  1003. case AGGREMOVE:
  1004. case AGGREDUCE_CHAR:
  1005. case BETRAY:
  1006. case DELUXE_KEY_UNLOCK:
  1007. case SOW:
  1008. case HARVEST:
  1009. case DISARM:
  1010. case STEAL_BUFF:
  1011. case INSTANT_JUMP:
  1012. return true;
  1013. default:
  1014. return this.isDebuff();
  1015. }
  1016. }
  1017. // int weapons[] = {L2Weapon.WEAPON_TYPE_ETC, L2Weapon.WEAPON_TYPE_BOW,
  1018. // L2Weapon.WEAPON_TYPE_POLE, L2Weapon.WEAPON_TYPE_DUALFIST,
  1019. // L2Weapon.WEAPON_TYPE_DUAL, L2Weapon.WEAPON_TYPE_BLUNT,
  1020. // L2Weapon.WEAPON_TYPE_SWORD, L2Weapon.WEAPON_TYPE_DAGGER};
  1021. public final boolean getWeaponDependancy(L2Character activeChar)
  1022. {
  1023. if(getWeaponDependancy(activeChar,false))
  1024. {
  1025. return true;
  1026. }
  1027. else
  1028. {
  1029. SystemMessage message = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  1030. message.addSkillName(this);
  1031. activeChar.sendPacket(message);
  1032. return false;
  1033. }
  1034. }
  1035. public final boolean getWeaponDependancy(L2Character activeChar,boolean chance)
  1036. {
  1037. int weaponsAllowed = getWeaponsAllowed();
  1038. //check to see if skill has a weapon dependency.
  1039. if (weaponsAllowed == 0)
  1040. return true;
  1041. int mask = 0;
  1042. if (activeChar.getActiveWeaponItem() != null)
  1043. mask |= activeChar.getActiveWeaponItem().getItemType().mask();
  1044. if (activeChar.getSecondaryWeaponItem() != null)
  1045. mask |= activeChar.getSecondaryWeaponItem().getItemType().mask();
  1046. if ((mask & weaponsAllowed) != 0)
  1047. return true;
  1048. return false;
  1049. }
  1050. public boolean checkCondition(L2Character activeChar, L2Object target, boolean itemOrWeapon)
  1051. {
  1052. if ((getCondition() & L2Skill.COND_SHIELD) != 0)
  1053. {
  1054. /*
  1055. L2Armor armorPiece;
  1056. L2ItemInstance dummy;
  1057. dummy = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  1058. armorPiece = (L2Armor) dummy.getItem();
  1059. */
  1060. //TODO add checks for shield here.
  1061. }
  1062. Condition preCondition = _preCondition;
  1063. if(itemOrWeapon) preCondition = _itemPreCondition;
  1064. if (preCondition == null) return true;
  1065. Env env = new Env();
  1066. env.player = activeChar;
  1067. if (target instanceof L2Character) // TODO: object or char?
  1068. env.target = (L2Character)target;
  1069. env.skill = this;
  1070. if (!preCondition.test(env))
  1071. {
  1072. String msg = preCondition.getMessage();
  1073. int msgId = preCondition.getMessageId();
  1074. if (msgId != 0)
  1075. {
  1076. SystemMessage sm = new SystemMessage(msgId);
  1077. if (preCondition.isAddName())
  1078. sm.addSkillName(_id);
  1079. activeChar.sendPacket(sm);
  1080. }
  1081. else if (msg != null)
  1082. {
  1083. activeChar.sendMessage(msg);
  1084. }
  1085. return false;
  1086. }
  1087. return true;
  1088. }
  1089. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst)
  1090. {
  1091. // Init to null the target of the skill
  1092. L2Character target = null;
  1093. // Get the L2Objcet targeted by the user of the skill at this moment
  1094. L2Object objTarget = activeChar.getTarget();
  1095. // If the L2Object targeted is a L2Character, it becomes the L2Character target
  1096. if (objTarget instanceof L2Character)
  1097. {
  1098. target = (L2Character) objTarget;
  1099. }
  1100. return getTargetList(activeChar, onlyFirst, target);
  1101. }
  1102. /**
  1103. * Return all targets of the skill in a table in function a the skill type.<BR><BR>
  1104. *
  1105. * <B><U> Values of skill type</U> :</B><BR><BR>
  1106. * <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>
  1107. * <li>SELF</li>
  1108. * <li>HOLY, UNDEAD</li>
  1109. * <li>PET</li>
  1110. * <li>AURA, AURA_CLOSE</li>
  1111. * <li>AREA</li>
  1112. * <li>MULTIFACE</li>
  1113. * <li>PARTY, CLAN</li>
  1114. * <li>CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN</li>
  1115. * <li>UNLOCKABLE</li>
  1116. * <li>ITEM</li><BR><BR>
  1117. *
  1118. * @param activeChar The L2Character who use the skill
  1119. *
  1120. */
  1121. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst, L2Character target)
  1122. {
  1123. List<L2Character> targetList = new FastList<L2Character>();
  1124. // Get the target type of the skill
  1125. // (ex : ONE, SELF, HOLY, PET, AURA, AURA_CLOSE, AREA, MULTIFACE, PARTY, CLAN, CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN, UNLOCKABLE, ITEM, UNDEAD)
  1126. SkillTargetType targetType = getTargetType();
  1127. // Get the type of the skill
  1128. // (ex : PDAM, MDAM, DOT, BLEED, POISON, HEAL, HOT, MANAHEAL, MANARECHARGE, AGGDAMAGE, BUFF, DEBUFF, STUN, ROOT, RESURRECT, PASSIVE...)
  1129. L2SkillType skillType = getSkillType();
  1130. switch (targetType)
  1131. {
  1132. // The skill can only be used on the L2Character targeted, or on the caster itself
  1133. case TARGET_ONE:
  1134. {
  1135. boolean canTargetSelf = false;
  1136. switch (skillType)
  1137. {
  1138. case BUFF:
  1139. case HEAL:
  1140. case HOT:
  1141. case HEAL_PERCENT:
  1142. case MANARECHARGE:
  1143. case MANAHEAL:
  1144. case NEGATE:
  1145. case CANCEL:
  1146. case CANCEL_DEBUFF:
  1147. case REFLECT:
  1148. case COMBATPOINTHEAL:
  1149. case MAGE_BANE:
  1150. case WARRIOR_BANE:
  1151. case BETRAY:
  1152. case BALANCE_LIFE:
  1153. canTargetSelf = true;
  1154. break;
  1155. }
  1156. // Check for null target or any other invalid target
  1157. if (target == null || target.isDead() || (target == activeChar && !canTargetSelf))
  1158. {
  1159. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1160. return _emptyTargetList;
  1161. }
  1162. // If a target is found, return it in a table else send a system message TARGET_IS_INCORRECT
  1163. return new L2Character[] {target};
  1164. }
  1165. case TARGET_SELF:
  1166. case TARGET_GROUND:
  1167. {
  1168. return new L2Character[] {activeChar};
  1169. }
  1170. case TARGET_HOLY:
  1171. {
  1172. if (activeChar instanceof L2PcInstance)
  1173. {
  1174. if (target instanceof L2ArtefactInstance)
  1175. return new L2Character[] {target};
  1176. }
  1177. return _emptyTargetList;
  1178. }
  1179. case TARGET_FLAGPOLE:
  1180. {
  1181. return new L2Character[] {activeChar};
  1182. }
  1183. case TARGET_PET:
  1184. {
  1185. target = activeChar.getPet();
  1186. if (target != null && !target.isDead()) return new L2Character[] {target};
  1187. return _emptyTargetList;
  1188. }
  1189. case TARGET_SUMMON:
  1190. {
  1191. target = activeChar.getPet();
  1192. if (target != null && !target.isDead() && target instanceof L2SummonInstance) return new L2Character[] {target};
  1193. return _emptyTargetList;
  1194. }
  1195. case TARGET_OWNER_PET:
  1196. {
  1197. if (activeChar instanceof L2Summon)
  1198. {
  1199. target = ((L2Summon)activeChar).getOwner();
  1200. if (target != null && !target.isDead())
  1201. return new L2Character[]{target};
  1202. }
  1203. return _emptyTargetList;
  1204. }
  1205. case TARGET_CORPSE_PET:
  1206. {
  1207. if (activeChar instanceof L2PcInstance)
  1208. {
  1209. target = activeChar.getPet();
  1210. if (target != null && target.isDead())
  1211. return new L2Character[]{target};
  1212. }
  1213. return _emptyTargetList;
  1214. }
  1215. case TARGET_AURA:
  1216. {
  1217. int radius = getSkillRadius();
  1218. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1219. L2PcInstance src = activeChar.getActingPlayer();
  1220. // Go through the L2Character _knownList
  1221. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1222. //synchronized (activeChar.getKnownList().getKnownObjects())
  1223. if (getSkillType() == L2SkillType.DUMMY)
  1224. {
  1225. for (L2Object obj : objs)
  1226. {
  1227. if (!(obj == activeChar || obj instanceof L2Npc || obj instanceof L2Attackable))
  1228. continue;
  1229. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1230. continue;
  1231. targetList.add((L2Character) obj);
  1232. }
  1233. targetList.add(activeChar);
  1234. }
  1235. else
  1236. {
  1237. for (L2Object obj : objs)
  1238. {
  1239. if (obj instanceof L2Attackable
  1240. || obj instanceof L2Playable)
  1241. {
  1242. // Don't add this target if this is a Pc->Pc pvp
  1243. // casting and pvp condition not met
  1244. if (obj == activeChar || obj == src
  1245. || ((L2Character) obj).isDead())
  1246. continue;
  1247. if (src != null)
  1248. {
  1249. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1250. continue;
  1251. // check if both attacker and target are
  1252. // L2PcInstances and if they are in same party
  1253. if (obj instanceof L2PcInstance)
  1254. {
  1255. if (!src.checkPvpSkill(obj, this))
  1256. continue;
  1257. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1258. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1259. continue;
  1260. if (!srcInArena
  1261. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1262. {
  1263. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1264. && src.getAllyId() != 0)
  1265. continue;
  1266. if (src.getClanId() != 0
  1267. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1268. continue;
  1269. }
  1270. }
  1271. if (obj instanceof L2Summon)
  1272. {
  1273. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1274. if (trg == src)
  1275. continue;
  1276. if (!src.checkPvpSkill(trg, this))
  1277. continue;
  1278. if ((src.getParty() != null && trg.getParty() != null)
  1279. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1280. continue;
  1281. if (!srcInArena
  1282. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1283. {
  1284. if (src.getAllyId() == trg.getAllyId()
  1285. && src.getAllyId() != 0)
  1286. continue;
  1287. if (src.getClanId() != 0
  1288. && src.getClanId() == trg.getClanId())
  1289. continue;
  1290. }
  1291. }
  1292. }
  1293. else
  1294. // Skill user is not L2PlayableInstance
  1295. {
  1296. if (!(obj instanceof L2Playable) // Target
  1297. // is
  1298. // not
  1299. // L2PlayableInstance
  1300. && !activeChar.isConfused()) // and
  1301. // caster
  1302. // not
  1303. // confused
  1304. // (?)
  1305. continue;
  1306. }
  1307. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1308. continue;
  1309. if (onlyFirst == false)
  1310. targetList.add((L2Character) obj);
  1311. else
  1312. return new L2Character[] { (L2Character) obj };
  1313. }
  1314. }
  1315. }
  1316. return targetList.toArray(new L2Character[targetList.size()]);
  1317. }
  1318. case TARGET_FRONT_AURA:
  1319. {
  1320. int radius = getSkillRadius();
  1321. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1322. L2PcInstance src = activeChar.getActingPlayer();
  1323. // Go through the L2Character _knownList
  1324. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1325. //synchronized (activeChar.getKnownList().getKnownObjects())
  1326. {
  1327. for (L2Object obj : objs)
  1328. {
  1329. if (obj instanceof L2Attackable
  1330. || obj instanceof L2Playable)
  1331. {
  1332. // Don't add this target if this is a Pc->Pc pvp
  1333. // casting and pvp condition not met
  1334. if (obj == activeChar || obj == src
  1335. || ((L2Character) obj).isDead())
  1336. continue;
  1337. if (src != null)
  1338. {
  1339. if (!((L2Character) obj).isInFrontOf(activeChar))
  1340. continue;
  1341. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1342. continue;
  1343. // check if both attacker and target are
  1344. // L2PcInstances and if they are in same party
  1345. if (obj instanceof L2PcInstance)
  1346. {
  1347. if (!src.checkPvpSkill(obj, this))
  1348. continue;
  1349. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1350. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1351. continue;
  1352. if (!srcInArena
  1353. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1354. {
  1355. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1356. && src.getAllyId() != 0)
  1357. continue;
  1358. if (src.getClanId() != 0
  1359. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1360. continue;
  1361. }
  1362. }
  1363. if (obj instanceof L2Summon)
  1364. {
  1365. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1366. if (trg == src)
  1367. continue;
  1368. if (!src.checkPvpSkill(trg, this))
  1369. continue;
  1370. if ((src.getParty() != null && trg.getParty() != null)
  1371. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1372. continue;
  1373. if (!srcInArena
  1374. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1375. {
  1376. if (src.getAllyId() == trg.getAllyId()
  1377. && src.getAllyId() != 0)
  1378. continue;
  1379. if (src.getClanId() != 0
  1380. && src.getClanId() == trg.getClanId())
  1381. continue;
  1382. }
  1383. }
  1384. }
  1385. else
  1386. // Skill user is not L2PlayableInstance
  1387. {
  1388. if (!(obj instanceof L2Playable) // Target
  1389. // is
  1390. // not
  1391. // L2PlayableInstance
  1392. && !activeChar.isConfused()) // and
  1393. // caster
  1394. // not
  1395. // confused
  1396. // (?)
  1397. continue;
  1398. }
  1399. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1400. continue;
  1401. if (onlyFirst == false)
  1402. targetList.add((L2Character) obj);
  1403. else
  1404. return new L2Character[] { (L2Character) obj };
  1405. }
  1406. }
  1407. }
  1408. return targetList.toArray(new L2Character[targetList.size()]);
  1409. }
  1410. case TARGET_BEHIND_AURA:
  1411. {
  1412. int radius = getSkillRadius();
  1413. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1414. L2PcInstance src = activeChar.getActingPlayer();
  1415. // Go through the L2Character _knownList
  1416. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1417. //synchronized (activeChar.getKnownList().getKnownObjects())
  1418. {
  1419. for (L2Object obj : objs)
  1420. {
  1421. if (obj instanceof L2Attackable
  1422. || obj instanceof L2Playable)
  1423. {
  1424. // Don't add this target if this is a Pc->Pc pvp
  1425. // casting and pvp condition not met
  1426. if (obj == activeChar || obj == src
  1427. || ((L2Character) obj).isDead())
  1428. continue;
  1429. if (src != null)
  1430. {
  1431. if (!((L2Character) obj).isBehind(activeChar))
  1432. continue;
  1433. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1434. continue;
  1435. // check if both attacker and target are
  1436. // L2PcInstances and if they are in same party
  1437. if (obj instanceof L2PcInstance)
  1438. {
  1439. if (!src.checkPvpSkill(obj, this))
  1440. continue;
  1441. if ((src.getParty() != null && ((L2PcInstance) obj).getParty() != null)
  1442. && src.getParty().getPartyLeaderOID() == ((L2PcInstance) obj).getParty().getPartyLeaderOID())
  1443. continue;
  1444. if (!srcInArena
  1445. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1446. {
  1447. if (src.getAllyId() == ((L2PcInstance) obj).getAllyId()
  1448. && src.getAllyId() != 0)
  1449. continue;
  1450. if (src.getClanId() != 0
  1451. && src.getClanId() == ((L2PcInstance) obj).getClanId())
  1452. continue;
  1453. }
  1454. }
  1455. if (obj instanceof L2Summon)
  1456. {
  1457. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1458. if (trg == src)
  1459. continue;
  1460. if (!src.checkPvpSkill(trg, this))
  1461. continue;
  1462. if ((src.getParty() != null && trg.getParty() != null)
  1463. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1464. continue;
  1465. if (!srcInArena
  1466. && !(((L2Character) obj).isInsideZone(L2Character.ZONE_PVP) && !((L2Character) obj).isInsideZone(L2Character.ZONE_SIEGE)))
  1467. {
  1468. if (src.getAllyId() == trg.getAllyId()
  1469. && src.getAllyId() != 0)
  1470. continue;
  1471. if (src.getClanId() != 0
  1472. && src.getClanId() == trg.getClanId())
  1473. continue;
  1474. }
  1475. }
  1476. }
  1477. else
  1478. // Skill user is not L2PlayableInstance
  1479. {
  1480. if (!(obj instanceof L2Playable) // Target
  1481. // is
  1482. // not
  1483. // L2PlayableInstance
  1484. && !activeChar.isConfused()) // and
  1485. // caster
  1486. // not
  1487. // confused
  1488. // (?)
  1489. continue;
  1490. }
  1491. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1492. continue;
  1493. if (onlyFirst == false)
  1494. targetList.add((L2Character) obj);
  1495. else
  1496. return new L2Character[] { (L2Character) obj };
  1497. }
  1498. }
  1499. }
  1500. return targetList.toArray(new L2Character[targetList.size()]);
  1501. }
  1502. case TARGET_AREA:
  1503. {
  1504. if ((!(target instanceof L2Attackable || target instanceof L2Playable)) || // Target
  1505. // is
  1506. // not
  1507. // L2Attackable
  1508. // or
  1509. // L2PlayableInstance
  1510. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1511. // is
  1512. // null
  1513. // or
  1514. // self
  1515. // or
  1516. // dead/faking
  1517. {
  1518. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1519. return _emptyTargetList;
  1520. }
  1521. L2Character cha;
  1522. if (getCastRange() >= 0)
  1523. {
  1524. cha = target;
  1525. if(!onlyFirst) targetList.add(cha); // Add target to target list
  1526. else return new L2Character[]{cha};
  1527. }
  1528. else cha = activeChar;
  1529. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2Playable);
  1530. L2PcInstance src = activeChar.getActingPlayer();
  1531. int radius = getSkillRadius();
  1532. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1533. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1534. //synchronized (activeChar.getKnownList().getKnownObjects())
  1535. {
  1536. for (L2Object obj : objs)
  1537. {
  1538. if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  1539. continue;
  1540. if (obj == cha)
  1541. continue;
  1542. target = (L2Character) obj;
  1543. if (!GeoData.getInstance().canSeeTarget(activeChar, target))
  1544. continue;
  1545. if (!target.isDead() && (target != activeChar))
  1546. {
  1547. if (!Util.checkIfInRange(radius, obj, cha, true))
  1548. continue;
  1549. if (src != null) // caster is l2playableinstance
  1550. // and exists
  1551. {
  1552. if (obj instanceof L2PcInstance)
  1553. {
  1554. L2PcInstance trg = (L2PcInstance) obj;
  1555. if (trg == src)
  1556. continue;
  1557. if ((src.getParty() != null && trg.getParty() != null)
  1558. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1559. continue;
  1560. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  1561. continue;
  1562. if (!srcInArena
  1563. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1564. {
  1565. if (src.getAllyId() == trg.getAllyId()
  1566. && src.getAllyId() != 0)
  1567. continue;
  1568. if (src.getClan() != null
  1569. && trg.getClan() != null)
  1570. {
  1571. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1572. continue;
  1573. }
  1574. if (!src.checkPvpSkill(obj, this))
  1575. continue;
  1576. }
  1577. }
  1578. if (obj instanceof L2Summon)
  1579. {
  1580. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1581. if (trg == src)
  1582. continue;
  1583. if ((src.getParty() != null && trg.getParty() != null)
  1584. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1585. continue;
  1586. if (!srcInArena
  1587. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1588. {
  1589. if (src.getAllyId() == trg.getAllyId()
  1590. && src.getAllyId() != 0)
  1591. continue;
  1592. if (src.getClan() != null
  1593. && trg.getClan() != null)
  1594. {
  1595. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1596. continue;
  1597. }
  1598. if (!src.checkPvpSkill(trg, this))
  1599. continue;
  1600. }
  1601. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  1602. continue;
  1603. }
  1604. }
  1605. else
  1606. // Skill user is not L2PlayableInstance
  1607. {
  1608. if (effectOriginIsL2PlayableInstance && // If
  1609. // effect
  1610. // starts
  1611. // at
  1612. // L2PlayableInstance
  1613. // and
  1614. !(obj instanceof L2Playable)) // Object
  1615. // is
  1616. // not
  1617. // L2PlayableInstance
  1618. continue;
  1619. }
  1620. targetList.add((L2Character) obj);
  1621. }
  1622. }
  1623. }
  1624. if (targetList.isEmpty())
  1625. return _emptyTargetList;
  1626. return targetList.toArray(new L2Character[targetList.size()]);
  1627. }
  1628. case TARGET_FRONT_AREA:
  1629. {
  1630. if ((!(target instanceof L2Attackable || target instanceof L2Playable)) || // Target
  1631. // is
  1632. // not
  1633. // L2Attackable
  1634. // or
  1635. // L2PlayableInstance
  1636. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1637. // is
  1638. // null
  1639. // or
  1640. // self
  1641. // or
  1642. // dead/faking
  1643. {
  1644. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1645. return _emptyTargetList;
  1646. }
  1647. L2Character cha;
  1648. if (getCastRange() >= 0)
  1649. {
  1650. cha = target;
  1651. if(!onlyFirst) targetList.add(cha); // Add target to target
  1652. // list
  1653. else return new L2Character[]{cha};
  1654. }
  1655. else cha = activeChar;
  1656. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2Playable);
  1657. boolean srcIsSummon = (activeChar instanceof L2Summon);
  1658. L2PcInstance src = activeChar.getActingPlayer();
  1659. int radius = getSkillRadius();
  1660. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1661. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1662. //synchronized (activeChar.getKnownList().getKnownObjects())
  1663. {
  1664. for (L2Object obj : objs)
  1665. {
  1666. if (obj == cha)
  1667. continue;
  1668. if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  1669. continue;
  1670. target = (L2Character) obj;
  1671. if (!target.isDead() && (target != activeChar))
  1672. {
  1673. if (!Util.checkIfInRange(radius, obj, activeChar, true))
  1674. continue;
  1675. if (!((L2Character) obj).isInFrontOf(activeChar))
  1676. continue;
  1677. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  1678. continue;
  1679. if (src != null) // caster is l2playableinstance
  1680. // and exists
  1681. {
  1682. if (obj instanceof L2PcInstance)
  1683. {
  1684. L2PcInstance trg = (L2PcInstance) obj;
  1685. if (trg == src)
  1686. continue;
  1687. if ((src.getParty() != null && trg.getParty() != null)
  1688. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1689. continue;
  1690. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  1691. continue;
  1692. if (!srcInArena
  1693. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1694. {
  1695. if (src.getAllyId() == trg.getAllyId()
  1696. && src.getAllyId() != 0)
  1697. continue;
  1698. if (src.getClan() != null
  1699. && trg.getClan() != null)
  1700. {
  1701. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1702. continue;
  1703. }
  1704. if (!src.checkPvpSkill(obj, this, srcIsSummon))
  1705. continue;
  1706. }
  1707. }
  1708. if (obj instanceof L2Summon)
  1709. {
  1710. L2PcInstance trg = ((L2Summon) obj).getOwner();
  1711. if (trg == src)
  1712. continue;
  1713. if ((src.getParty() != null && trg.getParty() != null)
  1714. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  1715. continue;
  1716. if (!srcInArena
  1717. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  1718. {
  1719. if (src.getAllyId() == trg.getAllyId()
  1720. && src.getAllyId() != 0)
  1721. continue;
  1722. if (src.getClan() != null
  1723. && trg.getClan() != null)
  1724. {
  1725. if (src.getClan().getClanId() == trg.getClan().getClanId())
  1726. continue;
  1727. }
  1728. if (!src.checkPvpSkill(trg, this, srcIsSummon))
  1729. continue;
  1730. }
  1731. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  1732. continue;
  1733. }
  1734. }
  1735. else
  1736. // Skill user is not L2PlayableInstance
  1737. {
  1738. if (effectOriginIsL2PlayableInstance && // If
  1739. // effect
  1740. // starts
  1741. // at
  1742. // L2PlayableInstance
  1743. // and
  1744. !(obj instanceof L2Playable)) // Object
  1745. // is
  1746. // not
  1747. // L2PlayableInstance
  1748. continue;
  1749. }
  1750. targetList.add((L2Character) obj);
  1751. }
  1752. }
  1753. }
  1754. if (targetList.isEmpty())
  1755. return _emptyTargetList;
  1756. return targetList.toArray(new L2Character[targetList.size()]);
  1757. }
  1758. case TARGET_BEHIND_AREA:
  1759. {
  1760. if ((!(target instanceof L2Attackable || target instanceof L2Playable)) || // Target
  1761. // is
  1762. // not
  1763. // L2Attackable
  1764. // or
  1765. // L2PlayableInstance
  1766. (getCastRange() >= 0 && (target == null || target == activeChar || target.isAlikeDead()))) // target
  1767. // is
  1768. // null
  1769. // or
  1770. // self
  1771. // or
  1772. // dead/faking
  1773. {
  1774. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1775. return _emptyTargetList;
  1776. }
  1777. L2Character cha;
  1778. if (getCastRange() >= 0)
  1779. {
  1780. cha = target;
  1781. if(!onlyFirst) targetList.add(cha); // Add target to target
  1782. // list
  1783. else return new L2Character[]{cha};
  1784. }
  1785. else cha = activeChar;
  1786. boolean effectOriginIsL2PlayableInstance = (cha instanceof L2Playable);
  1787. L2PcInstance src = activeChar.getActingPlayer();
  1788. int radius = getSkillRadius();
  1789. boolean srcInArena = (activeChar.isInsideZone(L2Character.ZONE_PVP) && !activeChar.isInsideZone(L2Character.ZONE_SIEGE));
  1790. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1791. //synchronized (activeChar.getKnownList().getKnownObjects())
  1792. {
  1793. for (L2Object obj : objs)
  1794. {
  1795. if (!(obj instanceof L2Attackable || obj instanceof L2Playable))
  1796. continue;
  1797. if (obj == cha)
  1798. continue;
  1799. target = (L2Character) obj;
  1800. if (!target.isDead() && (target != activeChar))
  1801. {
  1802. if (!Util.checkIfInRange(radius, obj, activeChar, true))
  1803. continue;
  1804. if (!((L2Character) obj).isBehind(activeChar))
  1805. continue;
  1806. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  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. targetList.add((L2Character) obj);
  1880. }
  1881. }
  1882. }
  1883. if (targetList.isEmpty())
  1884. return _emptyTargetList;
  1885. return targetList.toArray(new L2Character[targetList.size()]);
  1886. }
  1887. case TARGET_MULTIFACE:
  1888. {
  1889. if ((!(target instanceof L2Attackable) && !(target instanceof L2PcInstance)))
  1890. {
  1891. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  1892. return _emptyTargetList;
  1893. }
  1894. if (onlyFirst == false) targetList.add(target);
  1895. else return new L2Character[] {target};
  1896. int radius = getSkillRadius();
  1897. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  1898. //synchronized (activeChar.getKnownList().getKnownObjects())
  1899. {
  1900. for (L2Object obj : objs)
  1901. {
  1902. if (!Util.checkIfInRange(radius, activeChar, obj, true))
  1903. continue;
  1904. if (obj instanceof L2Attackable && obj != target)
  1905. targetList.add((L2Character) 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<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  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 (!Util.checkIfInRange(radius, target, obj, true))
  2291. continue;
  2292. if (!GeoData.getInstance().canSeeTarget(activeChar, obj))
  2293. continue;
  2294. if (obj instanceof L2PcInstance && src != null)
  2295. {
  2296. trg = (L2PcInstance) obj;
  2297. if ((src.getParty() != null && trg.getParty() != null)
  2298. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  2299. continue;
  2300. if (trg.isInsideZone(L2Character.ZONE_PEACE))
  2301. continue;
  2302. if (!srcInArena
  2303. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  2304. {
  2305. if (src.getAllyId() == trg.getAllyId()
  2306. && src.getAllyId() != 0)
  2307. continue;
  2308. if (src.getClan() != null
  2309. && trg.getClan() != null)
  2310. {
  2311. if (src.getClan().getClanId() == trg.getClan().getClanId())
  2312. continue;
  2313. }
  2314. if (!src.checkPvpSkill(obj, this))
  2315. continue;
  2316. }
  2317. }
  2318. if (obj instanceof L2Summon && src != null)
  2319. {
  2320. trg = ((L2Summon) obj).getOwner();
  2321. if ((src.getParty() != null && trg.getParty() != null)
  2322. && src.getParty().getPartyLeaderOID() == trg.getParty().getPartyLeaderOID())
  2323. continue;
  2324. if (!srcInArena
  2325. && !(trg.isInsideZone(L2Character.ZONE_PVP) && !trg.isInsideZone(L2Character.ZONE_SIEGE)))
  2326. {
  2327. if (src.getAllyId() == trg.getAllyId()
  2328. && src.getAllyId() != 0)
  2329. continue;
  2330. if (src.getClan() != null
  2331. && trg.getClan() != null)
  2332. {
  2333. if (src.getClan().getClanId() == trg.getClan().getClanId())
  2334. continue;
  2335. }
  2336. if (!src.checkPvpSkill(trg, this))
  2337. continue;
  2338. }
  2339. if (((L2Summon) obj).isInsideZone(L2Character.ZONE_PEACE))
  2340. continue;
  2341. }
  2342. targetList.add((L2Character) obj);
  2343. }
  2344. }
  2345. if (targetList.isEmpty()) return _emptyTargetList;
  2346. return targetList.toArray(new L2Character[targetList.size()]);
  2347. }
  2348. case TARGET_UNLOCKABLE:
  2349. {
  2350. if (!(target instanceof L2DoorInstance) && !(target instanceof L2ChestInstance))
  2351. {
  2352. //activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
  2353. return _emptyTargetList;
  2354. }
  2355. if (onlyFirst == false)
  2356. {
  2357. targetList.add(target);
  2358. return targetList.toArray(new L2Object[targetList.size()]);
  2359. }
  2360. else return new L2Character[] {target};
  2361. }
  2362. case TARGET_UNDEAD:
  2363. {
  2364. if (target instanceof L2Npc || target instanceof L2SummonInstance)
  2365. {
  2366. if (!target.isUndead() || target.isDead())
  2367. {
  2368. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2369. return _emptyTargetList;
  2370. }
  2371. if (onlyFirst == false) targetList.add(target);
  2372. else return new L2Character[] {target};
  2373. return targetList.toArray(new L2Object[targetList.size()]);
  2374. }
  2375. else
  2376. {
  2377. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  2378. return _emptyTargetList;
  2379. }
  2380. }
  2381. case TARGET_AREA_UNDEAD:
  2382. {
  2383. L2Character cha;
  2384. int radius = getSkillRadius();
  2385. if (getCastRange() >= 0 && (target instanceof L2Npc || target instanceof L2SummonInstance)
  2386. && target.isUndead() && !target.isAlikeDead())
  2387. {
  2388. cha = target;
  2389. if (onlyFirst == false) targetList.add(cha); // Add target to target list
  2390. else return new L2Character[] {cha};
  2391. }
  2392. else cha = activeChar;
  2393. Collection<L2Object> objs = cha.getKnownList().getKnownObjects().values();
  2394. //synchronized (cha.getKnownList().getKnownObjects())
  2395. {
  2396. for (L2Object obj : objs)
  2397. {
  2398. if (obj instanceof L2Npc)
  2399. target = (L2Npc) obj;
  2400. else if (obj instanceof L2SummonInstance)
  2401. target = (L2SummonInstance) obj;
  2402. else
  2403. continue;
  2404. if (!GeoData.getInstance().canSeeTarget(activeChar, target))
  2405. continue;
  2406. if (!target.isAlikeDead()) // If target is not
  2407. // dead/fake death and not
  2408. // self
  2409. {
  2410. if (!target.isUndead())
  2411. continue;
  2412. if (!Util.checkIfInRange(radius, cha, obj, true))
  2413. continue;
  2414. if (onlyFirst == false)
  2415. targetList.add((L2Character) obj);
  2416. else
  2417. return new L2Character[] { (L2Character) obj };
  2418. }
  2419. }
  2420. }
  2421. if (targetList.isEmpty()) return _emptyTargetList;
  2422. return targetList.toArray(new L2Character[targetList.size()]);
  2423. }
  2424. case TARGET_ENEMY_SUMMON:
  2425. {
  2426. if(target instanceof L2Summon)
  2427. {
  2428. L2Summon targetSummon = (L2Summon)target;
  2429. if (activeChar instanceof L2PcInstance && activeChar.getPet() != targetSummon && !targetSummon.isDead()
  2430. && (targetSummon.getOwner().getPvpFlag() != 0 || targetSummon.getOwner().getKarma() > 0)
  2431. || (targetSummon.getOwner().isInsideZone(L2Character.ZONE_PVP) && ((L2PcInstance)activeChar).isInsideZone(L2Character.ZONE_PVP)))
  2432. return new L2Character[]{targetSummon};
  2433. }
  2434. return _emptyTargetList;
  2435. }
  2436. default:
  2437. {
  2438. activeChar.sendMessage("Target type of skill is not currently handled");
  2439. return _emptyTargetList;
  2440. }
  2441. }//end switch
  2442. }
  2443. public final L2Object[] getTargetList(L2Character activeChar)
  2444. {
  2445. return getTargetList(activeChar, false);
  2446. }
  2447. public final L2Object getFirstOfTargetList(L2Character activeChar)
  2448. {
  2449. L2Object[] targets;
  2450. targets = getTargetList(activeChar, true);
  2451. if (targets.length == 0)
  2452. return null;
  2453. else
  2454. return targets[0];
  2455. }
  2456. public final Func[] getStatFuncs(L2Effect effect, L2Character player)
  2457. {
  2458. if (!(player instanceof L2PcInstance) && !(player instanceof L2Attackable)
  2459. && !(player instanceof L2Summon)) return _emptyFunctionSet;
  2460. if (_funcTemplates == null) return _emptyFunctionSet;
  2461. List<Func> funcs = new FastList<Func>();
  2462. for (FuncTemplate t : _funcTemplates)
  2463. {
  2464. Env env = new Env();
  2465. env.player = player;
  2466. env.skill = this;
  2467. Func f = t.getFunc(env, this); // skill is owner
  2468. if (f != null) funcs.add(f);
  2469. }
  2470. if (funcs.isEmpty()) return _emptyFunctionSet;
  2471. return funcs.toArray(new Func[funcs.size()]);
  2472. }
  2473. public boolean hasEffects()
  2474. {
  2475. return (_effectTemplates != null && _effectTemplates.length > 0);
  2476. }
  2477. /**
  2478. * Env is used to pass parameters for secondary effects (shield and ss/bss/bsss)
  2479. *
  2480. * @return an array with the effects that have been added to effector
  2481. */
  2482. public final L2Effect[] getEffects(L2Character effector, L2Character effected, Env env)
  2483. {
  2484. if (isPassive()) return _emptyEffectSet;
  2485. if (_effectTemplates == null)
  2486. return _emptyEffectSet;
  2487. // doors and siege flags cannot receive any effects
  2488. if (effected instanceof L2DoorInstance ||effected instanceof L2SiegeFlagInstance )
  2489. return _emptyEffectSet;
  2490. if (effector != effected)
  2491. {
  2492. if (effected.isInvul())
  2493. return _emptyEffectSet;
  2494. if ((isOffensive() || isDebuff()) && effector instanceof L2PcInstance && ((L2PcInstance)effector).isGM())
  2495. {
  2496. if (!((L2PcInstance)effector).getAccessLevel().canGiveDamage())
  2497. return _emptyEffectSet;
  2498. }
  2499. }
  2500. List<L2Effect> effects = new FastList<L2Effect>();
  2501. if (env == null)
  2502. env = new Env();
  2503. env.skillMastery = Formulas.calcSkillMastery(effector, this);
  2504. env.player = effector;
  2505. env.target = effected;
  2506. env.skill = this;
  2507. for (EffectTemplate et : _effectTemplates)
  2508. {
  2509. boolean success = true;
  2510. if (et.effectPower > -1)
  2511. success = Formulas.calcEffectSuccess(effector, effected, et, this, env.shld, env.ss, env.sps, env.bss);
  2512. if (success)
  2513. {
  2514. L2Effect e = et.getEffect(env);
  2515. if (e != null)
  2516. {
  2517. e.scheduleEffect();
  2518. effects.add(e);
  2519. }
  2520. }
  2521. else if (effector instanceof L2PcInstance)
  2522. {
  2523. SystemMessage sm = new SystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
  2524. sm.addCharName(effected);
  2525. sm.addSkillName(this);
  2526. ((L2PcInstance)effector).sendPacket(sm);
  2527. }
  2528. }
  2529. if (effects.isEmpty()) return _emptyEffectSet;
  2530. return effects.toArray(new L2Effect[effects.size()]);
  2531. }
  2532. /**
  2533. * Warning: this method doesn't consider modifier (shield, ss, sps, bss) for secondary effects
  2534. *
  2535. */
  2536. public final L2Effect[] getEffects(L2Character effector, L2Character effected)
  2537. {
  2538. return getEffects(effector, effected, null);
  2539. }
  2540. /**
  2541. * This method has suffered some changes in CT2.2 ->CT2.3<br>
  2542. * Effect engine is now supporting secondary effects with independent
  2543. * success/fail calculus from effect skill. Env parameter has been added to
  2544. * pass parameters like soulshot, spiritshots, blessed spiritshots or shield deffence.
  2545. * Some other optimizations have been done
  2546. * <br><br>
  2547. * This new feature works following next rules:
  2548. * <li> To enable feature, effectPower must be over -1 (check DocumentSkill#attachEffect for further information)</li>
  2549. * <li> If main skill fails, secondary effect always fail</li>
  2550. */
  2551. public final L2Effect[] getEffects(L2CubicInstance effector, L2Character effected, Env env)
  2552. {
  2553. if (isPassive()) return _emptyEffectSet;
  2554. if (_effectTemplates == null)
  2555. return _emptyEffectSet;
  2556. if ((!effector.equals(effected)) && effected.isInvul())
  2557. return _emptyEffectSet;
  2558. if ((isDebuff() || isOffensive()) && effector.getOwner() != effected &&
  2559. effector.getOwner().isGM() &&
  2560. !effector.getOwner().getAccessLevel().canGiveDamage())
  2561. {
  2562. return _emptyEffectSet;
  2563. }
  2564. List<L2Effect> effects = new FastList<L2Effect>();
  2565. if (env == null)
  2566. env = new Env();
  2567. env.player = effector.getOwner();
  2568. env.cubic = effector;
  2569. env.target = effected;
  2570. env.skill = this;
  2571. for (EffectTemplate et : _effectTemplates)
  2572. {
  2573. boolean success = true;
  2574. if (et.effectPower > -1)
  2575. success = Formulas.calcEffectSuccess(effector.getOwner(), effected, et, this, env.shld, env.ss, env.sps, env.bss);
  2576. if (success)
  2577. {
  2578. L2Effect e = et.getEffect(env);
  2579. if (e != null)
  2580. {
  2581. e.scheduleEffect();
  2582. effects.add(e);
  2583. }
  2584. }
  2585. }
  2586. if (effects.isEmpty()) return _emptyEffectSet;
  2587. return effects.toArray(new L2Effect[effects.size()]);
  2588. }
  2589. public final L2Effect[] getEffectsSelf(L2Character effector)
  2590. {
  2591. if (isPassive()) return _emptyEffectSet;
  2592. if (_effectTemplatesSelf == null) return _emptyEffectSet;
  2593. List<L2Effect> effects = new FastList<L2Effect>();
  2594. for (EffectTemplate et : _effectTemplatesSelf)
  2595. {
  2596. Env env = new Env();
  2597. env.player = effector;
  2598. env.target = effector;
  2599. env.skill = this;
  2600. L2Effect e = et.getEffect(env);
  2601. if (e != null)
  2602. {
  2603. e.scheduleEffect();
  2604. effects.add(e);
  2605. }
  2606. }
  2607. if (effects.isEmpty()) return _emptyEffectSet;
  2608. return effects.toArray(new L2Effect[effects.size()]);
  2609. }
  2610. public final void attach(FuncTemplate f)
  2611. {
  2612. if (_funcTemplates == null)
  2613. {
  2614. _funcTemplates = new FuncTemplate[] {f};
  2615. }
  2616. else
  2617. {
  2618. int len = _funcTemplates.length;
  2619. FuncTemplate[] tmp = new FuncTemplate[len + 1];
  2620. System.arraycopy(_funcTemplates, 0, tmp, 0, len);
  2621. tmp[len] = f;
  2622. _funcTemplates = tmp;
  2623. }
  2624. }
  2625. public final void attach(EffectTemplate effect)
  2626. {
  2627. if (_effectTemplates == null)
  2628. {
  2629. _effectTemplates = new EffectTemplate[] {effect};
  2630. }
  2631. else
  2632. {
  2633. int len = _effectTemplates.length;
  2634. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2635. System.arraycopy(_effectTemplates, 0, tmp, 0, len);
  2636. tmp[len] = effect;
  2637. _effectTemplates = tmp;
  2638. }
  2639. }
  2640. public final void attachSelf(EffectTemplate effect)
  2641. {
  2642. if (_effectTemplatesSelf == null)
  2643. {
  2644. _effectTemplatesSelf = new EffectTemplate[] {effect};
  2645. }
  2646. else
  2647. {
  2648. int len = _effectTemplatesSelf.length;
  2649. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  2650. System.arraycopy(_effectTemplatesSelf, 0, tmp, 0, len);
  2651. tmp[len] = effect;
  2652. _effectTemplatesSelf = tmp;
  2653. }
  2654. }
  2655. public final void attach(Condition c, boolean itemOrWeapon)
  2656. {
  2657. if(itemOrWeapon) _itemPreCondition = c;
  2658. else _preCondition = c;
  2659. }
  2660. @Override
  2661. public String toString()
  2662. {
  2663. return "" + _name + "[id=" + _id + ",lvl=" + _level + "]";
  2664. }
  2665. /**
  2666. * @return
  2667. */
  2668. public boolean isAdvancedFlag()
  2669. {
  2670. return _isAdvancedFlag;
  2671. }
  2672. /**
  2673. * @return pet food
  2674. */
  2675. public int getFeed()
  2676. {
  2677. return _feed;
  2678. }
  2679. /**
  2680. * used for tracking item id in case that item consume cannot be used
  2681. * @return reference item id
  2682. */
  2683. public int getReferenceItemId()
  2684. {
  2685. return _refId;
  2686. }
  2687. /**
  2688. * @return
  2689. */
  2690. public int getAfroColor()
  2691. {
  2692. return _afroId;
  2693. }
  2694. /**
  2695. * used for learning skills through skills
  2696. * @return new skill id to learn (if not defined, default 0)
  2697. */
  2698. public int getNewSkillId()
  2699. {
  2700. return _learnSkillId;
  2701. }
  2702. /**
  2703. * used for learning skills through skills
  2704. * @return skill lvl to learn (if not defined, default 1)
  2705. */
  2706. public int getNewSkillLvl()
  2707. {
  2708. return _learnSkillLvl;
  2709. }
  2710. public final int getRequiredCharges()
  2711. {
  2712. return _requiredCharges;
  2713. }
  2714. public final int getMaxCharges()
  2715. {
  2716. return _maxCharges;
  2717. }
  2718. public int getAfterEffectId()
  2719. {
  2720. return _afterEffectId;
  2721. }
  2722. public int getAfterEffectLvl()
  2723. {
  2724. return _afterEffectLvl;
  2725. }
  2726. @Override
  2727. public boolean triggersChanceSkill()
  2728. {
  2729. return _triggeredId > 0 && isChance();
  2730. }
  2731. @Override
  2732. public int getTriggeredChanceId()
  2733. {
  2734. return _triggeredId;
  2735. }
  2736. @Override
  2737. public int getTriggeredChanceLevel()
  2738. {
  2739. return _triggeredLevel;
  2740. }
  2741. @Override
  2742. public ChanceCondition getTriggeredChanceCondition()
  2743. {
  2744. return _chanceCondition;
  2745. }
  2746. public String getAttributeName()
  2747. {
  2748. return _attribute;
  2749. }
  2750. public boolean useShield()
  2751. {
  2752. return _useShield;
  2753. }
  2754. public int[] getTeleportCoords()
  2755. {
  2756. return _teleportCoords;
  2757. }
  2758. public String getRecallType()
  2759. {
  2760. return _recallType;
  2761. }
  2762. }