summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/skill.c44
-rw-r--r--src/map/skill.h4
-rw-r--r--src/map/status.c2
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Defs.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc12
5 files changed, 49 insertions, 17 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 5ac1bdf71..e987e4c8f 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -484,14 +484,26 @@ static int skill_get_time2(int skill_id, int skill_lv)
return skill->dbs->db[idx].upkeep_time2[skill_get_lvl_idx(skill_lv)];
}
-static int skill_get_castdef(int skill_id)
+/**
+ * Gets a skill's cast defence rate by its ID and level.
+ *
+ * @param skill_id The skill's ID.
+ * @param skill_lv The skill's level.
+ * @return The skill's cast defence rate corresponding to the passed level. Defaults to 0 in case of error.
+ *
+ **/
+static int skill_get_castdef(int skill_id, int skill_lv)
{
- int idx;
if (skill_id == 0)
return 0;
- idx = skill->get_index(skill_id);
+
+ Assert_ret(skill_lv > 0);
+
+ int idx = skill->get_index(skill_id);
+
Assert_ret(idx != 0);
- return skill->dbs->db[idx].cast_def_rate;
+
+ return skill->dbs->db[idx].cast_def_rate[skill_get_lvl_idx(skill_lv)];
}
static int skill_get_weapontype(int skill_id)
@@ -20972,13 +20984,33 @@ static void skill_validate_cast_def_rate(struct config_setting_t *conf, struct s
nullpo_retv(conf);
nullpo_retv(sk);
- sk->cast_def_rate = 0;
+ skill->level_set_value(sk->cast_def_rate, 0);
+
+ struct config_setting_t *t = libconfig->setting_get_member(conf, "CastDefRate");
+
+ if (t != NULL && config_setting_is_group(t)) {
+ for (int i = 0; i < MAX_SKILL_LEVEL; i++) {
+ char lv[6]; // Big enough to contain "Lv999" in case of custom MAX_SKILL_LEVEL.
+ safesnprintf(lv, sizeof(lv), "Lv%d", i + 1);
+ int cast_def_rate;
+
+ if (libconfig->setting_lookup_int(t, lv, &cast_def_rate) == CONFIG_TRUE) {
+ if (cast_def_rate >= SHRT_MIN && cast_def_rate <= SHRT_MAX)
+ sk->cast_def_rate[i] = cast_def_rate;
+ else
+ ShowWarning("%s: Invalid cast defence rate %d specified in level %d for skill ID %d in %s! Minimum is %d, maximum is %d. Defaulting to 0...\n",
+ __func__, cast_def_rate, i + 1, sk->nameid, conf->file, SHRT_MIN, SHRT_MAX);
+ }
+ }
+
+ return;
+ }
int cast_def_rate;
if (libconfig->setting_lookup_int(conf, "CastDefRate", &cast_def_rate) == CONFIG_TRUE) {
if (cast_def_rate >= SHRT_MIN && cast_def_rate <= SHRT_MAX)
- sk->cast_def_rate = cast_def_rate;
+ skill->level_set_value(sk->cast_def_rate, cast_def_rate);
else
ShowWarning("%s: Invalid cast defence rate %d specified for skill ID %d in %s! Minimum is %d, maximum is %d. Defaulting to 0...\n",
__func__, cast_def_rate, sk->nameid, conf->file, SHRT_MIN, SHRT_MAX);
diff --git a/src/map/skill.h b/src/map/skill.h
index 598917f2a..a185535a1 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -1765,7 +1765,7 @@ struct s_skill_db {
#endif
int upkeep_time[MAX_SKILL_LEVEL],upkeep_time2[MAX_SKILL_LEVEL],cooldown[MAX_SKILL_LEVEL];
int castcancel[MAX_SKILL_LEVEL];
- int cast_def_rate;
+ int cast_def_rate[MAX_SKILL_LEVEL];
int inf2;
int maxcount[MAX_SKILL_LEVEL];
int skill_type[MAX_SKILL_LEVEL];
@@ -1992,7 +1992,7 @@ struct skill_interface {
int (*get_time2) (int skill_id, int skill_lv);
int (*get_castnodex) (int skill_id, int skill_lv);
int (*get_delaynodex) (int skill_id, int skill_lv);
- int (*get_castdef) (int skill_id);
+ int (*get_castdef) (int skill_id, int skill_lv);
int (*get_weapontype) (int skill_id);
int (*get_ammotype) (int skill_id);
int (*get_ammo_qty) (int skill_id, int skill_lv);
diff --git a/src/map/status.c b/src/map/status.c
index a6e6b24c0..637342632 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -6503,7 +6503,7 @@ static defType status_get_def(struct block_list *bl)
int def = st ? st->def : 0;
ud = unit->bl2ud(bl);
if (ud && ud->skilltimer != INVALID_TIMER)
- def -= def * skill->get_castdef(ud->skill_id)/100;
+ def -= def * skill->get_castdef(ud->skill_id, ud->skill_lv) / 100;
return cap_value(def, DEFTYPE_MIN, DEFTYPE_MAX);
}
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc
index 8973ecfdb..5ce0ba4e6 100644
--- a/src/plugins/HPMHooking/HPMHooking.Defs.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc
@@ -7284,8 +7284,8 @@ typedef int (*HPMHOOK_pre_skill_get_castnodex) (int *skill_id, int *skill_lv);
typedef int (*HPMHOOK_post_skill_get_castnodex) (int retVal___, int skill_id, int skill_lv);
typedef int (*HPMHOOK_pre_skill_get_delaynodex) (int *skill_id, int *skill_lv);
typedef int (*HPMHOOK_post_skill_get_delaynodex) (int retVal___, int skill_id, int skill_lv);
-typedef int (*HPMHOOK_pre_skill_get_castdef) (int *skill_id);
-typedef int (*HPMHOOK_post_skill_get_castdef) (int retVal___, int skill_id);
+typedef int (*HPMHOOK_pre_skill_get_castdef) (int *skill_id, int *skill_lv);
+typedef int (*HPMHOOK_post_skill_get_castdef) (int retVal___, int skill_id, int skill_lv);
typedef int (*HPMHOOK_pre_skill_get_weapontype) (int *skill_id);
typedef int (*HPMHOOK_post_skill_get_weapontype) (int retVal___, int skill_id);
typedef int (*HPMHOOK_pre_skill_get_ammotype) (int *skill_id);
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index 3b4948853..357ba2421 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -77498,15 +77498,15 @@ int HP_skill_get_delaynodex(int skill_id, int skill_lv) {
}
return retVal___;
}
-int HP_skill_get_castdef(int skill_id) {
+int HP_skill_get_castdef(int skill_id, int skill_lv) {
int hIndex = 0;
int retVal___ = 0;
if (HPMHooks.count.HP_skill_get_castdef_pre > 0) {
- int (*preHookFunc) (int *skill_id);
+ int (*preHookFunc) (int *skill_id, int *skill_lv);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_get_castdef_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_skill_get_castdef_pre[hIndex].func;
- retVal___ = preHookFunc(&skill_id);
+ retVal___ = preHookFunc(&skill_id, &skill_lv);
}
if (*HPMforce_return) {
*HPMforce_return = false;
@@ -77514,13 +77514,13 @@ int HP_skill_get_castdef(int skill_id) {
}
}
{
- retVal___ = HPMHooks.source.skill.get_castdef(skill_id);
+ retVal___ = HPMHooks.source.skill.get_castdef(skill_id, skill_lv);
}
if (HPMHooks.count.HP_skill_get_castdef_post > 0) {
- int (*postHookFunc) (int retVal___, int skill_id);
+ int (*postHookFunc) (int retVal___, int skill_id, int skill_lv);
for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_get_castdef_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_skill_get_castdef_post[hIndex].func;
- retVal___ = postHookFunc(retVal___, skill_id);
+ retVal___ = postHookFunc(retVal___, skill_id, skill_lv);
}
}
return retVal___;