L2Skill.java 80 KB

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