From 310b7dd9b8d2e862657d84cc72bb156e0d2ad226 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 19:37:22 +0200 Subject: Fix an issue that prevents homunculus auto-vaporize on death or skill reset The >80% HP condition is now ignored in the cases the vaporization is forced by the server Signed-off-by: Haru --- src/map/homunculus.c | 6 +++--- src/map/homunculus.h | 2 +- src/map/pc.c | 6 +++--- src/map/script.c | 2 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 31744f479..aed853313 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -172,7 +172,7 @@ static int homunculus_dead(struct homun_data *hd) } //Vaporize a character's homun. If flag, HP needs to be 80% or above. -static int homunculus_vaporize(struct map_session_data *sd, enum homun_state flag) +static int homunculus_vaporize(struct map_session_data *sd, enum homun_state state, bool force) { struct homun_data *hd; @@ -185,13 +185,13 @@ static int homunculus_vaporize(struct map_session_data *sd, enum homun_state fla if (status->isdead(&hd->bl)) return 0; //Can't vaporize a dead homun. - if (flag == HOM_ST_REST && get_percentage(hd->battle_status.hp, hd->battle_status.max_hp) < 80) + if (!force && get_percentage(hd->battle_status.hp, hd->battle_status.max_hp) < 80) return 0; hd->regen.state.block = 3; //Block regen while vaporized. //Delete timers when vaporized. homun->hunger_timer_delete(hd); - hd->homunculus.vaporize = flag; + hd->homunculus.vaporize = state; if(battle_config.hom_setting&0x40) memset(hd->blockskill, 0, sizeof(hd->blockskill)); clif->hominfo(sd, sd->hd, 0); diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 745c7cd84..b1c21e546 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -167,7 +167,7 @@ struct homunculus_interface { enum homun_type (*class2type) (int class_); void (*damaged) (struct homun_data *hd); int (*dead) (struct homun_data *hd); - int (*vaporize) (struct map_session_data *sd, enum homun_state flag); + int (*vaporize) (struct map_session_data *sd, enum homun_state state, bool force); int (*delete) (struct homun_data *hd, int emote); int (*checkskill) (struct homun_data *hd, uint16 skill_id); int (*calc_skilltree) (struct homun_data *hd, int flag_evolve); diff --git a/src/map/pc.c b/src/map/pc.c index 1e7ac5817..b0c77049c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -7765,7 +7765,7 @@ static int pc_resetskill(struct map_session_data *sd, int flag) pc->setoption(sd, i); if( homun_alive(sd->hd) && pc->checkskill(sd, AM_CALLHOMUN) ) - homun->vaporize(sd, HOM_ST_REST); + homun->vaporize(sd, HOM_ST_REST, true); if ((sd->sc.data[SC_SPRITEMABLE] && pc->checkskill(sd, SU_SPRITEMABLE))) status_change_end(&sd->bl, SC_SPRITEMABLE, INVALID_TIMER); @@ -8054,7 +8054,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) if (sd->status.hom_id > 0){ if(battle_config.homunculus_auto_vapor && sd->hd) - homun->vaporize(sd, HOM_ST_REST); + homun->vaporize(sd, HOM_ST_REST, true); } if( sd->md ) @@ -9069,7 +9069,7 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper) pc->setoption(sd, i); if(homun_alive(sd->hd) && !pc->checkskill(sd, AM_CALLHOMUN)) - homun->vaporize(sd, HOM_ST_REST); + homun->vaporize(sd, HOM_ST_REST, true); if ((sd->sc.data[SC_SPRITEMABLE] && pc->checkskill(sd, SU_SPRITEMABLE))) status_change_end(&sd->bl, SC_SPRITEMABLE, INVALID_TIMER); diff --git a/src/map/script.c b/src/map/script.c index 51cf29816..04c985ea4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12633,7 +12633,7 @@ static BUILDIN(homunculus_morphembryo) clif->additem(sd, 0, 0, i); clif->emotion(&sd->hd->bl, E_SWT); } else { - homun->vaporize(sd, HOM_ST_MORPH); + homun->vaporize(sd, HOM_ST_MORPH, true); success = true; } } else { diff --git a/src/map/skill.c b/src/map/skill.c index af61c887c..4b6ab7d0d 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -8710,7 +8710,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * case AM_REST: if (sd) { - if (homun->vaporize(sd,HOM_ST_REST)) + if (homun->vaporize(sd, HOM_ST_REST, false)) clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); else clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); diff --git a/src/map/status.c b/src/map/status.c index 63e71c9dc..e9636e214 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -9070,7 +9070,7 @@ static int status_change_start(struct block_list *src, struct block_list *bl, en if (sd->status.pet_id > 0) pet->menu(sd, 3); if (homun_alive(sd->hd)) - homun->vaporize(sd,HOM_ST_REST); + homun->vaporize(sd, HOM_ST_REST, true); if (sd->md) mercenary->delete(sd->md,3); } -- cgit v1.2.3-60-g2f50 From 2d1b14d4b4315bb8705d9c1977343615c708a514 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 21:14:48 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 ++-- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index e8c7705a0..0c20fdcf5 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -3138,8 +3138,8 @@ typedef void (*HPMHOOK_pre_homun_damaged) (struct homun_data **hd); typedef void (*HPMHOOK_post_homun_damaged) (struct homun_data *hd); typedef int (*HPMHOOK_pre_homun_dead) (struct homun_data **hd); typedef int (*HPMHOOK_post_homun_dead) (int retVal___, struct homun_data *hd); -typedef int (*HPMHOOK_pre_homun_vaporize) (struct map_session_data **sd, enum homun_state *flag); -typedef int (*HPMHOOK_post_homun_vaporize) (int retVal___, struct map_session_data *sd, enum homun_state flag); +typedef int (*HPMHOOK_pre_homun_vaporize) (struct map_session_data **sd, enum homun_state *state, bool *force); +typedef int (*HPMHOOK_post_homun_vaporize) (int retVal___, struct map_session_data *sd, enum homun_state state, bool force); typedef int (*HPMHOOK_pre_homun_delete) (struct homun_data **hd, int *emote); typedef int (*HPMHOOK_post_homun_delete) (int retVal___, struct homun_data *hd, int emote); typedef int (*HPMHOOK_pre_homun_checkskill) (struct homun_data **hd, uint16 *skill_id); diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 5820ab92f..8f7b928b8 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -35383,15 +35383,15 @@ int HP_homun_dead(struct homun_data *hd) { } return retVal___; } -int HP_homun_vaporize(struct map_session_data *sd, enum homun_state flag) { +int HP_homun_vaporize(struct map_session_data *sd, enum homun_state state, bool force) { int hIndex = 0; int retVal___ = 0; if (HPMHooks.count.HP_homun_vaporize_pre > 0) { - int (*preHookFunc) (struct map_session_data **sd, enum homun_state *flag); + int (*preHookFunc) (struct map_session_data **sd, enum homun_state *state, bool *force); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_homun_vaporize_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_homun_vaporize_pre[hIndex].func; - retVal___ = preHookFunc(&sd, &flag); + retVal___ = preHookFunc(&sd, &state, &force); } if (*HPMforce_return) { *HPMforce_return = false; @@ -35399,13 +35399,13 @@ int HP_homun_vaporize(struct map_session_data *sd, enum homun_state flag) { } } { - retVal___ = HPMHooks.source.homun.vaporize(sd, flag); + retVal___ = HPMHooks.source.homun.vaporize(sd, state, force); } if (HPMHooks.count.HP_homun_vaporize_post > 0) { - int (*postHookFunc) (int retVal___, struct map_session_data *sd, enum homun_state flag); + int (*postHookFunc) (int retVal___, struct map_session_data *sd, enum homun_state state, bool force); for (hIndex = 0; hIndex < HPMHooks.count.HP_homun_vaporize_post; hIndex++) { postHookFunc = HPMHooks.list.HP_homun_vaporize_post[hIndex].func; - retVal___ = postHookFunc(retVal___, sd, flag); + retVal___ = postHookFunc(retVal___, sd, state, force); } } return retVal___; -- cgit v1.2.3-60-g2f50 From 29d5ccb4f6f5d94b2991bae6eeb3bf86987bf21c Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 19:38:52 +0200 Subject: Fix a bug that caused homunculi's HP and SP to be refilled on login They're now only refilled on homunculus creation Signed-off-by: Haru --- src/map/homunculus.c | 13 +++++++++---- src/map/homunculus.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/map/homunculus.c b/src/map/homunculus.c index aed853313..9f7ae0bac 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -826,7 +826,7 @@ static int homunculus_db_search(int key, int type) * @param hom The homunculus source data. * @retval false in case of errors. */ -static bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom) +static bool homunculus_create(struct map_session_data *sd, const struct s_homunculus *hom, bool is_new) { struct homun_data *hd; int i = 0; @@ -870,7 +870,9 @@ static bool homunculus_create(struct map_session_data *sd, const struct s_homunc map->addiddb(&hd->bl); status_calc_homunculus(hd,SCO_FIRST); - status_percent_heal(&hd->bl, 100, 100); + if (is_new) { + status_percent_heal(&hd->bl, 100, 100); + } hd->hungry_timer = INVALID_TIMER; return true; @@ -927,6 +929,7 @@ static bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, { struct map_session_data *sd; struct homun_data *hd; + bool is_new = false; nullpo_retr(false, sh); @@ -942,15 +945,17 @@ static bool homunculus_recv_data(int account_id, const struct s_homunculus *sh, if (sd->status.char_id != sh->char_id && sd->status.hom_id != sh->hom_id) return false; - if (sd->status.hom_id == 0) //Hom just created. + if (sd->status.hom_id == 0) { // Hom just created. sd->status.hom_id = sh->hom_id; + is_new = true; + } if (sd->hd != NULL) { //uh? Overwrite the data. memcpy(&sd->hd->homunculus, sh, sizeof sd->hd->homunculus); sd->hd->homunculus.char_id = sd->status.char_id; // Correct char id if necessary. } else { - homun->create(sd, sh); + homun->create(sd, sh, is_new); } hd = sd->hd; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index b1c21e546..bcbda7e6c 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -189,7 +189,7 @@ struct homunculus_interface { int (*change_name) (struct map_session_data *sd, const char *name); bool (*change_name_ack) (struct map_session_data *sd, const char *name, int flag); int (*db_search) (int key,int type); - bool (*create) (struct map_session_data *sd, const struct s_homunculus *hom); + bool (*create) (struct map_session_data *sd, const struct s_homunculus *hom, bool is_new); void (*init_timers) (struct homun_data * hd); bool (*call) (struct map_session_data *sd); bool (*recv_data) (int account_id, const struct s_homunculus *sh, int flag); -- cgit v1.2.3-60-g2f50 From 6d04c0c88e7adc85fc3bf6ab67a84ba159450bfe Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 21:15:09 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 ++-- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 0c20fdcf5..dd4dfbe5d 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -3182,8 +3182,8 @@ typedef bool (*HPMHOOK_pre_homun_change_name_ack) (struct map_session_data **sd, typedef bool (*HPMHOOK_post_homun_change_name_ack) (bool retVal___, struct map_session_data *sd, const char *name, int flag); typedef int (*HPMHOOK_pre_homun_db_search) (int *key, int *type); typedef int (*HPMHOOK_post_homun_db_search) (int retVal___, int key, int type); -typedef bool (*HPMHOOK_pre_homun_create) (struct map_session_data **sd, const struct s_homunculus **hom); -typedef bool (*HPMHOOK_post_homun_create) (bool retVal___, struct map_session_data *sd, const struct s_homunculus *hom); +typedef bool (*HPMHOOK_pre_homun_create) (struct map_session_data **sd, const struct s_homunculus **hom, bool *is_new); +typedef bool (*HPMHOOK_post_homun_create) (bool retVal___, struct map_session_data *sd, const struct s_homunculus *hom, bool is_new); typedef void (*HPMHOOK_pre_homun_init_timers) (struct homun_data **hd); typedef void (*HPMHOOK_post_homun_init_timers) (struct homun_data *hd); typedef bool (*HPMHOOK_pre_homun_call) (struct map_session_data **sd); diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 8f7b928b8..1ccb60e85 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -35973,15 +35973,15 @@ int HP_homun_db_search(int key, int type) { } return retVal___; } -bool HP_homun_create(struct map_session_data *sd, const struct s_homunculus *hom) { +bool HP_homun_create(struct map_session_data *sd, const struct s_homunculus *hom, bool is_new) { int hIndex = 0; bool retVal___ = false; if (HPMHooks.count.HP_homun_create_pre > 0) { - bool (*preHookFunc) (struct map_session_data **sd, const struct s_homunculus **hom); + bool (*preHookFunc) (struct map_session_data **sd, const struct s_homunculus **hom, bool *is_new); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_homun_create_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_homun_create_pre[hIndex].func; - retVal___ = preHookFunc(&sd, &hom); + retVal___ = preHookFunc(&sd, &hom, &is_new); } if (*HPMforce_return) { *HPMforce_return = false; @@ -35989,13 +35989,13 @@ bool HP_homun_create(struct map_session_data *sd, const struct s_homunculus *hom } } { - retVal___ = HPMHooks.source.homun.create(sd, hom); + retVal___ = HPMHooks.source.homun.create(sd, hom, is_new); } if (HPMHooks.count.HP_homun_create_post > 0) { - bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, const struct s_homunculus *hom); + bool (*postHookFunc) (bool retVal___, struct map_session_data *sd, const struct s_homunculus *hom, bool is_new); for (hIndex = 0; hIndex < HPMHooks.count.HP_homun_create_post; hIndex++) { postHookFunc = HPMHooks.list.HP_homun_create_post[hIndex].func; - retVal___ = postHookFunc(retVal___, sd, hom); + retVal___ = postHookFunc(retVal___, sd, hom, is_new); } } return retVal___; -- cgit v1.2.3-60-g2f50 From 2bee596ad0bb84a92d878d3d76993ba365c70e2b Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 25 Aug 2019 19:40:47 +0200 Subject: Fix the intimacy requirement check for the homunculus ultimate skills Signed-off-by: Haru --- src/map/homunculus.c | 4 ++-- src/map/homunculus.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 9f7ae0bac..9c0460320 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -258,7 +258,7 @@ static int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) for( i = 0; i < MAX_SKILL_TREE && ( id = homun->dbs->skill_tree[c][i].id ) > 0; i++ ) { if( hd->homunculus.hskill[ id - HM_SKILLBASE ].id ) continue; //Skill already known. - j = ( flag_evolve ) ? 10 : hd->homunculus.intimacy; + j = ( flag_evolve ) ? 1000 : hd->homunculus.intimacy; if( j < homun->dbs->skill_tree[c][i].intimacylv ) continue; if(!battle_config.skillfree) { @@ -1317,7 +1317,7 @@ static bool homunculus_read_skill_db_sub(char *split[], int columns, int current homun->dbs->skill_tree[classid][j].need[k].lv = atoi(split[3+k*2+minJobLevelPresent+1]); } - homun->dbs->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]); + homun->dbs->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]) * 100; return true; } diff --git a/src/map/homunculus.h b/src/map/homunculus.h index bcbda7e6c..5bb4334cb 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -133,7 +133,7 @@ struct homun_skill_tree_entry { short id; unsigned char max; unsigned char joblv; - short intimacylv; + int intimacylv; struct { short id; unsigned char lv; -- cgit v1.2.3-60-g2f50 From 4e093cebcb83bab380dc655bb951de1e2d14c73c Mon Sep 17 00:00:00 2001 From: Mathy Date: Sun, 25 Aug 2019 20:17:00 +0200 Subject: Prevent pets, homunculi etc. from being loaded if the character doesn't have a client attached to it (e.g. is autotrading). Signed-off-by: Haru --- src/map/pc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/map/pc.c b/src/map/pc.c index b0c77049c..9ca35acce 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1536,17 +1536,16 @@ static int pc_reg_received(struct map_session_data *sd) if (sd->status.guild_id) guild->member_joined(sd); - // pet - if (sd->status.pet_id > 0) - intif->request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id); - - // Homunculus [albator] - if( sd->status.hom_id > 0 ) - intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id); - if( sd->status.mer_id > 0 ) - intif->mercenary_request(sd->status.mer_id, sd->status.char_id); - if( sd->status.ele_id > 0 ) - intif->elemental_request(sd->status.ele_id, sd->status.char_id); + if (sd->state.standalone == 0 && sd->state.autotrade == 0) { // prevents loading pets, homunculi, mercenaries or elementals if the character doesn't have a client attached + if (sd->status.pet_id != 0) + intif->request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id); + if (sd->status.hom_id != 0) + intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id); + if (sd->status.mer_id != 0) + intif->mercenary_request(sd->status.mer_id, sd->status.char_id); + if (sd->status.ele_id != 0) + intif->elemental_request(sd->status.ele_id, sd->status.char_id); + } map->addiddb(&sd->bl); map->delnickdb(sd->status.char_id, sd->status.name); @@ -8006,7 +8005,7 @@ static void pc_damage(struct map_session_data *sd, struct block_list *src, unsig if( sd->status.pet_id > 0 && sd->pd && battle_config.pet_damage_support ) pet->target_check(sd,src,1); - if( sd->status.ele_id > 0 ) + if (sd->status.ele_id != 0 && sd->ed != NULL) elemental->set_target(sd,src); if (battle_config.prevent_logout_trigger & PLT_DAMAGE) -- cgit v1.2.3-60-g2f50