L2Skill.java 76 KB

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