L2Skill.java 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081
  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.List;
  18. import java.util.Map;
  19. import java.util.StringTokenizer;
  20. import java.util.logging.Level;
  21. import java.util.logging.Logger;
  22. import javolution.util.FastList;
  23. import javolution.util.FastMap;
  24. import com.l2jserver.Config;
  25. import com.l2jserver.gameserver.GeoData;
  26. import com.l2jserver.gameserver.datatables.GMSkillTable;
  27. import com.l2jserver.gameserver.datatables.HeroSkillTable;
  28. import com.l2jserver.gameserver.datatables.ItemTable;
  29. import com.l2jserver.gameserver.datatables.SkillTable;
  30. import com.l2jserver.gameserver.handler.ITargetTypeHandler;
  31. import com.l2jserver.gameserver.handler.TargetHandler;
  32. import com.l2jserver.gameserver.model.actor.L2Attackable;
  33. import com.l2jserver.gameserver.model.actor.L2Character;
  34. import com.l2jserver.gameserver.model.actor.L2Playable;
  35. import com.l2jserver.gameserver.model.actor.L2Summon;
  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.L2SiegeFlagInstance;
  40. import com.l2jserver.gameserver.model.entity.TvTEvent;
  41. import com.l2jserver.gameserver.network.SystemMessageId;
  42. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  43. import com.l2jserver.gameserver.skills.BaseStats;
  44. import com.l2jserver.gameserver.skills.Env;
  45. import com.l2jserver.gameserver.skills.Formulas;
  46. import com.l2jserver.gameserver.skills.Stats;
  47. import com.l2jserver.gameserver.skills.conditions.Condition;
  48. import com.l2jserver.gameserver.skills.funcs.Func;
  49. import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
  50. import com.l2jserver.gameserver.templates.StatsSet;
  51. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  52. import com.l2jserver.gameserver.templates.item.L2Armor;
  53. import com.l2jserver.gameserver.templates.item.L2ArmorType;
  54. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  55. import com.l2jserver.gameserver.templates.skills.L2TargetType;
  56. import com.l2jserver.gameserver.templates.skills.L2TraitType;
  57. import com.l2jserver.gameserver.util.Util;
  58. /**
  59. * This class...
  60. *
  61. * @version $Revision: 1.3.2.8.2.22 $ $Date: 2005/04/06 16:13:42 $
  62. */
  63. public abstract class L2Skill implements IChanceSkillTrigger
  64. {
  65. protected static final Logger _log = Logger.getLogger(L2Skill.class.getName());
  66. private static final L2Object[] _emptyTargetList = new L2Object[0];
  67. public static final int SKILL_LUCKY = 194;
  68. public static final int SKILL_CREATE_COMMON = 1320;
  69. public static final int SKILL_CREATE_DWARVEN = 172;
  70. public static final int SKILL_CRYSTALLIZE = 248;
  71. public static final int SKILL_DIVINE_INSPIRATION = 1405;
  72. public static final int SKILL_CLAN_LUCK = 390;
  73. public static final int SKILL_NPC_RACE = 4416;
  74. public static final boolean geoEnabled = Config.GEODATA > 0;
  75. public static enum SkillOpType
  76. {
  77. OP_PASSIVE, OP_ACTIVE, OP_TOGGLE
  78. }
  79. //conditional values
  80. public final static int COND_RUNNING = 0x0001;
  81. public final static int COND_WALKING = 0x0002;
  82. public final static int COND_SIT = 0x0004;
  83. public final static int COND_BEHIND = 0x0008;
  84. public final static int COND_CRIT = 0x0010;
  85. public final static int COND_LOWHP = 0x0020;
  86. public final static int COND_ROBES = 0x0040;
  87. public final static int COND_CHARGES = 0x0080;
  88. public final static int COND_SHIELD = 0x0100;
  89. private static final Func[] _emptyFunctionSet = new Func[0];
  90. private static final L2Effect[] _emptyEffectSet = new L2Effect[0];
  91. // these two build the primary key
  92. private final int _id;
  93. private final int _level;
  94. /** Identifier for a skill that client can't display */
  95. private int _displayId;
  96. // not needed, just for easier debug
  97. private final String _name;
  98. private final SkillOpType _operateType;
  99. private final boolean _magic;
  100. private final L2TraitType _traitType;
  101. private final boolean _staticReuse;
  102. private final boolean _staticHitTime;
  103. private final boolean _staticDamage; // Damage dealing skills do static damage based on the power value.
  104. private final int _mpConsume;
  105. private final int _mpInitialConsume;
  106. private final int _hpConsume;
  107. private final int _cpConsume;
  108. private final int _targetConsume;
  109. private final int _targetConsumeId;
  110. private final int _itemConsume;
  111. private final int _itemConsumeId;
  112. private final int _castRange;
  113. private final int _effectRange;
  114. // Abnormal levels for skills and their canceling, e.g. poison vs negate
  115. private final int _abnormalLvl; // e.g. poison or bleed lvl 2
  116. // Note: see also _effectAbnormalLvl
  117. private final int _negateLvl; // abnormalLvl is negated with negateLvl
  118. private final int[] _negateId; // cancels the effect of skill ID
  119. private final L2SkillType[] _negateStats; // lists the effect types that are canceled
  120. private final Map<String, Byte> _negateAbnormals; // lists the effect abnormal types with order below the presented that are canceled
  121. private final int _maxNegatedEffects; // maximum number of effects to negate
  122. private final boolean _stayAfterDeath; // skill should stay after death
  123. private final boolean _stayOnSubclassChange; // skill should stay on subclass change
  124. // kill by damage over time
  125. private final boolean _killByDOT;
  126. private final int _refId;
  127. // all times in milliseconds
  128. private final int _hitTime;
  129. private final int[] _hitTimings;
  130. //private final int _skillInterruptTime;
  131. private final int _coolTime;
  132. private final int _reuseHashCode;
  133. private final int _reuseDelay;
  134. private final int _buffDuration;
  135. // for item skills delay on equip
  136. private final int _equipDelay;
  137. /** Target type of the skill : SELF, PARTY, CLAN, PET... */
  138. private final L2TargetType _targetType;
  139. private final int _feed;
  140. // base success chance
  141. private final double _power;
  142. private final double _pvpPower;
  143. private final double _pvePower;
  144. private final int _magicLevel;
  145. private final int _levelDepend;
  146. private final boolean _ignoreResists;
  147. private final int _minChance;
  148. private final int _maxChance;
  149. private final int _blowChance;
  150. private final boolean _isNeutral;
  151. // Effecting area of the skill, in radius.
  152. // The radius center varies according to the _targetType:
  153. // "caster" if targetType = AURA/PARTY/CLAN or "target" if targetType = AREA
  154. private final int _skillRadius;
  155. private final L2SkillType _skillType;
  156. private final L2SkillType _effectType; // additional effect has a type
  157. private final int _effectAbnormalLvl; // abnormal level for the additional effect type, e.g. poison lvl 1
  158. private final int _effectId;
  159. private final int _effectLvl; // normal effect level
  160. private final boolean _nextActionIsAttack;
  161. private final boolean _removedOnAnyActionExceptMove;
  162. private final boolean _removedOnDamage;
  163. private final boolean _isPotion;
  164. private final byte _element;
  165. private final int _elementPower;
  166. private final Stats _stat;
  167. private final BaseStats _saveVs;
  168. private final int _condition;
  169. private final int _conditionValue;
  170. private final boolean _overhit;
  171. private final int _weaponsAllowed;
  172. private final int _armorsAllowed;
  173. private final int _minPledgeClass;
  174. private final boolean _isOffensive;
  175. private final int _maxCharges;
  176. private final int _numCharges;
  177. private final int _triggeredId;
  178. private final int _triggeredLevel;
  179. private final String _chanceType;
  180. private final int _soulMaxConsume;
  181. private final int _soulConsume;
  182. private final int _numSouls;
  183. private final int _expNeeded;
  184. private final int _critChance;
  185. private final float _dependOnTargetBuff;
  186. private final int _transformId;
  187. private final int _transformDuration;
  188. private final int _afterEffectId;
  189. private final int _afterEffectLvl;
  190. private final boolean _isHeroSkill; // If true the skill is a Hero Skill
  191. private final boolean _isGMSkill; // True if skill is GM skill
  192. 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
  193. 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)
  194. 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)
  195. private final boolean _directHpDmg; // If true then dmg is being make directly
  196. private final boolean _isTriggeredSkill; // If true the skill will take activation buff slot instead of a normal buff slot
  197. private final boolean _isDance; // If true then casting more dances will cost more MP
  198. private final int _nextDanceCost;
  199. private final float _sSBoost; //If true skill will have SoulShot boost (power*2)
  200. private final int _aggroPoints;
  201. protected List<Condition> _preCondition;
  202. protected List<Condition> _itemPreCondition;
  203. protected FuncTemplate[] _funcTemplates;
  204. protected EffectTemplate[] _effectTemplates;
  205. protected EffectTemplate[] _effectTemplatesSelf;
  206. protected EffectTemplate[] _effectTemplatesPassive;
  207. protected ChanceCondition _chanceCondition = null;
  208. // Flying support
  209. private final String _flyType;
  210. private final int _flyRadius;
  211. private final float _flyCourse;
  212. private final boolean _isDebuff;
  213. private final String _attribute;
  214. private final boolean _ignoreShield;
  215. private final boolean _ignoreSkillMute;
  216. private final boolean _isSuicideAttack;
  217. private final boolean _canBeReflected;
  218. private final boolean _canBeDispeled;
  219. private final boolean _isClanSkill;
  220. private final boolean _excludedFromCheck;
  221. private final boolean _simultaneousCast;
  222. private L2ExtractableSkill _extractableItems = null;
  223. private final int _maxTargets;
  224. private final boolean _isStaticHeal;
  225. protected L2Skill(StatsSet set)
  226. {
  227. _id = set.getInteger("skill_id");
  228. _level = set.getInteger("level");
  229. _refId = set.getInteger("referenceId", 0);
  230. _displayId = set.getInteger("displayId", _id);
  231. _name = set.getString("name");
  232. _operateType = set.getEnum("operateType", SkillOpType.class);
  233. _magic = set.getBool("isMagic", false);
  234. _traitType = set.getEnum("trait", L2TraitType.class, L2TraitType.NONE);
  235. _staticReuse = set.getBool("staticReuse", false);
  236. _staticHitTime = set.getBool("staticHitTime", false);
  237. _staticDamage = set.getBool("staticDamage", false);
  238. _isPotion = set.getBool("isPotion", false);
  239. _mpConsume = set.getInteger("mpConsume", 0);
  240. _mpInitialConsume = set.getInteger("mpInitialConsume", 0);
  241. _hpConsume = set.getInteger("hpConsume", 0);
  242. _cpConsume = set.getInteger("cpConsume", 0);
  243. _targetConsume = set.getInteger("targetConsumeCount", 0);
  244. _targetConsumeId = set.getInteger("targetConsumeId", 0);
  245. _itemConsume = set.getInteger("itemConsumeCount", 0);
  246. _itemConsumeId = set.getInteger("itemConsumeId", 0);
  247. _afterEffectId = set.getInteger("afterEffectId", 0);
  248. _afterEffectLvl = set.getInteger("afterEffectLvl", 1);
  249. _castRange = set.getInteger("castRange", -1);
  250. _effectRange = set.getInteger("effectRange", -1);
  251. _abnormalLvl = set.getInteger("abnormalLvl", -1);
  252. _effectAbnormalLvl = set.getInteger("effectAbnormalLvl", -1); // support for a separate effect abnormal lvl, e.g. poison inside a different skill
  253. _negateLvl = set.getInteger("negateLvl", -1);
  254. _attribute = set.getString("attribute","");
  255. String str = set.getString("negateStats", "");
  256. if (str == "")
  257. _negateStats = new L2SkillType[0];
  258. else
  259. {
  260. String[] stats = str.split(" ");
  261. L2SkillType[] array = new L2SkillType[stats.length];
  262. for (int i = 0; i < stats.length; i++)
  263. {
  264. L2SkillType type = null;
  265. try
  266. {
  267. type = Enum.valueOf(L2SkillType.class, stats[i]);
  268. }
  269. catch (Exception e)
  270. {
  271. throw new IllegalArgumentException("SkillId: "+_id+"Enum value of type "+L2SkillType.class.getName()+"required, but found: "+stats[i]);
  272. }
  273. array[i] = type;
  274. }
  275. _negateStats = array;
  276. }
  277. String negateAbnormals = set.getString("negateAbnormals", null);
  278. if (negateAbnormals != null && negateAbnormals != "")
  279. {
  280. _negateAbnormals = new FastMap<String, Byte>();
  281. for (String ngtStack : negateAbnormals.split(";"))
  282. {
  283. String[] ngt = ngtStack.split(",");
  284. if (ngt.length == 1) // Only abnormalType is present, without abnormalLvl
  285. {
  286. _negateAbnormals.put(ngt[0], Byte.MAX_VALUE);
  287. }
  288. else if (ngt.length == 2) // Both abnormalType and abnormalLvl are present
  289. {
  290. try
  291. {
  292. _negateAbnormals.put(ngt[0], Byte.parseByte(ngt[1]));
  293. }
  294. catch (Exception e)
  295. {
  296. throw new IllegalArgumentException("SkillId: "+_id+" Byte value required, but found: "+ngt[1]);
  297. }
  298. }
  299. else // If not both from above, then smth is messed up... throw an error.
  300. throw new IllegalArgumentException("SkillId: "+_id+": Incorrect negate Abnormals for "+ngtStack+". Lvl: abnormalType1,abnormalLvl1;abnormalType2,abnormalLvl2;abnormalType3,abnormalLvl3... or abnormalType1;abnormalType2;abnormalType3...");
  301. }
  302. }
  303. else
  304. _negateAbnormals = null;
  305. String negateId = set.getString("negateId", null);
  306. if (negateId != null)
  307. {
  308. String[] valuesSplit = negateId.split(",");
  309. _negateId = new int[valuesSplit.length];
  310. for (int i = 0; i < valuesSplit.length;i++)
  311. {
  312. _negateId[i] = Integer.parseInt(valuesSplit[i]);
  313. }
  314. }
  315. else
  316. _negateId = new int[0];
  317. _maxNegatedEffects = set.getInteger("maxNegated", 0);
  318. _stayAfterDeath = set.getBool("stayAfterDeath", false);
  319. _stayOnSubclassChange = set.getBool("stayOnSubclassChange", true);
  320. _killByDOT = set.getBool("killByDOT", false);
  321. _isNeutral = set.getBool("neutral",false);
  322. _hitTime = set.getInteger("hitTime", 0);
  323. String hitTimings = set.getString("hitTimings", null);
  324. if (hitTimings != null)
  325. {
  326. try
  327. {
  328. String [] valuesSplit = hitTimings.split(",");
  329. _hitTimings = new int[valuesSplit.length];
  330. for (int i = 0; i < valuesSplit.length; i++)
  331. _hitTimings[i] = Integer.parseInt(valuesSplit[i]);
  332. }
  333. catch (Exception e)
  334. {
  335. throw new IllegalArgumentException("SkillId: "+_id+" invalid hitTimings value: "+hitTimings+", \"percent,percent,...percent\" required");
  336. }
  337. }
  338. else
  339. _hitTimings = new int[0];
  340. _coolTime = set.getInteger("coolTime", 0);
  341. _isDebuff = set.getBool("isDebuff", false);
  342. _feed = set.getInteger("feed", 0);
  343. String reuseHash = set.getString("sharedReuse", null);
  344. if (reuseHash != null)
  345. {
  346. try
  347. {
  348. String[] valuesSplit = reuseHash.split("-");
  349. _reuseHashCode = SkillTable.getSkillHashCode(Integer.parseInt(valuesSplit[0]), Integer.parseInt(valuesSplit[1]));
  350. }
  351. catch (Exception e)
  352. {
  353. throw new IllegalArgumentException("SkillId: "+_id+" invalid sharedReuse value: "+reuseHash+", \"skillId-skillLvl\" required");
  354. }
  355. }
  356. else
  357. _reuseHashCode = SkillTable.getSkillHashCode(_id, _level);
  358. if (Config.ENABLE_MODIFY_SKILL_REUSE && Config.SKILL_REUSE_LIST.containsKey(_id))
  359. {
  360. if ( Config.DEBUG )
  361. _log.info("*** Skill " + _name + " (" + _level + ") changed reuse from " + set.getInteger("reuseDelay", 0) + " to " + Config.SKILL_REUSE_LIST.get(_id) + " seconds.");
  362. _reuseDelay = Config.SKILL_REUSE_LIST.get(_id);
  363. }
  364. else
  365. {
  366. _reuseDelay = set.getInteger("reuseDelay", 0);
  367. }
  368. _buffDuration = set.getInteger("buffDuration", 0);
  369. _equipDelay = set.getInteger("equipDelay", 0);
  370. _skillRadius = set.getInteger("skillRadius", 80);
  371. _targetType = set.getEnum("target", L2TargetType.class);
  372. _power = set.getFloat("power", 0.f);
  373. _pvpPower = set.getFloat("pvpPower", (float)getPower());
  374. _pvePower = set.getFloat("pvePower", (float)getPower());
  375. _magicLevel = set.getInteger("magicLvl", 0);
  376. _levelDepend = set.getInteger("lvlDepend", 0);
  377. _ignoreResists = set.getBool("ignoreResists", false);
  378. _minChance = set.getInteger("minChance", Config.MIN_DEBUFF_CHANCE);
  379. _maxChance = set.getInteger("maxChance", Config.MAX_DEBUFF_CHANCE);
  380. _stat = set.getEnum("stat", Stats.class, null);
  381. _ignoreShield = set.getBool("ignoreShld", false);
  382. _ignoreSkillMute = set.getBool("ignoreSkillMute", false);
  383. _skillType = set.getEnum("skillType", L2SkillType.class);
  384. _effectType = set.getEnum("effectType", L2SkillType.class, null);
  385. _effectId = set.getInteger("effectId", 0);
  386. _effectLvl = set.getInteger("effectLevel", 0);
  387. _nextActionIsAttack = set.getBool("nextActionAttack", false);
  388. _removedOnAnyActionExceptMove = set.getBool("removedOnAnyActionExceptMove", false);
  389. _removedOnDamage = set.getBool("removedOnDamage", _skillType == L2SkillType.SLEEP);
  390. _element = set.getByte("element", (byte)-1);
  391. _elementPower = set.getInteger("elementPower", 0);
  392. _saveVs = set.getEnum("saveVs", BaseStats.class, null);
  393. _condition = set.getInteger("condition", 0);
  394. _conditionValue = set.getInteger("conditionValue", 0);
  395. _overhit = set.getBool("overHit", false);
  396. _isSuicideAttack = set.getBool("isSuicideAttack", false);
  397. String weaponsAllowedString = set.getString("weaponsAllowed", null);
  398. if (weaponsAllowedString != null && !weaponsAllowedString.trim().isEmpty())
  399. {
  400. int mask = 0;
  401. StringTokenizer st = new StringTokenizer(weaponsAllowedString, ",");
  402. while (st.hasMoreTokens())
  403. {
  404. int old = mask;
  405. String item = st.nextToken().trim();
  406. if (ItemTable._weaponTypes.containsKey(item))
  407. mask |= ItemTable._weaponTypes.get(item).mask();
  408. if (ItemTable._armorTypes.containsKey(item)) // for shield
  409. mask |= ItemTable._armorTypes.get(item).mask();
  410. if (old == mask)
  411. _log.info("[weaponsAllowed] Unknown item type name: "+item);
  412. }
  413. _weaponsAllowed = mask;
  414. }
  415. else
  416. _weaponsAllowed = 0;
  417. _armorsAllowed = set.getInteger("armorsAllowed", 0);
  418. _minPledgeClass = set.getInteger("minPledgeClass", 0);
  419. _isOffensive = set.getBool("offensive", isSkillTypeOffensive());
  420. _maxCharges = set.getInteger("maxCharges", 0);
  421. _numCharges = set.getInteger("numCharges", 0);
  422. _triggeredId = set.getInteger("triggeredId", 0);
  423. _triggeredLevel = set.getInteger("triggeredLevel", 0);
  424. _chanceType = set.getString("chanceType", "");
  425. if (_chanceType != "" && !_chanceType.isEmpty())
  426. _chanceCondition = ChanceCondition.parse(set);
  427. _numSouls = set.getInteger("num_souls", 0);
  428. _soulMaxConsume = set.getInteger("soulMaxConsumeCount", 0);
  429. _blowChance = set.getInteger("blowChance", 0);
  430. _soulConsume = set.getInteger("soulConsumeCount", 0);
  431. _expNeeded = set.getInteger("expNeeded", 0);
  432. _critChance = set.getInteger("critChance", 0);
  433. _transformId = set.getInteger("transformId", 0);
  434. _transformDuration = set.getInteger("transformDuration", 0);
  435. _isHeroSkill = HeroSkillTable.isHeroSkill(_id);
  436. _isGMSkill = GMSkillTable.isGMSkill(_id);
  437. _baseCritRate = set.getInteger("baseCritRate", (_skillType == L2SkillType.PDAM || _skillType == L2SkillType.BLOW) ? 0 : -1);
  438. _lethalEffect1 = set.getInteger("lethal1",0);
  439. _lethalEffect2 = set.getInteger("lethal2",0);
  440. _directHpDmg = set.getBool("dmgDirectlyToHp",false);
  441. _isTriggeredSkill = set.getBool("isTriggeredSkill",false);
  442. _isDance = set.getBool("isDance",false);
  443. _nextDanceCost = set.getInteger("nextDanceCost", 0);
  444. _sSBoost = set.getFloat("SSBoost", 0.f);
  445. _aggroPoints = set.getInteger("aggroPoints", 0);
  446. _flyType = set.getString("flyType", null);
  447. _flyRadius = set.getInteger("flyRadius", 0);
  448. _flyCourse = set.getFloat("flyCourse", 0);
  449. _canBeReflected = set.getBool("canBeReflected", true);
  450. _canBeDispeled = set.getBool("canBeDispeled", true);
  451. _isClanSkill = set.getBool("isClanSkill", false);
  452. _excludedFromCheck = set.getBool("excludedFromCheck", false);
  453. _dependOnTargetBuff = set.getFloat("dependOnTargetBuff", 0);
  454. _simultaneousCast = set.getBool("simultaneousCast", false);
  455. String capsuled_items = set.getString("capsuled_items_skill", null);
  456. if (capsuled_items != null)
  457. {
  458. if (capsuled_items.isEmpty())
  459. _log.warning("Empty Extractable Item Skill data in Skill Id: " + _id);
  460. _extractableItems = parseExtractableSkill(_id, _level, capsuled_items);
  461. }
  462. _maxTargets = set.getInteger("maxTargets", -1);
  463. _isStaticHeal = set.getBool("isStaticHeal", false);
  464. }
  465. public abstract void useSkill(L2Character caster, L2Object[] targets);
  466. public final boolean isPotion()
  467. {
  468. return _isPotion;
  469. }
  470. public final int getArmorsAllowed()
  471. {
  472. return _armorsAllowed;
  473. }
  474. public final int getConditionValue()
  475. {
  476. return _conditionValue;
  477. }
  478. public final L2SkillType getSkillType()
  479. {
  480. return _skillType;
  481. }
  482. public final L2TraitType getTraitType()
  483. {
  484. return _traitType;
  485. }
  486. public final byte getElement()
  487. {
  488. return _element;
  489. }
  490. public final int getElementPower()
  491. {
  492. return _elementPower;
  493. }
  494. /**
  495. * Return the target type of the skill : SELF, PARTY, CLAN, PET...<BR><BR>
  496. * @return
  497. */
  498. public final L2TargetType getTargetType()
  499. {
  500. return _targetType;
  501. }
  502. public final int getCondition()
  503. {
  504. return _condition;
  505. }
  506. public final boolean isOverhit()
  507. {
  508. return _overhit;
  509. }
  510. public final boolean killByDOT()
  511. {
  512. return _killByDOT;
  513. }
  514. public final boolean isSuicideAttack()
  515. {
  516. return _isSuicideAttack;
  517. }
  518. public final boolean allowOnTransform()
  519. {
  520. return isPassive();
  521. }
  522. /**
  523. * Return the power of the skill.
  524. * @param activeChar
  525. * @param target
  526. * @param isPvP
  527. * @param isPvE
  528. * @return
  529. */
  530. public final double getPower(L2Character activeChar, L2Character target, boolean isPvP, boolean isPvE)
  531. {
  532. if (activeChar == null)
  533. return getPower(isPvP, isPvE);
  534. switch (_skillType)
  535. {
  536. case DEATHLINK:
  537. {
  538. return getPower(isPvP, isPvE) * Math.pow(1.7165 - activeChar.getCurrentHp() / activeChar.getMaxHp(), 2) * 0.577;
  539. /*
  540. * DrHouse:
  541. * Rolling back to old formula (look below) for DEATHLINK due to this one based on logarithm is not
  542. * accurate enough. Commented here because probably is a matter of just adjusting a constant
  543. if(activeChar.getCurrentHp() / activeChar.getMaxHp() > 0.005)
  544. return _power*(-0.45*Math.log(activeChar.getCurrentHp()/activeChar.getMaxHp())+1.);
  545. else
  546. return _power*(-0.45*Math.log(0.005)+1.);
  547. */
  548. }
  549. case FATAL:
  550. {
  551. return getPower(isPvP, isPvE)*3.5*(1-target.getCurrentHp()/target.getMaxHp());
  552. }
  553. default:
  554. return getPower(isPvP, isPvE);
  555. }
  556. }
  557. public final double getPower()
  558. {
  559. return _power;
  560. }
  561. public final double getPower(boolean isPvP, boolean isPvE)
  562. {
  563. return isPvE ? _pvePower : isPvP ? _pvpPower : _power;
  564. }
  565. public final L2SkillType[] getNegateStats()
  566. {
  567. return _negateStats;
  568. }
  569. public final Map<String, Byte> getNegateAbnormals()
  570. {
  571. return _negateAbnormals;
  572. }
  573. public final int getAbnormalLvl()
  574. {
  575. return _abnormalLvl;
  576. }
  577. public final int getNegateLvl()
  578. {
  579. return _negateLvl;
  580. }
  581. public final int[] getNegateId()
  582. {
  583. return _negateId;
  584. }
  585. public final int getMagicLevel()
  586. {
  587. return _magicLevel;
  588. }
  589. public final int getMaxNegatedEffects()
  590. {
  591. return _maxNegatedEffects;
  592. }
  593. public final int getLevelDepend()
  594. {
  595. return _levelDepend;
  596. }
  597. /**
  598. * Return true if skill should ignore all resistances
  599. * @return
  600. */
  601. public final boolean ignoreResists()
  602. {
  603. return _ignoreResists;
  604. }
  605. /**
  606. * Return minimum skill/effect land rate (default is 1).
  607. * @return
  608. */
  609. public final int getMinChance()
  610. {
  611. return _minChance;
  612. }
  613. /**
  614. * Return maximum skill/effect land rate (default is 99).
  615. * @return
  616. */
  617. public final int getMaxChance()
  618. {
  619. return _maxChance;
  620. }
  621. /**
  622. * Return true if skill effects should be removed on any action except movement
  623. * @return
  624. */
  625. public final boolean isRemovedOnAnyActionExceptMove()
  626. {
  627. return _removedOnAnyActionExceptMove;
  628. }
  629. /**
  630. * Return true if skill effects should be removed on damage
  631. * @return
  632. */
  633. public final boolean isRemovedOnDamage()
  634. {
  635. return _removedOnDamage;
  636. }
  637. /**
  638. * Return the additional effect Id.<BR><BR>
  639. * @return
  640. */
  641. public final int getEffectId()
  642. {
  643. return _effectId;
  644. }
  645. /**
  646. * Return the additional effect level.<BR><BR>
  647. * @return
  648. */
  649. public final int getEffectLvl()
  650. {
  651. return _effectLvl;
  652. }
  653. public final int getEffectAbnormalLvl()
  654. {
  655. return _effectAbnormalLvl;
  656. }
  657. /**
  658. * Return the additional effect skill type (ex : STUN, PARALYZE,...).<BR><BR>
  659. * @return
  660. */
  661. public final L2SkillType getEffectType()
  662. {
  663. return _effectType;
  664. }
  665. /**
  666. * Return true if character should attack target after skill
  667. * @return
  668. */
  669. public final boolean nextActionIsAttack()
  670. {
  671. return _nextActionIsAttack;
  672. }
  673. /**
  674. * @return Returns the buffDuration.
  675. */
  676. public final int getBuffDuration()
  677. {
  678. return _buffDuration;
  679. }
  680. /**
  681. * @return Returns the castRange.
  682. */
  683. public final int getCastRange()
  684. {
  685. return _castRange;
  686. }
  687. /**
  688. * @return Returns the cpConsume;
  689. */
  690. public final int getCpConsume()
  691. {
  692. return _cpConsume;
  693. }
  694. /**
  695. * @return Returns the effectRange.
  696. */
  697. public final int getEffectRange()
  698. {
  699. return _effectRange;
  700. }
  701. /**
  702. * @return Returns the hpConsume.
  703. */
  704. public final int getHpConsume()
  705. {
  706. return _hpConsume;
  707. }
  708. /**
  709. * @return Returns the id.
  710. */
  711. public final int getId()
  712. {
  713. return _id;
  714. }
  715. /**
  716. * @return Returns the boolean _isDebuff.
  717. */
  718. public final boolean isDebuff()
  719. {
  720. return _isDebuff;
  721. }
  722. public int getDisplayId()
  723. {
  724. return _displayId;
  725. }
  726. public void setDisplayId(int id)
  727. {
  728. _displayId = id;
  729. }
  730. public int getTriggeredId()
  731. {
  732. return _triggeredId;
  733. }
  734. public int getTriggeredLevel()
  735. {
  736. return _triggeredLevel;
  737. }
  738. public boolean triggerAnotherSkill()
  739. {
  740. return _triggeredId > 1;
  741. }
  742. /**
  743. * Return the skill type (ex : BLEED, SLEEP, WATER...).
  744. * @return
  745. */
  746. public final Stats getStat()
  747. {
  748. return _stat;
  749. }
  750. /**
  751. * Return skill saveVs base stat (STR, INT ...).
  752. * @return
  753. */
  754. public final BaseStats getSaveVs()
  755. {
  756. return _saveVs;
  757. }
  758. /**
  759. * @return Returns the _targetConsumeId.
  760. */
  761. public final int getTargetConsumeId()
  762. {
  763. return _targetConsumeId;
  764. }
  765. /**
  766. * @return Returns the targetConsume.
  767. */
  768. public final int getTargetConsume()
  769. {
  770. return _targetConsume;
  771. }
  772. /**
  773. * @return Returns the itemConsume.
  774. */
  775. public final int getItemConsume()
  776. {
  777. return _itemConsume;
  778. }
  779. /**
  780. * @return Returns the itemConsumeId.
  781. */
  782. public final int getItemConsumeId()
  783. {
  784. return _itemConsumeId;
  785. }
  786. /**
  787. * @return Returns the level.
  788. */
  789. public final int getLevel()
  790. {
  791. return _level;
  792. }
  793. /**
  794. * @return Returns the magic.
  795. */
  796. public final boolean isMagic()
  797. {
  798. return _magic;
  799. }
  800. /**
  801. * @return Returns true to set static reuse.
  802. */
  803. public final boolean isStaticReuse()
  804. {
  805. return _staticReuse;
  806. }
  807. /**
  808. * @return Returns true to set static hittime.
  809. */
  810. public final boolean isStaticHitTime()
  811. {
  812. return _staticHitTime;
  813. }
  814. public final boolean isStaticDamage()
  815. {
  816. return _staticDamage;
  817. }
  818. /**
  819. * @return Returns the mpConsume.
  820. */
  821. public final int getMpConsume()
  822. {
  823. return _mpConsume;
  824. }
  825. /**
  826. * @return Returns the mpInitialConsume.
  827. */
  828. public final int getMpInitialConsume()
  829. {
  830. return _mpInitialConsume;
  831. }
  832. /**
  833. * @return Returns the name.
  834. */
  835. public final String getName()
  836. {
  837. return _name;
  838. }
  839. /**
  840. * @return Returns the reuseDelay.
  841. */
  842. public final int getReuseDelay()
  843. {
  844. return _reuseDelay;
  845. }
  846. public final int getReuseHashCode()
  847. {
  848. return _reuseHashCode;
  849. }
  850. public final int getEquipDelay()
  851. {
  852. return _equipDelay;
  853. }
  854. public final int getHitTime()
  855. {
  856. return _hitTime;
  857. }
  858. public final int getHitCounts()
  859. {
  860. return _hitTimings.length;
  861. }
  862. public final int[] getHitTimings()
  863. {
  864. return _hitTimings;
  865. }
  866. /**
  867. * @return Returns the coolTime.
  868. */
  869. public final int getCoolTime()
  870. {
  871. return _coolTime;
  872. }
  873. public final int getSkillRadius()
  874. {
  875. return _skillRadius;
  876. }
  877. public final boolean isActive()
  878. {
  879. return _operateType == SkillOpType.OP_ACTIVE;
  880. }
  881. public final boolean isPassive()
  882. {
  883. return _operateType == SkillOpType.OP_PASSIVE;
  884. }
  885. public final boolean isToggle()
  886. {
  887. return _operateType == SkillOpType.OP_TOGGLE;
  888. }
  889. public final boolean isChance()
  890. {
  891. return _chanceCondition != null && isPassive();
  892. }
  893. public final boolean isTriggeredSkill()
  894. {
  895. return _isTriggeredSkill;
  896. }
  897. public final boolean isDance()
  898. {
  899. return _isDance;
  900. }
  901. public final int getNextDanceMpCost()
  902. {
  903. return _nextDanceCost;
  904. }
  905. public final float getSSBoost()
  906. {
  907. return _sSBoost;
  908. }
  909. public final int getAggroPoints()
  910. {
  911. return _aggroPoints;
  912. }
  913. public final boolean useSoulShot()
  914. {
  915. switch (getSkillType())
  916. {
  917. case PDAM:
  918. case CHARGEDAM:
  919. case BLOW:
  920. return true;
  921. default:
  922. return false;
  923. }
  924. }
  925. public final boolean useSpiritShot()
  926. {
  927. return isMagic();
  928. }
  929. public final boolean useFishShot()
  930. {
  931. return ((getSkillType() == L2SkillType.PUMPING) || (getSkillType() == L2SkillType.REELING) );
  932. }
  933. public final int getWeaponsAllowed()
  934. {
  935. return _weaponsAllowed;
  936. }
  937. public int getMinPledgeClass() { return _minPledgeClass; }
  938. public final boolean isPvpSkill()
  939. {
  940. switch (_skillType)
  941. {
  942. case DOT:
  943. case BLEED:
  944. case CONFUSION:
  945. case POISON:
  946. case DEBUFF:
  947. case AGGDEBUFF:
  948. case STUN:
  949. case ROOT:
  950. case FEAR:
  951. case SLEEP:
  952. case MDOT:
  953. case MUTE:
  954. case PARALYZE:
  955. case CANCEL:
  956. case BETRAY:
  957. case DISARM:
  958. case AGGDAMAGE:
  959. case STEAL_BUFF:
  960. case AGGREDUCE_CHAR:
  961. case MANADAM:
  962. return true;
  963. default:
  964. return false;
  965. }
  966. }
  967. public final boolean isOffensive()
  968. {
  969. return _isOffensive;
  970. }
  971. public final boolean isNeutral()
  972. {
  973. return _isNeutral;
  974. }
  975. public final boolean isHeroSkill()
  976. {
  977. return _isHeroSkill;
  978. }
  979. public final boolean isGMSkill()
  980. {
  981. return _isGMSkill;
  982. }
  983. public final int getNumCharges()
  984. {
  985. return _numCharges;
  986. }
  987. public final int getNumSouls()
  988. {
  989. return _numSouls;
  990. }
  991. public final int getMaxSoulConsumeCount()
  992. {
  993. return _soulMaxConsume;
  994. }
  995. public final int getSoulConsumeCount()
  996. {
  997. return _soulConsume;
  998. }
  999. public final int getExpNeeded()
  1000. {
  1001. return _expNeeded;
  1002. }
  1003. public final int getCritChance()
  1004. {
  1005. return _critChance;
  1006. }
  1007. public final int getTransformId()
  1008. {
  1009. return _transformId;
  1010. }
  1011. public final int getTransformDuration()
  1012. {
  1013. return _transformDuration;
  1014. }
  1015. public final int getBaseCritRate()
  1016. {
  1017. return _baseCritRate;
  1018. }
  1019. public final int getLethalChance1()
  1020. {
  1021. return _lethalEffect1;
  1022. }
  1023. public final int getLethalChance2()
  1024. {
  1025. return _lethalEffect2;
  1026. }
  1027. public final boolean getDmgDirectlyToHP()
  1028. {
  1029. return _directHpDmg;
  1030. }
  1031. public final String getFlyType()
  1032. {
  1033. return _flyType;
  1034. }
  1035. public final int getFlyRadius()
  1036. {
  1037. return _flyRadius;
  1038. }
  1039. public final float getFlyCourse()
  1040. {
  1041. return _flyCourse;
  1042. }
  1043. public final boolean isSkillTypeOffensive()
  1044. {
  1045. switch (_skillType)
  1046. {
  1047. case PDAM:
  1048. case MDAM:
  1049. case CPDAM:
  1050. case DOT:
  1051. case CPDAMPERCENT:
  1052. case BLEED:
  1053. case POISON:
  1054. case AGGDAMAGE:
  1055. case DEBUFF:
  1056. case AGGDEBUFF:
  1057. case STUN:
  1058. case ROOT:
  1059. case CONFUSION:
  1060. case ERASE:
  1061. case BLOW:
  1062. case FATAL:
  1063. case FEAR:
  1064. case DRAIN:
  1065. case SLEEP:
  1066. case CHARGEDAM:
  1067. case CONFUSE_MOB_ONLY:
  1068. case DEATHLINK:
  1069. case DETECT_WEAKNESS:
  1070. case MANADAM:
  1071. case MDOT:
  1072. case MUTE:
  1073. case SOULSHOT:
  1074. case SPIRITSHOT:
  1075. case SPOIL:
  1076. case SWEEP:
  1077. case PARALYZE:
  1078. case DRAIN_SOUL:
  1079. case AGGREDUCE:
  1080. case CANCEL:
  1081. case AGGREMOVE:
  1082. case AGGREDUCE_CHAR:
  1083. case BETRAY:
  1084. case DELUXE_KEY_UNLOCK:
  1085. case SOW:
  1086. case HARVEST:
  1087. case DISARM:
  1088. case STEAL_BUFF:
  1089. case INSTANT_JUMP:
  1090. return true;
  1091. default:
  1092. return this.isDebuff();
  1093. }
  1094. }
  1095. public final boolean is7Signs()
  1096. {
  1097. if (_id > 4360 && _id < 4367)
  1098. return true;
  1099. return false;
  1100. }
  1101. public final boolean isStayAfterDeath()
  1102. {
  1103. return _stayAfterDeath;
  1104. }
  1105. public final boolean isStayOnSubclassChange()
  1106. {
  1107. return _stayOnSubclassChange;
  1108. }
  1109. // int weapons[] = {L2Weapon.WEAPON_TYPE_ETC, L2Weapon.WEAPON_TYPE_BOW,
  1110. // L2Weapon.WEAPON_TYPE_POLE, L2Weapon.WEAPON_TYPE_DUALFIST,
  1111. // L2Weapon.WEAPON_TYPE_DUAL, L2Weapon.WEAPON_TYPE_BLUNT,
  1112. // L2Weapon.WEAPON_TYPE_SWORD, L2Weapon.WEAPON_TYPE_DAGGER};
  1113. public final boolean getWeaponDependancy(L2Character activeChar)
  1114. {
  1115. if(getWeaponDependancy(activeChar, false))
  1116. {
  1117. return true;
  1118. }
  1119. final SystemMessage message = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  1120. message.addSkillName(this);
  1121. activeChar.sendPacket(message);
  1122. return false;
  1123. }
  1124. public final boolean getWeaponDependancy(L2Character activeChar,boolean chance)
  1125. {
  1126. int weaponsAllowed = getWeaponsAllowed();
  1127. //check to see if skill has a weapon dependency.
  1128. if (weaponsAllowed == 0)
  1129. return true;
  1130. int mask = 0;
  1131. if (activeChar.getActiveWeaponItem() != null)
  1132. mask |= activeChar.getActiveWeaponItem().getItemType().mask();
  1133. if (activeChar.getSecondaryWeaponItem() != null && activeChar.getSecondaryWeaponItem() instanceof L2Armor)
  1134. mask |= ((L2ArmorType) activeChar.getSecondaryWeaponItem().getItemType()).mask();
  1135. if ((mask & weaponsAllowed) != 0)
  1136. return true;
  1137. return false;
  1138. }
  1139. public boolean checkCondition(L2Character activeChar, L2Object target, boolean itemOrWeapon)
  1140. {
  1141. if (activeChar.isGM() && !Config.GM_SKILL_RESTRICTION)
  1142. return true;
  1143. if ((getCondition() & L2Skill.COND_SHIELD) != 0)
  1144. {
  1145. /*
  1146. L2Armor armorPiece;
  1147. L2ItemInstance dummy;
  1148. dummy = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  1149. armorPiece = (L2Armor) dummy.getItem();
  1150. */
  1151. //TODO add checks for shield here.
  1152. }
  1153. List<Condition> preCondition = _preCondition;
  1154. if(itemOrWeapon) preCondition = _itemPreCondition;
  1155. if (preCondition == null || preCondition.isEmpty()) return true;
  1156. for(Condition cond : preCondition)
  1157. {
  1158. Env env = new Env();
  1159. env.player = activeChar;
  1160. if (target instanceof L2Character) // TODO: object or char?
  1161. env.target = (L2Character)target;
  1162. env.skill = this;
  1163. if (!cond.test(env))
  1164. {
  1165. String msg = cond.getMessage();
  1166. int msgId = cond.getMessageId();
  1167. if (msgId != 0)
  1168. {
  1169. SystemMessage sm = SystemMessage.getSystemMessage(msgId);
  1170. if (cond.isAddName())
  1171. sm.addSkillName(_id);
  1172. activeChar.sendPacket(sm);
  1173. }
  1174. else if (msg != null)
  1175. {
  1176. activeChar.sendMessage(msg);
  1177. }
  1178. return false;
  1179. }
  1180. }
  1181. return true;
  1182. }
  1183. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst)
  1184. {
  1185. // Init to null the target of the skill
  1186. L2Character target = null;
  1187. // Get the L2Objcet targeted by the user of the skill at this moment
  1188. L2Object objTarget = activeChar.getTarget();
  1189. // If the L2Object targeted is a L2Character, it becomes the L2Character target
  1190. if (objTarget instanceof L2Character)
  1191. {
  1192. target = (L2Character) objTarget;
  1193. }
  1194. return getTargetList(activeChar, onlyFirst, target);
  1195. }
  1196. /**
  1197. * Return all targets of the skill in a table in function a the skill type.<BR><BR>
  1198. *
  1199. * <B><U> Values of skill type</U> :</B><BR><BR>
  1200. * <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>
  1201. * <li>SELF</li>
  1202. * <li>HOLY, UNDEAD</li>
  1203. * <li>PET</li>
  1204. * <li>AURA, AURA_CLOSE</li>
  1205. * <li>AREA</li>
  1206. * <li>MULTIFACE</li>
  1207. * <li>PARTY, CLAN</li>
  1208. * <li>CORPSE_PLAYER, CORPSE_MOB, CORPSE_CLAN</li>
  1209. * <li>UNLOCKABLE</li>
  1210. * <li>ITEM</li><BR><BR>
  1211. *
  1212. * @param activeChar The L2Character who use the skill
  1213. * @param onlyFirst
  1214. * @param target
  1215. * @return
  1216. *
  1217. */
  1218. public final L2Object[] getTargetList(L2Character activeChar, boolean onlyFirst, L2Character target)
  1219. {
  1220. final ITargetTypeHandler handler = TargetHandler.getInstance().getHandler(getTargetType());
  1221. if (handler != null)
  1222. {
  1223. try
  1224. {
  1225. return handler.getTargetList(this, activeChar, onlyFirst, target);
  1226. }
  1227. catch (Exception e)
  1228. {
  1229. _log.log(Level.WARNING, "Exception in L2Skill.getTargetList(): " + e.getMessage(), e);
  1230. }
  1231. }
  1232. activeChar.sendMessage("Target type of skill is not currently handled");
  1233. return _emptyTargetList;
  1234. }
  1235. public final L2Object[] getTargetList(L2Character activeChar)
  1236. {
  1237. return getTargetList(activeChar, false);
  1238. }
  1239. public final L2Object getFirstOfTargetList(L2Character activeChar)
  1240. {
  1241. L2Object[] targets;
  1242. targets = getTargetList(activeChar, true);
  1243. if (targets.length == 0)
  1244. return null;
  1245. return targets[0];
  1246. }
  1247. /*
  1248. * Check if should be target added to the target list
  1249. * false if target is dead, target same as caster,
  1250. * target inside peace zone, target in the same party with caster,
  1251. * caster can see target
  1252. * Additional checks if not in PvP zones (arena, siege):
  1253. * target in not the same clan and alliance with caster,
  1254. * and usual skill PvP check.
  1255. * If TvT event is active - performing additional checks.
  1256. *
  1257. * Caution: distance is not checked.
  1258. */
  1259. public static final boolean checkForAreaOffensiveSkills(L2Character caster, L2Character target, L2Skill skill, boolean sourceInArena)
  1260. {
  1261. if (target == null || target.isDead() || target == caster)
  1262. return false;
  1263. final L2PcInstance player = caster.getActingPlayer();
  1264. final L2PcInstance targetPlayer = target.getActingPlayer();
  1265. if (player != null)
  1266. {
  1267. if (targetPlayer != null)
  1268. {
  1269. if (targetPlayer == caster || targetPlayer == player)
  1270. return false;
  1271. if (targetPlayer.inObserverMode())
  1272. return false;
  1273. if (skill.isOffensive() && player.getSiegeState() > 0 && player.isInsideZone(L2Character.ZONE_SIEGE)
  1274. && player.getSiegeState() == targetPlayer.getSiegeState()
  1275. && player.getSiegeSide() == targetPlayer.getSiegeSide())
  1276. return false;
  1277. if (skill.isOffensive() && target.isInsideZone(L2Character.ZONE_PEACE))
  1278. return false;
  1279. if (player.isInParty() && targetPlayer.isInParty())
  1280. {
  1281. // Same party
  1282. if (player.getParty().getPartyLeaderOID() == targetPlayer.getParty().getPartyLeaderOID())
  1283. return false;
  1284. // Same commandchannel
  1285. if (player.getParty().getCommandChannel() != null
  1286. && player.getParty().getCommandChannel() == targetPlayer.getParty().getCommandChannel())
  1287. return false;
  1288. }
  1289. if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
  1290. return false;
  1291. if (!sourceInArena && !(targetPlayer.isInsideZone(L2Character.ZONE_PVP) && !targetPlayer.isInsideZone(L2Character.ZONE_SIEGE)))
  1292. {
  1293. if (player.getAllyId() != 0 && player.getAllyId() == targetPlayer.getAllyId())
  1294. return false;
  1295. if (player.getClanId() != 0 && player.getClanId() == targetPlayer.getClanId())
  1296. return false;
  1297. if (!player.checkPvpSkill(targetPlayer, skill, (caster instanceof L2Summon)))
  1298. return false;
  1299. }
  1300. }
  1301. }
  1302. else
  1303. {
  1304. // target is mob
  1305. if (targetPlayer == null && target instanceof L2Attackable && caster instanceof L2Attackable)
  1306. {
  1307. String casterEnemyClan = ((L2Attackable)caster).getEnemyClan();
  1308. if (casterEnemyClan == null || casterEnemyClan.isEmpty())
  1309. return false;
  1310. String targetClan = ((L2Attackable)target).getClan();
  1311. if (targetClan == null || targetClan.isEmpty())
  1312. return false;
  1313. if (!casterEnemyClan.equals(targetClan))
  1314. return false;
  1315. }
  1316. }
  1317. if (geoEnabled && !GeoData.getInstance().canSeeTarget(caster, target))
  1318. return false;
  1319. return true;
  1320. }
  1321. public static final boolean addSummon(L2Character caster, L2PcInstance owner, int radius, boolean isDead)
  1322. {
  1323. final L2Summon summon = owner.getPet();
  1324. if (summon == null)
  1325. return false;
  1326. return addCharacter(caster, summon, radius, isDead);
  1327. }
  1328. public static final boolean addCharacter(L2Character caster, L2Character target, int radius, boolean isDead)
  1329. {
  1330. if (isDead != target.isDead())
  1331. return false;
  1332. if (radius > 0 && !Util.checkIfInRange(radius, caster, target, true))
  1333. return false;
  1334. return true;
  1335. }
  1336. public final Func[] getStatFuncs(L2Effect effect, L2Character player)
  1337. {
  1338. if (_funcTemplates == null)
  1339. return _emptyFunctionSet;
  1340. if (!(player instanceof L2Playable) && !(player instanceof L2Attackable))
  1341. return _emptyFunctionSet;
  1342. ArrayList<Func> funcs = new ArrayList<Func>(_funcTemplates.length);
  1343. Env env = new Env();
  1344. env.player = player;
  1345. env.skill = this;
  1346. Func f;
  1347. for (FuncTemplate t : _funcTemplates)
  1348. {
  1349. f = t.getFunc(env, this); // skill is owner
  1350. if (f != null)
  1351. funcs.add(f);
  1352. }
  1353. if (funcs.isEmpty())
  1354. return _emptyFunctionSet;
  1355. return funcs.toArray(new Func[funcs.size()]);
  1356. }
  1357. public boolean hasEffects()
  1358. {
  1359. return (_effectTemplates != null && _effectTemplates.length > 0);
  1360. }
  1361. public EffectTemplate[] getEffectTemplates()
  1362. {
  1363. return _effectTemplates;
  1364. }
  1365. public EffectTemplate[] getEffectTemplatesPassive()
  1366. {
  1367. return _effectTemplatesPassive;
  1368. }
  1369. public boolean hasSelfEffects()
  1370. {
  1371. return (_effectTemplatesSelf != null && _effectTemplatesSelf.length > 0);
  1372. }
  1373. public boolean hasPassiveEffects()
  1374. {
  1375. return (_effectTemplatesPassive != null && _effectTemplatesPassive.length > 0);
  1376. }
  1377. /**
  1378. * Env is used to pass parameters for secondary effects (shield and ss/bss/bsss)
  1379. * @param effector
  1380. * @param effected
  1381. * @param env
  1382. * @return an array with the effects that have been added to effector
  1383. */
  1384. public final L2Effect[] getEffects(L2Character effector, L2Character effected, Env env)
  1385. {
  1386. if (!hasEffects() || isPassive())
  1387. return _emptyEffectSet;
  1388. // doors and siege flags cannot receive any effects
  1389. if (effected instanceof L2DoorInstance ||effected instanceof L2SiegeFlagInstance )
  1390. return _emptyEffectSet;
  1391. if (effector != effected)
  1392. {
  1393. if (isOffensive() || isDebuff())
  1394. {
  1395. if (effected.isInvul())
  1396. return _emptyEffectSet;
  1397. if (effector instanceof L2PcInstance && ((L2PcInstance)effector).isGM())
  1398. {
  1399. if (!((L2PcInstance)effector).getAccessLevel().canGiveDamage())
  1400. return _emptyEffectSet;
  1401. }
  1402. }
  1403. }
  1404. ArrayList<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplates.length);
  1405. if (env == null)
  1406. env = new Env();
  1407. env.skillMastery = Formulas.calcSkillMastery(effector, this);
  1408. env.player = effector;
  1409. env.target = effected;
  1410. env.skill = this;
  1411. for (EffectTemplate et : _effectTemplates)
  1412. {
  1413. boolean success = true;
  1414. if (et.effectPower > -1)
  1415. success = Formulas.calcEffectSuccess(effector, effected, et, this, env.shld, env.ss, env.sps, env.bss);
  1416. if (success)
  1417. {
  1418. L2Effect e = et.getEffect(env);
  1419. if (e != null)
  1420. {
  1421. e.scheduleEffect();
  1422. effects.add(e);
  1423. }
  1424. }
  1425. // display fail message only for effects with icons
  1426. else if (et.icon && effector instanceof L2PcInstance)
  1427. {
  1428. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_RESISTED_YOUR_S2);
  1429. sm.addCharName(effected);
  1430. sm.addSkillName(this);
  1431. ((L2PcInstance)effector).sendPacket(sm);
  1432. }
  1433. }
  1434. if (effects.isEmpty()) return _emptyEffectSet;
  1435. return effects.toArray(new L2Effect[effects.size()]);
  1436. }
  1437. /**
  1438. * Warning: this method doesn't consider modifier (shield, ss, sps, bss) for secondary effects
  1439. * @param effector
  1440. * @param effected
  1441. * @return
  1442. */
  1443. public final L2Effect[] getEffects(L2Character effector, L2Character effected)
  1444. {
  1445. return getEffects(effector, effected, null);
  1446. }
  1447. /**
  1448. * This method has suffered some changes in CT2.2 ->CT2.3<br>
  1449. * Effect engine is now supporting secondary effects with independent
  1450. * success/fail calculus from effect skill. Env parameter has been added to
  1451. * pass parameters like soulshot, spiritshots, blessed spiritshots or shield deffence.
  1452. * Some other optimizations have been done
  1453. * <br><br>
  1454. * This new feature works following next rules:
  1455. * <li> To enable feature, effectPower must be over -1 (check DocumentSkill#attachEffect for further information)</li>
  1456. * <li> If main skill fails, secondary effect always fail</li>
  1457. * @param effector
  1458. * @param effected
  1459. * @param env
  1460. * @return
  1461. */
  1462. public final L2Effect[] getEffects(L2CubicInstance effector, L2Character effected, Env env)
  1463. {
  1464. if (!hasEffects() || isPassive())
  1465. return _emptyEffectSet;
  1466. if (effector.getOwner() != effected)
  1467. {
  1468. if (isDebuff() || isOffensive())
  1469. {
  1470. if (effected.isInvul())
  1471. return _emptyEffectSet;
  1472. if (effector.getOwner().isGM() &&
  1473. !effector.getOwner().getAccessLevel().canGiveDamage())
  1474. {
  1475. return _emptyEffectSet;
  1476. }
  1477. }
  1478. }
  1479. ArrayList<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplates.length);
  1480. if (env == null)
  1481. env = new Env();
  1482. env.player = effector.getOwner();
  1483. env.cubic = effector;
  1484. env.target = effected;
  1485. env.skill = this;
  1486. for (EffectTemplate et : _effectTemplates)
  1487. {
  1488. boolean success = true;
  1489. if (et.effectPower > -1)
  1490. success = Formulas.calcEffectSuccess(effector.getOwner(), effected, et, this, env.shld, env.ss, env.sps, env.bss);
  1491. if (success)
  1492. {
  1493. L2Effect e = et.getEffect(env);
  1494. if (e != null)
  1495. {
  1496. e.scheduleEffect();
  1497. effects.add(e);
  1498. }
  1499. }
  1500. }
  1501. if (effects.isEmpty()) return _emptyEffectSet;
  1502. return effects.toArray(new L2Effect[effects.size()]);
  1503. }
  1504. public final L2Effect[] getEffectsSelf(L2Character effector)
  1505. {
  1506. if (!hasSelfEffects() || isPassive())
  1507. return _emptyEffectSet;
  1508. List<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplatesSelf.length);
  1509. for (EffectTemplate et : _effectTemplatesSelf)
  1510. {
  1511. Env env = new Env();
  1512. env.player = effector;
  1513. env.target = effector;
  1514. env.skill = this;
  1515. L2Effect e = et.getEffect(env);
  1516. if (e != null)
  1517. {
  1518. e.setSelfEffect();
  1519. e.scheduleEffect();
  1520. effects.add(e);
  1521. }
  1522. }
  1523. if (effects.isEmpty()) return _emptyEffectSet;
  1524. return effects.toArray(new L2Effect[effects.size()]);
  1525. }
  1526. public final L2Effect[] getEffectsPassive(L2Character effector)
  1527. {
  1528. if (!hasPassiveEffects())
  1529. return _emptyEffectSet;
  1530. List<L2Effect> effects = new ArrayList<L2Effect>(_effectTemplatesPassive.length);
  1531. for (EffectTemplate et : _effectTemplatesPassive)
  1532. {
  1533. Env env = new Env();
  1534. env.player = effector;
  1535. env.target = effector;
  1536. env.skill = this;
  1537. L2Effect e = et.getEffect(env);
  1538. if (e != null)
  1539. {
  1540. e.setPassiveEffect();
  1541. e.scheduleEffect();
  1542. effects.add(e);
  1543. }
  1544. }
  1545. if (effects.isEmpty()) return _emptyEffectSet;
  1546. return effects.toArray(new L2Effect[effects.size()]);
  1547. }
  1548. public final void attach(FuncTemplate f)
  1549. {
  1550. if (_funcTemplates == null)
  1551. {
  1552. _funcTemplates = new FuncTemplate[] {f};
  1553. }
  1554. else
  1555. {
  1556. int len = _funcTemplates.length;
  1557. FuncTemplate[] tmp = new FuncTemplate[len + 1];
  1558. System.arraycopy(_funcTemplates, 0, tmp, 0, len);
  1559. tmp[len] = f;
  1560. _funcTemplates = tmp;
  1561. }
  1562. }
  1563. public final void attach(EffectTemplate effect)
  1564. {
  1565. if (_effectTemplates == null)
  1566. {
  1567. _effectTemplates = new EffectTemplate[] {effect};
  1568. }
  1569. else
  1570. {
  1571. int len = _effectTemplates.length;
  1572. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  1573. System.arraycopy(_effectTemplates, 0, tmp, 0, len);
  1574. tmp[len] = effect;
  1575. _effectTemplates = tmp;
  1576. }
  1577. }
  1578. public final void attachSelf(EffectTemplate effect)
  1579. {
  1580. if (_effectTemplatesSelf == null)
  1581. {
  1582. _effectTemplatesSelf = new EffectTemplate[] {effect};
  1583. }
  1584. else
  1585. {
  1586. int len = _effectTemplatesSelf.length;
  1587. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  1588. System.arraycopy(_effectTemplatesSelf, 0, tmp, 0, len);
  1589. tmp[len] = effect;
  1590. _effectTemplatesSelf = tmp;
  1591. }
  1592. }
  1593. public final void attachPassive(EffectTemplate effect)
  1594. {
  1595. if (_effectTemplatesPassive == null)
  1596. {
  1597. _effectTemplatesPassive = new EffectTemplate[] {effect};
  1598. }
  1599. else
  1600. {
  1601. int len = _effectTemplatesPassive.length;
  1602. EffectTemplate[] tmp = new EffectTemplate[len + 1];
  1603. System.arraycopy(_effectTemplatesPassive, 0, tmp, 0, len);
  1604. tmp[len] = effect;
  1605. _effectTemplatesPassive = tmp;
  1606. }
  1607. }
  1608. public final void attach(Condition c, boolean itemOrWeapon)
  1609. {
  1610. if (itemOrWeapon)
  1611. {
  1612. if (_itemPreCondition == null)
  1613. _itemPreCondition = new FastList<Condition>();
  1614. _itemPreCondition.add(c);
  1615. }
  1616. else
  1617. {
  1618. if (_preCondition == null)
  1619. _preCondition = new FastList<Condition>();
  1620. _preCondition.add(c);
  1621. }
  1622. }
  1623. @Override
  1624. public String toString()
  1625. {
  1626. return "" + _name + "[id=" + _id + ",lvl=" + _level + "]";
  1627. }
  1628. /**
  1629. * @return pet food
  1630. */
  1631. public int getFeed()
  1632. {
  1633. return _feed;
  1634. }
  1635. /**
  1636. * used for tracking item id in case that item consume cannot be used
  1637. * @return reference item id
  1638. */
  1639. public int getReferenceItemId()
  1640. {
  1641. return _refId;
  1642. }
  1643. public final int getMaxCharges()
  1644. {
  1645. return _maxCharges;
  1646. }
  1647. public int getAfterEffectId()
  1648. {
  1649. return _afterEffectId;
  1650. }
  1651. public int getAfterEffectLvl()
  1652. {
  1653. return _afterEffectLvl;
  1654. }
  1655. @Override
  1656. public boolean triggersChanceSkill()
  1657. {
  1658. return _triggeredId > 0 && isChance();
  1659. }
  1660. @Override
  1661. public int getTriggeredChanceId()
  1662. {
  1663. return _triggeredId;
  1664. }
  1665. @Override
  1666. public int getTriggeredChanceLevel()
  1667. {
  1668. return _triggeredLevel;
  1669. }
  1670. @Override
  1671. public ChanceCondition getTriggeredChanceCondition()
  1672. {
  1673. return _chanceCondition;
  1674. }
  1675. public String getAttributeName()
  1676. {
  1677. return _attribute;
  1678. }
  1679. /**
  1680. * @return the _blowChance
  1681. */
  1682. public int getBlowChance()
  1683. {
  1684. return _blowChance;
  1685. }
  1686. public boolean ignoreShield()
  1687. {
  1688. return _ignoreShield;
  1689. }
  1690. public boolean ignoreSkillMute()
  1691. {
  1692. return _ignoreSkillMute;
  1693. }
  1694. public boolean canBeReflected()
  1695. {
  1696. return _canBeReflected;
  1697. }
  1698. public boolean canBeDispeled()
  1699. {
  1700. return _canBeDispeled;
  1701. }
  1702. public boolean isClanSkill()
  1703. {
  1704. return _isClanSkill;
  1705. }
  1706. public boolean isExcludedFromCheck()
  1707. {
  1708. return _excludedFromCheck;
  1709. }
  1710. public float getDependOnTargetBuff()
  1711. {
  1712. return _dependOnTargetBuff;
  1713. }
  1714. public boolean isSimultaneousCast()
  1715. {
  1716. return _simultaneousCast;
  1717. }
  1718. /**
  1719. * @param skillId
  1720. * @param skillLvl
  1721. * @param values
  1722. * @return L2ExtractableSkill
  1723. * @author Zoey76
  1724. */
  1725. private L2ExtractableSkill parseExtractableSkill(int skillId, int skillLvl, String values)
  1726. {
  1727. String[] lineSplit = values.split(";");
  1728. final FastList<L2ExtractableProductItem> product_temp = new FastList<L2ExtractableProductItem>();
  1729. for (int i = 0; i <= (lineSplit.length-1); i++)
  1730. {
  1731. final String[] lineSplit2 = lineSplit[i].split(",");
  1732. if (lineSplit2.length < 3)
  1733. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> wrong seperator!");
  1734. int[] production = null;
  1735. int[] amount = null;
  1736. double chance = 0;
  1737. int prodId = 0;
  1738. int quantity = 0;
  1739. try
  1740. {
  1741. int k =0;
  1742. production = new int[(lineSplit2.length-1)/2];
  1743. amount = new int[(lineSplit2.length-1)/2];
  1744. for (int j = 0; j < (lineSplit2.length-1); j++)
  1745. {
  1746. prodId = Integer.parseInt(lineSplit2[j]);
  1747. quantity = Integer.parseInt(lineSplit2[j+=1]);
  1748. if ((prodId <= 0) || (quantity <= 0))
  1749. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " wrong production Id: " + prodId + " or wrond quantity: " + quantity + "!");
  1750. production[k] = prodId;
  1751. amount[k] = quantity;
  1752. k++;
  1753. }
  1754. chance = Double.parseDouble(lineSplit2[lineSplit2.length-1]);
  1755. }
  1756. catch (Exception e)
  1757. {
  1758. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> incomplete/invalid production data or wrong seperator!");
  1759. }
  1760. product_temp.add(new L2ExtractableProductItem(production, amount, chance));
  1761. }
  1762. if (product_temp.size()== 0)
  1763. _log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> There are no production items!");
  1764. return new L2ExtractableSkill(SkillTable.getSkillHashCode(this), product_temp);
  1765. }
  1766. public L2ExtractableSkill getExtractableSkill()
  1767. {
  1768. return _extractableItems;
  1769. }
  1770. public int getMaxTargets()
  1771. {
  1772. return _maxTargets;
  1773. }
  1774. public boolean isStaticHeal()
  1775. {
  1776. return _isStaticHeal;
  1777. }
  1778. }