summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-08-04 19:53:09 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-08-04 19:53:09 +0000
commit8080c40c74b2c963470456010ba1b256f3c6f6c6 (patch)
treefca768ba3be59e577c5072c80ef2045e3ae5d84d /crawl-ref/source/fight.cc
parent3a788f6705485ce09e262e7789050d86ef635451 (diff)
downloadcrawl-ref-8080c40c74b2c963470456010ba1b256f3c6f6c6.tar.gz
crawl-ref-8080c40c74b2c963470456010ba1b256f3c6f6c6.zip
* 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
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc35
1 files changed, 27 insertions, 8 deletions
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.