L2Skill.java 81 KB

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