L2Skill.java 102 KB

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