L2Skill.java 81 KB

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