summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--crawl-ref/docs/crawl_manual.txt3
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/fight.cc35
-rw-r--r--crawl-ref/source/mon-util.cc1
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