From a35b2358a4eb8eb1935ce8059a24a353aa0e8e7c Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 8 Mar 2020 22:53:24 +0900 Subject: [PATCH] =?utf8?q?[Feature]=20#39581=20=E5=BA=83=E5=9F=9F=E3=83=9E?= =?utf8?q?=E3=83=83=E3=83=97=E3=81=A7=E3=81=AF=E5=A4=89=E7=95=B0=E3=81=AB?= =?utf8?q?=E3=82=88=E3=82=8B=E6=AD=A6=E5=99=A8=E3=83=89=E3=83=AD=E3=83=83?= =?utf8?q?=E3=83=97=E5=87=A6=E7=90=86=E3=81=8C=E8=B5=B7=E3=81=93=E3=82=89?= =?utf8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4=EF=BC=8E?= =?utf8?q?=E5=BD=93=E8=A9=B2=E5=87=A6=E7=90=86=E3=82=92=20drop=5Fweapons()?= =?utf8?q?=E3=80=80=E3=81=AB=E5=88=86=E9=9B=A2=EF=BC=8E=20/=20In=20wild=20?= =?utf8?q?map,=20a=20player=20doesn't=20drop=20weapons.=E3=80=80That=20pro?= =?utf8?q?cess=20is=20divided=20to=20drop=5Fweapons().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/core.c | 27 +-------------------------- src/player-effects.c | 35 +++++++++++++++++++++++++++++++++++ src/player-effects.h | 1 + src/wizard2.c | 11 ++++++++--- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/core.c b/src/core.c index b7a9c8cad..7aaa8abb8 100644 --- a/src/core.c +++ b/src/core.c @@ -2225,35 +2225,10 @@ static void process_world_aux_mutation(player_type *creature_ptr) if ((creature_ptr->muta2 & MUT2_DISARM) && one_in_(10000)) { - INVENTORY_IDX slot = 0; - object_type *o_ptr = NULL; - disturb(creature_ptr, FALSE, TRUE); msg_print(_("足がもつれて転んだ!", "You trip over your own feet!")); take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->wt / 6), _("転倒", "tripping"), -1); - - msg_print(NULL); - if (has_melee_weapon(creature_ptr, INVEN_RARM)) - { - slot = INVEN_RARM; - o_ptr = &creature_ptr->inventory_list[INVEN_RARM]; - - if (has_melee_weapon(creature_ptr, INVEN_LARM) && one_in_(2)) - { - o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; - slot = INVEN_LARM; - } - } - else if (has_melee_weapon(creature_ptr, INVEN_LARM)) - { - o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; - slot = INVEN_LARM; - } - if (slot && !object_is_cursed(o_ptr)) - { - msg_print(_("武器を落としてしまった!", "You drop your weapon!")); - drop_from_inventory(creature_ptr, slot, 1); - } + drop_weapons(creature_ptr); } } diff --git a/src/player-effects.c b/src/player-effects.c index 98af10f3f..97acc4abc 100644 --- a/src/player-effects.c +++ b/src/player-effects.c @@ -3809,3 +3809,38 @@ bool choose_ele_immune(player_type *creature_ptr, TIME_EFFECT immune_turn) screen_load(); return TRUE; } + +bool_hack drop_weapons(player_type *creature_ptr) +{ + INVENTORY_IDX slot = 0; + object_type *o_ptr = NULL; + + if (creature_ptr->wild_mode) return FALSE; + + msg_print(NULL); + if (has_melee_weapon(creature_ptr, INVEN_RARM)) + { + slot = INVEN_RARM; + o_ptr = &creature_ptr->inventory_list[INVEN_RARM]; + + if (has_melee_weapon(creature_ptr, INVEN_LARM) && one_in_(2)) + { + o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; + slot = INVEN_LARM; + } + } + else if (has_melee_weapon(creature_ptr, INVEN_LARM)) + { + o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; + slot = INVEN_LARM; + } + + if (slot && !object_is_cursed(o_ptr)) + { + msg_print(_("武器を落としてしまった!", "You drop your weapon!")); + drop_from_inventory(creature_ptr, slot, 1); + return TRUE; + } + + return FALSE; +} diff --git a/src/player-effects.h b/src/player-effects.h index c35e9c3ba..071de3c83 100644 --- a/src/player-effects.h +++ b/src/player-effects.h @@ -82,6 +82,7 @@ extern bool set_tim_esp(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); extern bool set_superstealth(player_type *creature_ptr, bool set); extern void do_poly_wounds(player_type *creature_ptr); extern void change_race(player_type *creature_ptr, CHARACTER_IDX new_race, concptr effect_msg); +extern bool_hack drop_weapons(player_type *creature_ptr); extern const kamae kamae_shurui[MAX_KAMAE]; extern const kamae kata_shurui[MAX_KATA]; diff --git a/src/wizard2.c b/src/wizard2.c index 33d07b0ae..9c8842787 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -72,11 +72,12 @@ typedef struct debug_spell_command spell_functions command_function; } debug_spell_command; -#define SPELL_MAX 2 +#define SPELL_MAX 3 debug_spell_command debug_spell_commands_list[SPELL_MAX] = { { 2, "vanish dungeon", {.spell2 = { vanish_dungeon } } }, - { 3, "true healing", {.spell3 = { true_healing } } } + { 3, "true healing", {.spell3 = { true_healing } } }, + { 2, "drop weapons", {.spell2 = { drop_weapons } } } }; /*! @@ -88,7 +89,7 @@ static bool do_cmd_debug_spell(player_type *creature_ptr) char tmp_val[50] = "\0"; int tmp_int; - if (!get_string("SPELL:", tmp_val, 32)) return FALSE; + if (!get_string("SPELL: ", tmp_val, 32)) return FALSE; for (int i = 0; i < SPELL_MAX; i++) { @@ -98,18 +99,22 @@ static bool do_cmd_debug_spell(player_type *creature_ptr) { case 2: (*(debug_spell_commands_list[i].command_function.spell2.spell_function))(creature_ptr); + return TRUE; break; case 3: tmp_val[0] = '\0'; if (!get_string("POWER:", tmp_val, 32)) return FALSE; tmp_int = atoi(tmp_val); (*(debug_spell_commands_list[i].command_function.spell3.spell_function))(creature_ptr, tmp_int); + return TRUE; break; default: break; } } + msg_format("Command not found."); + return FALSE; } -- 2.11.0