L2Skill.java 53 KB

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