From e7450db908a0ba078f7f5301b760c4b5d7418d6b Mon Sep 17 00:00:00 2001 From: kinther Date: Sat, 20 Dec 2025 11:41:48 -0800 Subject: [PATCH] Convert roll_survival_check to generic skill check function --- src/act.item.c | 11 +------- src/utils.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------ src/utils.h | 2 +- 3 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/act.item.c b/src/act.item.c index 8132166..c7a03d8 100644 --- a/src/act.item.c +++ b/src/act.item.c @@ -2008,16 +2008,7 @@ ACMD(do_skin) return; } - d20 = dice(1, 20); - - if (d20 == 1) { - send_to_char(ch, "You aren't able to cut anything useful from the corpse.\r\n"); - dump_obj_contents_to_room(corpse, room); - extract_obj(corpse); - return; - } - - total = roll_survival_check(ch, 0, &d20); + total = roll_skill_check(ch, SKILL_SURVIVAL, 0, &d20); if (d20 == 1) { send_to_char(ch, "You aren't able to cut anything useful from the corpse.\r\n"); diff --git a/src/utils.c b/src/utils.c index ace7b07..ffec051 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1707,9 +1707,48 @@ int roll_d20(void) { return rand_number(1, 20); } int roll_d20_adv(void) { int a=roll_d20(), b=roll_d20(); return (a>b)?a:b; } int roll_d20_disadv(void) { int a=roll_d20(), b=roll_d20(); return (a TOP_SPELL_DEFINE) + return total; + + pct = GET_SKILL(ch, skillnum); + if (pct <= 0) { + /* Requirement #4: no skill => regular ability check only. */ + return total; + } + + /* + * Requirement #6/#7: + * If they have the skill, check proficiency using existing helpers. + * We treat GET_PROFICIENCY(pct) > 0 as proficient for this purpose. + */ + if (GET_PROFICIENCY(pct) > 0) total += get_total_proficiency_bonus(ch); return total; diff --git a/src/utils.h b/src/utils.h index 20a3d05..841f231 100644 --- a/src/utils.h +++ b/src/utils.h @@ -82,7 +82,7 @@ const char *const *obj_value_labels(int item_type); const char *get_char_sdesc(const struct char_data *ch); int obj_is_storage(const struct obj_data *obj); int obj_storage_is_closed(const struct obj_data *obj); -int roll_survival_check(struct char_data *ch, int mode, int *out_d20); +int roll_skill_check(struct char_data *ch, int skillnum, int mode, int *out_d20); /* 5e system helpers */