summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-01 01:30:35 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-01 01:30:35 +0300
commit4f35fa5d10ba0a30157205227f25aed6da67f4e1 (patch)
tree5d348e835494204a5b4f6ea0a70cb5d0d2dae470 /src
parenta3158d2110a2a846d39a5ddc364adb40c212241d (diff)
downloadevol-hercules-4f35fa5d10ba0a30157205227f25aed6da67f4e1.tar.gz
evol-hercules-4f35fa5d10ba0a30157205227f25aed6da67f4e1.tar.bz2
evol-hercules-4f35fa5d10ba0a30157205227f25aed6da67f4e1.tar.xz
evol-hercules-4f35fa5d10ba0a30157205227f25aed6da67f4e1.zip
Add into mob_db skill type attacks modifier.
New group in mob_db: SkillAttacks Example: SkillAttacks: { SM_BASH: 5000 // mean SM_BASH skill do 50% of normal damage } Default value is 10000 mean 100%
Diffstat (limited to 'src')
-rw-r--r--src/emap/battle.c16
-rw-r--r--src/emap/data/mobd.c2
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/mob.c30
-rw-r--r--src/emap/struct/mobdext.h1
5 files changed, 47 insertions, 4 deletions
diff --git a/src/emap/battle.c b/src/emap/battle.c
index 161da3d..1404795 100644
--- a/src/emap/battle.c
+++ b/src/emap/battle.c
@@ -85,8 +85,8 @@ bool ebattle_check_arrows_post(bool retVal,
struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal,
struct block_list *src,
- struct block_list *target __attribute__ ((unused)),
- uint16 skill_id __attribute__ ((unused)),
+ struct block_list *target,
+ uint16 skill_id,
uint16 skill_lv __attribute__ ((unused)),
int wflag __attribute__ ((unused)))
{
@@ -105,9 +105,17 @@ struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal,
if (data == NULL)
return retVal;
- const int mod = data->weaponAttacks[sd->weapontype1];
+ int mod = 0;
+ if (skill_id > 0)
+ {
+ const int idx = skill->get_index(skill_id);
+ mod = data->skillAttacks[idx];
+ }
+ else
+ {
+ mod = data->weaponAttacks[sd->weapontype1];
+ }
retVal.damage = apply_percentrate64(retVal.damage, mod, 10000);
retVal.damage2 = apply_percentrate64(retVal.damage2, mod, 10000);
-
return retVal;
}
diff --git a/src/emap/data/mobd.c b/src/emap/data/mobd.c
index abddb3d..8f77994 100644
--- a/src/emap/data/mobd.c
+++ b/src/emap/data/mobd.c
@@ -49,5 +49,7 @@ struct MobdExt *mobd_create(void)
data->walkMask = 0;
for (int f = 0; f < MAX_WEAPON_TYPE; f ++)
data->weaponAttacks[f] = 10000;
+ for (int f = 0; f < MAX_SKILL_DB; f ++)
+ data->skillAttacks[f] = 10000;
return data;
}
diff --git a/src/emap/init.c b/src/emap/init.c
index 179fe59..fb95d32 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -270,6 +270,8 @@ HPExport void plugin_init (void)
addHookPre(homun, gainexp, ehomunculus_gainexp_pre);
addHookPost(battle, calc_weapon_attack, ebattle_calc_weapon_attack_post);
+ addHookPost(battle, calc_magic_attack, ebattle_calc_weapon_attack_post);
+ addHookPost(battle, calc_misc_attack, ebattle_calc_weapon_attack_post);
addHookPost(battle, check_arrows, ebattle_check_arrows_post);
addHookPost(clif, addcards, eclif_addcards_post);
addHookPost(clif, addcards2, eclif_addcards2_post);
diff --git a/src/emap/mob.c b/src/emap/mob.c
index 534e858..f12a936 100644
--- a/src/emap/mob.c
+++ b/src/emap/mob.c
@@ -18,6 +18,7 @@
#include "map/battle.h"
#include "map/itemdb.h"
#include "map/mob.h"
+#include "map/script.h"
#include "plugins/HPMHooking.h"
@@ -199,6 +200,23 @@ static void emob_load_weaponattacks(const char *type,
data->weaponAttacks[key] = val;
}
+static void emob_load_skillattacks(const char *type,
+ int val,
+ struct MobdExt *data,
+ struct mob_db *entry)
+{
+ int skill_id = 0;
+ if (script->get_constant(type, &skill_id))
+ {
+ const int idx = skill->get_index(skill_id);
+ data->skillAttacks[idx] = val;
+ }
+ else
+ {
+ ShowError("Mob %d. Unknown skill name %s\n", entry->mob_id, type);
+ }
+}
+
void emob_read_db_additional_fields_pre(struct mob_db **entryPtr,
struct config_setting_t **itPtr,
int *nPtr __attribute__ ((unused)),
@@ -227,6 +245,18 @@ void emob_read_db_additional_fields_pre(struct mob_db **entryPtr,
emob_load_weaponattacks(config_setting_name(wpt), libconfig->setting_get_int(wpt), data, *entryPtr);
}
}
+
+ tt = libconfig->setting_get_member(*itPtr, "SkillAttacks");
+
+ if (tt && config_setting_is_group(tt))
+ {
+ int j = 0;
+ struct config_setting_t *wpt = NULL;
+ while ((wpt = libconfig->setting_get_elem(tt, j++)) != NULL)
+ {
+ emob_load_skillattacks(config_setting_name(wpt), libconfig->setting_get_int(wpt), data, *entryPtr);
+ }
+ }
}
uint32 emob_read_db_mode_sub_post(uint32 retVal,
diff --git a/src/emap/struct/mobdext.h b/src/emap/struct/mobdext.h
index 879ca99..012485f 100644
--- a/src/emap/struct/mobdext.h
+++ b/src/emap/struct/mobdext.h
@@ -8,6 +8,7 @@ struct MobdExt
{
int walkMask;
int weaponAttacks[MAX_WEAPON_TYPE];
+ int skillAttacks[MAX_SKILL_DB];
};
#endif // EVOL_MAP_MOBDEXT