From 8080c40c74b2c963470456010ba1b256f3c6f6c6 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 4 Aug 2009 19:53:09 +0000 Subject: * Implement 2831014: !a inscription prompts when attempting to attack with this wielded item. As usual, once you answer yes you won't be prompted again until you switch weapons. * Nonmoving monsters shouldn't flounder and "splash around" in shallow water. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10490 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/crawl_manual.txt | 3 +++ crawl-ref/source/enum.h | 1 + crawl-ref/source/fight.cc | 35 +++++++++++++++++++++++++++-------- crawl-ref/source/mon-util.cc | 1 + 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/crawl-ref/docs/crawl_manual.txt b/crawl-ref/docs/crawl_manual.txt index 328c27a65a..a79b2d0c82 100644 --- a/crawl-ref/docs/crawl_manual.txt +++ b/crawl-ref/docs/crawl_manual.txt @@ -2736,6 +2736,9 @@ Inscriptions containing the following strings affect the behaviour of some commands: !* prompt before any action using this item !w prompt before wielding and unwielding + !a prompt before attacking when wielding this item + Non-weapons and ranged weapons prompt automatically. Also, if you + answer 'y', you won't be prompted again until you switch weapons. !e prompt before eating !q prompt before quaffing !r prompt before reading diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 15029f6f2c..fd323df555 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2415,6 +2415,7 @@ enum operation_types OPER_EVOKE = 'v', OPER_DESTROY = 'D', OPER_QUIVER = 'Q', + OPER_ATTACK = 'a', OPER_ANY = 0 }; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index f6c7291ece..2ced048a7c 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -30,6 +30,7 @@ REVISION("$Rev$"); #include "delay.h" #include "effects.h" #include "food.h" +#include "invent.h" #include "it_use2.h" #include "items.h" #include "itemname.h" @@ -5089,28 +5090,46 @@ int melee_attack::mons_to_hit() static bool wielded_weapon_check(const item_def *weapon) { - bool result = true; + bool weapon_warning = false; + bool unarmed_warning = false; + + if (weapon) + { + if (has_warning_inscription(*weapon, OPER_ATTACK) + || weapon->base_type != OBJ_STAVES + && (weapon->base_type != OBJ_WEAPONS + || is_range_weapon(*weapon))) + { + weapon_warning = true; + } + } + else if (you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] + && you_tran_can_wear(EQ_WEAPON)) + { + unarmed_warning = true; + } + if (!you.received_weapon_warning && !you.confused() - && (weapon && weapon->base_type != OBJ_STAVES - && (weapon->base_type != OBJ_WEAPONS || is_range_weapon(*weapon)) - || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - && you_tran_can_wear(EQ_WEAPON))) + && (weapon_warning || unarmed_warning)) { std::string prompt = "Really attack while "; - if (!weapon) + if (unarmed_warning) prompt += "being unarmed?"; else prompt += "wielding " + weapon->name(DESC_NOCAP_YOUR) + "? "; - result = yesno(prompt.c_str(), true, 'n'); + const bool result = yesno(prompt.c_str(), true, 'n'); learned_something_new(TUT_WIELD_WEAPON); // for tutorial Rangers // Don't warn again if you decide to continue your attack. if (result) you.received_weapon_warning = true; + + return (result); } - return (result); + + return (true); } // Returns true if you hit the monster. diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 5115102bc6..8f70f23498 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3664,6 +3664,7 @@ bool monsters::floundering() const { const dungeon_feature_type grid = grd(pos()); return (grid_is_water(grid) + && !cannot_fight() // Can't use monster_habitable_grid() because that'll return // true for non-water monsters in shallow water. && mons_primary_habitat(this) != HT_WATER -- cgit v1.2.3-54-g00ecf