L2Skill.java 103 KB

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