diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-09-14 20:39:31 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-09-14 20:39:31 -0300 |
commit | 9214290c4141782f76f1f454f32c936513d2a66d (patch) | |
tree | 18175df627bac6cf3bd520851184a5d8497a1a59 | |
parent | 48e8506f5297301a7dcb098cbaa19deaf01a722b (diff) | |
download | evol-hercules-9214290c4141782f76f1f454f32c936513d2a66d.tar.gz evol-hercules-9214290c4141782f76f1f454f32c936513d2a66d.tar.bz2 evol-hercules-9214290c4141782f76f1f454f32c936513d2a66d.tar.xz evol-hercules-9214290c4141782f76f1f454f32c936513d2a66d.zip |
This should effectively store the three bonuses, making a commit to record them
-rw-r--r-- | src/emap/init.c | 11 | ||||
-rw-r--r-- | src/emap/pc.c | 54 | ||||
-rw-r--r-- | src/emap/pc.h | 12 |
3 files changed, 77 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index eb06678..d5d8571 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -102,6 +102,16 @@ HPExport void plugin_init (void) htreg_init(); skilld_init(); + /* grab some unique bonus ID for us */ + bHomunculusAtk = map->get_new_bonus_id(); + bHomunculusDef = map->get_new_bonus_id(); + bHomunculusMaxHP = map->get_new_bonus_id(); + + /* set bonus constants and their values */ + script->set_constant("bHomunculusAtk", bHomunculusAtk, false, false); + script->set_constant("bHomunculusDef", bHomunculusDef, false, false); + script->set_constant("bHomunculusMaxHP", bHomunculusMaxHP, false, false); + addAtcommand("setskill", setSkill); addAtcommand("slide", slide); addAtcommand("mapexit", mapExit); @@ -360,6 +370,7 @@ HPExport void plugin_init (void) // TMW2 Custom Pre Hooks //addHookPre(battle, calc_weapon_attack, ebattle_calc_weapon_attack_pre); + addHookPre(pc, bonus, epc_bonus_preHook); addHookPost(battle, calc_weapon_attack, ebattle_calc_weapon_attack_post); addHookPost(battle, calc_magic_attack, ebattle_calc_weapon_attack_post); diff --git a/src/emap/pc.c b/src/emap/pc.c index 011743e..b2acafe 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -39,6 +39,10 @@ int langScriptId; int mountScriptId; +int bHomunculusAtk = -1; +int bHomunculusDef = -1; +int bHomunculusMaxHP = -1; + int64 epc_readparam_pre(const TBL_PC **sdPtr, int *type) { @@ -1097,3 +1101,53 @@ bool epc_read_skill_job_skip_pre(short *skill_idPtr __attribute__ ((unused)), hookStop(); return false; } + +// TMW2 Custom +int epc_bonus_preHook(struct map_session_data **sd, int *type, int *val) +{ + + // int bHomunculusAtk = -1; + if (*type == bHomunculusAtk) { + struct s_homunculus_atk *data; + + if ((data = getFromMSD(*sd, 0)) == NULL) { /* don't have, create */ + CREATE(data, struct s_homunculus_atk, 1); /* alloc */ + data->rate = 0; /* default */ + addToMSD(*sd, data, 0, true); /* link to sd */ + } + data->rate += *val; + + hookStop(); /* don't need to run the original */ + } + + // int bHomunculusDef = -1; + if (*type == bHomunculusDef) { + struct s_homunculus_def *data; + + if ((data = getFromMSD(*sd, 0)) == NULL) { + CREATE(data, struct s_homunculus_def, 1); + data->rate = 0; + addToMSD(*sd, data, 0, true); + } + data->rate += *val; + + hookStop(); + } + + // int bHomunculusMaxHP = -1; + if (*type == bHomunculusMaxHP) { + struct s_homunculus_maxhp *data; + + if ((data = getFromMSD(*sd, 0)) == NULL) { + CREATE(data, struct s_homunculus_maxhp, 1); + data->rate = 0; + addToMSD(*sd, data, 0, true); + } + data->rate += *val; + + hookStop(); + } + + return 0; +} + diff --git a/src/emap/pc.h b/src/emap/pc.h index d5c59bf..0dd9708 100644 --- a/src/emap/pc.h +++ b/src/emap/pc.h @@ -9,6 +9,18 @@ enum VarConst Const_ClientVersion = 10000 }; +struct s_homunculus_atk { + int rate; +}; + +struct s_homunculus_def { + int rate; +}; + +struct s_homunculus_maxhp { + int rate; +}; + int64 epc_readparam_pre(const TBL_PC **sdPtr, int *type); |