diff options
Diffstat (limited to 'src/map/skill.c')
-rw-r--r-- | src/map/skill.c | 2117 |
1 files changed, 1356 insertions, 761 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index 51a8a28e7..069db55df 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2016 Hercules Dev Team + * Copyright (C) 2012-2018 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -26,6 +26,7 @@ #include "map/battle.h" #include "map/battleground.h" #include "map/chrif.h" +#include "map/clan.h" #include "map/clif.h" #include "map/date.h" #include "map/elemental.h" @@ -36,6 +37,7 @@ #include "map/log.h" #include "map/map.h" #include "map/mercenary.h" +#include "map/messages.h" #include "map/mob.h" #include "map/npc.h" #include "map/party.h" @@ -78,13 +80,13 @@ #error GD_SKILLRANGEMAX is greater than 999 #endif -struct skill_interface skill_s; +static struct skill_interface skill_s; struct s_skill_dbs skilldbs; struct skill_interface *skill; //Since only mob-casted splash skills can hit ice-walls -int skill_splash_target(struct block_list* bl) +static int skill_splash_target(struct block_list *bl) { nullpo_retr(BL_CHAR, bl); #ifndef RENEWAL @@ -95,7 +97,7 @@ int skill_splash_target(struct block_list* bl) } /// Returns the id of the skill, or 0 if not found. -int skill_name2id(const char* name) +static int skill_name2id(const char *name) { if( name == NULL ) return 0; @@ -105,7 +107,7 @@ int skill_name2id(const char* name) /// Maps skill ids to skill db offsets. /// Returns the skill's array index, or 0 (Unknown Skill). -int skill_get_index (uint16 skill_id) +static int skill_get_index(int skill_id) { // avoid ranges reserved for mapping guild/homun/mercenary skills if( (skill_id >= GD_SKILLRANGEMIN && skill_id <= GD_SKILLRANGEMAX) @@ -138,88 +140,589 @@ int skill_get_index (uint16 skill_id) } // validate result - if( !skill_id || skill_id >= MAX_SKILL_DB ) + if (skill_id <= 0|| skill_id >= MAX_SKILL_DB) return 0; return skill_id; } -const char* skill_get_name( uint16 skill_id ) { +static const char *skill_get_name(int skill_id) +{ return skill->dbs->db[skill->get_index(skill_id)].name; } -const char* skill_get_desc( uint16 skill_id ) { +static const char *skill_get_desc(int skill_id) +{ return skill->dbs->db[skill->get_index(skill_id)].desc; } -// out of bounds error checking [celest] -void skill_chk(uint16* skill_id) { - *skill_id = skill->get_index(*skill_id); // checks/adjusts id -} +#define skill_get_lvl_idx(lv) (min((lv), MAX_SKILL_LEVEL) - 1) +#define skill_adjust_over_level(val, lv, max_lv) ((val) > 1 ? ((val) + ((lv) - (max_lv)) / 2) : (val)) -#define skill_get(var,id) do { skill->chk(&(id)); if(!(id)) return 0; return (var); } while(0) -#define skill_get2(var,id,lv) do { \ - skill->chk(&(id)); \ - if(!(id)) return 0; \ - if( (lv) > MAX_SKILL_LEVEL && (var) > 1 ) { \ - int lv2__ = (lv); (lv) = skill->dbs->db[(id)].max; \ - return (var) + ((lv2__-(lv))/2);\ - } \ - return (var);\ -} while(0) -#define skill_glv(lv) min((lv),MAX_SKILL_LEVEL-1) // Skill DB -int skill_get_hit( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].hit, skill_id); } -int skill_get_inf( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf, skill_id); } -int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get (skill->dbs->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } -int skill_get_nk( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].nk, skill_id); } -int skill_get_max( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].max, skill_id); } -int skill_get_range( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 ( (skill->dbs->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->dbs->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } -int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_state(uint16 skill_id) { skill_get (skill->dbs->db[skill_id].state, skill_id); } -int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->dbs->db[skill_id].itemid[idx], skill_id); } -int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->dbs->db[skill_id].amount[idx], skill_id); } -int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castdef( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].cast_def_rate, skill_id); } -int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].weapon, skill_id); } -int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].ammo, skill_id); } -int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_inf2( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf2, skill_id); } -int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].castcancel, skill_id); } -int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_type( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].skill_type, skill_id); } -int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->dbs->db[skill_id].unit_id[flag], skill_id); } -int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_interval, skill_id); } -int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_target&BCT_ALL, skill_id); } -int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_target&BL_ALL, skill_id); } -int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_flag, skill_id); } -int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) { + +static int skill_get_hit(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].hit; +} + +static int skill_get_inf(int skill_id) +{ + int idx; + if (skill_id == 0) + return INF_NONE; + idx = skill->get_index(skill_id); + Assert_retr(INF_NONE, idx != 0); + return skill->dbs->db[idx].inf; +} + +static int skill_get_ele(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return ELE_NEUTRAL; + idx = skill->get_index(skill_id); + Assert_retr(ELE_NEUTRAL, idx != 0); + Assert_retr(ELE_NEUTRAL, skill_lv > 0); + return skill->dbs->db[idx].element[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_nk(int skill_id) +{ + int idx; + if (skill_id == 0) + return NK_NONE; + idx = skill->get_index(skill_id); + Assert_retr(NK_NONE, idx != 0); + return skill->dbs->db[idx].nk; +} + +static int skill_get_max(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].max; +} + +static int skill_get_range(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].range[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].range[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_splash(int skill_id, int skill_lv) +{ + int idx, val; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + val = skill->dbs->db[idx].splash[skill_get_lvl_idx(skill_lv)]; + if (val < 0) { + val = AREA_SIZE; + } + if (skill_lv > MAX_SKILL_LEVEL) { + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return val; +} + +static int skill_get_hp(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].hp[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].hp[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_sp(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].sp[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].sp[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_hp_rate(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].hp_rate[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].hp_rate[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_sp_rate(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].sp_rate[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].sp_rate[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_state(int skill_id) +{ + int idx; + if (skill_id == 0) + return ST_NONE; + idx = skill->get_index(skill_id); + Assert_retr(ST_NONE, idx != 0); + return skill->dbs->db[idx].state; +} + +static int skill_get_spiritball(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].spiritball[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].spiritball[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_itemid(int skill_id, int item_idx) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(item_idx >= 0 && item_idx < MAX_SKILL_ITEM_REQUIRE); + return skill->dbs->db[idx].itemid[item_idx]; +} + +static int skill_get_itemqty(int skill_id, int item_idx) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(item_idx >= 0 && item_idx < MAX_SKILL_ITEM_REQUIRE); + return skill->dbs->db[idx].amount[item_idx]; +} + +static int skill_get_zeny(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].zeny[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].zeny[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_num(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].num[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].num[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_cast(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].cast[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].cast[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_delay(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].delay[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].delay[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_walkdelay(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].walkdelay[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].walkdelay[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_time(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].upkeep_time[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].upkeep_time[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_time2(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].upkeep_time2[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].upkeep_time2[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_castdef(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].cast_def_rate; +} + +static int skill_get_weapontype(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].weapon; +} + +static int skill_get_ammotype(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].ammo; +} + +static int skill_get_ammo_qty(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].ammo_qty[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].ammo_qty[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_inf2(int skill_id) +{ + int idx; + if (skill_id == 0) + return INF2_NONE; + idx = skill->get_index(skill_id); + Assert_retr(INF2_NONE, idx != 0); + return skill->dbs->db[idx].inf2; +} + +static int skill_get_castcancel(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].castcancel; +} + +static int skill_get_maxcount(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].maxcount[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].maxcount[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_blewcount(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].blewcount[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].blewcount[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_mhp(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].mhp[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].mhp[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_castnodex(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].castnodex[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].castnodex[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_delaynodex(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].delaynodex[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].delaynodex[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_type(int skill_id) +{ + int idx; + if (skill_id == 0) + return BF_NONE; + idx = skill->get_index(skill_id); + Assert_retr(BF_NONE, idx != 0); + return skill->dbs->db[idx].skill_type; +} + +static int skill_get_unit_id(int skill_id, int flag) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(flag >= 0 && flag < ARRAYLENGTH(skill->dbs->db[0].unit_id)); + return skill->dbs->db[idx].unit_id[flag]; +} + +static int skill_get_unit_interval(int skill_id) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + return skill->dbs->db[idx].unit_interval; +} + +static int skill_get_unit_range(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].unit_range[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].unit_range[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_unit_target(int skill_id) +{ + int idx; + if (skill_id == 0) + return BCT_NOONE; + idx = skill->get_index(skill_id); + Assert_retr(BCT_NOONE, idx != 0); + return skill->dbs->db[idx].unit_target & BCT_ALL; +} + +static int skill_get_unit_bl_target(int skill_id) +{ + int idx; + if (skill_id == 0) + return BL_NUL; + idx = skill->get_index(skill_id); + Assert_retr(BL_NUL, idx != 0); + return skill->dbs->db[idx].unit_target & BL_ALL; +} + +static int skill_get_unit_flag(int skill_id) +{ + int idx; + if (skill_id == 0) + return UF_NONE; + idx = skill->get_index(skill_id); + Assert_retr(UF_NONE, idx != 0); + return skill->dbs->db[idx].unit_flag; +} + +static int skill_get_unit_layout_type(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].unit_layout_type[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].unit_layout_type[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_cooldown(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].cooldown[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].cooldown[skill_get_lvl_idx(skill_lv)]; +} + +static int skill_get_fixed_cast(int skill_id, int skill_lv) +{ + int idx; + if (skill_id == 0) + return 0; + idx = skill->get_index(skill_id); + Assert_ret(idx != 0); + Assert_ret(skill_lv > 0); #ifdef RENEWAL_CAST - Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); + if (skill_lv > MAX_SKILL_LEVEL) { + int val = skill->dbs->db[idx].fixed_cast[skill_get_lvl_idx(skill_lv)]; + return skill_adjust_over_level(val, skill_lv, skill->dbs->db[idx].max); + } + return skill->dbs->db[idx].fixed_cast[skill_get_lvl_idx(skill_lv)]; #else return 0; #endif } -int skill_tree_get_max(uint16 skill_id, int class) +static int skill_tree_get_max(int skill_id, int class) { int i; int class_idx = pc->class2idx(class); @@ -231,7 +734,7 @@ int skill_tree_get_max(uint16 skill_id, int class) return skill->get_max(skill_id); } -int skill_get_casttype(uint16 skill_id) +static int skill_get_casttype(int skill_id) { int inf = skill->get_inf(skill_id); if (inf&(INF_GROUND_SKILL)) @@ -248,7 +751,7 @@ int skill_get_casttype(uint16 skill_id) return CAST_DAMAGE; } -int skill_get_casttype2(uint16 index) +static int skill_get_casttype2(int index) { int inf; Assert_retr(CAST_NODAMAGE, index < MAX_SKILL_DB); @@ -268,7 +771,7 @@ int skill_get_casttype2(uint16 index) } //Returns actual skill range taking into account attack range and AC_OWL [Skotlex] -int skill_get_range2(struct block_list *bl, uint16 skill_id, uint16 skill_lv) +static int skill_get_range2(struct block_list *bl, int skill_id, int skill_lv) { int range; struct map_session_data *sd = BL_CAST(BL_PC, bl); @@ -303,7 +806,7 @@ int skill_get_range2(struct block_list *bl, uint16 skill_id, uint16 skill_lv) if (sd != NULL) range += pc->checkskill(sd, AC_VULTURE); else - range += 10; //Assume level 10? + range += battle->bc->mob_eye_range_bonus; break; // added to allow GS skills to be effected by the range of Snake Eyes [Reddozen] case GS_RAPIDSHOWER: @@ -314,7 +817,7 @@ int skill_get_range2(struct block_list *bl, uint16 skill_id, uint16 skill_lv) if (sd != NULL) range += pc->checkskill(sd, GS_SNAKEEYE); else - range += 10; //Assume level 10? + range += battle->bc->mob_eye_range_bonus; break; case NJ_KIRIKAGE: if (sd != NULL) @@ -357,7 +860,8 @@ int skill_get_range2(struct block_list *bl, uint16 skill_id, uint16 skill_lv) return range; } -int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal) { +static int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal) +{ int skill2_lv, hp; struct map_session_data *sd = BL_CAST(BL_PC, src); struct map_session_data *tsd = BL_CAST(BL_PC, target); @@ -452,7 +956,7 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk } // Making plagiarize check its own function [Aru] -int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* bl) +static int can_copy(struct map_session_data *sd, uint16 skill_id, struct block_list *bl) { nullpo_ret(sd); // Never copy NPC/Wedding Skills @@ -476,20 +980,20 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b return 0; // Couldn't preserve 3rd Class/Summoner skills except only when using Reproduce skill. [Jobbie] - if (!(sd->sc.data[SC__REPRODUCE]) && - ((skill_id >= RK_ENCHANTBLADE && skill_id <= LG_OVERBRAND_PLUSATK) || - (skill_id >= RL_GLITTERING_GREED && skill_id <= OB_AKAITSUKI) || + if (!(sd->sc.data[SC__REPRODUCE]) && + ((skill_id >= RK_ENCHANTBLADE && skill_id <= LG_OVERBRAND_PLUSATK) || + (skill_id >= RL_GLITTERING_GREED && skill_id <= OB_AKAITSUKI) || (skill_id >= GC_DARKCROW && skill_id <= SU_FRESHSHRIMP))) return 0; // Reproduce will only copy skills according on the list. [Jobbie] - else if( sd->sc.data[SC__REPRODUCE] && !skill->dbs->reproduce_db[skill->get_index(skill_id)] ) + else if (sd->sc.data[SC__REPRODUCE] && (skill->get_inf2(skill_id) & INF2_ALLOW_REPRODUCE) == 0) return 0; return 1; } // [MouseJstr] - skill ok to cast? and when? -int skillnotok (uint16 skill_id, struct map_session_data *sd) +static int skillnotok(uint16 skill_id, struct map_session_data *sd) { int16 idx,m; nullpo_retr (1, sd); @@ -519,7 +1023,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) } if (sd->blockskill[idx]) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SKILLINTERVAL, 0, 0); return 1; } @@ -566,7 +1070,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) //char output[150]; //sprintf(output, msg_txt(862), battle_config.min_npc_vendchat_distance); // "You're too close to a NPC, you must be at least %d cells away from any NPC." //clif->message(sd->fd, output); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_THERE_ARE_NPC_AROUND,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_THERE_ARE_NPC_AROUND, 0, 0); return 1; } FALLTHROUGH @@ -575,13 +1079,13 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case WZ_ICEWALL: // noicewall flag [Valaris] if (map->list[m].flag.noicewall) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } break; case GC_DARKILLUSION: if( map_flag_gvg2(m) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } break; @@ -590,7 +1094,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) || !(battle_config.emergency_call&(map->list[m].flag.gvg || map->list[m].flag.gvg_castle?8:4)) || (battle_config.emergency_call&16 && map->list[m].flag.nowarpto && !map->list[m].flag.gvg_castle) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } break; @@ -610,7 +1114,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return (map->list[m].flag.noskill); } -int skill_notok_unknown(uint16 skill_id, struct map_session_data *sd) +static int skill_notok_unknown(uint16 skill_id, struct map_session_data *sd) { int16 m; nullpo_retr (1, sd); @@ -618,7 +1122,7 @@ int skill_notok_unknown(uint16 skill_id, struct map_session_data *sd) return (map->list[m].flag.noskill); } -int skillnotok_hom(uint16 skill_id, struct homun_data *hd) +static int skillnotok_hom(uint16 skill_id, struct homun_data *hd) { uint16 idx = skill->get_index(skill_id); nullpo_retr(1,hd); @@ -632,7 +1136,7 @@ int skillnotok_hom(uint16 skill_id, struct homun_data *hd) case MH_LIGHT_OF_REGENE: if( homun->get_intimacy_grade(hd) != 4 ){ if( hd->master ) - clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_RELATIONGRADE, 0); + clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_RELATIONGRADE, 0, 0); return 1; } break; @@ -652,14 +1156,14 @@ int skillnotok_hom(uint16 skill_id, struct homun_data *hd) return skill->not_ok(skill_id, hd->master); } -int skillnotok_hom_unknown(uint16 skill_id, struct homun_data *hd) +static int skillnotok_hom_unknown(uint16 skill_id, struct homun_data *hd) { nullpo_retr(1, hd); //Use master's criteria. return skill->not_ok(skill_id, hd->master); } -int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) +static int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) { uint16 idx = skill->get_index(skill_id); nullpo_retr(1,md); @@ -672,7 +1176,7 @@ int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) return skill->not_ok(skill_id, md->master); } -struct s_skill_unit_layout* skill_get_unit_layout(uint16 skill_id, uint16 skill_lv, struct block_list* src, int x, int y) +static struct s_skill_unit_layout *skill_get_unit_layout(uint16 skill_id, uint16 skill_lv, struct block_list *src, int x, int y) { int pos = skill->get_unit_layout_type(skill_id,skill_lv); uint8 dir; @@ -702,7 +1206,8 @@ struct s_skill_unit_layout* skill_get_unit_layout(uint16 skill_id, uint16 skill_ /*========================================== * *------------------------------------------*/ -int skill_additional_effect(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, int64 tick) { +static int skill_additional_effect(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, int64 tick) +{ struct map_session_data *sd, *dstsd; struct mob_data *md, *dstmd; struct status_data *sstatus, *tstatus; @@ -806,7 +1311,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; // If a normal attack is a skill, it's splash damage. [Inkfish] if(sd) { // Automatic trigger of Blitz Beat - if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && + if (pc_isfalcon(sd) && sd->weapontype == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && rnd()%1000 <= sstatus->luk*3 ) { rate = sd->status.job_level / 10 + 1; skill->castend_damage_id(src,bl,HT_BLITZBEAT,(temp<rate)?temp:rate,tick,SD_LEVEL); @@ -815,13 +1320,13 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 if( pc_iswug(sd) && (temp=pc->checkskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*3 ) skill->castend_damage_id(src,bl,RA_WUGSTRIKE,temp,tick,0); // Gank - if(dstmd && sd->status.weapon != W_BOW && + if(dstmd && sd->weapontype != W_BOW && (temp=pc->checkskill(sd,RG_SNATCHER)) > 0 && (temp*15 + 55) + pc->checkskill(sd,TF_STEAL)*10 > rnd()%1000) { if(pc->steal_item(sd,bl,pc->checkskill(sd,TF_STEAL))) clif->skill_nodamage(src,bl,TF_STEAL,temp,1); else - clif->skill_fail(sd,RG_SNATCHER,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, RG_SNATCHER, USESKILL_FAIL_LEVEL, 0, 0); } // Chance to trigger Taekwon kicks [Dralnu] if(sc && !sc->data[SC_COMBOATTACK]) { @@ -887,7 +1392,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 if (!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv)) && sd && skill_id==TF_POISON ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case AS_SONICBLOW: @@ -905,7 +1410,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 if (!sc_start(src,bl,SC_FREEZE,skill_lv*3+35,skill_lv,skill->get_time2(skill_id,skill_lv)) && sd && skill_id == MG_FROSTDIVER ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; #ifdef RENEWAL @@ -1672,10 +2177,12 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 return 0; } -void skill_additional_effect_unknown(struct block_list* src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int *attack_type, int *dmg_lv, int64 *tick) { +static void skill_additional_effect_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int *attack_type, int *dmg_lv, int64 *tick) +{ } -int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint16 skill_id, int64 tick) { +static int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint16 skill_id, int64 tick) +{ int temp, skill_lv, i, type, notok; struct block_list *tbl; @@ -1769,7 +2276,8 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 * type of skills, so not every instance of skill->additional_effect needs a call * to this one. */ -int skill_counter_additional_effect(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int64 tick) { +static int skill_counter_additional_effect(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int64 tick) +{ int rate; struct map_session_data *sd=NULL; struct map_session_data *dstsd=NULL; @@ -1853,11 +2361,11 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b ) { // Soul Drain should only work on targeted spells [Skotlex] if( pc_issit(sd) ) pc->setstand(sd); // Character stuck in attacking animation while 'sitting' fix. [Skotlex] - if( skill->get_nk(skill_id)&NK_SPLASH && skill->area_temp[1] != bl->id ) + if (skill->get_nk(skill_id)&NK_SPLASH && skill->area_temp[1] != bl->id) { ; - else { + } else { clif->skill_nodamage(src,bl,HW_SOULDRAIN,rate,1); - status->heal(src, 0, status->get_lv(bl)*(95+15*rate)/100, 2); + status->heal(src, 0, status->get_lv(bl)*(95+15*rate)/100, STATUS_HEAL_SHOWEFFECT); } } @@ -1880,9 +2388,9 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check. } } - if( hp || sp ) { + if (hp != 0 || sp != 0) { // updated to force healing to allow healing through berserk - status->heal(src, hp, sp, battle_config.show_hp_sp_gain ? 3 : 1); + status->heal(src, hp, sp, STATUS_HEAL_FORCED | (battle_config.show_hp_sp_gain ? STATUS_HEAL_SHOWEFFECT : STATUS_HEAL_DEFAULT)); } } @@ -1986,7 +2494,8 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b return 0; } -void skill_counter_additional_effect_unknown(struct block_list* src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int *attack_type, int64 *tick) { +static void skill_counter_additional_effect_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int *attack_type, int64 *tick) +{ } /*========================================================================= @@ -1995,7 +2504,7 @@ void skill_counter_additional_effect_unknown(struct block_list* src, struct bloc * - flag is a BCT_ flag to indicate which type of adjustment should be used * (BCT_ENEMY/BCT_PARTY/BCT_SELF) are the valid values. *------------------------------------------------------------------------*/ -int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag) +static int skill_break_equip(struct block_list *bl, unsigned short where, int rate, int flag) { const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM}; const enum sc_type scatk[4] = {SC_NOEQUIPWEAPON, SC_NOEQUIPARMOR, SC_NOEQUIPSHIELD, SC_NOEQUIPHELM}; @@ -2012,7 +2521,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in if (sd->bonus.unbreakable) rate -= rate*sd->bonus.unbreakable/100; if (where&EQP_WEAPON) { - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_FIST: //Bare fists should not break :P case W_1HAXE: case W_2HAXE: @@ -2079,13 +2588,13 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in pc->unequipitem(sd, j, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); } } - clif->equiplist(sd); + clif->equipList(sd); } return where; //Return list of pieces broken. } -int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int lv, int time) +static int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int lv, int time) { struct status_change *sc; const int pos[5] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM, EQP_ACC}; @@ -2120,7 +2629,7 @@ int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int * if 'flag&0x1', position update packets must not be sent. * if 'flag&0x2', skill blown ignores players' special_state.no_knockback */ -int skill_blown(struct block_list* src, struct block_list* target, int count, int8 dir, int flag) +static int skill_blown(struct block_list *src, struct block_list *target, int count, int8 dir, int flag) { int dx = 0, dy = 0; struct status_change *tsc = status->get_sc(target); @@ -2184,7 +2693,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in 1 - Regular reflection (Maya) 2 - SL_KAITE reflection */ -int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) +static int skill_magic_reflect(struct block_list *src, struct block_list *bl, int type) { struct status_change *sc = status->get_sc(bl); struct map_session_data* sd = BL_CAST(BL_PC, bl); @@ -2233,10 +2742,14 @@ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) * client (causes player characters to not scream skill name) * flag&0x4000 - Return 0 if damage was reflected *-------------------------------------------------------------------------*/ -int skill_attack(int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static int skill_attack(int attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct Damage dmg; +#if MAGIC_REFLECTION_TYPE struct status_data *sstatus, *tstatus; +#else + struct status_data *tstatus; +#endif struct status_change *sc; struct map_session_data *sd, *tsd; int type; @@ -2271,7 +2784,9 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr ) return 0; +#if MAGIC_REFLECTION_TYPE sstatus = status->get_status_data(src); +#endif tstatus = status->get_status_data(bl); sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; //Don't need it. @@ -2384,7 +2899,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr sp = sp * sc->data[SC_MAGICROD]->val2 / 100; if(skill_id == WZ_WATERBALL && skill_lv > 1) sp = sp/((skill_lv|1)*(skill_lv|1)); //Estimate SP cost of a single water-ball - status->heal(bl, 0, sp, 2); + status->heal(bl, 0, sp, STATUS_HEAL_SHOWEFFECT); } } @@ -2555,7 +3070,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,skill_lv,BDT_MULTIHIT); break; case WL_CHAINLIGHTNING_ATK: - dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,WL_CHAINLIGHTNING,-2,BDT_SKILL); + dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,WL_CHAINLIGHTNING_ATK,-2,BDT_SKILL); break; case LG_OVERBRAND_BRANDISH: case LG_OVERBRAND: @@ -2703,8 +3218,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr } tsd->reproduceskill_id = copy_skill; - pc_setglobalreg(tsd, script->add_str("REPRODUCE_SKILL"), copy_skill); - pc_setglobalreg(tsd, script->add_str("REPRODUCE_SKILL_LV"), lv); + pc_setglobalreg(tsd, script->add_variable("REPRODUCE_SKILL"), copy_skill); + pc_setglobalreg(tsd, script->add_variable("REPRODUCE_SKILL_LV"), lv); tsd->status.skill[cidx].id = copy_skill; tsd->status.skill[cidx].lv = lv; @@ -2727,8 +3242,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr lv = plagiarismlvl; tsd->cloneskill_id = copy_skill; - pc_setglobalreg(tsd, script->add_str("CLONE_SKILL"), copy_skill); - pc_setglobalreg(tsd, script->add_str("CLONE_SKILL_LV"), lv); + pc_setglobalreg(tsd, script->add_variable("CLONE_SKILL"), copy_skill); + pc_setglobalreg(tsd, script->add_variable("CLONE_SKILL_LV"), lv); tsd->status.skill[cidx].id = copy_skill; tsd->status.skill[cidx].lv = lv; @@ -2929,17 +3444,17 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr return (int)cap_value(damage,INT_MIN,INT_MAX); } -void skill_attack_combo1_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, struct status_change_entry *sce, int *combo) +static void skill_attack_combo1_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, struct status_change_entry *sce, int *combo) { if (src == dsrc) // Ground skills are exceptions. [Inkfish] status_change_end(src, SC_COMBOATTACK, INVALID_TIMER); } -void skill_attack_combo2_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *combo) +static void skill_attack_combo2_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *combo) { } -void skill_attack_display_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage) +static void skill_attack_display_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage) { nullpo_retv(bl); nullpo_retv(dmg); @@ -2960,18 +3475,18 @@ void skill_attack_display_unknown(int *attack_type, struct block_list* src, stru dmg->dmotion = clif->skill_damage(dsrc, bl, *tick, dmg->amotion, dmg->dmotion, *damage, dmg->div_, *skill_id, (*flag & SD_LEVEL) ? -1 : *skill_lv, *type); } -int skill_attack_copy_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static int skill_attack_copy_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { nullpo_ret(skill_id); return *skill_id; } -int skill_attack_dir_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static int skill_attack_dir_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { return -1; } -void skill_attack_blow_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir) +static void skill_attack_blow_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir) { nullpo_retv(bl); nullpo_retv(dmg); @@ -2986,7 +3501,7 @@ void skill_attack_blow_unknown(int *attack_type, struct block_list* src, struct } } -void skill_attack_post_unknown(int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static void skill_attack_post_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { } @@ -2995,7 +3510,7 @@ void skill_attack_post_unknown(int *attack_type, struct block_list* src, struct * Checking bl battle flag and display damage * then call func with source,target,skill_id,skill_lv,tick,flag *------------------------------------------*/ -int skill_area_sub(struct block_list *bl, va_list ap) +static int skill_area_sub(struct block_list *bl, va_list ap) { struct block_list *src; uint16 skill_id,skill_lv; @@ -3025,7 +3540,7 @@ int skill_area_sub(struct block_list *bl, va_list ap) return 0; } -int skill_check_unit_range_sub(struct block_list *bl, va_list ap) +static int skill_check_unit_range_sub(struct block_list *bl, va_list ap) { const struct skill_unit *su = NULL; uint16 skill_id,g_skill_id; @@ -3096,7 +3611,8 @@ int skill_check_unit_range_sub(struct block_list *bl, va_list ap) return 1; } -int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) { +static int skill_check_unit_range(struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) +{ //Non players do not check for the skill's splash-trigger area. int range = bl->type == BL_PC ? skill->get_unit_range(skill_id, skill_lv):0; int layout_type = skill->get_unit_layout_type(skill_id,skill_lv); @@ -3109,7 +3625,8 @@ int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id return map->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id); } -int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { +static int skill_check_unit_range2_sub(struct block_list *bl, va_list ap) +{ uint16 skill_id; if(bl->prev == NULL) @@ -3128,7 +3645,8 @@ int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { return 1; } -int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) { +static int skill_check_unit_range2(struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) +{ int range, type; switch (skill_id) { @@ -3171,12 +3689,13 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i * &1: finished casting the skill (invoke hp/sp/item consumption) * &2: picked menu entry (Warp Portal, Teleport and other menu based skills) *------------------------------------------*/ -int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, int type) { +static int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, int type) +{ struct status_data *st; struct map_session_data *sd = NULL; int i, hp, sp, hp_rate, sp_rate, state, mhp; - uint16 idx; - int itemid[MAX_SKILL_ITEM_REQUIRE],amount[ARRAYLENGTH(itemid)],index[ARRAYLENGTH(itemid)]; + int idx; + int itemid[MAX_SKILL_ITEM_REQUIRE], amount[MAX_SKILL_ITEM_REQUIRE], index[MAX_SKILL_ITEM_REQUIRE]; if( lv < 1 || lv > MAX_SKILL_LEVEL ) return 0; @@ -3192,8 +3711,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, return 0; // Requirements - for( i = 0; i < ARRAYLENGTH(itemid); i++ ) - { + for (i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) { itemid[i] = skill->dbs->db[idx].itemid[i]; amount[i] = skill->dbs->db[idx].amount[i]; } @@ -3229,11 +3747,11 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, if( !(type&2) ) { if( hp > 0 && st->hp <= (unsigned int)hp ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0, 0); return 0; } if( sp > 0 && st->sp <= (unsigned int)sp ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0, 0); return 0; } } @@ -3242,7 +3760,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, switch( state ) { case ST_MOVE_ENABLE: if( !unit->can_move(bl) ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -3256,7 +3774,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, if (itemid[i] < 1) continue; // No item index[i] = pc->search_inventory(sd, itemid[i]); if (index[i] == INDEX_NOT_FOUND || sd->status.inventory[index[i]].amount < amount[i]) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_ITEM, amount[i]|(itemid[i] << 16)); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_ITEM, amount[i], itemid[i] << 16); return 0; } } @@ -3279,14 +3797,16 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, /*========================================== * what the hell it doesn't need to receive this many params, it doesn't do anything ~_~ *------------------------------------------*/ -int skill_area_sub_count(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { +static int skill_area_sub_count(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +{ return 1; } /*========================================== * *------------------------------------------*/ -int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { +static int skill_timerskill(int tid, int64 tick, int id, intptr_t data) +{ struct block_list *src = map->id2bl(id),*target = NULL; struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; @@ -3519,25 +4039,25 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { return 0; } -bool skill_timerskill_dead_unknown(struct block_list *src, struct unit_data *ud, struct skill_timerskill *skl) +static bool skill_timerskill_dead_unknown(struct block_list *src, struct unit_data *ud, struct skill_timerskill *skl) { return false; } -void skill_timerskill_target_unknown(int tid, int64 tick, struct block_list *src, struct block_list *target, struct unit_data *ud, struct skill_timerskill *skl) +static void skill_timerskill_target_unknown(int tid, int64 tick, struct block_list *src, struct block_list *target, struct unit_data *ud, struct skill_timerskill *skl) { nullpo_retv(skl); skill->attack(skl->type, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); } -void skill_timerskill_notarget_unknown(int tid, int64 tick, struct block_list *src, struct unit_data *ud, struct skill_timerskill *skl) +static void skill_timerskill_notarget_unknown(int tid, int64 tick, struct block_list *src, struct unit_data *ud, struct skill_timerskill *skl) { } /*========================================== * *------------------------------------------*/ -int skill_addtimerskill(struct block_list *src, int64 tick, int target, int x,int y, uint16 skill_id, uint16 skill_lv, int type, int flag) +static int skill_addtimerskill(struct block_list *src, int64 tick, int target, int x, int y, uint16 skill_id, uint16 skill_lv, int type, int flag) { int i; struct unit_data *ud; @@ -3567,7 +4087,7 @@ int skill_addtimerskill(struct block_list *src, int64 tick, int target, int x,in /*========================================== * *------------------------------------------*/ -int skill_cleartimerskill (struct block_list *src) +static int skill_cleartimerskill(struct block_list *src) { int i; struct unit_data *ud; @@ -3600,12 +4120,12 @@ int skill_cleartimerskill (struct block_list *src) return 1; } -bool skill_cleartimerskill_exception(int skill_id) +static bool skill_cleartimerskill_exception(int skill_id) { return false; } -int skill_activate_reverberation(struct block_list *bl, va_list ap) +static int skill_activate_reverberation(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; struct skill_unit_group *sg = NULL; @@ -3618,14 +4138,14 @@ int skill_activate_reverberation(struct block_list *bl, va_list ap) if( su->alive && (sg = su->group) != NULL && sg->skill_id == WM_REVERBERATION && sg->unit_id == UNT_REVERBERATION ) { int64 tick = timer->gettick(); clif->changetraplook(bl,UNT_USED_TRAPS); - map->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, tick); + skill->trap_do_splash(bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); su->limit = DIFF_TICK32(tick,sg->tick)+1500; sg->unit_id = UNT_USED_TRAPS; } return 0; } -int skill_reveal_trap(struct block_list *bl, va_list ap) +static int skill_reveal_trap(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; @@ -3642,7 +4162,7 @@ int skill_reveal_trap(struct block_list *bl, va_list ap) return 0; } -void skill_castend_type(int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static void skill_castend_type(int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { switch (type) { case CAST_GROUND: @@ -3662,7 +4182,7 @@ void skill_castend_type(int type, struct block_list *src, struct block_list *bl, * * *------------------------------------------*/ -int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static int skill_castend_damage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct map_session_data *sd = NULL; struct status_data *tstatus; @@ -3926,7 +4446,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 unit->setdir(bl,dir); } else if (sd) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -3957,7 +4477,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( skill_id == MO_EXTREMITYFIST ) { mbl = src; i = 3; // for Asura(from caster) - status->set_sp(src, 0, 0); + status->set_sp(src, 0, STATUS_HEAL_DEFAULT); status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER); status_change_end(src, SC_BLADESTOP, INVALID_TIMER); #ifdef RENEWAL @@ -3967,9 +4487,9 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 status_change_end(src, SC_NJ_NEN, INVALID_TIMER); status_change_end(src, SC_HIDING, INVALID_TIMER); #ifdef RENEWAL - status->set_hp(src, max(status_get_max_hp(src)/100, 1), 0); + status->set_hp(src, max(status_get_max_hp(src)/100, 1), STATUS_HEAL_DEFAULT); #else // not RENEWAL - status->set_hp(src, 1, 0); + status->set_hp(src, 1, STATUS_HEAL_DEFAULT); #endif // RENEWAL } dir = map->calc_dir(src,bl->x,bl->y); @@ -4083,7 +4603,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag); if (skill_id == NPC_VAMPIRE_GIFT && heal > 0) { clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); - status->heal(src,heal,0,0); + status->heal(src, heal, 0, STATUS_HEAL_DEFAULT); } if (skill_id == SU_SCRATCH && status->get_lv(src) >= 30 && (rnd() % 100 < (int)(status->get_lv(src) / 30) + 10)) // TODO: Need activation chance. skill->addtimerskill(src, tick + skill->get_delay(skill_id, skill_lv), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag); @@ -4135,6 +4655,11 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 // recursive invocation of skill->castend_damage_id() with flag|1 map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), skill->splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + if (skill_id == AS_SPLASHER) { + // Prevent double item consumption when the target explodes (item requirements have already been processed in skill_castend_nodamage_id) + flag |= 1; + } + if (sd && skill_id == SU_LUNATICCARROTBEAT) { short item_idx = pc->search_inventory(sd, ITEMID_CARROT); @@ -4377,7 +4902,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 case SL_STUN: if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) { status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag); @@ -4446,7 +4971,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 src, src, bl, skill_id, skill_lv, tick, flag); if (heal > 0){ clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); - status->heal(src, heal, 0, 0); + status->heal(src, heal, 0, STATUS_HEAL_DEFAULT); } } break; @@ -4521,12 +5046,12 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == GC_WEAPONBLOCKING ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_WEAPONBLOCKING,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_WEAPONBLOCKING, 0, 0); break; case GC_CROSSRIPPERSLASHER: if( sd && !(sc && sc->data[SC_ROLLINGCUTTER]) ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); else { skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); @@ -4557,7 +5082,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 heal = 0; // Don't absorb heal from Ice Walls or other skill units. if( heal && rnd()%100 < rate ) { - status->heal(src, heal, 0, 0); + status->heal(src, heal, 0, STATUS_HEAL_DEFAULT); clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); } } @@ -4681,7 +5206,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( path->search(NULL,src,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKNOREACH) ) { skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); }else if( sd && skill_id == RA_WUGBITE ) // Only RA_WUGBITE has the skill fail message. - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; @@ -4703,7 +5228,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 item_tmp.nameid = sg->item_id ? sg->item_id : ITEMID_BOOBY_TRAP; item_tmp.identify = 1; if( item_tmp.nameid ) - map->addflooritem(bl, &item_tmp, 1, bl->m, bl->x, bl->y, 0, 0, 0, 0); + map->addflooritem(bl, &item_tmp, 1, bl->m, bl->x, bl->y, 0, 0, 0, 0, false); } skill->delunit(su); } @@ -4839,7 +5364,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); status_change_end(bl, SC_POISON, INVALID_TIMER); } else if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -5004,7 +5529,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 return 0; } -bool skill_castend_damage_id_unknown(struct block_list* src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, struct status_data *tstatus, struct status_change *sc) +static bool skill_castend_damage_id_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, struct status_data *tstatus, struct status_change *sc) { nullpo_retr(true, skill_id); nullpo_retr(true, skill_lv); @@ -5021,7 +5546,7 @@ bool skill_castend_damage_id_unknown(struct block_list* src, struct block_list * /*========================================== * *------------------------------------------*/ -int skill_castend_id(int tid, int64 tick, int id, intptr_t data) +static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { struct block_list *target, *src; struct map_session_data *sd; @@ -5160,7 +5685,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) } if( sd && (inf2&INF2_CHORUS_SKILL) && skill->check_pc_partner(sd, ud->skill_id, &ud->skill_lv, 1, 0) < 1 ) { - clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0); + clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0, 0); break; } @@ -5168,7 +5693,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) if (BL_UCCAST(BL_MOB, target)->class_ == MOBID_EMPELIUM) break; } else if (inf && battle->check_target(src, target, inf) <= 0) { - if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } else if (ud->skill_id == RK_PHANTOMTHRUST && target->type != BL_MOB) { if( !map_flag_vs(src->m) && battle->check_target(src,target,BCT_PARTY) <= 0 ) @@ -5180,7 +5705,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) && rnd() % 100 < 75 ) { // Fogwall makes all offensive-type targeted skills fail at 75% - if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0); + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -5199,7 +5724,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) !check_distance_bl(src, target, skill->get_range2(src,ud->skill_id,ud->skill_lv)+battle_config.skill_add_range)) { if (sd) { - clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); if(battle_config.skill_out_range_consume) //Consume items anyway. [Skotlex] skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,3); } @@ -5318,7 +5843,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) //When Asura fails... (except when it fails from Fog of Wall) //Consume SP/spheres skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1); - status->set_sp(src, 0, 0); + status->set_sp(src, 0, STATUS_HEAL_DEFAULT); sc = &sd->sc; if (sc->count) { //End states @@ -5343,7 +5868,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) clif->slide(src,src->x,src->y); clif->spiritball(src); } - clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); } } @@ -5360,7 +5885,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) return 0; } -bool skill_castend_id_unknown(struct unit_data *ud, struct block_list *src, struct block_list *target) +static bool skill_castend_id_unknown(struct unit_data *ud, struct block_list *src, struct block_list *target) { return false; } @@ -5368,7 +5893,7 @@ bool skill_castend_id_unknown(struct unit_data *ud, struct block_list *src, stru /*========================================== * *------------------------------------------*/ -int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct map_session_data *sd, *dstsd; struct mob_data *md, *dstmd; @@ -5427,7 +5952,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case AL_DECAGI: case AB_RENOVATIO: case AB_HIGHNESSHEAL: - clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET, 0, 0); return 0; default: if (skill->castend_nodamage_id_mado_unknown(src, bl, &skill_id, &skill_lv, &tick, &flag)) @@ -5443,7 +5968,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin switch (skill_id) { case HLIF_HEAL: // [orn] if (bl->type != BL_HOM) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0) ; + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0) ; break ; } FALLTHROUGH @@ -5461,7 +5986,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sd && battle->check_undead(tstatus->race,tstatus->def_ele) && skill_id != AL_INCAGI) { if (battle->check_target(src, bl, BCT_ENEMY) < 1) { //Offensive heal does not works on non-enemies. [Skotlex] - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } return skill->castend_damage_id(src, bl, skill_id, skill_lv, tick, flag); @@ -5601,7 +6126,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage (src, bl, skill_id, heal, 1); if( tsc && tsc->data[SC_AKAITSUKI] && heal && skill_id != HLIF_HEAL ) heal = ~heal + 1; - heal_get_jobexp = status->heal(bl,heal,0,0); + heal_get_jobexp = status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); if(sd && dstsd && heal > 0 && sd != dstsd && battle_config.heal_exp > 0){ heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100; @@ -5615,7 +6140,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case PR_REDEMPTIO: if (sd && !(flag&1)) { if (sd->status.party_id == 0) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } skill->area_temp[0] = 0; @@ -5624,7 +6149,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin src,skill_id,skill_lv,tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); if (skill->area_temp[0] == 0) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } skill->area_temp[0] = 5 - skill->area_temp[0]; // The actual penalty... @@ -5634,8 +6159,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->updatestatus(sd,SP_BASEEXP); clif->updatestatus(sd,SP_JOBEXP); } - status->set_hp(src, 1, 0); - status->set_sp(src, 0, 0); + status->set_hp(src, 1, STATUS_HEAL_DEFAULT); + status->set_sp(src, 0, STATUS_HEAL_DEFAULT); break; } else if (status->isdead(bl) && flag&1) { //Revive skill->area_temp[0]++; //Count it in, then fall-through to the Resurrection code. @@ -5646,7 +6171,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case ALL_RESURRECTION: if(sd && (map_flag_gvg2(bl->m) || map->list[bl->m].flag.battleground)) { //No reviving in WoE grounds! - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if (!status->isdead(bl)) @@ -5799,7 +6324,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case SA_SUMMONMONSTER: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE); + if (sd != NULL) + mob->once_spawn(sd, src->m, src->x, src->y, DEFAULT_MOB_JNAME, -1, 1, "", SZ_SMALL, AI_NONE); break; case SA_LEVELUP: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -5807,7 +6333,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case SA_INSTANTDEATH: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - status->set_hp(bl,1,0); + status->set_hp(bl, 1, STATUS_HEAL_DEFAULT); break; case SA_QUESTION: case SA_GRAVITY: @@ -5820,7 +6346,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int class_; if ( sd && dstmd->status.mode&MD_BOSS ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } class_ = skill_id == SA_MONOCELL ? MOBID_PORING : mob->get_random_id(4, 1, 0); @@ -5840,7 +6366,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SA_DEATH: if ( sd && dstmd && dstmd->status.mode&MD_BOSS ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -5868,7 +6394,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case CR_PROVIDENCE: if(sd && dstsd){ //Check they are not another crusader [Skotlex] if ((dstsd->job & MAPID_UPPERMASK) == MAPID_CRUSADER) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -5883,7 +6409,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sd != NULL && dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex) { // Cannot cast on another bard/dancer-type class of the same gender as caster - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -5900,7 +6426,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin status_change_end(bl, SC_MARIONETTE, INVALID_TIMER); } else { if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -5917,7 +6443,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SA_LIGHTNINGLOADER: case SA_SEISMICWEAPON: if (dstsd) { - if(dstsd->status.weapon == W_FIST || + if (dstsd->weapontype == W_FIST || (dstsd->sc.count && !dstsd->sc.data[type] && ( //Allow re-enchanting to lengthen time. [Skotlex] dstsd->sc.data[SC_PROPERTYFIRE] || @@ -5929,7 +6455,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin dstsd->sc.data[SC_ENCHANTPOISON] )) ) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); clif->skill_nodamage(src,bl,skill_id,skill_lv,0); break; } @@ -5937,7 +6463,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // 100% success rate at lv4 & 5, but lasts longer at lv5 if(!clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,(60+skill_lv*10),skill_lv, skill->get_time(skill_id,skill_lv)))) { if (sd) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); if (skill->break_equip(bl, EQP_WEAPON, 10000, BCT_PARTY) && sd && sd != dstsd) clif->message(sd->fd, msg_sd(sd,869)); // "You broke the target's weapon." } @@ -5998,16 +6524,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case TK_JUMPKICK: /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit->movepos (exploitable) */ - if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) - { - if( unit->movepos(src, bl->x, bl->y, 1, 1) ) - { - skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); - clif->slide(src,bl->x,bl->y); + if (battle->check_target(src, bl, BCT_ENEMY) > 0) { + if (unit->movepos(src, bl->x, bl->y, 1, 1)) { + skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); + clif->slide(src, bl->x, bl->y); } + } else if (sd != NULL) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); } - else - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); break; case AL_INCAGI: @@ -6128,7 +6652,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case HP_ASSUMPTIO: if( sd && dstmd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); else clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -6181,7 +6705,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case AS_ENCHANTPOISON: // Prevent spamming [Valaris] if (sd && dstsd && dstsd->sc.count) { @@ -6194,7 +6718,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex] ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -6224,17 +6748,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int id; if (sd->mission_mobid && (sd->mission_count || rnd()%100)) { //Cannot change target when already have one clif->mission_info(sd, sd->mission_mobid, sd->mission_count); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } id = mob->get_random_id(0,0xF, sd->status.base_level); if (!id) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } sd->mission_mobid = id; sd->mission_count = 0; - pc_setglobalreg(sd,script->add_str("TK_MISSION_ID"), id); + pc_setglobalreg(sd,script->add_variable("TK_MISSION_ID"), id); clif->mission_info(sd, id, 0); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } @@ -6264,7 +6788,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin (failure = sc_start(src,bl,type, skill_id == SM_SELFPROVOKE ? 100:( 50 + 3*skill_lv + status->get_lv(src) - status->get_lv(bl)), skill_lv, skill->get_time(skill_id,skill_lv)))); if( !failure ) { if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } @@ -6294,7 +6818,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( !dstsd || (!sd && !mer) ) { // Only players can be devoted if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } @@ -6307,7 +6831,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin (dstsd->sc.data[SC_HELLPOWER])) // Players affected by SC_HELLPOWERR cannot be devoted. { if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -6322,7 +6846,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin ARR_FIND(0, count, i, sd->devotion[i] == 0 ); if( i == count ) { // No free slots, skill Fail - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -6387,7 +6911,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (dstsd && dstsd->charm_type != CHARM_TYPE_NONE && dstsd->charm_count > 0) { pc->del_charm(dstsd, dstsd->charm_count, dstsd->charm_type); } - if (sp) status->heal(src, 0, sp, 3); + if (sp != 0) + status->heal(src, 0, sp, STATUS_HEAL_FORCED | STATUS_HEAL_SHOWEFFECT); clif->skill_nodamage(src,bl,skill_id,skill_lv,sp?1:0); } break; @@ -6583,7 +7108,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin ) ) { status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDRATE); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -6610,7 +7135,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 0; } else if( tsc && tsc->option&OPTION_MADOGEAR ) { //Mado Gear cannot hide - if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if( sd ) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } @@ -6636,7 +7161,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( failure ) clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,failure); else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); if ( skill_id == LG_FORCEOFVANGUARD || skill_id == RA_CAMOUFLAGE ) break; map->freeblock_unlock(); @@ -6646,7 +7171,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( failure ) clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,failure); else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -6666,8 +7191,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // custom hack to make the mob display the skill, because these skills don't show the skill use text themselves //NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches) char temp[70]; - snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->dbs->db[skill_id].desc); - clif->disp_overhead(&md->bl,temp); + snprintf(temp, sizeof(temp), "%s : %s !!", md->name, skill->get_desc(skill_id)); + clif->disp_overhead(&md->bl, temp, AREA_CHAT_WOC, NULL); } break; @@ -6686,7 +7211,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start2(src,bl,type,70,skill_lv,src->id,skill->get_time(skill_id,skill_lv))); } else { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); - if(sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if(sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } } break; @@ -6696,7 +7221,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if(pc->steal_item(sd,bl,skill_lv)) clif->skill_nodamage(src,bl,skill_id,skill_lv,1); else - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); } break; @@ -6709,7 +7234,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src, bl, skill_id, amount, 1); } else - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -6717,7 +7242,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { int brate = 0; if (tstatus->mode&MD_BOSS) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if(status->isimmune(bl) || !tsc) @@ -6736,7 +7261,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin skill->get_time2(skill_id,skill_lv))) clif->skill_nodamage(src,bl,skill_id,skill_lv,1); else if(sd) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); // Level 6-10 doesn't consume a red gem if it fails [celest] if (skill_lv > 5) { // not to consume items @@ -6749,7 +7274,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case NV_FIRSTAID: clif->skill_nodamage(src,bl,skill_id,5,1); - status->heal(bl,5,0,0); + status->heal(bl, 5, 0, STATUS_HEAL_DEFAULT); break; case AL_CURE: @@ -6826,7 +7351,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case MER_SCAPEGOAT: if( mer && mer->master ) { - status->heal(&mer->master->bl, mer->battle_status.hp, 0, 2); + status->heal(&mer->master->bl, mer->battle_status.hp, 0, STATUS_HEAL_SHOWEFFECT); status->damage(src, src, mer->battle_status.max_hp, 0, 0, 1); } break; @@ -6840,7 +7365,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; if( dstsd ) { // Fail on Players - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if (dstmd && dstmd->class_ == MOBID_EMPELIUM) @@ -6865,7 +7390,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( sd->skillitem != skill_id ) - status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded + status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded } break; @@ -6881,7 +7406,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sd) { //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex] if ( !pc_can_give_items(sd) ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); else { sd->state.prevend = sd->state.workinprogress = 3; clif->openvendingreq(sd,2+skill_lv); @@ -6929,7 +7454,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (skill->produce_mix(sd, skill_id, ITEMID_HOLY_WATER, 0, 0, 0, 1)) clif->skill_nodamage(src,bl,skill_id,skill_lv,1); else - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -6948,7 +7473,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin eflag = pc->additem(sd,&item_tmp,1,LOG_TYPE_PRODUCE); if(eflag) { clif->additem(sd,0,0,eflag); - map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } break; @@ -7027,7 +7552,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Nothing stripped. if( sd && !rate ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } @@ -7041,22 +7566,23 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( sd ) { - int x,bonus=100, potion = min(500+skill_lv,505); - x = skill_lv%11 - 1; - i = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[x]); - if (i == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[x] <= 0) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + int bonus = 100, potion = min(500+skill_lv,505); + int item_idx = (skill_lv - 1) % MAX_SKILL_ITEM_REQUIRE; + int item_id = skill->get_itemid(skill_id, item_idx); + int inventory_idx = pc->search_inventory(sd, item_id); + if (inventory_idx == INDEX_NOT_FOUND || item_id <= 0) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } - if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->dbs->db[skill_id].amount[x]) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd->inventory_data[inventory_idx] == NULL || sd->status.inventory[inventory_idx].amount < skill->get_itemqty(skill_id, item_idx)) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } if( skill_id == AM_BERSERKPITCHER ) { - if (dstsd && dstsd->status.base_level < sd->inventory_data[i]->elv) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (dstsd != NULL && dstsd->status.base_level < sd->inventory_data[inventory_idx]->elv) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -7064,7 +7590,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin script->potion_flag = 1; script->potion_hp = script->potion_sp = script->potion_per_hp = script->potion_per_sp = 0; script->potion_target = bl->id; - script->run_use_script(sd, sd->inventory_data[i], 0); + script->run_use_script(sd, sd->inventory_data[inventory_idx], 0); script->potion_flag = script->potion_target = 0; if( sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ALCHEMIST ) bonus += sd->status.base_level; @@ -7142,7 +7668,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( tsc && tsc->data[SC_EXTREMITYFIST2] ) sp = 0; #endif - status->heal(bl,(int)hp,sp,0); + status->heal(bl, (int)hp, sp, STATUS_HEAL_DEFAULT); } break; case AM_CP_WEAPON: @@ -7156,7 +7682,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin (dstsd && equip[skill_id - AM_CP_WEAPON] == EQP_SHIELD && pc->checkequip(dstsd, EQP_SHIELD) > 0 && (index = dstsd->equip_index[EQI_HAND_L]) >= 0 && dstsd->inventory_data[index] && dstsd->inventory_data[index]->type != IT_ARMOR)) ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); // Don't consume item requirements return 0; } @@ -7169,7 +7695,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv,1); //Prepare 200 White Potions. if (!skill->produce_mix(sd, skill_id, ITEMID_WHITE_POTION, 0, 0, 0, 200)) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; case AM_TWILIGHT2: @@ -7177,7 +7703,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv,1); //Prepare 200 Slim White Potions. if (!skill->produce_mix(sd, skill_id, ITEMID_WHITE_SLIM_POTION, 0, 0, 0, 200)) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; case AM_TWILIGHT3: @@ -7191,7 +7717,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin || !skill->can_produce_mix(sd,ITEMID_FIRE_BOTTLE,-1, 50) //50 Flame Bottle || ebottle < 200 //200 empty bottle are required at total. ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -7217,7 +7743,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin || rnd()%100 >= 50+10*skill_lv ) { if (sd) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if(status->isimmune(bl) || !tsc || !tsc->count) @@ -7317,7 +7843,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sp = skill->get_sp(skill_id,skill_lv); sp = sp * tsc->data[SC_MAGICROD]->val2 / 100; if(sp < 1) sp = 1; - status->heal(bl,0,sp,2); + status->heal(bl, 0, sp, STATUS_HEAL_SHOWEFFECT); status_percent_damage(bl, src, 0, -20, false); //20% max SP damage. } else { struct unit_data *ud = unit->bl2ud(bl); @@ -7330,7 +7856,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Only 10% success chance against bosses. [Skotlex] if (rnd()%100 < 90) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } else if (!dstsd || map_flag_vs(bl->m)) //HP damage only on pvp-maps when against players. @@ -7349,8 +7875,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sp) //Recover some of the SP used sp = sp*(25*(skill_lv-1))/100; - if(hp || sp) - status->heal(src, hp, sp, 2); + if (hp != 0 || sp != 0) + status->heal(src, hp, sp, STATUS_HEAL_SHOWEFFECT); } } break; @@ -7384,7 +7910,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin maxlv = skill_lv - 4; } else if(skill_lv >=2) { - int i = rnd()%3; + int i = rnd() % ARRAYLENGTH(spellarray); spellid = spellarray[i]; maxlv = skill_lv - 1; } @@ -7470,8 +7996,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case NPC_LICK: status_zap(bl, 0, 100); - clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(src,bl,type,(skill_lv*5),skill_lv,skill->get_time2(skill_id,skill_lv))); + clif->skill_nodamage(src, bl, skill_id, skill_lv, + sc_start(src, bl, type, (skill_lv * 20), skill_lv, skill->get_time2(skill_id, skill_lv))); break; case NPC_SUICIDE: @@ -7591,16 +8117,16 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case WE_MALE: { - int hp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].hp_rate[skill_lv-1]; + int hp_rate = skill_lv == 0 ? 0 : skill->get_hp_rate(skill_id, skill_lv); int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it cost the caster. [Skotlex] - clif->skill_nodamage(src,bl,skill_id,status->heal(bl, gain_hp, 0, 0),1); + clif->skill_nodamage(src, bl, skill_id, status->heal(bl, gain_hp, 0, STATUS_HEAL_DEFAULT), 1); } break; case WE_FEMALE: { - int sp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].sp_rate[skill_lv-1]; + int sp_rate = skill_lv == 0 ? 0 : skill->get_sp_rate(skill_id, skill_lv); int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it cost the caster. [Skotlex] - clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1); + clif->skill_nodamage(src, bl, skill_id, status->heal(bl, 0, gain_sp, STATUS_HEAL_DEFAULT), 1); } break; @@ -7621,7 +8147,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin we_baby_parents = true; } if (!we_baby_parents) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } @@ -7636,11 +8162,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin hp = sstatus->max_hp/10; sp = hp * 10 * skill_lv / 100; if (!status->charge(src,hp,0)) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - status->heal(bl,0,sp,2); + status->heal(bl, 0, sp, STATUS_HEAL_SHOWEFFECT); } break; @@ -7661,16 +8187,17 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( battle_config.skill_removetrap_type ) { int i; // get back all items used to deploy the trap - for( i = 0; i < 10; i++ ) { - if( skill->dbs->db[su->group->skill_id].itemid[i] > 0 ) { + for (i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) { + int nameid = skill->get_itemid(su->group->skill_id, i); + if (nameid > 0) { int success; - struct item item_tmp; - memset(&item_tmp,0,sizeof(item_tmp)); - item_tmp.nameid = skill->dbs->db[su->group->skill_id].itemid[i]; + struct item item_tmp = { 0 }; + int amount = skill->get_itemqty(su->group->skill_id, i); + item_tmp.nameid = nameid; item_tmp.identify = 1; - if (item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],LOG_TYPE_SKILL)) != 0) { + if ((success = pc->additem(sd, &item_tmp, amount, LOG_TYPE_SKILL)) != 0) { clif->additem(sd,0,0,success); - map->addflooritem(&sd->bl, &item_tmp, skill->dbs->db[su->group->skill_id].amount[i], sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &item_tmp, amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } } @@ -7682,13 +8209,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin item_tmp.identify = 1; if (item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SKILL)) != 0) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } } skill->delunit(su); }else if(sd) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -7735,7 +8262,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin || tstatus-> hp > tstatus->max_hp*3/4 #endif // RENEWAL ) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 1; } @@ -7765,7 +8292,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (!clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv))) ) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } @@ -7789,12 +8316,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin unsigned int sp1 = 0, sp2 = 0; if (dstmd) { if (dstmd->state.soul_change_flag) { - if(sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if(sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } dstmd->state.soul_change_flag = 1; sp2 = sstatus->max_sp * 3 /100; - status->heal(src, 0, sp2, 2); + status->heal(src, 0, sp2, STATUS_HEAL_SHOWEFFECT); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); break; } @@ -7806,8 +8333,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( tsc && tsc->data[SC_EXTREMITYFIST2] ) sp1 = tstatus->sp; #endif // RENEWAL - status->set_sp(src, sp2, 3); - status->set_sp(bl, sp1, 3); + status->set_sp(src, sp2, STATUS_HEAL_FORCED | STATUS_HEAL_SHOWEFFECT); + status->set_sp(bl, sp1, STATUS_HEAL_FORCED | STATUS_HEAL_SHOWEFFECT); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -7845,7 +8372,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(NULL,bl,AL_HEAL,hp,1); if(sp > 0) clif->skill_nodamage(NULL,bl,MG_SRECOVERY,sp,1); - status->heal(bl,hp,sp,0); + status->heal(bl, hp, sp, STATUS_HEAL_DEFAULT); } break; // Full Chemical Protection @@ -7865,7 +8392,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin s++; } if ( sd && !s ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); // Don't consume item requirements return 0; } @@ -7897,12 +8424,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } if (rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPELIUM) || mob_is_battleground(dstmd)))) { if (sd != NULL) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } - status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] + status_zap(src, 0, skill->get_sp(skill_id, skill_lv)); // consume sp only if succeeded [Inkfish] do { int eff = rnd() % 14; if( eff == 5 ) @@ -7926,7 +8453,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->damage(src,bl,0,0,1000,0,BDT_NORMAL,0); if( !status->isdead(bl) ) { int where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM, EQP_SHOES, EQP_GARMENT }; - skill->break_equip(bl, where[rnd()%5], 10000, BCT_ENEMY); + skill->break_equip(bl, where[rnd() % ARRAYLENGTH(where)], 10000, BCT_ENEMY); } } break; @@ -7934,7 +8461,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sc_start(src,bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); break; case 5: // 2000HP heal, random teleported - status->heal(src, 2000, 0, 0); + status->heal(src, 2000, 0, STATUS_HEAL_DEFAULT); if( !map_flag_vs(bl->m) ) unit->warp(bl, -1,-1,-1, CLR_TELEPORT); break; @@ -7947,7 +8474,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case 7: // stop freeze or stoned { enum sc_type sc[] = { SC_STOP, SC_FREEZE, SC_STONE }; - sc_start(src,bl,sc[rnd()%3],100,skill_lv,skill->get_time2(skill_id,skill_lv)); + sc_start(src,bl,sc[rnd() % ARRAYLENGTH(sc)],100,skill_lv,skill->get_time2(skill_id,skill_lv)); } break; case 8: // curse coma and poison @@ -8005,13 +8532,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SL_WIZARD: //NOTE: here, 'type' has the value of the associated MAPID, not of the SC_SOULLINK constant. if (sd != NULL && !(dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == type)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if (skill_id == SL_SUPERNOVICE && dstsd && dstsd->die_counter && !(rnd()%100)) { //Erase death count 1% of the casts dstsd->die_counter = 0; - pc_setglobalreg(dstsd,script->add_str("PC_DIE_COUNTER"), 0); + pc_setglobalreg(dstsd,script->add_variable("PC_DIE_COUNTER"), 0); clif->specialeffect(bl, 0x152, AREA); //SC_SOULLINK invokes status_calc_pc for us. } @@ -8021,7 +8548,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case SL_HIGH: if (sd != NULL && !(dstsd != NULL && (dstsd->job & JOBL_UPPER) != 0 && (dstsd->job & JOBL_2) == 0 && dstsd->status.base_level < 70)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv, @@ -8032,7 +8559,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SL_SWOO: if (tsce) { if(sd) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,10000,SCFLAG_FIXEDRATE); status_change_end(bl, SC_SWOO, INVALID_TIMER); break; @@ -8040,7 +8567,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SL_SKA: // [marquis007] case SL_SKE: if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); status->change_start(src,src,SC_STUN,10000,skill_lv,0,0,0,500,SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); break; } @@ -8132,7 +8659,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (sd) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if (!pc->set_hate_mob(sd, skill_lv-1, bl)) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -8162,7 +8689,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (homun->call(sd)) clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); else - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -8171,7 +8698,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (homun->vaporize(sd,HOM_ST_REST)) clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); else - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -8181,8 +8708,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int x,y; x = src->x; y = src->y; - if (hd) - skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id,skill_lv)); + if (hd) { +#ifdef RENEWAL + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); +#else + skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id, skill_lv)); +#endif + } + if (unit->movepos(src,bl->x,bl->y,0,0)) { clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homun @@ -8200,9 +8733,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } // Failed else if (hd && hd->master) - clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(hd->master, skill_id, USESKILL_FAIL_LEVEL, 0, 0); else if (sd) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case HVAN_CHAOTIC: // [orn] { @@ -8222,7 +8755,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Eh? why double skill packet? clif->skill_nodamage(src,bl,AL_HEAL,hp,1); clif->skill_nodamage(src,bl,skill_id,hp,1); - status->heal(bl, hp, 0, 0); + status->heal(bl, hp, 0, STATUS_HEAL_DEFAULT); } break; // Homun single-target support skills [orn] @@ -8305,7 +8838,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { if( !sd->status.party_id ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); @@ -8361,7 +8894,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( status->charge(bl,heal,0) ) clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start2(src,bl,type,100,skill_lv,heal,skill->get_time(skill_id,skill_lv))); else - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; case RK_REFRESH: @@ -8369,7 +8902,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int heal = status_get_max_hp(bl) * 25 / 100; clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); - status->heal(bl,heal,0,1); + status->heal(bl, heal, 0, STATUS_HEAL_FORCED); status->change_clear_buffs(bl,4); } break; @@ -8423,7 +8956,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin value = status_get_max_hp(bl) * 25 / 100; status->change_clear_buffs(bl,4); skill->area_temp[5] &= ~0x20; - status->heal(bl,value,0,1); + status->heal(bl, value, 0, STATUS_HEAL_FORCED); type = SC_REFRESH; }else if( skill->area_temp[5]&0x40 ){ skill->area_temp[5] &= ~0x40; @@ -8539,11 +9072,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { int heal = status_get_max_hp(bl) * ( 18 - 2 * skill_lv ) / 100; if( status_get_hp(bl) < heal ) { // if you haven't enough HP skill fails. - if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0, 0); break; } if( !status->charge(bl,heal,0) ) { - if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -8569,7 +9102,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(src, bl, type, 100, level + (sd?(sd->status.job_level / 10):0), skill->get_time(skill_id,skill_lv))); else if( sd ) { if( !level ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); else party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); } @@ -8608,7 +9141,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(bl, bl, skill_id, heal, 1); if( tsc && tsc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; - status->heal(bl, heal, 0, 1); + status->heal(bl, heal, 0, STATUS_HEAL_FORCED); } } else if( sd ) party->foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); @@ -8675,7 +9208,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if ((dstsd != NULL && (dstsd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || rnd()%100 >= 60 + 8 * skill_lv) { if (sd) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if(status->isimmune(bl) || !tsc || !tsc->count) @@ -8738,11 +9271,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int failure = sc_start2(src,bl,type,rate,skill_lv,src->id,(src == bl)?5000:(bl->type == BL_PC)?skill->get_time(skill_id,skill_lv):skill->get_time2(skill_id, skill_lv)); clif->skill_nodamage(src,bl,skill_id,skill_lv,failure); if( sd && !failure ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } }else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET, 0, 0); break; case WL_FROSTMISTY: @@ -8778,7 +9311,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id); }else if( sd ) // Failure on Rate - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } break; @@ -8808,7 +9341,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( sc && !sc->data[i] ) break; if( i == SC_SPELLBOOK7 ) { - clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0); + clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0, 0); break; } @@ -8884,7 +9417,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin pc->setmadogear(sd, false); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); skill->castend_damage_id(src, src, skill_id, skill_lv, tick, flag); - status->set_sp(src, 0, 0); + status->set_sp(src, 0, STATUS_HEAL_DEFAULT); } break; @@ -8912,7 +9445,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( sd ) { int heal, hp = 0; // % of max hp regen if( !dstsd || !pc_ismadogear(dstsd) ) { - clif->skill_fail(sd, skill_id,USESKILL_FAIL_TOTARGET,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET, 0, 0); break; } switch (cap_value(skill_lv, 1, 5)) { @@ -8923,7 +9456,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case 5: hp = 23; break; } heal = tstatus->max_hp * hp / 100; - status->heal(bl,heal,0,2); + status->heal(bl, heal, 0, STATUS_HEAL_SHOWEFFECT); clif->skill_nodamage(src, bl, skill_id, skill_lv, heal); } break; @@ -8946,7 +9479,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,1,1); } else - clif->skill_fail(sd,skill_id,USESKILL_FAIL_IMITATION_SKILL_NONE,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_IMITATION_SKILL_NONE, 0, 0); } break; @@ -8956,7 +9489,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin dstsd->shadowform_id = src->id; } else if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case SC_BODYPAINT: @@ -9001,7 +9534,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int sp = 100 * skill_lv; if( dstmd ) sp = dstmd->level * 2; if( status_zap(bl,0,sp) ) - status->heal(src,0,sp/2,3);//What does flag 3 do? [Rytech] + status->heal(src, 0, sp / 2, STATUS_HEAL_FORCED | STATUS_HEAL_SHOWEFFECT); } if ( tsc && tsc->data[SC__UNLUCKY] && skill_id == SC_UNLUCKY) { //If the target was successfully inflected with the Unlucky status, give 1 of 3 random status's. @@ -9017,7 +9550,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } } } else if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case LG_TRAMPLE: @@ -9044,7 +9577,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin struct item_data *shield_data = NULL; if( sd->equip_index[EQI_HAND_L] < 0 || !( shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]] ) || shield_data->type != IT_ARMOR ) { //Skill will first check if a shield is equipped. If none is found on the caster the skill will fail. - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } //Generates a number between 1 - 3. The number generated will determine which effect will be triggered. @@ -9125,7 +9658,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case 3: sc_start(src, bl, SC_SHIELDSPELL_REF, 100, opt, INFINITE_DURATION); // HP Recovery val = sstatus->max_hp * ((status->get_lv(src) / 10) + (shield->refine + 1)) / 100; - status->heal(bl, val, 0, 2); + status->heal(bl, val, 0, STATUS_HEAL_SHOWEFFECT); status_change_end(bl,SC_SHIELDSPELL_REF,INVALID_TIMER); break; } @@ -9268,7 +9801,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } heal = 120 * skill_lv + status_get_max_hp(bl) * (2 + skill_lv) / 100; - status->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); if( (tsc && tsc->opt1) && (rnd()%100 < ((skill_lv * 5) + (status_get_dex(src) + status->get_lv(src)) / 4) - (1 + (rnd() % 10))) ) { status_change_end(bl, SC_STONE, INVALID_TIMER); @@ -9339,7 +9872,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin heal = 1; status->fixed_revive(bl, heal, 0); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - status->set_sp(bl, 0, 0); + status->set_sp(bl, 0, STATUS_HEAL_DEFAULT); } } break; @@ -9378,7 +9911,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case WM_GLOOMYDAY: if ( tsc && tsc->data[type] ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } // val4 indicates caster's voice lesson level @@ -9510,7 +10043,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; } if( !mapindex ) { //Given map not found? - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); map->freeblock_unlock(); return 0; } @@ -9605,7 +10138,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // Summoning the new one. if( !elemental->create(sd,elemental_class,skill->get_time(skill_id,skill_lv)) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -9627,7 +10160,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case 3: mode = EL_MODE_AGGRESSIVE; break; } if (!elemental->change_mode(sd->ed, mode)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -9671,12 +10204,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( !ed ) break; if( !status->charge(&sd->bl,s_hp,s_sp) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } e_hp = ed->battle_status.max_hp * 10 / 100; e_sp = ed->battle_status.max_sp * 10 / 100; - status->heal(&ed->bl,e_hp,e_sp,3); + status->heal(&ed->bl, e_hp, e_sp, STATUS_HEAL_FORCED | STATUS_HEAL_SHOWEFFECT); clif->skill_nodamage(src,&ed->bl,skill_id,skill_lv,1); } break; @@ -9702,7 +10235,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sc_start2(src,bl, type, 100, skill_lv, src->id, skill->get_time(skill_id,skill_lv)); (sc->bs_counter)++; } else if( sd ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -9725,7 +10258,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case GN_SLINGITEM: if( sd ) { - short ammo_id; + int ammo_id; int equip_idx = sd->equip_index[EQI_AMMO]; if( equip_idx <= 0 ) break; // No ammo. @@ -9740,7 +10273,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin else skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag); } else //Otherwise, it fails, shows animation and removes items. - clif->skill_fail(sd,GN_SLINGITEM_RANGEMELEEATK,0xa,0); + clif->skill_fail(sd, GN_SLINGITEM_RANGEMELEEATK, 0xa, 0, 0); } else if( itemdb_is_GNthrowable(ammo_id) ) { struct script_code *scriptroot = sd->inventory_data[equip_idx]->script; if( !scriptroot ) @@ -9868,7 +10401,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case KO_KYOUGAKU: if (!map_flag_vs(src->m) || !dstsd) { - if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_SIZE, 0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_SIZE, 0, 0); break; } else { int time; @@ -9890,14 +10423,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( status->get_lv(bl) <= status->get_lv(src) ) status->change_start(src, bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, SCFLAG_NONE); } else if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; case KO_GENWAKU: if ( !map_flag_gvg2(src->m) && ( dstsd || dstmd ) && !(tstatus->mode&MD_PLANT) && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { int x = src->x, y = src->y; if( sd && rnd()%100 > max(5, (45 + 5 * skill_lv) - status_get_int(bl) / 10) ){//[(Base chance of success) - ( target's int / 10)]%. - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } @@ -9919,7 +10452,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case OB_OBOROGENSOU: if( sd && ( (skill_id == OB_OBOROGENSOU && bl->type == BL_MOB) // This skill does not work on monsters. || is_boss(bl) ) ){ // Does not work on Boss monsters. - clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET_PLAYER, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET_PLAYER, 0, 0); break; } case KO_IZAYOI: @@ -9986,7 +10519,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } } heal = 5 * status->get_lv(&hd->bl) + status->base_matk(&hd->bl, &hd->battle_status, status->get_lv(&hd->bl)); - status->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); clif->skill_nodamage(src, src, skill_id, skill_lv, clif->skill_nodamage(src, bl, AL_HEAL, heal, 1)); status->change_start(src, src, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); status->change_start(src, bl, type, 1000, skill_lv, 0, 0, 0, skill->get_time(skill_id,skill_lv), SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); @@ -10083,22 +10616,22 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 0; } -bool skill_castend_nodamage_id_dead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static bool skill_castend_nodamage_id_dead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { return true; } -bool skill_castend_nodamage_id_undead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static bool skill_castend_nodamage_id_undead_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { return true; } -bool skill_castend_nodamage_id_mado_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static bool skill_castend_nodamage_id_mado_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { return false; } -bool skill_castend_nodamage_id_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +static bool skill_castend_nodamage_id_unknown(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { nullpo_retr(true, skill_id); nullpo_retr(true, skill_lv); @@ -10111,7 +10644,7 @@ bool skill_castend_nodamage_id_unknown(struct block_list *src, struct block_list /*========================================== * *------------------------------------------*/ -int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) +static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) { struct block_list* src = map->id2bl(id); struct map_session_data *sd; @@ -10153,7 +10686,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) skill->check_unit_range(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv) ) { - if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if( src->type&battle_config.skill_nofootset && @@ -10161,7 +10694,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) skill->check_unit_range2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv) ) { - if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } if( src->type&battle_config.land_skill_limit && @@ -10174,7 +10707,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) } if( maxcount == 0 ) { - if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -10272,7 +10805,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) } -int skill_check_npc_chaospanic(struct block_list *bl, va_list args) +static int skill_check_npc_chaospanic(struct block_list *bl, va_list args) { const struct npc_data *nd = NULL; @@ -10287,7 +10820,7 @@ int skill_check_npc_chaospanic(struct block_list *bl, va_list args) } /* skill count without self */ -int skill_count_wos(struct block_list *bl, va_list ap) +static int skill_count_wos(struct block_list *bl, va_list ap) { struct block_list* src = va_arg(ap, struct block_list*); nullpo_retr(1, bl); @@ -10301,7 +10834,7 @@ int skill_count_wos(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *mapname) +static int skill_castend_map(struct map_session_data *sd, uint16 skill_id, const char *mapname) { nullpo_ret(sd); nullpo_ret(mapname); @@ -10374,7 +10907,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char map_index = mapindex->name2id(mapname); if(!map_index) { //Given map not found? - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); skill_failed(sd); return 0; } @@ -10389,7 +10922,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char maxcount--; } if(!maxcount) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); skill_failed(sd); return 0; } @@ -10441,7 +10974,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char /*========================================== * *------------------------------------------*/ -int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static int skill_castend_pos2(struct block_list *src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct map_session_data* sd; struct status_change* sc; @@ -10537,7 +11070,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case SC_CHAOSPANIC: case SC_MAELSTROM: if (sd && map->foreachinarea(skill->check_npc_chaospanic, src->m, x-3, y-3, x+3, y+3, BL_NPC) > 0 ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } FALLTHROUGH @@ -10685,7 +11218,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui else { // Create Basilica. Start SC on caster. Unit timer start SC on others. if( map->foreachinrange(skill->count_wos, src, 2, BL_MOB|BL_PC, src) ) { if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); return 1; } @@ -10831,55 +11364,58 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui // Slim Pitcher [Celest] case CR_SLIMPITCHER: if (sd) { - int i = skill_lv%11 - 1; - int j = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[i]); - if (j == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[i] <= 0 - || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->dbs->db[skill_id].amount[i] + int item_idx = (skill_lv - 1) % MAX_SKILL_ITEM_REQUIRE; + int item_id = skill->get_itemid(skill_id, item_idx); + int inventory_idx = pc->search_inventory(sd, item_id); + int bonus; + if (inventory_idx == INDEX_NOT_FOUND || item_id <= 0 + || sd->inventory_data[inventory_idx] == NULL + || sd->status.inventory[inventory_idx].amount < skill->get_itemqty(skill_id, item_idx) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } script->potion_flag = 1; script->potion_hp = 0; script->potion_sp = 0; - script->run_use_script(sd, sd->inventory_data[j], 0); + script->run_use_script(sd, sd->inventory_data[inventory_idx], 0); script->potion_flag = 0; //Apply skill bonuses - i = pc->checkskill(sd,CR_SLIMPITCHER)*10 + bonus = pc->checkskill(sd,CR_SLIMPITCHER)*10 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5 + pc->skillheal_bonus(sd, skill_id); - script->potion_hp = script->potion_hp * (100+i)/100; - script->potion_sp = script->potion_sp * (100+i)/100; + script->potion_hp = script->potion_hp * (100 + bonus) / 100; + script->potion_sp = script->potion_sp * (100 + bonus) / 100; - if(script->potion_hp > 0 || script->potion_sp > 0) { - i = skill->get_splash(skill_id, skill_lv); + if (script->potion_hp > 0 || script->potion_sp > 0) { + r = skill->get_splash(skill_id, skill_lv); map->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + src->m, x - r, y - r, x + r, y + r, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_PARTY|BCT_GUILD|1, skill->castend_nodamage_id); } } else { - int i = skill_lv%11 - 1; - struct item_data *item; - i = skill->dbs->db[skill_id].itemid[i]; - item = itemdb->search(i); + int item_idx = (skill_lv - 1) % MAX_SKILL_ITEM_REQUIRE; + int item_id = skill->get_itemid(skill_id, item_idx); + struct item_data *item = itemdb->search(item_id); + int bonus; script->potion_flag = 1; script->potion_hp = 0; script->potion_sp = 0; script->run(item->script,0,src->id,0); script->potion_flag = 0; - i = skill->get_max(CR_SLIMPITCHER)*10; + bonus = skill->get_max(CR_SLIMPITCHER)*10; - script->potion_hp = script->potion_hp * (100+i)/100; - script->potion_sp = script->potion_sp * (100+i)/100; + script->potion_hp = script->potion_hp * (100 + bonus)/100; + script->potion_sp = script->potion_sp * (100 + bonus)/100; - if(script->potion_hp > 0 || script->potion_sp > 0) { - i = skill->get_splash(skill_id, skill_lv); + if (script->potion_hp > 0 || script->potion_sp > 0) { + r = skill->get_splash(skill_id, skill_lv); map->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + src->m, x - r, y - r, x + r, y + r, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_PARTY|BCT_GUILD|1, skill->castend_nodamage_id); } } @@ -10892,7 +11428,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui r = skill->get_splash(skill_id, skill_lv); map->foreachinarea(skill->cell_overlap, src->m, x-r, y-r, x+r, y+r, BL_SKILL, HW_GANBANTEIN, &dummy, src); } else { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } break; @@ -10907,15 +11443,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case CR_CULTIVATION: if (sd) { if( map->count_oncell(src->m,x,y,BL_CHAR,0) > 0 ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 1; } clif->skill_poseffect(src,skill_id,skill_lv,x,y,tick); if (rnd()%100 < 50) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); } else { int mob_id = skill_lv < 2 ? MOBID_BLACK_MUSHROOM + rnd()%2 : MOBID_RED_PLANT + rnd()%6; - struct mob_data *md = mob->once_spawn_sub(src, src->m, x, y, "--ja--", mob_id, "", SZ_SMALL, AI_NONE); + struct mob_data *md = mob->once_spawn_sub(src, src->m, x, y, DEFAULT_MOB_JNAME, mob_id, "", SZ_SMALL, AI_NONE); int i; if (md == NULL) break; @@ -10961,7 +11497,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case AM_RESURRECTHOMUN: // [orn] if (sd) { if (!homun->ressurect(sd, 20*skill_lv, x, y)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); break; } } @@ -11005,7 +11541,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case GC_POISONSMOKE: if( !(sc && sc->data[SC_POISONINGWEAPON]) ) { if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_POISONINGWEAPON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_POISONINGWEAPON, 0, 0); return 0; } clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,BDT_SKILL); @@ -11114,7 +11650,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,skill->splash_target(src), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); } else if( sd ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); break; case WM_DOMINION_IMPULSE: @@ -11223,20 +11759,22 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui return 0; } -void skill_castend_pos2_effect_unknown(struct block_list* src, int *x, int *y, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { +static void skill_castend_pos2_effect_unknown(struct block_list *src, int *x, int *y, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +{ if (skill->get_inf(*skill_id) & INF_SELF_SKILL) clif->skill_nodamage(src, src, *skill_id, *skill_lv, 1); else clif->skill_poseffect(src, *skill_id, *skill_lv, *x, *y, *tick); } -bool skill_castend_pos2_unknown(struct block_list* src, int *x, int *y, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { +static bool skill_castend_pos2_unknown(struct block_list *src, int *x, int *y, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) +{ ShowWarning("skill_castend_pos2: Unknown skill used:%d\n", *skill_id); return true; } /// transforms 'target' skill unit into dissonance (if conditions are met) -int skill_dance_overlap_sub(struct block_list *bl, va_list ap) +static int skill_dance_overlap_sub(struct block_list *bl, va_list ap) { struct skill_unit *target = NULL; struct skill_unit *src = va_arg(ap, struct skill_unit*); @@ -11266,7 +11804,7 @@ int skill_dance_overlap_sub(struct block_list *bl, va_list ap) //Does the song/dance overlapping -> dissonance check. [Skotlex] //When flag is 0, this unit is about to be removed, cancel the dissonance effect //When 1, this unit has been positioned, so start the cancel effect. -int skill_dance_overlap(struct skill_unit* su, int flag) +static int skill_dance_overlap(struct skill_unit *su, int flag) { if (!su || !su->group || !(su->group->state.song_dance&0x1)) return 0; @@ -11289,7 +11827,7 @@ int skill_dance_overlap(struct skill_unit* su, int flag) * @param flag 1 Revert * @retval true success **/ -bool skill_dance_switch(struct skill_unit* su, int flag) +static bool skill_dance_switch(struct skill_unit *su, int flag) { static int prevflag = 1; // by default the backup is empty static struct skill_unit_group backup; @@ -11346,7 +11884,7 @@ bool skill_dance_switch(struct skill_unit* su, int flag) * Initializes and sets a ground skill. * flag&1 is used to determine when the skill 'morphs' (Warp portal becomes active, or Fire Pillar becomes active) *------------------------------------------*/ -struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_id, uint16 skill_lv, int16 x, int16 y, int flag) +static struct skill_unit_group *skill_unitsetting(struct block_list *src, uint16 skill_id, uint16 skill_lv, int16 x, int16 y, int flag) { struct skill_unit_group *group; int i,limit,val1=0,val2=0,val3=0; @@ -11630,27 +12168,27 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ int element[5]={ELE_WIND,ELE_DARK,ELE_POISON,ELE_WATER,ELE_FIRE}; val1 = st->rhw.ele; - if (!val1) - val1=element[rnd()%5]; + if (val1 == ELE_NEUTRAL) + val1 = element[rnd() % ARRAYLENGTH(element)]; - switch (val1) - { + switch (val1) { case ELE_FIRE: - subunt++; - FALLTHROUGH + subunt = 4; + break; case ELE_WATER: - subunt++; - FALLTHROUGH + subunt = 3; + break; case ELE_POISON: - subunt++; - FALLTHROUGH + subunt = 2; + break; case ELE_DARK: - subunt++; - FALLTHROUGH + subunt = 1; + break; case ELE_WIND: + subunt = 0; break; default: - subunt=rnd()%5; + subunt = rnd() % 5; break; } @@ -11867,11 +12405,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ return group; } -void skill_unitsetting1_unknown(struct block_list *src, uint16 *skill_id, uint16 *skill_lv, int16 *x, int16 *y, int *flag, int *val1, int *val2, int *val3) +static void skill_unitsetting1_unknown(struct block_list *src, uint16 *skill_id, uint16 *skill_lv, int16 *x, int16 *y, int *flag, int *val1, int *val2, int *val3) { } -void skill_unitsetting2_unknown(struct block_list *src, uint16 *skill_id, uint16 *skill_lv, int16 *x, int16 *y, int *flag, int *unit_flag, int *val1, int *val2, int *val3, struct skill_unit_group *group) +static void skill_unitsetting2_unknown(struct block_list *src, uint16 *skill_id, uint16 *skill_lv, int16 *x, int16 *y, int *flag, int *unit_flag, int *val1, int *val2, int *val3, struct skill_unit_group *group) { nullpo_retv(group); nullpo_retv(val2); @@ -11883,7 +12421,7 @@ void skill_unitsetting2_unknown(struct block_list *src, uint16 *skill_id, uint16 /*========================================== * *------------------------------------------*/ -int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick) +static int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct block_list *ss; @@ -12107,7 +12645,7 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick if (sg->src_id == bl->id) break; //Does not affect the caster. clif->changetraplook(&src->bl,UNT_USED_TRAPS); - map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); sg->unit_id = UNT_USED_TRAPS; sg->limit = DIFF_TICK32(tick,sg->tick) + 1500; break; @@ -12138,19 +12676,19 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick return skill_id; } -void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +static void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) { } /*========================================== * *------------------------------------------*/ -int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int64 tick) +static int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct block_list *ss; struct map_session_data *tsd; - struct status_data *tstatus, *bst; + struct status_data *tstatus; struct status_change *tsc, *ssc; struct skill_unit_group_tickset *ts; enum sc_type type; @@ -12175,8 +12713,6 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 tstatus = status->get_status_data(bl); nullpo_ret(tstatus); - bst = status->get_base_status(bl); - nullpo_ret(bst); type = status->skill2sc(sg->skill_id); skill_id = sg->skill_id; @@ -12265,7 +12801,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); if (tsc && tsc->data[SC_AKAITSUKI] && heal) heal = ~heal + 1; - status->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); if (diff >= 500) sg->val1--; } @@ -12286,7 +12822,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 if (status->isimmune(bl)) heal = 0; clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); - status->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); } break; @@ -12403,7 +12939,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 } - map->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again. } break; @@ -12434,10 +12970,10 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_FREEZINGTRAP: case UNT_FIREPILLAR_ACTIVE: case UNT_CLAYMORETRAP: - if( sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP ) - map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick); + if (sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP) + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag | BL_SKILL | ~BCT_SELF, tick); else - map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); if (sg->unit_id != UNT_FIREPILLAR_ACTIVE) clif->changetraplook(&src->bl, sg->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS); sg->limit=DIFF_TICK32(tick,sg->tick)+1500 + @@ -12497,7 +13033,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 if( tsc && tsc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); - status->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); } } break; @@ -12551,7 +13087,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case 0: // Heal 1~9999 HP heal = rnd() %9999+1; clif->skill_nodamage(ss,bl,AL_HEAL,heal,1); - status->heal(bl,heal,0,0); + status->heal(bl, heal, 0, STATUS_HEAL_DEFAULT); break; case 1: // End all negative status status->change_clear_buffs(bl,2); @@ -12668,9 +13204,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_GROUNDDRIFT_POISON: case UNT_GROUNDDRIFT_WATER: case UNT_GROUNDDRIFT_FIRE: - map->foreachinrange(skill->trap_splash,&src->bl, - skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, - &src->bl,tick); + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); sg->unit_id = UNT_USED_TRAPS; //clif->changetraplook(&src->bl, UNT_FIREPILLAR_ACTIVE); sg->limit=DIFF_TICK32(tick,sg->tick)+1500; @@ -12698,7 +13232,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 } hp = tstatus->max_hp * hp / 100; sp = tstatus->max_sp * sp / 100; - status->heal(bl, hp, sp, 2); + status->heal(bl, hp, sp, STATUS_HEAL_SHOWEFFECT); sc_start(ss, bl, type, 100, sg->skill_lv, (sg->interval * 3) + 100); } // Reveal hidden players every 5 seconds. @@ -12731,7 +13265,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_REVERBERATION: clif->changetraplook(&src->bl,UNT_USED_TRAPS); - map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); sg->limit = DIFF_TICK32(tick,sg->tick)+1500; sg->unit_id = UNT_USED_TRAPS; break; @@ -12820,7 +13354,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 clif->skill_nodamage(&src->bl, bl, AL_HEAL, hp, 0); if( tsc && tsc->data[SC_AKAITSUKI] && hp ) hp = ~hp + 1; - status->heal(bl, hp, 0, 0); + status->heal(bl, hp, 0, STATUS_HEAL_DEFAULT); sc_start(ss, bl, type, 100, sg->skill_lv, sg->interval + 100); } break; @@ -12834,13 +13368,13 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 int hp = tstatus->max_hp / 100; //+1% each 5s if ((sg->val3) % 5) { //each 5s if (tstatus->def_ele == skill->get_ele(sg->skill_id,sg->skill_lv)) { - status->heal(bl, hp, 0, 2); + status->heal(bl, hp, 0, STATUS_HEAL_SHOWEFFECT); } else if( (sg->unit_id == UNT_FIRE_INSIGNIA && tstatus->def_ele == ELE_EARTH) || (sg->unit_id == UNT_WATER_INSIGNIA && tstatus->def_ele == ELE_FIRE) || (sg->unit_id == UNT_WIND_INSIGNIA && tstatus->def_ele == ELE_WATER) || (sg->unit_id == UNT_EARTH_INSIGNIA && tstatus->def_ele == ELE_WIND) ) { - status->heal(bl, -hp, 0, 0); + status->heal(bl, -hp, 0, STATUS_HEAL_DEFAULT); } } sg->val3++; //timer @@ -12852,6 +13386,8 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 if (tsc && (tsc->data[SC_HALLUCINATIONWALK] || tsc->data[SC_VACUUM_EXTREME])) { return 0; } else { + struct status_data *bst = status->get_base_status(bl); + nullpo_ret(bst); sg->limit -= 1000 * bst->str/20; sc_start(ss, bl, SC_VACUUM_EXTREME, 100, sg->skill_lv, sg->limit); @@ -12943,14 +13479,14 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 return skill_id; } -void skill_unit_onplace_timer_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +static void skill_unit_onplace_timer_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) { } /*========================================== * Triggered when a char steps out of a skill cell *------------------------------------------*/ -int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick) +static int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct status_change *sc; @@ -13016,7 +13552,7 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick) /*========================================== * Triggered when a char steps out of a skill group (entirely) [Skotlex] *------------------------------------------*/ -int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) +static int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) { struct status_change *sc; struct status_change_entry *sce; @@ -13131,7 +13667,7 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) * flag&1: Invoke onplace function (otherwise invoke onout) * flag&4: Invoke a onleft call (the unit might be scheduled for deletion) *------------------------------------------*/ -int skill_unit_effect(struct block_list* bl, va_list ap) +static int skill_unit_effect(struct block_list *bl, va_list ap) { struct skill_unit* su = va_arg(ap,struct skill_unit*); struct skill_unit_group* group; @@ -13175,7 +13711,7 @@ int skill_unit_effect(struct block_list* bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl, int64 damage, int64 tick) +static int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl, int64 damage, int64 tick) { struct skill_unit_group *sg; @@ -13210,7 +13746,7 @@ int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl, int64 da /*========================================== * *------------------------------------------*/ -int skill_check_condition_char_sub (struct block_list *bl, va_list ap) +static int skill_check_condition_char_sub(struct block_list *bl, va_list ap) { struct map_session_data *tsd = NULL; struct block_list *src = va_arg(ap, struct block_list *); @@ -13296,7 +13832,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) /*========================================== * Checks and stores partners for ensemble skills [Skotlex] *------------------------------------------*/ -int skill_check_pc_partner(struct map_session_data *sd, uint16 skill_id, uint16* skill_lv, int range, int cast_flag) +static int skill_check_pc_partner(struct map_session_data *sd, uint16 skill_id, uint16 *skill_lv, int range, int cast_flag) { static int c=0; static int p_sd[2] = { 0, 0 }; @@ -13355,7 +13891,7 @@ int skill_check_pc_partner(struct map_session_data *sd, uint16 skill_id, uint16* /*========================================== * *------------------------------------------*/ -int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap) +static int skill_check_condition_mob_master_sub(struct block_list *bl, va_list ap) { const struct mob_data *md = NULL; int src_id = va_arg(ap, int); @@ -13380,12 +13916,12 @@ int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap) * Determines if a given skill should be made to consume ammo * when used by the player. [Skotlex] *------------------------------------------*/ -int skill_isammotype (struct map_session_data *sd, int skill_id) +static int skill_isammotype(struct map_session_data *sd, int skill_id) { nullpo_ret(sd); return ( battle_config.arrow_decrement==2 && - (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) && + (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)) && skill_id != HT_PHANTASMIC && skill->get_type(skill_id) == BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_DAMAGE) && @@ -13396,7 +13932,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) /** * Checks whether a skill can be used in combos or not **/ -bool skill_is_combo( int skill_id ) +static bool skill_is_combo(int skill_id) { switch( skill_id ) { @@ -13422,7 +13958,7 @@ bool skill_is_combo( int skill_id ) return false; } -int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) +static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct status_data *st; struct status_change *sc; @@ -13492,7 +14028,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } if( pc_is90overweight(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_WEIGHTOVER,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } @@ -13625,15 +14161,28 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id // perform skill-specific checks (and actions) switch( skill_id ) { + case MC_VENDING: + case ALL_BUYING_STORE: + if (map->list[sd->bl.m].flag.novending) { + clif->message(sd->fd, msg_sd(sd, 276)); // "You can't open a shop on this map" + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); + return 0; + } + if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING)) { + clif->message(sd->fd, msg_sd(sd, 204)); // "You can't open a shop on this cell." + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); + return 0; + } + break; case SO_SPELLFIST: if(sd->skill_id_old != MG_FIREBOLT && sd->skill_id_old != MG_COLDBOLT && sd->skill_id_old != MG_LIGHTNINGBOLT){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH case SA_CASTCANCEL: if(sd->ud.skilltimer == INVALID_TIMER) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13648,7 +14197,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if(sc && sc->data[SC_RAISINGDRAGON]) skill_lv += sc->data[SC_RAISINGDRAGON]->val1; if(sd->spiritball >= skill_lv) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13669,7 +14218,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sc->data[SC_COMBOATTACK]) { if( sc->data[SC_COMBOATTACK]->val1 == MO_TRIPLEATTACK ) break; - clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_TRIPLEATTACK); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_TRIPLEATTACK, 0); } return 0; case MO_COMBOFINISH: @@ -13678,7 +14227,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[SC_COMBOATTACK] ) { if ( sc->data[SC_COMBOATTACK]->val1 == MO_CHAINCOMBO ) break; - clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_CHAINCOMBO); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_CHAINCOMBO, 0); } return 0; case CH_TIGERFIST: @@ -13687,7 +14236,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[SC_COMBOATTACK] ) { if ( sc->data[SC_COMBOATTACK]->val1 == MO_COMBOFINISH ) break; - clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_COMBOFINISH); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_COMBOFINISH, 0); } return 0; case CH_CHAINCRUSH: @@ -13696,7 +14245,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[SC_COMBOATTACK] ) { if( sc->data[SC_COMBOATTACK]->val1 == CH_TIGERFIST ) break; - clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, CH_TIGERFIST); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, CH_TIGERFIST, 0); } return 0; case MO_EXTREMITYFIST: @@ -13717,7 +14266,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } } else if (!unit->can_move(&sd->bl)) { //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex] - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13725,7 +14274,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case TK_MISSION: if ((sd->job & MAPID_UPPERMASK) != MAPID_TAEKWON) { // Cannot be used by Non-Taekwon classes - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13737,7 +14286,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case TK_JUMPKICK: if ((sd->job & MAPID_UPPERMASK) == MAPID_SOUL_LINKER) { // Soul Linkers cannot use this skill - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13770,7 +14319,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id int time; if(!(sc && sc->data[SC_DANCING])) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } time = 1000*(sc->data[SC_DANCING]->val3>>16); @@ -13779,7 +14328,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id (sc->data[SC_DANCING]->val1>>16)) //Dance Skill LV - time < skill->get_time2(skill_id,skill_lv)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } } @@ -13788,7 +14337,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case PR_BENEDICTIO: if (skill->check_pc_partner(sd, skill_id, &skill_lv, 1, 0) < 2) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13806,7 +14355,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case CG_HERMODE: if(!npc->check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill->get_splash(skill_id, skill_lv))) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13818,7 +14367,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id int x = sd->bl.x+(i%size-range); int y = sd->bl.y+(i/size-range); if (map->getcell(sd->bl.m, &sd->bl, x, y, CELL_CHKWALL)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } } @@ -13826,10 +14375,10 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case PR_REDEMPTIO: { - int exp; - if( ((exp = pc->nextbaseexp(sd)) > 0 && get_percentage(sd->status.base_exp, exp) < 1) || - ((exp = pc->nextjobexp(sd)) > 0 && get_percentage(sd->status.job_exp, exp) < 1)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); //Not enough exp. + int64 exp; + if (((exp = pc->nextbaseexp(sd)) > 0 && get_percentage64(sd->status.base_exp, exp) < 1) || + ((exp = pc->nextjobexp(sd)) > 0 && get_percentage64(sd->status.job_exp, exp) < 1)) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); //Not enough exp. return 0; } break; @@ -13838,7 +14387,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case AM_TWILIGHT3: if (!party->skill_check(sd, sd->status.party_id, skill_id, skill_lv)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13849,7 +14398,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; if (sd->bl.m == sd->feel_map[skill_id-SG_SUN_WARM].m) break; - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; break; case SG_SUN_COMFORT: @@ -13860,7 +14409,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sd->bl.m == sd->feel_map[skill_id-SG_SUN_COMFORT].m && (battle_config.allow_skill_without_day || pc->sg_info[skill_id-SG_SUN_COMFORT].day_func())) break; - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; case SG_FUSION: if (sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_STAR) @@ -13869,7 +14418,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id //Only invoke on skill begin cast (instant cast skill). [Kevin] if( require.sp > 0 ) { if (st->sp < (unsigned int)require.sp) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SP_INSUFFICIENT,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0, 0); else status_zap(&sd->bl, 0, require.sp); } @@ -13878,7 +14427,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case GD_REGENERATION: case GD_RESTORE: if (!map_flag_gvg2(sd->bl.m)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH @@ -13890,7 +14439,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case GS_GLITTERING: if(sd->spiritball >= 10) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13901,13 +14450,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id #else if (st->hp < 2) { #endif - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH case NJ_BUNSINJYUTSU: if (!(sc && sc->data[SC_NJ_NEN])) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13915,7 +14464,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case NJ_ZENYNAGE: case KO_MUCHANAGE: if(sd->status.zeny < require.zeny) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_MONEY,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_MONEY, 0, 0); return 0; } break; @@ -13925,14 +14474,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case AM_CALLHOMUN: //Can't summon if a hom is already out if (sd->status.hom_id && sd->hd && !sd->hd->homunculus.vaporize) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case AM_REST: //Can't vapo homun if you don't have an active homun or it's hp is < 80% if (!homun_alive(sd->hd) || sd->hd->battle_status.hp < (sd->hd->battle_status.max_hp*80/100)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13941,12 +14490,12 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id **/ case AB_ANCILLA: { - int count = 0, i; - for( i = 0; i < MAX_INVENTORY; i ++ ) + int count = 0; + for (int i = 0; i < sd->status.inventorySize; i ++) if (sd->status.inventory[i].nameid == ITEMID_ANSILA) count += sd->status.inventory[i].amount; if( count >= 3 ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_ANCILLA_NUMOVER, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_ANCILLA_NUMOVER, 0, 0); return 0; } } @@ -13966,8 +14515,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id && ((idx = pc->search_inventory(sd,require.itemid[0])) == INDEX_NOT_FOUND || sd->status.inventory[idx].amount < require.amount[0]) ) { - //clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_ITEM,require.amount[0],require.itemid[0]); - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + //clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_ITEM, require.amount[0], 0, require.itemid[0]); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -13987,7 +14536,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id switch(skill_id){ case WL_TETRAVORTEX: if( i < 4 ){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; @@ -13996,13 +14545,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[j] ) i++; if( i == 0 ){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON_NONE,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON_NONE, 0, 0); return 0; } break; default: if( i == 5 ){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0, 0); return 0; } } @@ -14013,14 +14562,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id **/ case GC_HALLUCINATIONWALK: if( sc && (sc->data[SC_HALLUCINATIONWALK] || sc->data[SC_HALLUCINATIONWALK_POSTDELAY]) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case GC_COUNTERSLASH: case GC_WEAPONCRUSH: if( !(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == GC_WEAPONBLOCKING) ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_WEAPONBLOCKING, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_WEAPONBLOCKING, 0, 0); return 0; } break; @@ -14029,25 +14578,25 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id **/ case RA_WUGMASTERY: if( pc_isfalcon(sd) || pc_isridingwug(sd) || sd->sc.data[SC__GROOMY] ) { - clif->skill_fail(sd,skill_id,sd->sc.data[SC__GROOMY]?USESKILL_FAIL_MANUAL_NOTIFY:USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, sd->sc.data[SC__GROOMY] ? USESKILL_FAIL_MANUAL_NOTIFY : USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; case RA_WUGSTRIKE: if( !pc_iswug(sd) && !pc_isridingwug(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; case RA_WUGRIDER: if( pc_isfalcon(sd) || ( !pc_isridingwug(sd) && !pc_iswug(sd) ) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; case RA_WUGDASH: if(!pc_isridingwug(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; @@ -14056,13 +14605,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id **/ case LG_BANDING: if( sc && sc->data[SC_INSPIRATION] ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case LG_PRESTIGE: if( sc && (sc->data[SC_BANDING] || sc->data[SC_INSPIRATION]) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14071,7 +14620,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[SC_INSPIRATION] ) return 1; // Don't check for partner. if( !(sc && sc->data[SC_BANDING]) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL, 0, 0); return 0; } if( sc->data[SC_BANDING] && @@ -14082,12 +14631,12 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sc && sc->data[SC_COMBOATTACK] ) { if( sc->data[SC_COMBOATTACK]->val1 == SR_DRAGONCOMBO ) break; - clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, SR_DRAGONCOMBO); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, SR_DRAGONCOMBO, 0); } return 0; case SR_CRESCENTELBOW: if( sc && sc->data[SC_CRESCENTELBOW] ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_DUPLICATE, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_DUPLICATE, 0, 0); return 0; } break; @@ -14104,7 +14653,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if( sd->spiritball > 0 ) sd->spiritball_old = require.spiritball = sd->spiritball; else { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14115,7 +14664,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case SC_MANHOLE: case SC_DIMENSIONDOOR: if( sc && sc->data[SC_MAGNETICFIELD] ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14123,7 +14672,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id int count; count = skill->check_pc_partner(sd, skill_id, &skill_lv, skill->get_splash(skill_id,skill_lv), 0); if( count < 1 ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_HELPER,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_HELPER, 0, 0); return 0; } else require.sp -= require.sp * 20 * count / 100; // -20% each W/M in the party. @@ -14133,7 +14682,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sd->equip_index[EQI_HAND_R] < 0 || !itemid_is_pilebunker(sd->status.inventory[sd->equip_index[EQI_HAND_R]].nameid) ) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0, 0); return 0; } break; @@ -14141,7 +14690,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (( sd->equip_index[EQI_ACC_L] >= 0 && sd->status.inventory[sd->equip_index[EQI_ACC_L]].nameid == ITEMID_HOVERING_BOOSTER ) || ( sd->equip_index[EQI_ACC_R] >= 0 && sd->status.inventory[sd->equip_index[EQI_ACC_R]].nameid == ITEMID_HOVERING_BOOSTER )); else { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14149,25 +14698,25 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case SO_ELECTRICWALK: // Can't be casted until you've walked all cells. if( sc && sc->data[SC_PROPERTYWALK] && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case SO_EL_CONTROL: if( !sd->status.ele_id || !sd->ed ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_EL_SUMMON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_EL_SUMMON, 0, 0); return 0; } break; case RETURN_TO_ELDICASTES: if( pc_ismadogear(sd) ) { //Cannot be used if Mado is equipped. - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case CR_REFLECTSHIELD: if( sc && sc->data[SC_KYOMU] && rnd()%100 < 5 * sc->data[SC_KYOMU]->val1 ){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14176,14 +14725,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case KO_KAZEHU_SEIRAN: case KO_DOHU_KOUKAI: if (sd->charm_type == skill->get_ele(skill_id, skill_lv) && sd->charm_count >= MAX_SPIRITCHARM) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0, 0); return 0; } break; case KO_KAIHOU: case KO_ZENKAI: if (sd->charm_type == CHARM_TYPE_NONE || sd->charm_count <= 0) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0, 0); return 0; } break; @@ -14198,67 +14747,67 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id switch(require.state) { case ST_HIDING: if(!(sc && sc->option&OPTION_HIDE)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_CLOAKING: if(!pc_iscloaking(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_HIDDEN: if(!pc_ishiding(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_RIDING: if (!pc_isridingpeco(sd) && !pc_isridingdragon(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_FALCON: if(!pc_isfalcon(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_CARTBOOST: if(!(sc && sc->data[SC_CARTBOOST])) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH case ST_CART: if(!pc_iscarton(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CART,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CART, 0, 0); return 0; } break; case ST_SHIELD: - if(sd->status.shield <= 0) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + if (!sd->has_shield) { + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_SIGHT: if(!(sc && sc->data[SC_SIGHT])) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_EXPLOSIONSPIRITS: if(!(sc && sc->data[SC_EXPLOSIONSPIRITS])) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_EXPLOSIONSPIRITS,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_EXPLOSIONSPIRITS, 0, 0); return 0; } break; case ST_RECOV_WEIGHT_RATE: if(battle_config.natural_heal_weight_rate <= 100 && sd->weight*100/sd->max_weight >= (unsigned int)battle_config.natural_heal_weight_rate) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14267,7 +14816,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id sd->ud.canmove_tick = timer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] if (!unit->can_move(&sd->bl)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14276,65 +14825,65 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKWATER)) break; - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; case ST_RIDINGDRAGON: if( !pc_isridingdragon(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_DRAGON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_DRAGON, 0, 0); return 0; } break; case ST_WUG: if( !pc_iswug(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_RIDINGWUG: if( !pc_isridingwug(sd) ){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; case ST_MADO: if( !pc_ismadogear(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_MADOGEAR, 0, 0); return 0; } break; case ST_ELEMENTALSPIRIT: if(!sd->ed) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_EL_SUMMON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_EL_SUMMON, 0, 0); return 0; } break; case ST_POISONINGWEAPON: if (!(sc && sc->data[SC_POISONINGWEAPON])) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_POISONINGWEAPON, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_POISONINGWEAPON, 0, 0); return 0; } break; case ST_ROLLINGCUTTER: if (!(sc && sc->data[SC_ROLLINGCUTTER])) { - clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CONDITION, 0, 0); return 0; } break; case ST_MH_FIGHTING: if (!(sc && sc->data[SC_STYLE_CHANGE] && sc->data[SC_STYLE_CHANGE]->val2 == MH_MD_FIGHTING)){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH case ST_MH_GRAPPLING: if (!(sc && sc->data[SC_STYLE_CHANGE] && sc->data[SC_STYLE_CHANGE]->val2 == MH_MD_GRAPPLING)){ - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } FALLTHROUGH case ST_PECO: if (!pc_isridingpeco(sd)) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } break; @@ -14343,27 +14892,27 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if(require.mhp > 0 && get_percentage(st->hp, st->max_hp) > require.mhp) { //mhp is the max-hp-requirement, that is, //you must have this % or less of HP to cast it. - clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0, 0); return 0; } if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0, 0); return 0; } if( require.sp > 0 && st->sp < (unsigned int)require.sp) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SP_INSUFFICIENT,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0, 0); return 0; } if( require.zeny > 0 && sd->status.zeny < require.zeny ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_MONEY,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_MONEY, 0, 0); return 0; } if( require.spiritball > 0 && sd->spiritball < require.spiritball) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_SPIRITS,require.spiritball); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SPIRITS, require.spiritball, 0); return 0; } @@ -14378,27 +14927,27 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 1; } -int skill_check_condition_castbegin_off_unknown(struct status_change *sc, uint16 *skill_id) +static int skill_check_condition_castbegin_off_unknown(struct status_change *sc, uint16 *skill_id) { return -1; } -int skill_check_condition_castbegin_mount_unknown(struct status_change *sc, uint16 *skill_id) +static int skill_check_condition_castbegin_mount_unknown(struct status_change *sc, uint16 *skill_id) { return 0; } -int skill_check_condition_castbegin_madogear_unknown(struct status_change *sc, uint16 *skill_id) +static int skill_check_condition_castbegin_madogear_unknown(struct status_change *sc, uint16 *skill_id) { return 0; } -int skill_check_condition_castbegin_unknown(struct status_change *sc, uint16 *skill_id) +static int skill_check_condition_castbegin_unknown(struct status_change *sc, uint16 *skill_id) { return -1; } -int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) +static int skill_check_condition_castend(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct skill_condition require; struct status_data *st; @@ -14445,7 +14994,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, if( sd->skillitem == skill_id ) return 1; if( pc_is90overweight(sd) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_WEIGHTOVER,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_WEIGHTOVER, 0, 0); return 0; } @@ -14479,7 +15028,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, || (skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2) ) { //Fails when: exceed max limit. There are other plant types already out. - clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } } @@ -14499,7 +15048,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, MOBID_SILVERSNIPER, skill_id, &c); } if( c >= maxcount ) { - clif->skill_fail(sd , skill_id, USESKILL_FAIL_SUMMON, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0, 0); return 0; } } @@ -14509,14 +15058,15 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, int c = 0; i = map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, MOBID_KO_KAGE, skill_id, &c); if( c >= skill->get_maxcount(skill_id,skill_lv) || c != i) { - clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); return 0; } } break; default: - skill->check_condition_castend_unknown(sd, &skill_id, &skill_lv); - break; + if (!skill->check_condition_castend_unknown(sd, &skill_id, &skill_lv)) + break; + return 0; } st = &sd->battle_status; @@ -14524,19 +15074,19 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, require = skill->get_requirement(sd,skill_id,skill_lv); if( require.hp > 0 && st->hp <= (unsigned int)require.hp) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0, 0); return 0; } if( require.weapon && !pc_check_weapontype(sd,require.weapon) ) { - clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0, 0); return 0; } if( require.ammo ) { //Skill requires stuff equipped in the arrow slot. if((i=sd->equip_index[EQI_AMMO]) < 0 || !sd->inventory_data[i] ) { if( require.ammo&1<<8 ) - clif->skill_fail(sd,skill_id,USESKILL_FAIL_CANONBALL,0); + clif->skill_fail(sd, skill_id, USESKILL_FAIL_CANONBALL, 0, 0); else clif->arrow_fail(sd,0); return 0; @@ -14549,10 +15099,10 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, clif->messagecolor_self(sd->fd, COLOR_RED, e_msg); return 0; } - if (!(require.ammo&1<<sd->inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message + if (!(require.ammo&1<<sd->inventory_data[i]->subtype)) { //Ammo type check. Send the "wrong weapon type" message //which is the closest we have to wrong ammo type. [Skotlex] clif->arrow_fail(sd,0); //Haplo suggested we just send the equip-arrows message instead. [Skotlex] - //clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); + //clif->skill_fail(sd, skill_id, USESKILL_FAIL_THIS_WEAPON, 0, 0); return 0; } } @@ -14591,11 +15141,11 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, cause = USESKILL_FAIL_NEED_EQUIPMENT; /* Fall through */ default: - clif->skill_fail(sd, skill_id, cause, max(1,require.amount[i])|(require.itemid[i] << 16)); + clif->skill_fail(sd, skill_id, cause, max(1, require.amount[i]), require.itemid[i]); return 0; } } - clif->skill_fail(sd, skill_id, cause, 0); + clif->skill_fail(sd, skill_id, cause, 0, 0); return 0; } } @@ -14603,13 +15153,14 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, return 1; } -void skill_check_condition_castend_unknown(struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv) +static bool skill_check_condition_castend_unknown(struct map_session_data *sd, uint16 *skill_id, uint16 *skill_lv) { + return false; } // type&2: consume items (after skill was used) // type&1: consume the others (before skill was used) -int skill_consume_requirement(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type) +static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type) { struct skill_condition req; @@ -14691,7 +15242,7 @@ int skill_consume_requirement(struct map_session_data *sd, uint16 skill_id, uint return 1; } -struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) +static struct skill_condition skill_get_requirement(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct skill_condition req; struct status_data *st; @@ -14818,7 +15369,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 } for( i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++ ) { - if( (skill_id == AM_POTIONPITCHER || skill_id == CR_SLIMPITCHER || skill_id == CR_CULTIVATION) && i != skill_lv%11 - 1 ) + int item_idx = (skill_lv - 1) % MAX_SKILL_ITEM_REQUIRE; + if ((skill_id == AM_POTIONPITCHER || skill_id == CR_SLIMPITCHER || skill_id == CR_CULTIVATION) && i != item_idx) continue; switch( skill_id ) { @@ -15021,24 +15573,24 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 return req; } -bool skill_get_requirement_off_unknown(struct status_change *sc, uint16 *skill_id) +static bool skill_get_requirement_off_unknown(struct status_change *sc, uint16 *skill_id) { return false; } -bool skill_get_requirement_item_unknown(struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, uint16 *idx, int *i) +static bool skill_get_requirement_item_unknown(struct status_change *sc, struct map_session_data *sd, uint16 *skill_id, uint16 *skill_lv, uint16 *idx, int *i) { return false; } -void skill_get_requirement_unknown(struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req) +static void skill_get_requirement_unknown(struct status_change *sc, struct map_session_data *sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req) { } /*========================================== * Does cast-time reductions based on dex, item bonuses and config setting *------------------------------------------*/ -int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) +static int skill_castfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv) { int time = skill->get_cast(skill_id, skill_lv); @@ -15089,7 +15641,7 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) /*========================================== * Does cast-time reductions based on sc data. *------------------------------------------*/ -int skill_castfix_sc (struct block_list *bl, int time) +static int skill_castfix_sc(struct block_list *bl, int time) { struct status_change *sc = status->get_sc(bl); @@ -15125,7 +15677,7 @@ int skill_castfix_sc (struct block_list *bl, int time) return time; } -int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv) +static int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv) { #ifdef RENEWAL_CAST struct status_change *sc = status->get_sc(bl); @@ -15268,7 +15820,7 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 /*========================================== * Does delay reductions based on dex/agi, sc data, item bonuses, ... *------------------------------------------*/ -int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) +static int skill_delay_fix(struct block_list *bl, uint16 skill_id, uint16 skill_lv) { int delaynodex = skill->get_delaynodex(skill_id, skill_lv); int time = skill->get_delay(skill_id, skill_lv); @@ -15368,7 +15920,7 @@ struct square { int val2[5]; }; -void skill_brandishspear_first (struct square *tc, uint8 dir, int16 x, int16 y) +static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int16 y) { nullpo_retv(tc); @@ -15464,7 +16016,7 @@ void skill_brandishspear_first (struct square *tc, uint8 dir, int16 x, int16 y) } -void skill_brandishspear_dir (struct square* tc, uint8 dir, int are) +static void skill_brandishspear_dir(struct square *tc, uint8 dir, int are) { int c; nullpo_retv(tc); @@ -15483,7 +16035,7 @@ void skill_brandishspear_dir (struct square* tc, uint8 dir, int are) } } -void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +static void skill_brandishspear(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { int c,n=4; uint8 dir; @@ -15538,7 +16090,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s /*========================================== * Weapon Repair [Celest/DracoRPG] *------------------------------------------*/ -void skill_repairweapon (struct map_session_data *sd, int idx) +static void skill_repairweapon(struct map_session_data *sd, int idx) { int material; int materials[4] = { @@ -15555,15 +16107,18 @@ void skill_repairweapon (struct map_session_data *sd, int idx) if ( !( target_sd = map->id2sd(sd->menuskill_val) ) ) //Failed.... return; - if( idx == 0xFFFF ) // No item selected ('Cancel' clicked) + if (idx == 0xFFFF || idx == -1) // No item selected ('Cancel' clicked) return; - if( idx < 0 || idx >= MAX_INVENTORY ) + if (idx < 0 || idx >= sd->status.inventorySize) return; //Invalid index?? item = &target_sd->status.inventory[idx]; if( item->nameid <= 0 || (item->attribute & ATTR_BROKEN) == 0 ) return; //Again invalid item.... + if (item->card[0] == CARD0_PET) + return; + if( sd != target_sd && !battle->check_range(&sd->bl,&target_sd->bl, skill->get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){ clif->item_repaireffect(sd,idx,1); return; @@ -15574,7 +16129,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) else material = materials[2]; // Armors consume 1 Steel if (pc->search_inventory(sd,material) == INDEX_NOT_FOUND) { - clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, sd->menuskill_id, USESKILL_FAIL_LEVEL, 0, 0); return; } @@ -15583,7 +16138,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) item->attribute |= ATTR_BROKEN; item->attribute ^= ATTR_BROKEN; /* clear broken state */ - clif->equiplist(target_sd); + clif->equipList(target_sd); pc->delitem(sd, pc->search_inventory(sd, material), 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME); // FIXME: is this the correct reason flag? @@ -15596,13 +16151,13 @@ void skill_repairweapon (struct map_session_data *sd, int idx) /*========================================== * Item Appraisal *------------------------------------------*/ -void skill_identify (struct map_session_data *sd, int idx) +static void skill_identify(struct map_session_data *sd, int idx) { int flag=1; nullpo_retv(sd); sd->state.workinprogress = 0; - if(idx >= 0 && idx < MAX_INVENTORY) { + if (idx >= 0 && idx < sd->status.inventorySize) { if(sd->status.inventory[idx].nameid > 0 && sd->status.inventory[idx].identify == 0 ){ flag=0; sd->status.inventory[idx].identify=1; @@ -15614,11 +16169,11 @@ void skill_identify (struct map_session_data *sd, int idx) /*========================================== * Weapon Refine [Celest] *------------------------------------------*/ -void skill_weaponrefine (struct map_session_data *sd, int idx) +static void skill_weaponrefine(struct map_session_data *sd, int idx) { nullpo_retv(sd); - if (idx >= 0 && idx < MAX_INVENTORY) { + if (idx >= 0 && idx < sd->status.inventorySize) { struct item *item; struct item_data *ditem = sd->inventory_data[idx]; item = &sd->status.inventory[idx]; @@ -15634,7 +16189,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) int i = 0, per; if( ditem->flag.no_refine ) { // if the item isn't refinable - clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, sd->menuskill_id, USESKILL_FAIL_LEVEL, 0, 0); return; } if( item->refine >= sd->menuskill_val || item->refine >= 10 ){ @@ -15646,7 +16201,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) return; } - per = status->get_refine_chance(ditem->wlv, (int)item->refine) * 10; + per = status->get_refine_chance(ditem->wlv, (int)item->refine, REFINE_CHANCE_TYPE_NORMAL) * 10; // Aegis leaked formula. [malufett] if (sd->status.class == JOB_MECHANIC_T) @@ -15666,7 +16221,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) } clif->delitem(sd, idx, 1, DELITEM_NORMAL); clif->upgrademessage(sd->fd, 0,item->nameid); - clif->inventorylist(sd); + clif->inventoryList(sd); clif->refine(sd->fd,0,idx,item->refine); if (ep) pc->equipitem(sd,idx,ep); @@ -15703,7 +16258,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) /*========================================== * *------------------------------------------*/ -int skill_autospell (struct map_session_data *sd, uint16 skill_id) +static int skill_autospell(struct map_session_data *sd, uint16 skill_id) { uint16 skill_lv; int maxlv=1,lv; @@ -15746,7 +16301,7 @@ int skill_autospell (struct map_session_data *sd, uint16 skill_id) /*========================================== * Sitting skills functions. *------------------------------------------*/ -int skill_sit_count(struct block_list *bl, va_list ap) +static int skill_sit_count(struct block_list *bl, va_list ap) { int type = va_arg(ap, int); struct map_session_data *sd = NULL; @@ -15767,7 +16322,7 @@ int skill_sit_count(struct block_list *bl, va_list ap) return 0; } -int skill_sit_in(struct block_list *bl, va_list ap) +static int skill_sit_in(struct block_list *bl, va_list ap) { int type = va_arg(ap, int); struct map_session_data *sd = NULL; @@ -15791,7 +16346,7 @@ int skill_sit_in(struct block_list *bl, va_list ap) return 0; } -int skill_sit_out(struct block_list *bl, va_list ap) +static int skill_sit_out(struct block_list *bl, va_list ap) { int type = va_arg(ap, int); struct map_session_data *sd = NULL; @@ -15810,7 +16365,7 @@ int skill_sit_out(struct block_list *bl, va_list ap) return 0; } -int skill_sit (struct map_session_data *sd, int type) +static int skill_sit(struct map_session_data *sd, int type) { int flag = 0; int range = 0, lv; @@ -15850,7 +16405,7 @@ int skill_sit (struct map_session_data *sd, int type) /*========================================== * *------------------------------------------*/ -int skill_frostjoke_scream(struct block_list *bl, va_list ap) +static int skill_frostjoke_scream(struct block_list *bl, va_list ap) { struct block_list *src; uint16 skill_id,skill_lv; @@ -15883,7 +16438,7 @@ int skill_frostjoke_scream(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag) +static void skill_unitsetmapcell(struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag) { int range = skill->get_unit_range(skill_id,skill_lv); int x,y; @@ -15897,7 +16452,7 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill /*========================================== * *------------------------------------------*/ -int skill_attack_area(struct block_list *bl, va_list ap) +static int skill_attack_area(struct block_list *bl, va_list ap) { struct block_list *src,*dsrc; int atk_type,skill_id,skill_lv,flag,type; @@ -15940,7 +16495,7 @@ int skill_attack_area(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_clear_group (struct block_list *bl, int flag) +static int skill_clear_group(struct block_list *bl, int flag) { struct unit_data *ud = unit->bl2ud(bl); struct skill_unit_group *group[MAX_SKILLUNITGROUP]; @@ -15984,7 +16539,7 @@ int skill_clear_group (struct block_list *bl, int flag) /*========================================== * Returns the first element field found [Skotlex] *------------------------------------------*/ -struct skill_unit_group *skill_locate_element_field(struct block_list *bl) +static struct skill_unit_group *skill_locate_element_field(struct block_list *bl) { struct unit_data *ud = unit->bl2ud(bl); int i; @@ -16007,7 +16562,7 @@ struct skill_unit_group *skill_locate_element_field(struct block_list *bl) } // for graffiti cleaner [Valaris] -int skill_graffitiremover(struct block_list *bl, va_list ap) +static int skill_graffitiremover(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; @@ -16023,7 +16578,7 @@ int skill_graffitiremover(struct block_list *bl, va_list ap) return 0; } -int skill_greed(struct block_list *bl, va_list ap) +static int skill_greed(struct block_list *bl, va_list ap) { struct block_list *src = va_arg(ap, struct block_list *); @@ -16040,7 +16595,7 @@ int skill_greed(struct block_list *bl, va_list ap) } //For Ranger's Detonator [Jobbie/3CeAM] -int skill_detonator(struct block_list *bl, va_list ap) +static int skill_detonator(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; struct block_list *src = va_arg(ap,struct block_list *); @@ -16074,10 +16629,10 @@ int skill_detonator(struct block_list *bl, va_list ap) case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); + skill->trap_do_splash(bl, su->group->skill_id, su->group->skill_lv, su->group->bl_flag | BL_SKILL | ~BCT_SELF, su->group->tick); break; default: - map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); + skill->trap_do_splash(bl, su->group->skill_id, su->group->skill_lv, su->group->bl_flag, su->group->tick); } clif->changetraplook(bl, UNT_USED_TRAPS); su->group->limit = DIFF_TICK32(timer->gettick(),su->group->tick) + @@ -16091,7 +16646,7 @@ int skill_detonator(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_cell_overlap(struct block_list *bl, va_list ap) +static int skill_cell_overlap(struct block_list *bl, va_list ap) { uint16 skill_id; int *alive; @@ -16189,7 +16744,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_chastle_mob_changetarget(struct block_list *bl, va_list ap) +static int skill_chastle_mob_changetarget(struct block_list *bl, va_list ap) { struct unit_data *ud = unit->bl2ud(bl); struct block_list *from_bl = va_arg(ap, struct block_list *); @@ -16210,16 +16765,38 @@ int skill_chastle_mob_changetarget(struct block_list *bl, va_list ap) return 0; } +/** + * Does final adjustments (e.g. count enemies affected by splash) then runs trap splash function (skill_trap_splash). + * + * @param bl : trap skill unit's bl + * @param skill_id : Trap Skill ID + * @param skill_lv : Trap Skill Level + * @param bl_flag : Flag representing units affected by this trap + * @param tick : tick related to this trap + */ +static void skill_trap_do_splash(struct block_list *bl, uint16 skill_id, uint16 skill_lv, int bl_flag, int64 tick) +{ + int enemy_count = 0; + + if (skill->get_nk(skill_id) & NK_SPLASHSPLIT) { + enemy_count = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, bl, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); + enemy_count = max(1, enemy_count); // Don't let enemy_count be 0 when spliting trap damage + } + + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(skill_id, skill_lv), bl_flag, bl, tick, enemy_count); +} + /*========================================== * *------------------------------------------*/ -int skill_trap_splash(struct block_list *bl, va_list ap) +static int skill_trap_splash(struct block_list *bl, va_list ap) { struct block_list *src = va_arg(ap, struct block_list *); int64 tick = va_arg(ap, int64); struct skill_unit *src_su = NULL; struct skill_unit_group *sg; struct block_list *ss; + int enemy_count = va_arg(ap, int); nullpo_ret(bl); nullpo_ret(src); @@ -16314,7 +16891,7 @@ int skill_trap_splash(struct block_list *bl, va_list ap) } /* Fall through */ default: - skill->attack(skill->get_type(sg->skill_id),ss,src,bl,sg->skill_id,sg->skill_lv,tick,0); + skill->attack(skill->get_type(sg->skill_id), ss, src, bl, sg->skill_id, sg->skill_lv, tick, enemy_count); break; } return 1; @@ -16323,7 +16900,7 @@ int skill_trap_splash(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_enchant_elemental_end(struct block_list *bl, int type) +static int skill_enchant_elemental_end(struct block_list *bl, int type) { struct status_change *sc; const enum sc_type scs[] = { SC_ENCHANTPOISON, SC_ASPERSIO, SC_PROPERTYFIRE, SC_PROPERTYWATER, SC_PROPERTYWIND, SC_PROPERTYGROUND, SC_PROPERTYDARK, SC_PROPERTYTELEKINESIS, SC_ENCHANTARMS }; @@ -16340,7 +16917,7 @@ int skill_enchant_elemental_end(struct block_list *bl, int type) return 0; } -bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce) +static bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce) { bool wall = true; @@ -16379,7 +16956,7 @@ bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce /** * Verifies if an user can use SC_CLOAKING **/ -bool skill_can_cloak(struct map_session_data *sd) +static bool skill_can_cloak(struct map_session_data *sd) { nullpo_retr(false, sd); @@ -16397,7 +16974,7 @@ bool skill_can_cloak(struct map_session_data *sd) * Verifies if an user can still be cloaked (AS_CLOAKING) * Is called via map->foreachinrange when any kind of wall disapears **/ -int skill_check_cloaking_end(struct block_list *bl, va_list ap) +static int skill_check_cloaking_end(struct block_list *bl, va_list ap) { struct map_session_data *sd = BL_CAST(BL_PC, bl); @@ -16407,7 +16984,7 @@ int skill_check_cloaking_end(struct block_list *bl, va_list ap) return 0; } -bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *sce) +static bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *sce) { bool wall = true; @@ -16435,7 +17012,7 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s return wall; } -bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) +static bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) { struct status_change *sc; @@ -16474,7 +17051,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) /*========================================== * *------------------------------------------*/ -struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2) +static struct skill_unit *skill_initunit(struct skill_unit_group *group, int idx, int x, int y, int val1, int val2) { struct skill_unit *su; @@ -16527,7 +17104,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int /*========================================== * *------------------------------------------*/ -int skill_delunit (struct skill_unit* su) +static int skill_delunit(struct skill_unit *su) { struct skill_unit_group *group; @@ -16603,24 +17180,25 @@ int skill_delunit (struct skill_unit* su) * *------------------------------------------*/ /// Returns the target skill_unit_group or NULL if not found. -struct skill_unit_group* skill_id2group(int group_id) +static struct skill_unit_group *skill_id2group(int group_id) { return (struct skill_unit_group*)idb_get(skill->group_db, group_id); } /// Returns a new group_id that isn't being used in skill->group_db. /// Fatal error if nothing is available. -int skill_get_new_group_id(void) +static int skill_get_new_group_id(void) { - if( skill->unit_group_newid >= MAX_SKILL_DB && skill->id2group(skill->unit_group_newid) == NULL ) + if (skill->unit_group_newid > MAX_SKILL_ID && skill->id2group(skill->unit_group_newid) == NULL) return skill->unit_group_newid++;// available - {// find next id + + { + // find next id int base_id = skill->unit_group_newid; - while( base_id != ++skill->unit_group_newid ) - { - if( skill->unit_group_newid < MAX_SKILL_DB ) - skill->unit_group_newid = MAX_SKILL_DB; - if( skill->id2group(skill->unit_group_newid) == NULL ) + while (base_id != ++skill->unit_group_newid) { + if (skill->unit_group_newid <= MAX_SKILL_ID) + skill->unit_group_newid = MAX_SKILL_ID + 1; + if (skill->id2group(skill->unit_group_newid) == NULL) return skill->unit_group_newid++;// available } // full loop, nothing available @@ -16629,7 +17207,7 @@ int skill_get_new_group_id(void) } } -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) +static 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) { struct unit_data* ud = unit->bl2ud( src ); struct skill_unit_group* group; @@ -16663,6 +17241,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, group->party_id = status->get_party_id(src); group->guild_id = status->get_guild_id(src); group->bg_id = bg->team_get_id(src); + group->clan_id = clan->get_id(src); group->group_id = skill->get_new_group_id(); CREATE(group->unit.data, struct skill_unit, count); group->unit.count = count; @@ -16691,7 +17270,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, /*========================================== * *------------------------------------------*/ -int skill_delunitgroup(struct skill_unit_group *group, const char *file, int line, const char *func) +static int skill_delunitgroup(struct skill_unit_group *group, const char *file, int line, const char *func) { struct block_list* src; struct unit_data *ud; @@ -16827,7 +17406,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char *file, int lin /*========================================== * *------------------------------------------*/ -int skill_clear_unitgroup (struct block_list *src) +static int skill_clear_unitgroup(struct block_list *src) { struct unit_data *ud = unit->bl2ud(src); @@ -16842,7 +17421,7 @@ int skill_clear_unitgroup (struct block_list *src) /*========================================== * *------------------------------------------*/ -struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list *bl, struct skill_unit_group *group, int64 tick) +static struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list *bl, struct skill_unit_group *group, int64 tick) { int i,j=-1,s,id; struct unit_data *ud; @@ -16884,7 +17463,7 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list /*========================================== * *------------------------------------------*/ -int skill_unit_timer_sub_onplace(struct block_list* bl, va_list ap) +static int skill_unit_timer_sub_onplace(struct block_list *bl, va_list ap) { struct skill_unit* su; struct skill_unit_group* group; @@ -16914,7 +17493,7 @@ int skill_unit_timer_sub_onplace(struct block_list* bl, va_list ap) /** * @see DBApply */ -int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) +static int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) { struct skill_unit* su; struct skill_unit_group* group; @@ -16985,7 +17564,7 @@ int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = group->item_id ? group->item_id : ITEMID_BOOBY_TRAP; item_tmp.identify = 1; - map->addflooritem(bl, &item_tmp, 1, bl->m, bl->x, bl->y, 0, 0, 0, 0); + map->addflooritem(bl, &item_tmp, 1, bl->m, bl->x, bl->y, 0, 0, 0, 0, false); } skill->delunit(su); } @@ -17027,7 +17606,7 @@ int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) break; } clif->changetraplook(bl,UNT_USED_TRAPS); - map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); + skill->trap_do_splash(bl, group->skill_id, group->skill_lv, group->bl_flag, tick); group->limit = DIFF_TICK32(tick,group->tick)+1500; su->limit = DIFF_TICK32(tick,group->tick)+1500; group->unit_id = UNT_USED_TRAPS; @@ -17134,7 +17713,7 @@ int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap) /*========================================== * Executes on all skill units every SKILLUNITTIMER_INTERVAL milliseconds. *------------------------------------------*/ -int skill_unit_timer(int tid, int64 tick, int id, intptr_t data) +static int skill_unit_timer(int tid, int64 tick, int id, intptr_t data) { map->freeblock_lock(); @@ -17148,7 +17727,7 @@ int skill_unit_timer(int tid, int64 tick, int id, intptr_t data) /*========================================== * *------------------------------------------*/ -int skill_unit_move_sub(struct block_list* bl, va_list ap) +static int skill_unit_move_sub(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; struct skill_unit_group *group = NULL; @@ -17248,7 +17827,7 @@ int skill_unit_move_sub(struct block_list* bl, va_list ap) * units to figure out when they have left a group. * flag&4: Force a onleft event (triggered when the bl is killed, for example) *------------------------------------------*/ -int skill_unit_move(struct block_list *bl, int64 tick, int flag) +static int skill_unit_move(struct block_list *bl, int64 tick, int flag) { nullpo_ret(bl); @@ -17274,7 +17853,7 @@ int skill_unit_move(struct block_list *bl, int64 tick, int flag) /*========================================== * *------------------------------------------*/ -int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx, int16 dy) +static int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx, int16 dy) { int i,j; int64 tick = timer->gettick(); @@ -17364,7 +17943,7 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx /*========================================== * *------------------------------------------*/ -int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, int qty) +static int skill_can_produce_mix(struct map_session_data *sd, int nameid, int trigger, int qty) { int i,j; @@ -17413,8 +17992,8 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, if (pc->search_inventory(sd,id) == INDEX_NOT_FOUND) return 0; } else { - int x, y; - for(y=0,x=0;y<MAX_INVENTORY;y++) + int x = 0; + for (int y = 0; y < sd->status.inventorySize; y++) if( sd->status.inventory[y].nameid == id ) x+=sd->status.inventory[y].amount; if(x<qty*skill->dbs->produce_db[i].mat_amount[j]) @@ -17427,7 +18006,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, /*========================================== * *------------------------------------------*/ -int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty) +static int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty) { int slot[3]; int i,sc,ele,idx,equip,wlv,make_per = 0,flag = 0,skill_lv = 0; @@ -17485,10 +18064,12 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, else temp_qty = 1; if (data->stack.inventory) { - for( i = 0; i < MAX_INVENTORY; i++ ) { + for (i = 0; i < sd->status.inventorySize; i++ ) { if( sd->status.inventory[i].nameid == nameid ) { if( sd->status.inventory[i].amount >= data->stack.amount ) { - clif->msgtable(sd, MSG_RUNE_STONE_MAX_AMOUNT); +#if PACKETVER >= 20090729 + clif->msgtable(sd, MSG_RUNESTONE_MAKEERROR_OVERCOUNT); +#endif return 0; } else { /** @@ -17713,7 +18294,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int difficulty = 30 + rnd()%120; // Random number between (30 ~ 150) make_per = sd->status.job_level / 4 + st->luk / 2 + st->dex / 3; // (Caster?s Job Level / 4) + (Caster?s LUK / 2) + (Caster?s DEX / 3) - qty = ~(5 + rnd()%5) + 1; + qty = ~(5 + rnd()%5) + 1; // FIXME[Haru]: This smells, if anyone knows the intent, please rewrite the expression in a more clear form. switch(nameid){// difficulty factor case ITEMID_APPLE_BOMB: @@ -17749,7 +18330,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, qty = 5; if( qty < 0 || (skill_lv == 1 && make_per < difficulty)){ - qty = ~qty + 1; + qty = ~qty + 1; // FIXME[Haru]: This smells. If anyone knows the intent, please rewrite the expression in a more clear form. make_per = 0; }else make_per = 10000; @@ -17926,7 +18507,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, { //Cooking items. clif->specialeffect(&sd->bl, 608, AREA); if( sd->cook_mastery < 1999 ) - pc_setglobalreg(sd, script->add_str("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->dbs->produce_db[idx].itemlv - 11) / 2 ) ) * 5); + pc_setglobalreg(sd, script->add_variable("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->dbs->produce_db[idx].itemlv - 11) / 2 ) ) * 5); } break; } @@ -17940,24 +18521,28 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, tmp_item.amount = qty * skill->dbs->changematerial_db[i].qty[j]; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } k++; } } break; } - if( k ){ + if (k) { +#if PACKETVER >= 20091013 clif->msgtable_skill(sd, skill_id, MSG_SKILL_SUCCESS); +#endif return 1; } } else if (tmp_item.amount) { //Success if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } - if( skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY ) +#if PACKETVER >= 20091013 + if (skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY) clif->msgtable_skill(sd, skill_id, MSG_SKILL_SUCCESS); +#endif return 1; } } @@ -18006,7 +18591,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int rate = rnd()%500; memset(&tmp_item,0,sizeof(tmp_item)); if( rate < 50) i = 4; - else if( rate < 100) i = 2+rnd()%1; + else if( rate < 100) i = 2+rnd()%1; // FIXME[Haru]: This '%1' is certainly not intended. If anyone knows the purpose, please rewrite this code. else if( rate < 250 ) i = 1; else if( rate < 500 ) i = 0; tmp_item.nameid = compensation[i]; @@ -18014,29 +18599,33 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, tmp_item.identify = 1; if( pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } - clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAILURE); +#if PACKETVER >= 20091013 + clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAIL); +#endif } break; case GN_MAKEBOMB: case GN_S_PHARMACY: case GN_CHANGEMATERIAL: - clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAILURE); +#if PACKETVER >= 20091013 + clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAIL); +#endif break; default: if( skill->dbs->produce_db[idx].itemlv > 10 && skill->dbs->produce_db[idx].itemlv <= 20 ) { //Cooking items. clif->specialeffect(&sd->bl, 609, AREA); if( sd->cook_mastery > 0 ) - pc_setglobalreg(sd, script->add_str("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); + pc_setglobalreg(sd, script->add_variable("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); } } } return 0; } -int skill_arrow_create (struct map_session_data *sd, int nameid) +static int skill_arrow_create(struct map_session_data *sd, int nameid) { int i,j,flag,index=-1; struct item tmp_item; @@ -18071,20 +18660,20 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) continue; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } return 0; } -int skill_poisoningweapon(struct map_session_data *sd, int nameid) +static int skill_poisoningweapon(struct map_session_data *sd, int nameid) { sc_type type; int chance, i; nullpo_ret(sd); if (nameid <= 0 || (i = pc->search_inventory(sd,nameid)) == INDEX_NOT_FOUND || pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME)) { - clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, GC_POISONINGWEAPON, USESKILL_FAIL_LEVEL, 0, 0); return 0; } switch( nameid ) @@ -18098,7 +18687,7 @@ int skill_poisoningweapon(struct map_session_data *sd, int nameid) case ITEMID_POISON_LAUGHING: type = SC_MAGICMUSHROOM; break; case ITEMID_POISON_OBLIVION: type = SC_OBLIVIONCURSE; break; default: - clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, GC_POISONINGWEAPON, USESKILL_FAIL_LEVEL, 0, 0); return 0; } @@ -18110,7 +18699,7 @@ int skill_poisoningweapon(struct map_session_data *sd, int nameid) return 0; } -void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) +static void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) { struct status_change *sc = status->get_sc(bl); @@ -18135,7 +18724,7 @@ void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) } } -int skill_magicdecoy(struct map_session_data *sd, int nameid) +static int skill_magicdecoy(struct map_session_data *sd, int nameid) { int x, y, i, class_ = 0, skill_id; struct mob_data *md; @@ -18146,7 +18735,7 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) || (i = pc->search_inventory(sd, nameid)) == INDEX_NOT_FOUND || pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME) != 0 ) { - clif->skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, NC_MAGICDECOY, USESKILL_FAIL_LEVEL, 0, 0); return 0; } @@ -18187,7 +18776,7 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) } // Warlock Spellbooks. [LimitLine/3CeAM] -int skill_spellbook(struct map_session_data *sd, int nameid) +static int skill_spellbook(struct map_session_data *sd, int nameid) { int i, max_preserve, skill_id, point; struct status_change *sc; @@ -18200,7 +18789,7 @@ int skill_spellbook(struct map_session_data *sd, int nameid) for(i=SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) if( sc && !sc->data[i] ) break; if( i > SC_SPELLBOOK7 ) { - clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0); + clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0, 0); return 0; } @@ -18210,7 +18799,7 @@ int skill_spellbook(struct map_session_data *sd, int nameid) if( !pc->checkskill(sd, (skill_id = skill->dbs->spellbook_db[i].skill_id)) ) { // User don't know the skill sc_start(&sd->bl, &sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc->checkskill(sd,WL_READING_SB))); - clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0); + clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0, 0); return 0; } @@ -18219,7 +18808,7 @@ int skill_spellbook(struct map_session_data *sd, int nameid) if( sc && sc->data[SC_READING_SB] ) { if( (sc->data[SC_READING_SB]->val2 + point) > max_preserve ) { - clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_PRESERVATION_POINT, 0); + clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_PRESERVATION_POINT, 0, 0); return 0; } for(i = SC_SPELLBOOK7; i >= SC_SPELLBOOK1; i--){ // This is how official saves spellbook. [malufett] @@ -18237,7 +18826,7 @@ int skill_spellbook(struct map_session_data *sd, int nameid) return 1; } -int skill_select_menu(struct map_session_data *sd,uint16 skill_id) +static int skill_select_menu(struct map_session_data *sd, uint16 skill_id) { int id, lv, prob, aslvl = 0, idx = 0; nullpo_ret(sd); @@ -18251,7 +18840,7 @@ int skill_select_menu(struct map_session_data *sd,uint16 skill_id) if( skill_id >= GS_GLITTERING || skill->get_type(skill_id) != BF_MAGIC || (id = sd->status.skill[idx].id) == 0 || sd->status.skill[idx].flag != SKILL_FLAG_PLAGIARIZED ) { - clif->skill_fail(sd,SC_AUTOSHADOWSPELL,0,0); + clif->skill_fail(sd, SC_AUTOSHADOWSPELL, 0, 0, 0); return 0; } @@ -18262,7 +18851,7 @@ int skill_select_menu(struct map_session_data *sd,uint16 skill_id) return 0; } -int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const struct itemlist *item_list) +static int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const struct itemlist *item_list) { int i; @@ -18283,10 +18872,10 @@ int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const del_amount -= (del_amount % 10); add_amount = (skill_lv == 1) ? del_amount * (5 + rnd()%5) : del_amount / 10 ; - if (idx < 0 || idx >= MAX_INVENTORY + if (idx < 0 || idx >= sd->status.inventorySize || (nameid = sd->status.inventory[idx].nameid) <= 0 || del_amount < 0 || del_amount > sd->status.inventory[idx].amount) { - clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, SO_EL_ANALYSIS, USESKILL_FAIL_LEVEL, 0, 0); return 1; } @@ -18302,18 +18891,18 @@ int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const case ITEMID_WIND_OF_VERDURE: product = ITEMID_ROUGH_WIND; break; case ITEMID_YELLOW_LIVE: product = ITEMID_GREAT_NATURE; break; default: - clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, SO_EL_ANALYSIS, USESKILL_FAIL_LEVEL, 0, 0); return 1; } if( pc->delitem(sd, idx, del_amount, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME) ) { - clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, SO_EL_ANALYSIS, USESKILL_FAIL_LEVEL, 0, 0); return 1; } if( skill_lv == 2 && rnd()%100 < 25 ) { // At level 2 have a fail chance. You loose your items if it fails. - clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0); + clif->skill_fail(sd, SO_EL_ANALYSIS, USESKILL_FAIL_LEVEL, 0, 0); return 1; } @@ -18326,7 +18915,7 @@ int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const int flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME); if (flag) { clif->additem(sd,0,0,flag); - map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + map->addflooritem(&sd->bl, &tmp_item, tmp_item.amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); } } @@ -18335,7 +18924,7 @@ int skill_elementalanalysis(struct map_session_data *sd, uint16 skill_lv, const return 0; } -int skill_changematerial(struct map_session_data *sd, const struct itemlist *item_list) +static int skill_changematerial(struct map_session_data *sd, const struct itemlist *item_list) { int i, j, k, c, p = 0, nameid, amount; @@ -18354,11 +18943,13 @@ int skill_changematerial(struct map_session_data *sd, const struct itemlist *ite for (k = 0; k < VECTOR_LENGTH(*item_list); k++) { const struct itemlist_entry *entry = &VECTOR_INDEX(*item_list, k); int idx = entry->id; - Assert_ret(idx >= 0 && idx < MAX_INVENTORY); + Assert_ret(idx >= 0 && idx < sd->status.inventorySize); amount = entry->amount; nameid = sd->status.inventory[idx].nameid; if (nameid > 0 && sd->status.inventory[idx].identify == 0) { - clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_ITEM_NEED_IDENTIFY); +#if PACKETVER >= 20091013 + clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_FAIL_MATERIAL_IDENTITY); +#endif return 0; } if( nameid == skill->dbs->produce_db[i].mat_id[j] && (amount-p*skill->dbs->produce_db[i].mat_amount[j]) >= skill->dbs->produce_db[i].mat_amount[j] @@ -18378,17 +18969,17 @@ int skill_changematerial(struct map_session_data *sd, const struct itemlist *ite } } } - - if( p == 0) - clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_ITEM_NOT_FOUND); - +#if PACKETVER >= 20091013 + if (p == 0) + clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_RECIPE_NOTEXIST); +#endif return 0; } /** * for Royal Guard's LG_TRAMPLE **/ -int skill_destroy_trap(struct block_list *bl, va_list ap) +static int skill_destroy_trap(struct block_list *bl, va_list ap) { struct skill_unit *su = NULL; struct skill_unit_group *sg; @@ -18403,7 +18994,7 @@ int skill_destroy_trap(struct block_list *bl, va_list ap) case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick); + skill->trap_do_splash(&su->bl, sg->skill_id, sg->skill_lv, sg->bl_flag | BL_SKILL | ~BCT_SELF, tick); break; case UNT_LANDMINE: case UNT_BLASTMINE: @@ -18412,7 +19003,7 @@ int skill_destroy_trap(struct block_list *bl, va_list ap) case UNT_FLASHER: case UNT_FREEZINGTRAP: case UNT_CLUSTERBOMB: - map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick); + skill->trap_do_splash(&su->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick); break; } // Traps aren't recovered. @@ -18424,12 +19015,12 @@ int skill_destroy_trap(struct block_list *bl, va_list ap) /*========================================== * *------------------------------------------*/ -int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) +static int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = map->id2sd(id); struct skill_cd * cd = NULL; - if (data <= 0 || data >= MAX_SKILL) + if (data <= 0 || data >= MAX_SKILL_DB) return 0; if (!sd || !sd->blockskill[data]) return 0; @@ -18477,7 +19068,7 @@ int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) * @param tick the length of time the delay should last * @return 0 if successful, -1 otherwise */ -int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) +static int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) { struct skill_cd* cd = NULL; uint16 idx = skill->get_index(skill_id); @@ -18513,9 +19104,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) if (DIFF_TICK32(cd->entry[i]->started + cd->entry[i]->duration, now) > tick) return 0; cd->entry[i]->duration = tick; -#if PACKETVER >= 20120604 cd->entry[i]->total = tick; -#endif cd->entry[i]->started = now; if( timer->settick(cd->entry[i]->timer,now+tick) != -1 ) return 0; @@ -18547,9 +19136,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) cd->entry[cd->cursor] = ers_alloc(skill->cd_entry_ers,struct skill_cd_entry); cd->entry[cd->cursor]->duration = tick; -#if PACKETVER >= 20120604 cd->entry[cd->cursor]->total = tick; -#endif cd->entry[cd->cursor]->skidx = idx; cd->entry[cd->cursor]->skill_id = skill_id; cd->entry[cd->cursor]->started = now; @@ -18562,10 +19149,10 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) } // [orn] -int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) +static int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) { struct homun_data *hd = map->id2hd(id); - if (data <= 0 || data >= MAX_SKILL) + if (data <= 0 || data >= MAX_SKILL_DB) return 0; if (hd != NULL) hd->blockskill[data] = 0; @@ -18574,7 +19161,7 @@ int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) } // [orn] -int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) +static int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { uint16 idx = skill->get_index(skill_id); nullpo_retr (-1, hd); @@ -18591,10 +19178,10 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) } // [orn] -int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) +static int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) { struct mercenary_data *md = map->id2mc(id); - if (data <= 0 || data >= MAX_SKILL) + if (data <= 0 || data >= MAX_SKILL_DB) return 0; if (md != NULL) md->blockskill[data] = 0; @@ -18602,7 +19189,7 @@ int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) return 1; } -int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) +static int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) { uint16 idx = skill->get_index(skill_id); nullpo_retr (-1, md); @@ -18621,7 +19208,7 @@ int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) /** * Adds a new skill unit entry for this player to recast after map load **/ -void skill_usave_add(struct map_session_data * sd, uint16 skill_id, uint16 skill_lv) +static void skill_usave_add(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct skill_unit_save * sus = NULL; @@ -18639,7 +19226,7 @@ void skill_usave_add(struct map_session_data * sd, uint16 skill_id, uint16 skill return; } -void skill_usave_trigger(struct map_session_data *sd) +static void skill_usave_trigger(struct map_session_data *sd) { struct skill_unit_save * sus = NULL; @@ -18657,7 +19244,7 @@ void skill_usave_trigger(struct map_session_data *sd) /* * */ -int skill_split_atoi(char *str, int *val) +static int skill_split_atoi(char *str, int *val) { int i, j, step = 1; @@ -18704,7 +19291,7 @@ int skill_split_atoi(char *str, int *val) /* * */ -void skill_init_unit_layout (void) +static void skill_init_unit_layout(void) { int i,j,pos = 0; @@ -18875,7 +19462,7 @@ void skill_init_unit_layout (void) } break; default: - skill->init_unit_layout_unknown(i); + skill->init_unit_layout_unknown(i, pos); break; } if (!skill->dbs->unit_layout[pos].count) @@ -18976,12 +19563,13 @@ void skill_init_unit_layout (void) } -void skill_init_unit_layout_unknown(int skill_idx) +static void skill_init_unit_layout_unknown(int skill_idx, int pos) { - ShowError("unknown unit layout at skill %d\n", skill_idx); + Assert_retv(skill_idx >= 0 && skill_idx < MAX_SKILL_DB); + ShowError("unknown unit layout at skill %d\n", skill->dbs->db[skill_idx].nameid); } -int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) +static int skill_block_check(struct block_list *bl, sc_type type, uint16 skill_id) { int inf = 0; struct status_change *sc = status->get_sc(bl); @@ -19129,7 +19717,7 @@ int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) return 0; } -int skill_get_elemental_type(uint16 skill_id , uint16 skill_lv) +static int skill_get_elemental_type(uint16 skill_id, uint16 skill_lv) { int type = 0; @@ -19149,7 +19737,7 @@ int skill_get_elemental_type(uint16 skill_id , uint16 skill_lv) * update stored skill cooldowns for player logout * @param sd the affected player structure */ -void skill_cooldown_save(struct map_session_data * sd) +static void skill_cooldown_save(struct map_session_data *sd) { int i; struct skill_cd* cd = NULL; @@ -19178,7 +19766,7 @@ void skill_cooldown_save(struct map_session_data * sd) * reload stored skill cooldowns when a player logs in. * @param sd the affected player structure */ -void skill_cooldown_load(struct map_session_data * sd) +static void skill_cooldown_load(struct map_session_data *sd) { int i; struct skill_cd* cd = NULL; @@ -19197,13 +19785,21 @@ void skill_cooldown_load(struct map_session_data * sd) // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { - cd->entry[i]->started = now; - cd->entry[i]->timer = timer->add(timer->gettick()+cd->entry[i]->duration,skill->blockpc_end,sd->bl.id,cd->entry[i]->skidx); + int64 remaining; + + if (battle_config.guild_skill_relog_delay == 2 && cd->entry[i]->skill_id >= GD_SKILLBASE && cd->entry[i]->skill_id < GD_MAX) { + remaining = cd->entry[i]->started + cd->entry[i]->total - now; + remaining = max(1, remaining); // expired cooldowns will be 1, so they'll expire in the normal way just after this. + } else { + cd->entry[i]->started = now; + remaining = cd->entry[i]->duration; + } + cd->entry[i]->timer = timer->add(timer->gettick() + remaining, skill->blockpc_end, sd->bl.id, cd->entry[i]->skidx); sd->blockskill[cd->entry[i]->skidx] = true; } } -bool skill_parse_row_producedb(char* split[], int columns, int current) +static bool skill_parse_row_producedb(char *split[], int columns, int current) { // ProduceItemID,ItemLV,RequireSkill,Requireskill_lv,MaterialID1,MaterialAmount1,...... int x,y; @@ -19227,7 +19823,7 @@ bool skill_parse_row_producedb(char* split[], int columns, int current) return true; } -bool skill_parse_row_createarrowdb(char* split[], int columns, int current) +static bool skill_parse_row_createarrowdb(char *split[], int columns, int current) { // SourceID,MakeID1,MakeAmount1,...,MakeID5,MakeAmount5 int x,y; @@ -19248,7 +19844,7 @@ bool skill_parse_row_createarrowdb(char* split[], int columns, int current) return true; } -bool skill_parse_row_spellbookdb(char* split[], int columns, int current) +static bool skill_parse_row_spellbookdb(char *split[], int columns, int current) { // skill_id,PreservePoints @@ -19278,7 +19874,7 @@ bool skill_parse_row_spellbookdb(char* split[], int columns, int current) return false; } -bool skill_parse_row_improvisedb(char* split[], int columns, int current) +static bool skill_parse_row_improvisedb(char *split[], int columns, int current) { // SkillID,Rate uint16 skill_id; @@ -19310,7 +19906,7 @@ bool skill_parse_row_improvisedb(char* split[], int columns, int current) return true; } -bool skill_parse_row_magicmushroomdb(char* split[], int column, int current) +static bool skill_parse_row_magicmushroomdb(char *split[], int column, int current) { // SkillID uint16 skill_id; @@ -19331,22 +19927,7 @@ bool skill_parse_row_magicmushroomdb(char* split[], int column, int current) return true; } -bool skill_parse_row_reproducedb(char* split[], int column, int current) -{ - uint16 skill_id; - uint16 idx; - nullpo_retr(false, split); - skill_id = atoi(split[0]); - idx = skill->get_index(skill_id); - if( !idx ) - return false; - - skill->dbs->reproduce_db[idx] = true; - - return true; -} - -bool skill_parse_row_abradb(char* split[], int columns, int current) +static bool skill_parse_row_abradb(char *split[], int columns, int current) { // skill_id,DummyName,RequiredHocusPocusLevel,Rate uint16 skill_id; @@ -19368,10 +19949,10 @@ bool skill_parse_row_abradb(char* split[], int columns, int current) return true; } -bool skill_parse_row_changematerialdb(char* split[], int columns, int current) +static bool skill_parse_row_changematerialdb(char *split[], int columns, int current) { // ProductID,BaseRate,MakeAmount1,MakeAmountRate1...,MakeAmount5,MakeAmountRate5 - uint16 skill_id; + int skill_id; short j; int x,y; @@ -19413,7 +19994,7 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) * @param *conf pointer to config setting. * @param *arr pointer to array to be set. */ -void skill_config_set_level(struct config_setting_t *conf, int *arr) +static void skill_config_set_level(struct config_setting_t *conf, int *arr) { int i=0; @@ -19442,7 +20023,7 @@ void skill_config_set_level(struct config_setting_t *conf, int *arr) * @param value value being set for the array. * @return (void) */ -void skill_level_set_value(int *arr, int value) +static void skill_level_set_value(int *arr, int value) { int i=0; @@ -19452,7 +20033,7 @@ void skill_level_set_value(int *arr, int value) } } -void skill_validate_hittype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_hittype(struct config_setting_t *conf, struct s_skill_db *sk) { const char *type = NULL; @@ -19477,7 +20058,7 @@ void skill_validate_hittype(struct config_setting_t *conf, struct s_skill_db *sk * @param sk struct, pointer to s_skill_db * @return (void) */ -void skill_validate_skilltype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_skilltype(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *t = NULL, *tt = NULL; @@ -19524,14 +20105,14 @@ void skill_validate_skilltype(struct config_setting_t *conf, struct s_skill_db * } } } - + /** * Validates "SkillInfo" when reading skill_db.conf * @param conf struct, pointer to skill configuration * @param sk struct, pointer to s_skill_db * @return (void) */ -void skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *t = NULL, *tt = NULL; @@ -19644,6 +20225,18 @@ void skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db * } else { sk->inf2 &= ~INF2_FREE_CAST_REDUCED; } + } else if (strcmpi(type, "ShowSkillScale") == 0) { + if (on) { + sk->inf2 |= INF2_SHOW_SKILL_SCALE; + } else { + sk->inf2 &= ~INF2_SHOW_SKILL_SCALE; + } + } else if (strcmpi(type, "AllowReproduce") == 0) { + if (on) { + sk->inf2 |= INF2_ALLOW_REPRODUCE; + } else { + sk->inf2 &= ~INF2_ALLOW_REPRODUCE; + } } else if (strcmpi(type, "None") != 0) { skilldb_invalid_error(type, config_setting_name(t), sk->nameid); } @@ -19657,7 +20250,7 @@ void skill_validate_skillinfo(struct config_setting_t *conf, struct s_skill_db * * @param sk struct, pointer to s_skill_db * @return (void) */ -void skill_validate_attacktype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_attacktype(struct config_setting_t *conf, struct s_skill_db *sk) { const char *type = NULL; @@ -19682,7 +20275,7 @@ void skill_validate_attacktype(struct config_setting_t *conf, struct s_skill_db * @param sk struct, pointer to s_skill_db * @return (void) */ -void skill_validate_element(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_element(struct config_setting_t *conf, struct s_skill_db *sk) { const char *type = NULL; struct config_setting_t *t = NULL; @@ -19730,7 +20323,7 @@ void skill_validate_element(struct config_setting_t *conf, struct s_skill_db *sk * @param sk struct, pointer to s_skill_db * @return (void) */ -void skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *t = NULL, *tt = NULL; @@ -19803,7 +20396,7 @@ void skill_validate_damagetype(struct config_setting_t *conf, struct s_skill_db * @param delay boolean, switch for cast/delay setting * @return (void) */ -void skill_validate_castnodex(struct config_setting_t *conf, struct s_skill_db *sk, bool delay) +static void skill_validate_castnodex(struct config_setting_t *conf, struct s_skill_db *sk, bool delay) { struct config_setting_t *t = NULL, *tt = NULL; @@ -19850,7 +20443,7 @@ void skill_validate_castnodex(struct config_setting_t *conf, struct s_skill_db * * @param *sk struct, pointer to s_skill_db * @return void */ -int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db *sk) +static int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db *sk) { nullpo_ret(sk); if (strcmpi(type, "NoWeapon") == 0) { @@ -20053,7 +20646,7 @@ int skill_validate_weapontype_sub(const char *type, bool on, struct s_skill_db * * @param sk struct, struct, pointer to s_skill_db * @return (void) */ -void skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *tt = NULL; const char *type = NULL; @@ -20080,7 +20673,7 @@ void skill_validate_weapontype(struct config_setting_t *conf, struct s_skill_db * @param sk struct, pointer to s_skill_db * @return void */ -int skill_validate_ammotype_sub(const char *type, bool on, struct s_skill_db *sk) +static int skill_validate_ammotype_sub(const char *type, bool on, struct s_skill_db *sk) { nullpo_ret(sk); if (strcmpi(type, "A_ARROW") == 0) { @@ -20157,7 +20750,7 @@ int skill_validate_ammotype_sub(const char *type, bool on, struct s_skill_db *sk * @param sk struct, pointer to s_skill_db * @return void */ -void skill_validate_ammotype(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_ammotype(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *tt = NULL; const char *tstr = NULL; @@ -20183,7 +20776,7 @@ void skill_validate_ammotype(struct config_setting_t *conf, struct s_skill_db *s * @param sk struct, pointer to s_skill_db * @return void */ -void skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) { const char *type = NULL; @@ -20224,7 +20817,7 @@ void skill_validate_state(struct config_setting_t *conf, struct s_skill_db *sk) * @param sk struct, pointer to s_skill_db * @return void */ -void skill_validate_item_requirements(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_item_requirements(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *tt = NULL; @@ -20261,7 +20854,7 @@ void skill_validate_item_requirements(struct config_setting_t *conf, struct s_sk * @param sk struct, pointer to s_skill_db * @return void */ -void skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db *sk) { const char *type = NULL; @@ -20303,7 +20896,7 @@ void skill_validate_unit_target(struct config_setting_t *conf, struct s_skill_db * @param sk struct, pointer to s_skill_db. * @return (void) */ -int skill_validate_unit_flag_sub(const char *type, bool on, struct s_skill_db *sk) +static int skill_validate_unit_flag_sub(const char *type, bool on, struct s_skill_db *sk) { nullpo_ret(type); nullpo_ret(sk); @@ -20399,7 +20992,7 @@ int skill_validate_unit_flag_sub(const char *type, bool on, struct s_skill_db *s * @param sk struct, struct, pointer to s_skill_db * @return (void) */ -void skill_validate_unit_flag(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_unit_flag(struct config_setting_t *conf, struct s_skill_db *sk) { struct config_setting_t *t = NULL; @@ -20422,7 +21015,7 @@ void skill_validate_unit_flag(struct config_setting_t *conf, struct s_skill_db * * @param sk struct, struct, pointer to s_skill_db * @return (void) */ -void skill_validate_additional_fields(struct config_setting_t *conf, struct s_skill_db *sk) +static void skill_validate_additional_fields(struct config_setting_t *conf, struct s_skill_db *sk) { // Does nothing like a boss. *cough* plugins *cough* } @@ -20433,10 +21026,10 @@ void skill_validate_additional_fields(struct config_setting_t *conf, struct s_sk * @param *source filepath constant. * @return boolean true on success. */ -bool skill_validate_skilldb(struct s_skill_db *sk, const char *source) +static bool skill_validate_skilldb(struct s_skill_db *sk, const char *source) { int idx; - + nullpo_retr(false, sk); idx = skill->get_index(sk->nameid); if (idx == 0) { @@ -20454,28 +21047,28 @@ bool skill_validate_skilldb(struct s_skill_db *sk, const char *source) strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill->dbs->db[idx].nameid); /* Set Name to Id script constants */ script->set_constant2(skill->dbs->db[idx].name, (int)skill->dbs->db[idx].nameid, false, false); - + return true; } - + /** * Reads skill_db.conf from relative filepath and processes [ Smokexyz/Hercules ] * entries into the skill database. * @param filename contains the file path and name. * @return boolean true on success */ -bool skill_read_skilldb(const char *filename) +static bool skill_read_skilldb(const char *filename) { struct config_t skilldb; struct config_setting_t *sk, *conf; char filepath[256]; int count=0, index=0; - bool duplicate[MAX_SKILL] = {0}; - + bool duplicate[MAX_SKILL_DB] = {0}; + nullpo_retr(false, filename); sprintf(filepath,"db/%s",filename); - + if (!libconfig->load_file(&skilldb, filepath)) { return false; // Libconfig error report. } @@ -20497,9 +21090,9 @@ bool skill_read_skilldb(const char *filename) ShowError("skill_read_skilldb: Skill Id not specified for entry %d in '%s', skipping...\n", index, filepath ); continue; } - + tmp_db.nameid = skill_id; - + if((idx = skill->get_index(skill_id)) == 0) { ShowError("skill_read_skilldb: Skill Id %d is out of range, or within a reserved range (for guild, homunculus, mercenary or elemental skills). skipping...\n", idx); continue; @@ -20509,7 +21102,7 @@ bool skill_read_skilldb(const char *filename) ShowWarning("skill_read_skilldb: Duplicate Skill Id %d in entry %d in '%s', skipping...\n", skill_id, index, filepath); continue; } - + /* Skill Name Constant */ if (!libconfig->setting_lookup_mutable_string(conf, "Name", tmp_db.name, sizeof(tmp_db.name))) { ShowError("skill_read_skilldb: Name not specified for skill Id %d in '%s', skipping...\n", skill_id, filepath); @@ -20699,12 +21292,12 @@ bool skill_read_skilldb(const char *filename) /* Additional Fields for Plugins */ skill->validate_additional_fields(conf, &tmp_db); - + // Validate the skill entry, add it to the duplicate array and increment count on success. if ((duplicate[idx] = skill->validate_skilldb(&tmp_db, filepath))) count++; } - + libconfig->destroy(&skilldb); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filepath); @@ -20721,7 +21314,7 @@ bool skill_read_skilldb(const char *filename) * create_arrow_db.txt * abra_db.txt *------------------------------*/ -void skill_readdb(bool minimal) +static void skill_readdb(bool minimal) { // init skill db structures db_clear(skill->name2id_db); @@ -20736,7 +21329,7 @@ void skill_readdb(bool minimal) safestrncpy(skill->dbs->db[0].desc, "Unknown Skill", sizeof(skill->dbs->db[0].desc)); itemdb->name_constants(); // refresh ItemDB constants before loading of skills - + #ifdef ENABLE_CASE_CHECK script->parser_current_file = DBPATH"skill_db.conf"; #endif // ENABLE_CASE_CHECK @@ -20747,7 +21340,7 @@ void skill_readdb(bool minimal) if (minimal) return; - + skill->init_unit_layout(); sv->readdb(map->db_path, "produce_db.txt", ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); sv->readdb(map->db_path, "create_arrow_db.txt", ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); @@ -20756,12 +21349,11 @@ void skill_readdb(bool minimal) sv->readdb(map->db_path, "spellbook_db.txt", ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); //Guillotine Cross sv->readdb(map->db_path, "magicmushroom_db.txt", ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); - sv->readdb(map->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); sv->readdb(map->db_path, "skill_improvise_db.txt", ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); sv->readdb(map->db_path, "skill_changematerial_db.txt", ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); } -void skill_reload(void) +static void skill_reload(void) { struct s_mapiterator *iter; struct map_session_data *sd; @@ -20794,7 +21386,7 @@ void skill_reload(void) /*========================================== * *------------------------------------------*/ -int do_init_skill(bool minimal) +static int do_init_skill(bool minimal) { skill->name2id_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH); skill->read_db(minimal); @@ -20828,7 +21420,7 @@ int do_init_skill(bool minimal) return 0; } -int do_final_skill(void) +static int do_final_skill(void) { db_destroy(skill->name2id_db); db_destroy(skill->group_db); @@ -20895,8 +21487,12 @@ void skill_defaults(void) skill->get_hp = skill_get_hp; skill->get_mhp = skill_get_mhp; skill->get_sp = skill_get_sp; + skill->get_hp_rate = skill_get_hp_rate; + skill->get_sp_rate = skill_get_sp_rate; skill->get_state = skill_get_state; skill->get_spiritball = skill_get_spiritball; + skill->get_itemid = skill_get_itemid; + skill->get_itemqty = skill_get_itemqty; skill->get_zeny = skill_get_zeny; skill->get_num = skill_get_num; skill->get_cast = skill_get_cast; @@ -20925,7 +21521,6 @@ void skill_defaults(void) skill->tree_get_max = skill_tree_get_max; skill->get_name = skill_get_name; skill->get_desc = skill_get_desc; - skill->chk = skill_chk; skill->get_casttype = skill_get_casttype; skill->get_casttype2 = skill_get_casttype2; skill->is_combo = skill_is_combo; @@ -21004,6 +21599,7 @@ void skill_defaults(void) skill->onskillusage = skill_onskillusage; skill->cell_overlap = skill_cell_overlap; skill->timerskill = skill_timerskill; + skill->trap_do_splash = skill_trap_do_splash; skill->trap_splash = skill_trap_splash; skill->check_condition_mercenary = skill_check_condition_mercenary; skill->locate_element_field = skill_locate_element_field; @@ -21067,7 +21663,6 @@ void skill_defaults(void) skill->parse_row_abradb = skill_parse_row_abradb; skill->parse_row_spellbookdb = skill_parse_row_spellbookdb; skill->parse_row_magicmushroomdb = skill_parse_row_magicmushroomdb; - skill->parse_row_reproducedb = skill_parse_row_reproducedb; skill->parse_row_improvisedb = skill_parse_row_improvisedb; skill->parse_row_changematerialdb = skill_parse_row_changematerialdb; skill->usave_add = skill_usave_add; |