L2Skill.java 53 KB

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