1 // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
2 // For more information, see LICENCE in the main folder
11 #include "../common/mmo.h" // MAX_SKILL, struct square
12 #include "../common/db.h"
13 #include "map.h" // struct block_list
14 #include "battle.h" // enum damage_lv
15 struct map_session_data;
18 struct skill_unit_group;
19 struct status_change_entry;
21 #define MAX_SKILL_PRODUCE_DB 280 /// Max Produce DB
22 #define MAX_PRODUCE_RESOURCE 12 /// Max Produce requirements
23 #define MAX_SKILL_ARROW_DB 150 /// Max Arrow Creation DB
24 #define MAX_ARROW_RESULT 5 /// Max Arrow results/created
25 #define MAX_SKILL_ABRA_DB 160 /// Max Skill list of Abracadabra DB
26 #define MAX_SKILL_IMPROVISE_DB 30 /// Max Skill for Improvise
27 #define MAX_SKILL_LEVEL 13 /// Max Skill Level (for skill_db storage)
28 #define MAX_MOBSKILL_LEVEL 100 /// Max monster skill level (on skill usage)
29 #define MAX_SKILL_CRIMSON_MARKER 3 /// Max Crimson Marker targets (RL_C_MARKER)
30 #define SKILL_NAME_LENGTH 31 /// Max Skill Name length
31 #define SKILL_DESC_LENGTH 31 /// Max Skill Desc length
33 extern DBMap* skilldb_name2id;
35 /// Constants to identify a skill's nk value (damage properties)
36 /// The NK value applies only to non INF_GROUND_SKILL skills
37 /// when determining skill castend function to invoke.
40 NK_SPLASH = 0x02|0x04, // 0x4 = splash & split
41 NK_SPLASHSPLIT = 0x04,
42 NK_NO_CARDFIX_ATK = 0x08,
45 NK_IGNORE_FLEE = 0x40,
46 NK_NO_CARDFIX_DEF = 0x80,
49 /// Constants to identify the skill's inf value:
51 INF_ATTACK_SKILL = 0x01,
52 INF_GROUND_SKILL = 0x02,
53 INF_SELF_SKILL = 0x04, // Skills casted on self where target is automatically chosen
55 INF_SUPPORT_SKILL = 0x10,
56 INF_TARGET_TRAP = 0x20,
59 /// A skill with 3 would be no damage + splash: area of effect.
60 /// Constants to identify a skill's inf2 value.
62 INF2_QUEST_SKILL = 0x00001,
63 INF2_NPC_SKILL = 0x00002, //NPC skills are those that players can't have in their skill tree.
64 INF2_WEDDING_SKILL = 0x00004,
65 INF2_SPIRIT_SKILL = 0x00008,
66 INF2_GUILD_SKILL = 0x00010,
67 INF2_SONG_DANCE = 0x00020,
68 INF2_ENSEMBLE_SKILL = 0x00040,
70 INF2_TARGET_SELF = 0x00100, //Refers to ground placed skills that will target the caster as well (like Grandcross)
71 INF2_NO_TARGET_SELF = 0x00200,
72 INF2_PARTY_ONLY = 0x00400,
73 INF2_GUILD_ONLY = 0x00800,
74 INF2_NO_ENEMY = 0x01000,
75 INF2_AUTOSHADOWSPELL = 0x02000, // Skill that available for SC_AUTOSHADOWSPELL
76 INF2_CHORUS_SKILL = 0x04000, // Chorus skill
77 INF2_NO_BG_DMG = 0x08000, // Skill that ignore bg reduction
78 INF2_NO_GVG_DMG = 0x10000, // Skill that ignore gvg reduction
79 INF2_NO_NEARNPC = 0x20000, // disable to cast skill if near with NPC [Cydh]
80 INF2_HIT_TRAP = 0x40000, // can hit trap-type skill (INF2_TRAP) [Cydh]
85 INF3_NOLP = 0x00001, // Skill that can ignore Land Protector
86 INF3_FREE = 0x00002, // Free
87 INF3_USABLE_HIDING = 0x00004, // Skill that can be use in hiding
88 INF3_USABLE_DANCE = 0x00008, // Skill that can be use while in dancing state
89 INF3_HIT_EMP = 0x00010, // Skill that could hit emperium
90 INF3_STASIS_BL = 0x00020, // Skill that can ignore SC_STASIS
91 INF3_KAGEHUMI_BL = 0x00040, // Skill blocked by kagehumi
92 INF3_EFF_VULTURE = 0x00080, // Skill range affected by AC_VULTURE
93 INF3_EFF_SNAKEEYE = 0x00100, // Skill range affected by GS_SNAKEEYE
94 INF3_EFF_SHADOWJUMP = 0x00200, // Skill range affected by NJ_SHADOWJUMP
95 INF3_EFF_RADIUS = 0x00400, // Skill range affected by WL_RADIUS
96 INF3_EFF_RESEARCHTRAP = 0x00800, // Skill range affected by RA_RESEARCHTRAP
97 INF3_NO_EFF_HOVERING = 0x01000, // Skill that does not affect user that has SC_HOVERING active
98 INF3_USABLE_WARG = 0x02000, // Skill that can be use while riding warg
99 INF3_DIS_MADO = 0x04000, // Skill that can't be used while in mado
100 INF3_USABLE_MANHOLE = 0x08000, // Skill that can be used to target while under SC__MANHOLE effect
101 INF3_HIT_HIDING = 0x10000, // Skill that affects hidden targets
102 INF3_SC_GLOOMYDAY_SK = 0x20000, // Skill that affects SC_GLOOMYDAY_SK
103 INF3_SC_DANCEWITHWUG = 0x40000, // Skill that is affected by SC_DANCEWITHWUG
104 INF3_BITE_BLOCK = 0x80000, // Skill blocked by RA_WUGBITE
107 /// Walk intervals at which chase-skills are attempted to be triggered.
108 /// If you change this, make sure it's an odd value (for icewall block behavior).
109 #define WALK_SKILL_INTERVAL 5
111 /// Time that's added to canact delay on castbegin and substracted on castend
112 /// This is to prevent hackers from sending a skill packet after cast but before a timer triggers castend
113 #define SECURITY_CASTTIME 100
115 /// Flags passed to skill_attack/skill_area_sub
116 enum e_skill_display {
117 SD_LEVEL = 0x1000, // skill_attack will send -1 instead of skill level (affects display of some skills)
118 SD_ANIMATION = 0x2000, // skill_attack will use '5' instead of the skill's 'type' (this makes skills show an animation). Also being used in skill_attack for splash skill (NK_SPLASH) to check status_check_skilluse
119 SD_SPLASH = 0x4000, // skill_area_sub will count targets in skill_area_temp[2]
120 SD_PREAMBLE = 0x8000, // skill_area_sub will transmit a 'magic' damage packet (-30000 dmg) for the first target selected
123 #define MAX_SKILL_ITEM_REQUIRE 10 /// Maximum required items
124 #define MAX_SKILL_STATUS_REQUIRE 3 /// Maximum required statuses
125 #define MAX_SKILL_EQUIP_REQUIRE 10 /// Maximum required equipped item
127 /// Single skill requirement. !TODO: Cleanup the variable types
128 struct skill_condition {
129 int32 hp; ///< HP cost
130 int32 mhp; ///< Max HP to trigger
131 int32 sp; /// SP cost
132 int16 hp_rate; /// HP cost (%)
133 int16 sp_rate; /// SP cost (%)
134 uint32 zeny; /// Zeny cost
135 uint32 weapon; /// Weapon type. Combined bitmask of enum weapon_type (1<<weapon)
136 uint16 ammo; /// Ammo type. Combine bitmask of enum ammo_type (1<<ammo)
137 int8 ammo_qty; /// Amount of ammo
138 uint8 state; /// State/condition. @see enum e_require_state
139 int8 spiritball; /// Spiritball cost
140 uint16 itemid[MAX_SKILL_ITEM_REQUIRE]; /// Required item
141 uint16 amount[MAX_SKILL_ITEM_REQUIRE]; /// Amount of item
142 uint16 *eqItem; /// List of equipped item
143 enum sc_type *status; /// List of Status required (SC)
144 uint8 status_count, /// Count of SC
145 eqItem_count; /// Count of equipped item
148 /// Skill requirement structure. !TODO: Cleanup the variable types that use array [MAX_SKILL_LEVEL]
149 struct s_skill_require {
150 int hp[MAX_SKILL_LEVEL]; ///< HP cost
151 int mhp[MAX_SKILL_LEVEL]; ///< Max HP to trigger
152 int sp[MAX_SKILL_LEVEL]; /// SP cost
153 int hp_rate[MAX_SKILL_LEVEL]; /// HP cost (%)
154 int sp_rate[MAX_SKILL_LEVEL]; /// SP cost (%)
155 int zeny[MAX_SKILL_LEVEL]; /// Zeny cost
156 uint32 weapon; /// Weapon type. Combined bitmask of enum weapon_type (1<<weapon)
157 uint16 ammo; /// Ammo type. Combine bitmask of enum ammo_type (1<<ammo)
158 int ammo_qty[MAX_SKILL_LEVEL]; /// Amount of ammo
159 uint8 state; /// State/condition. @see enum e_require_state
160 int spiritball[MAX_SKILL_LEVEL]; /// Spiritball cost
161 uint16 itemid[MAX_SKILL_ITEM_REQUIRE]; /// Required item
162 uint16 amount[MAX_SKILL_ITEM_REQUIRE]; /// Amount of item
163 uint16 *eqItem; /// List of equipped item
164 enum sc_type *status; /// List of Status required (SC)
165 uint8 status_count, /// Count of SC
166 eqItem_count; /// Count of equipped item
169 /// Database skills. !TODO: Cleanup the variable types that use array [MAX_SKILL_LEVEL]
172 uint16 nameid; ///< Skill ID
173 char name[SKILL_NAME_LENGTH]; ///< AEGIS_Name
174 char desc[SKILL_DESC_LENGTH]; ///< English Name
175 int range[MAX_SKILL_LEVEL]; ///< Range
176 int8 hit; ///< Hit type
177 uint8 inf; ///< Inf: 0- passive, 1- enemy, 2- place, 4- self, 16- friend, 32- trap
178 int element[MAX_SKILL_LEVEL]; ///< Element
179 uint8 nk; ///< Damage properties
180 int splash[MAX_SKILL_LEVEL]; ///< Splash effect
181 uint8 max; ///< Max level
182 int num[MAX_SKILL_LEVEL]; ///< Number of hit
183 bool castcancel; ///< Cancel cast when being hit
184 int16 cast_def_rate; ///< Def rate during cast a skill
185 uint16 skill_type; ///< Skill type
186 int blewcount[MAX_SKILL_LEVEL]; ///< Blew count
187 uint32 inf2; ///< Skill flags @see enum e_skill_inf2
188 uint32 inf3; ///< Skill flags @see enum e_skill_inf3
189 int maxcount[MAX_SKILL_LEVEL]; ///< Max number skill can be casted in same map
191 // skill_castnodex_db.txt
192 uint8 castnodex; ///< 1 - Not affected by dex, 2 - Not affected by SC, 4 - Not affected by item
193 uint8 delaynodex; ///< 1 - Not affected by dex, 2 - Not affected by SC, 4 - Not affected by item
195 // skill_nocast_db.txt
196 uint32 nocast; ///< Skill cannot be casted at this zone
199 uint16 unit_id[2]; ///< Unit ID. @see enum s_skill_unit_id
200 int unit_layout_type[MAX_SKILL_LEVEL]; ///< Layout type. -1 is special layout, others are square with lenght*width: (val*2+1)^2
201 int unit_range[MAX_SKILL_LEVEL]; ///< Unit cell effect range
202 int16 unit_interval; ///< Interval
203 uint32 unit_target; ///< Unit target. @see enum e_battle_check_target
204 uint32 unit_flag; ///< Unit flags. @see enum e_skill_unit_flag
207 int cast[MAX_SKILL_LEVEL]; ///< Variable casttime
209 int fixed_cast[MAX_SKILL_LEVEL]; ///< If -1 means 20% than 'cast'
211 int walkdelay[MAX_SKILL_LEVEL]; ///< Delay to walk after casting
212 int delay[MAX_SKILL_LEVEL]; ///< Global delay (delay before reusing all skills)
213 int cooldown[MAX_SKILL_LEVEL]; ///< Cooldown (delay before reusing same skill)
214 int upkeep_time[MAX_SKILL_LEVEL]; ///< Duration
215 int upkeep_time2[MAX_SKILL_LEVEL]; ///< Duration2
217 // skill_require_db.txt
218 struct s_skill_require require; ///< Skill requirement
220 // skill_nonearnpc_db.txt
221 uint8 unit_nonearnpc_range; //additional range for UF_NONEARNPC or INF2_NO_NEARNPC [Cydh]
222 uint8 unit_nonearnpc_type; //type of NPC [Cydh]
224 // skill_damage_db.txt
225 #ifdef ADJUST_SKILL_DAMAGE
226 struct s_skill_damage damage;
229 // skill_copyable_db.txt
230 struct s_copyable { // [Cydh]
232 uint16 joballowed, req_opt;
235 extern struct s_skill_db **skill_db;
237 #define MAX_SQUARE_LAYOUT 7 // 15*15 unit placement maximum
238 #define MAX_SKILL_UNIT_LAYOUT (47+MAX_SQUARE_LAYOUT) // 47 special ones + the square ones
239 #define MAX_SKILL_UNIT_LAYOUT2 17
240 #define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1))
241 struct s_skill_unit_layout {
243 int dx[MAX_SKILL_UNIT_COUNT];
244 int dy[MAX_SKILL_UNIT_COUNT];
247 struct s_skill_nounit_layout {
249 int dx[MAX_SKILL_UNIT_COUNT];
250 int dy[MAX_SKILL_UNIT_COUNT];
253 #define MAX_SKILLTIMERSKILL 50
254 struct skill_timerskill {
260 uint16 skill_id,skill_lv;
261 int type; // a BF_ type (NOTE: some places use this as general-purpose storage...)
265 #define MAX_SKILLUNITGROUP 25 /// Maximum skill unit group (for same skill each source)
267 struct skill_unit_group {
268 int src_id; /// Caster ID/RID, if player is account_id
269 int party_id; /// Party ID
270 int guild_id; /// Guild ID
271 int bg_id; /// Battleground ID
273 int target_flag; /// Holds BCT_* flag for battle_check_target
274 int bl_flag; /// Holds BL_* flag for map_foreachin* functions
275 unsigned int tick; /// Tick when skill unit initialized
276 int limit, /// Life time
277 interval; /// Timer interval
278 uint16 skill_id, /// Skill ID
279 skill_lv; /// Skill level
280 int val1, val2, val3; /// Values
281 char *valstr; /// String value, used for HT_TALKIEBOX & RG_GRAFFITI
282 int unit_id; /// Unit ID (for client effect)
283 int group_id; /// Skill Group ID
284 int link_group_id; /// Linked group that should be deleted if this one is deleted
285 int unit_count, /// Number of unit at this group
286 alive_count; /// Number of alive unit
287 int item_id; /// Store item used.
288 struct skill_unit *unit; /// Skill Unit
290 unsigned ammo_consume : 1; // Need to consume ammo
291 unsigned song_dance : 2; //0x1 Song/Dance, 0x2 Ensemble
292 unsigned guildaura : 1; // Guild Aura
298 struct block_list bl;
299 struct skill_unit_group *group; /// Skill group reference
307 #define MAX_SKILLUNITGROUPTICKSET 25
308 struct skill_unit_group_tickset {
314 enum e_skill_unit_flag {
315 UF_DEFNOTENEMY = 0x00001, // If 'defunit_not_enemy' is set, the target is changed to 'friend'
316 UF_NOREITERATION = 0x00002, // Spell cannot be stacked
317 UF_NOFOOTSET = 0x00004, // Spell cannot be cast near/on targets
318 UF_NOOVERLAP = 0x00008, // Spell effects do not overlap
319 UF_PATHCHECK = 0x00010, // Only cells with a shootable path will be placed
320 UF_NOPC = 0x00020, // May not target players
321 UF_NOMOB = 0x00040, // May not target mobs
322 UF_SKILL = 0x00080, // May target skills
323 UF_DANCE = 0x00100, // Dance
324 UF_ENSEMBLE = 0x00200, // Duet
325 UF_SONG = 0x00400, // Song
326 UF_DUALMODE = 0x00800, // Spells should trigger both ontimer and onplace/onout/onleft effects.
327 UF_NOKNOCKBACK = 0x01000, // Skill unit cannot be knocked back
328 UF_RANGEDSINGLEUNIT = 0x02000, // hack for ranged layout, only display center
329 UF_CRAZYWEED_IMMUNE = 0x04000, // Immune to Crazy Weed removal
330 UF_REM_FIRERAIN = 0x08000, // removed by Fire Rain
331 UF_KNOCKBACK_GROUP = 0x10000, // knockback skill unit with its group instead of single unit
332 UF_HIDDEN_TRAP = 0x20000, // Hidden trap [Cydh]
335 /// Enum for skill_blown
338 BLOWN_DONT_SEND_PACKET = 0x01, // Position update packets must not be sent to the client
339 BLOWN_IGNORE_NO_KNOCKBACK = 0x02, // Ignores players' special_state.no_knockback
340 // These flags return 'count' instead of 0 if target is cannot be knocked back
341 BLOWN_NO_KNOCKBACK_MAP = 0x04, // On a WoE/BG map
342 BLOWN_MD_KNOCKBACK_IMMUNE = 0x08, // If target is MD_KNOCKBACK_IMMUNE
343 BLOWN_TARGET_NO_KNOCKBACK = 0x10, // If target has 'special_state.no_knockback'
344 BLOWN_TARGET_BASILICA = 0x20, // If target is in Basilica area
347 /// Create Database item
348 struct s_skill_produce_db {
349 unsigned short nameid; /// Product ID
350 unsigned short req_skill; /// Required Skill
351 unsigned char req_skill_lv, /// Required Skill Level
352 itemlv; /// Item Level
353 unsigned short mat_id[MAX_PRODUCE_RESOURCE], /// Materials needed
354 mat_amount[MAX_PRODUCE_RESOURCE]; /// Amount of each materials
356 extern struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
358 /// Creating database arrow
359 struct s_skill_arrow_db {
360 unsigned short nameid, /// Material ID
361 cre_id[MAX_ARROW_RESULT], /// Arrow created
362 cre_amount[MAX_ARROW_RESULT]; /// Amount of each arrow created
364 extern struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
366 /// Abracadabra database
367 struct s_skill_abra_db {
368 uint16 skill_id; /// Skill ID
369 char name[SKILL_NAME_LENGTH]; /// Shouted skill name
370 int per[MAX_SKILL_LEVEL]; /// Probability summoned
372 extern struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
373 extern unsigned short skill_abra_count;
375 void do_init_skill(void);
376 void do_final_skill(void);
379 enum { CAST_GROUND, CAST_DAMAGE, CAST_NODAMAGE };
380 /// Returns the cast type of the skill: ground cast, castend damage, castend no damage
381 int skill_get_casttype(uint16 skill_id); //[Skotlex]
382 const char* skill_get_name( uint16 skill_id ); // [Skotlex]
383 const char* skill_get_desc( uint16 skill_id ); // [Skotlex]
384 int skill_tree_get_max( uint16 skill_id, int b_class ); // Celest
386 // Accessor to the skills database
387 int skill_get_index_( uint16 skill_id, bool silent, const char *func, const char *file, int line );
388 #define skill_get_index(skill_id) skill_get_index_((skill_id), false, __FUNCTION__, __FILE__, __LINE__) /// Get skill index from skill_id (common usage on source)
389 #define skill_get_index2(skill_id) skill_get_index_((skill_id), true, __FUNCTION__, __FILE__, __LINE__) /// Get skill index from skill_id (used when reading skill_db files)
390 int skill_get_type( uint16 skill_id );
391 enum e_damage_type skill_get_hit( uint16 skill_id );
392 int skill_get_inf( uint16 skill_id );
393 int skill_get_ele( uint16 skill_id , uint16 skill_lv );
394 int skill_get_nk( uint16 skill_id );
395 int skill_get_max( uint16 skill_id );
396 int skill_get_range( uint16 skill_id , uint16 skill_lv );
397 int skill_get_range2(struct block_list *bl, uint16 skill_id, uint16 skill_lv, bool isServer);
398 int skill_get_splash( uint16 skill_id , uint16 skill_lv );
399 int skill_get_num( uint16 skill_id ,uint16 skill_lv );
400 int skill_get_cast( uint16 skill_id ,uint16 skill_lv );
401 int skill_get_delay( uint16 skill_id ,uint16 skill_lv );
402 int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv );
403 int skill_get_time( uint16 skill_id ,uint16 skill_lv );
404 int skill_get_time2( uint16 skill_id ,uint16 skill_lv );
405 int skill_get_castnodex( uint16 skill_id );
406 int skill_get_castdef( uint16 skill_id );
407 int skill_get_nocast( uint16 skill_id );
408 int skill_get_unit_id(uint16 skill_id,int flag);
409 int skill_get_inf2( uint16 skill_id );
410 int skill_get_castcancel( uint16 skill_id );
411 int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv );
412 int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv );
413 int skill_get_unit_flag( uint16 skill_id );
414 int skill_get_unit_target( uint16 skill_id );
415 int skill_get_inf3( uint16 skill_id );
416 // Accessor for skill requirements
417 int skill_get_hp( uint16 skill_id ,uint16 skill_lv );
418 int skill_get_mhp( uint16 skill_id ,uint16 skill_lv );
419 int skill_get_sp( uint16 skill_id ,uint16 skill_lv );
420 int skill_get_status_count( uint16 skill_id );
421 int skill_get_hp_rate( uint16 skill_id, uint16 skill_lv );
422 int skill_get_sp_rate( uint16 skill_id, uint16 skill_lv );
423 int skill_get_zeny( uint16 skill_id ,uint16 skill_lv );
424 int skill_get_weapontype( uint16 skill_id );
425 int skill_get_ammotype( uint16 skill_id );
426 int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv );
427 int skill_get_state(uint16 skill_id);
428 //int skill_get_status( uint16 skill_id, int idx );
429 int skill_get_status_count( uint16 skill_id );
430 int skill_get_spiritball( uint16 skill_id, uint16 skill_lv );
431 int skill_get_itemid( uint16 skill_id, int idx );
432 int skill_get_itemqty( uint16 skill_id, int idx );
433 unsigned short skill_dummy2skill_id(unsigned short skill_id);
435 int skill_name2id(const char* name);
436 uint16 skill_idx2id(uint16 idx);
438 uint16 SKILL_MAX_DB(void);
440 int skill_isammotype(struct map_session_data *sd, unsigned short skill_id);
441 int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data);
442 int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data);
443 int skill_castend_map( struct map_session_data *sd,uint16 skill_id, const char *map);
445 int skill_cleartimerskill(struct block_list *src);
446 int skill_addtimerskill(struct block_list *src,unsigned int tick,int target,int x,int y,uint16 skill_id,uint16 skill_lv,int type,int flag);
449 int skill_additional_effect( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,enum damage_lv dmg_lv,unsigned int tick);
450 int skill_counter_additional_effect( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,unsigned int tick);
451 short skill_blown(struct block_list* src, struct block_list* target, char count, int8 dir, enum e_skill_blown flag);
452 int skill_break_equip(struct block_list *src,struct block_list *bl, unsigned short where, int rate, int flag);
453 int skill_strip_equip(struct block_list *src,struct block_list *bl, unsigned short where, int rate, int lv, int time);
455 struct skill_unit_group *skill_id2group(int group_id);
456 struct skill_unit_group *skill_unitsetting(struct block_list* src, uint16 skill_id, uint16 skill_lv, int16 x, int16 y, int flag);
457 struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2, bool hidden);
458 int skill_delunit(struct skill_unit *unit);
459 struct skill_unit_group *skill_initunitgroup(struct block_list* src, int count, uint16 skill_id, uint16 skill_lv, int unit_id, int limit, int interval);
460 int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int line, const char* func);
461 #define skill_delunitgroup(group) skill_delunitgroup_(group,__FILE__,__LINE__,__func__)
462 void skill_clear_unitgroup(struct block_list *src);
463 int skill_clear_group(struct block_list *bl, int flag);
464 void ext_skill_unit_onplace(struct skill_unit *unit, struct block_list *bl, unsigned int tick);
465 int64 skill_unit_ondamaged(struct skill_unit *unit,int64 damage);
467 // Skill unit visibility [Cydh]
468 void skill_getareachar_skillunit_visibilty(struct skill_unit *su, enum send_target target);
469 void skill_getareachar_skillunit_visibilty_single(struct skill_unit *su, struct block_list *bl);
471 int skill_castfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv);
472 int skill_castfix_sc(struct block_list *bl, double time, uint8 flag);
474 int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv);
476 int skill_delayfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv);
477 void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id);
479 // Skill conditions check and remove [Inkfish]
480 bool skill_check_condition_castbegin(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
481 bool skill_check_condition_castend(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
482 int skill_check_condition_char_sub (struct block_list *bl, va_list ap);
483 void skill_consume_requirement(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type);
484 struct skill_condition skill_get_requirement(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
485 int skill_disable_check(struct status_change *sc, uint16 skill_id);
487 int skill_check_pc_partner(struct map_session_data *sd, uint16 skill_id, uint16 *skill_lv, int range, int cast_flag);
488 int skill_unit_move(struct block_list *bl,unsigned int tick,int flag);
489 void skill_unit_move_unit_group( struct skill_unit_group *group, int16 m,int16 dx,int16 dy);
490 void skill_unit_move_unit(struct block_list *bl, int dx, int dy);
492 int skill_sit (struct map_session_data *sd, int type);
493 void skill_repairweapon(struct map_session_data *sd, int idx);
494 void skill_identify(struct map_session_data *sd,int idx);
495 void skill_weaponrefine(struct map_session_data *sd,int idx); // [Celest]
496 int skill_autospell(struct map_session_data *md,uint16 skill_id);
498 int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal);
500 bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce);
503 void skill_enchant_elemental_end(struct block_list *bl, int type);
504 bool skill_isNotOk(uint16 skill_id, struct map_session_data *sd);
505 bool skill_isNotOk_hom(struct homun_data *hd, uint16 skill_id, uint16 skill_lv);
506 bool skill_isNotOk_mercenary(uint16 skill_id, struct mercenary_data *md);
508 bool skill_isNotOk_npcRange(struct block_list *src, uint16 skill_id, uint16 skill_lv, int pos_x, int pos_y);
511 short skill_can_produce_mix( struct map_session_data *sd, unsigned short nameid, int trigger, int qty);
512 bool skill_produce_mix( struct map_session_data *sd, uint16 skill_id, unsigned short nameid, int slot1, int slot2, int slot3, int qty, short produce_idx );
514 bool skill_arrow_create( struct map_session_data *sd, unsigned short nameid);
516 // skills for the mob
517 int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag );
518 int skill_castend_damage_id( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag );
519 int skill_castend_pos2( struct block_list *src, int x,int y,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag);
521 int skill_blockpc_start(struct map_session_data*, int, int);
522 int skill_blockpc_get(struct map_session_data *sd, int skillid);
523 int skill_blockpc_clear(struct map_session_data *sd);
524 int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data);
525 int skill_blockhomun_start (struct homun_data*,uint16 skill_id,int);
526 int skill_blockmerc_start (struct mercenary_data*,uint16 skill_id,int);
529 // (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names)
530 #define skill_ischangesex(id) ( \
531 ((id) >= BD_ADAPTATION && (id) <= DC_SERVICEFORYOU) || ((id) >= CG_ARROWVULCAN && (id) <= CG_MARIONETTE) || \
532 ((id) >= CG_LONGINGFREEDOM && (id) <= CG_TAROTCARD) || ((id) >= WA_SWING_DANCE && (id) <= WM_UNLIMITED_HUMMING_VOICE))
534 // Skill action, (return dmg,heal)
535 int64 skill_attack( int attack_type, struct block_list* src, struct block_list *dsrc,struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag );
537 void skill_reload(void);
539 /// List of State Requirements
540 enum e_require_state {
547 ST_RECOV_WEIGHT_RATE,
744 NPC_CHANGETELEKINESIS,
766 NPC_TELEKINESISATTACK,
1082 CR_ACIDDEMONSTRATION,
1284 NPC_WIDEHELLDIGNITY,
1295 ALL_DREAM_SUMMERNIGHT,
1301 NPC_WIDEBODYBURNNING,
1304 NPC_WIDE_DEEP_SLEEP,
1307 NPC_MILLENNIUMSHIELD,
1314 NPC_DANCINGBLADE_ATK,
1326 NPC_REVERBERATION_ATK,
1330 NPC_SR_CURSEDCIRCLE,
1334 NPC_MAGMA_ERUPTION_DOTDAMAGE,
1343 NPC_HALLUCINATIONWALK,
1349 NPC_WIDECRITICALWOUND,
1351 KN_CHARGEATK = 1001,
1371 RK_ENCHANTBLADE = 2001,
1381 RK_MILLENNIUMSHIELD,
1386 RK_VITALITYACTIVATION,
1395 GC_RESEARCHNEWPOISON,
1406 GC_HALLUCINATIONWALK,
1408 GC_CROSSRIPPERSLASHER,
1427 AB_DUPLELIGHT_MELEE,
1428 AB_DUPLELIGHT_MAGIC,
1431 WL_WHITEIMPRISON = 2201,
1445 WL_CHAINLIGHTNING_ATK,
1448 WL_TETRAVORTEX_FIRE,
1449 WL_TETRAVORTEX_WATER,
1450 WL_TETRAVORTEX_WIND,
1451 WL_TETRAVORTEX_GROUND,
1457 WL_SUMMON_ATK_WATER,
1458 WL_SUMMON_ATK_GROUND,
1539 LG_CANNONSPEAR = 2307,
1575 SR_CRESCENTELBOW_AUTOSPELL,
1577 SR_GENTLETOUCH_QUIET,
1578 SR_GENTLETOUCH_CURE,
1579 SR_GENTLETOUCH_ENERGYGAIN,
1580 SR_GENTLETOUCH_CHANGE,
1581 SR_GENTLETOUCH_REVITALIZE,
1583 WA_SWING_DANCE = 2350,
1584 WA_SYMPHONY_OF_LOVER,
1585 WA_MOONLIT_SERENADE,
1587 MI_RUSH_WINDMILL = 2381,
1594 WM_REVERBERATION_MELEE,
1595 WM_REVERBERATION_MAGIC,
1596 WM_DOMINION_IMPULSE,
1597 WM_SEVERE_RAINSTORM,
1598 WM_POEMOFNETHERWORLD,
1601 WM_LULLABY_DEEPSLEEP,
1608 WM_SOUND_OF_DESTRUCTION,
1609 WM_SATURDAY_NIGHT_FEVER,
1612 WM_BEYOND_OF_WARCRY,
1613 WM_UNLIMITED_HUMMING_VOICE,
1642 GN_TRAINING_SWORD = 2474,
1655 GN_FIRE_EXPANSION_SMOKE_POWDER,
1656 GN_FIRE_EXPANSION_TEAR_GAS,
1657 GN_FIRE_EXPANSION_ACID,
1666 GN_SLINGITEM_RANGEMELEEATK,
1668 AB_SECRAMENT = 2515,
1669 WM_SEVERE_RAINSTORM_MELEE,
1672 LG_OVERBRAND_BRANDISH,
1673 LG_OVERBRAND_PLUSATK,
1675 ALL_ODINS_RECALL = 2533,
1676 RETURN_TO_ELDICASTES,
1678 ALL_GUARDIAN_RECALL,
1685 ALL_RAY_OF_PROTECTION,
1692 RL_GLITTERING_GREED = 2551,
1695 RL_BANISHING_BUSTER,
1715 RL_GLITTERING_GREED_ATK,
1744 OB_OBOROGENSOU_TRANSITION_ATK,
1747 ECL_SNOWFLIP = 3031,
1756 RK_DRAGONBREATH_WATER,
1760 SO_ELEMENTAL_SHIELD,
1764 WL_TELEKINESIS_INTENSE,
1768 SU_BASIC_SKILL = 5018,
1780 SU_SV_ROOTTWIST_ATK,
1784 SU_PICKYPECK_DOUBLE_ATK,
1786 SU_LUNATICCARROTBEAT,
1793 SU_LUNATICCARROTBEAT2,
1826 MH_NEEDLE_OF_PARALYZE,
1894 EL_CIRCLE_OF_FIRE = 8401,
1934 EL_ROCK_CRUSHER_ATK,
1938 /// The client view ids for land skills.
1939 enum s_skill_unit_id {
1940 UNT_SAFETYWALL = 0x7e,
1944 UNT_BENEDICTIO, //TODO
1948 UNT_DUMMYSKILL, //These show no effect on the client
1949 UNT_FIREPILLAR_WAITING,
1950 UNT_FIREPILLAR_ACTIVE,
1951 UNT_HIDDEN_TRAP, //TODO
1953 UNT_HIDDEN_WARP_NPC, //TODO
1975 UNT_DRUMBATTLEFIELD,
2004 UNT_GROUNDDRIFT_WIND,
2005 UNT_GROUNDDRIFT_DARK,
2006 UNT_GROUNDDRIFT_POISON,
2007 UNT_GROUNDDRIFT_WATER,
2008 UNT_GROUNDDRIFT_FIRE,
2009 UNT_DEATHWAVE, //TODO
2010 UNT_WATERATTACK, //TODO
2011 UNT_WINDATTACK, //TODO
2012 UNT_EARTHQUAKE, //TODO
2014 UNT_DARK_RUNNER, //TODO
2015 UNT_DARK_TRANSFER, //TODO
2030 UNT_ELECTRICSHOCKER,
2033 UNT_SEVERE_RAINSTORM,
2046 UNT_FIRE_EXPANSION_SMOKE_POWDER,
2047 UNT_FIRE_EXPANSION_TEAR_GAS,
2074 UNT_GLITTERING_GREED,
2084 UNT_GD_LEADERSHIP = 0xc1,
2085 UNT_GD_GLORYWOUNDS = 0xc2,
2086 UNT_GD_SOULCOLD = 0xc3,
2087 UNT_GD_HAWKEYES = 0xc4,
2095 void skill_usave_add(struct map_session_data * sd, uint16 skill_id, uint16 skill_lv);
2096 void skill_usave_trigger(struct map_session_data *sd);
2101 #define MAX_SKILL_SPELLBOOK_DB 17
2108 struct s_skill_spellbook_db {
2109 unsigned short nameid;
2110 unsigned short skill_id;
2111 unsigned short point;
2113 extern struct s_skill_spellbook_db skill_spellbook_db[MAX_SKILL_SPELLBOOK_DB];
2114 extern unsigned short skill_spellbook_count;
2115 void skill_spellbook(struct map_session_data *sd, unsigned short nameid);
2116 int skill_block_check(struct block_list *bl, enum sc_type type, uint16 skill_id);
2121 #define MAX_SKILL_MAGICMUSHROOM_DB 25
2122 struct s_skill_magicmushroom_db {
2125 extern struct s_skill_magicmushroom_db skill_magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB];
2126 extern unsigned short skill_magicmushroom_count;
2127 int skill_maelstrom_suction(struct block_list *bl, va_list ap);
2128 bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit);
2133 int skill_detonator(struct block_list *bl, va_list ap);
2134 bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *sce);
2139 int skill_magicdecoy(struct map_session_data *sd, unsigned short nameid);
2144 int skill_poisoningweapon( struct map_session_data *sd, unsigned short nameid);
2147 * Auto Shadow Spell (Shadow Chaser)
2149 int skill_select_menu(struct map_session_data *sd,uint16 skill_id);
2151 int skill_elementalanalysis(struct map_session_data *sd, int n, uint16 skill_lv, unsigned short *item_list); // Sorcerer Four Elemental Analisys.
2152 int skill_changematerial(struct map_session_data *sd, int n, unsigned short *item_list); // Genetic Change Material.
2153 int skill_get_elemental_type(uint16 skill_id, uint16 skill_lv);
2155 int skill_is_combo(uint16 skill_id);
2156 void skill_combo_toggle_inf(struct block_list* bl, uint16 skill_id, int inf);
2157 void skill_combo(struct block_list* src,struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int tick);
2159 void skill_reveal_trap_inarea(struct block_list *src, int range, int x, int y);
2161 #ifdef ADJUST_SKILL_DAMAGE
2162 /// Skill Damage target
2163 enum e_skill_damage_caster {
2170 SDC_ALL = SDC_PC|SDC_MOB|SDC_PET|SDC_HOM|SDC_MER|SDC_ELEM,
2174 /// Variable name of copied skill by Plagiarism
2175 #define SKILL_VAR_PLAGIARISM "CLONE_SKILL"
2176 /// Variable name of copied skill level by Plagiarism
2177 #define SKILL_VAR_PLAGIARISM_LV "CLONE_SKILL_LV"
2179 /// Variable name of copied skill by Reproduce
2180 #define SKILL_VAR_REPRODUCE "REPRODUCE_SKILL"
2181 /// Variable name of copied skill level by Reproduce
2182 #define SKILL_VAR_REPRODUCE_LV "REPRODUCE_SKILL_LV"
2184 #define SKILL_CHK_HOMUN(skill_id) ( (skill_id) >= HM_SKILLBASE && (skill_id) < HM_SKILLBASE+MAX_HOMUNSKILL )
2185 #define SKILL_CHK_MERC(skill_id) ( (skill_id) >= MC_SKILLBASE && (skill_id) < MC_SKILLBASE+MAX_MERCSKILL )
2186 #define SKILL_CHK_ELEM(skill_id) ( (skill_id) >= EL_SKILLBASE && (skill_id) < EL_SKILLBASE+MAX_ELEMENTALSKILL )
2187 #define SKILL_CHK_GUILD(skill_id) ( (skill_id) >= GD_SKILLBASE && (skill_id) < GD_SKILLBASE+MAX_GUILDSKILL )
2193 #endif /* _SKILL_H_ */