From f631d286ed7fa15b79ba4b2d0ac632545c5a3a2c Mon Sep 17 00:00:00 2001 From: dis- Date: Mon, 25 Mar 2013 14:27:57 +0000 Subject: [PATCH] Add new option -- show critical ratio of ammo --- src/bldg.c | 21 +++++++++++++++------ src/externs.h | 2 ++ src/flavor.c | 11 +++++++++++ src/tables.c | 3 +++ src/variable.c | 2 ++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/bldg.c b/src/bldg.c index 9be4995b8..0f6bcb393 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -3113,11 +3113,11 @@ static void town_history(void) screen_load(); } -s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow, int dam) +/* critical happens at i / 10000 */ +s16b calc_crit_ratio_shot(int weight, int plus_ammo, int plus_bow, int dam) { - u32b num; - int i, k, crit; - + int i; + /* Extract "shot" power */ i = p_ptr->to_h_b * 4 + plus_ammo + (p_ptr->lev * 2); @@ -3130,6 +3130,15 @@ s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow, int dam) if (i < 0) i = 0; + return i * 2; +} + +s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow, int dam) +{ + u32b num; + int i, k, crit; + i = calc_crit_ratio_shot(weight, plus_ammo, plus_bow, dam); + k = 0; num = 0; @@ -3151,8 +3160,8 @@ s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow, int dam) num /= 500; num *= i; - num += (5000 - i) * dam; - num /= 5000; + num += (10000 - i) * dam; + num /= 10000; return num; } diff --git a/src/externs.h b/src/externs.h index a8c192491..3680e756c 100644 --- a/src/externs.h +++ b/src/externs.h @@ -284,6 +284,7 @@ extern bool exp_need; /* Show the experience needed for next level */ extern bool ignore_unview; /* Ignore whenever any monster does */ extern bool show_ammo_detail; /* Show Description of ammo damage */ extern bool show_ammo_no_crit; /* Show No-crit damage of ammo */ +extern bool show_ammo_crit_ratio; /* Show critical ratio of ammo */ /*** Game-Play Options ***/ @@ -1301,6 +1302,7 @@ extern void quest_discovery(int q_idx); extern int quest_number(int level); extern int random_quest_number(int level); extern bool tele_town(void); +extern s16b calc_crit_ratio_shot(int weight, int plus_ammo,int plus_bow, int dam); extern s16b calc_expect_crit_shot(int weight, int plus_ammo,int plus_bow, int dam); extern s16b calc_expect_crit(int weight, int plus, int dam, s16b meichuu, bool dokubari); diff --git a/src/flavor.c b/src/flavor.c index fe6765339..94f0082ca 100644 --- a/src/flavor.c +++ b/src/flavor.c @@ -2479,6 +2479,17 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode) avgdam /= energy_fire; t = object_desc_num(t, avgdam); t = object_desc_str(t, show_ammo_detail ? "/turn" : ""); + + if(show_ammo_crit_ratio) + { + int percent = calc_crit_ratio_shot(o_ptr->weight, o_ptr->to_h, bow_ptr->to_h, avgdam); + + t = object_desc_chr(t, '/'); + t = object_desc_num(t, percent / 100); + t = object_desc_chr(t, '.'); + t = object_desc_num(t, percent % 100); + t = object_desc_str(t, show_ammo_detail ? "% crit" : "%"); + } } t = object_desc_chr(t, p2); diff --git a/src/tables.c b/src/tables.c index 6a361703e..c46e991e3 100644 --- a/src/tables.c +++ b/src/tables.c @@ -5000,6 +5000,9 @@ const option_type option_info[] = { &show_ammo_no_crit, FALSE, OPT_PAGE_TEXT, 2, 15, "show_ammo_no_crit", _("²ñ¿´¤ò¹Íθ¤·¤Ê¤¤¾ì¹ç¤ÎÌðÃƤΥÀ¥á¡¼¥¸¤òɽ¼¨¤¹¤ë", "Show ammo damage with no critical") }, + + { &show_ammo_crit_ratio, FALSE, OPT_PAGE_TEXT, 2, 16, + "show_ammo_crit_ratio", _("ÌðÃƤβñ¿´È¯À¸Î¨¤òɽ¼¨¤¹¤ë", "Show critical ratio of ammo") }, /*** Game-Play ***/ diff --git a/src/variable.c b/src/variable.c index c41f3e828..0ab674175 100644 --- a/src/variable.c +++ b/src/variable.c @@ -308,6 +308,8 @@ bool autochara; /* Autoroll for weight, height and social status */ bool powerup_home; /* Increase capacity of your home (*) */ bool show_ammo_detail; /* Show Description of ammo damage */ bool show_ammo_no_crit; /* Show No-crit damage of ammo */ +bool show_ammo_crit_ratio; /* Show critical ratio of ammo */ + -- 2.11.0