summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-28 21:46:27 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-28 21:46:27 +0000
commitfc09d2de4c77399a6562507ad99c394d93c5cee9 (patch)
treeb957a366c7ca56c83a0e3075aed0e738a0abf5ae /crawl-ref/source
parent0ffadca40b94c481141887d294d311ff738c2ad1 (diff)
downloadcrawl-ref-fc09d2de4c77399a6562507ad99c394d93c5cee9.tar.gz
crawl-ref-fc09d2de4c77399a6562507ad99c394d93c5cee9.zip
Fix 2004501: buggy ?identify; also finally properly id ?identify itself
after a successful identification (if there are several). Fix 2004793: wandering mushroom flees - for real, this time (I hope). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6189 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/debug.cc18
-rw-r--r--crawl-ref/source/effects.cc8
-rw-r--r--crawl-ref/source/item_use.cc5
-rw-r--r--crawl-ref/source/itemprop.cc6
-rw-r--r--crawl-ref/source/monstuff.cc16
-rw-r--r--crawl-ref/source/player.cc10
-rw-r--r--crawl-ref/source/spells1.cc27
7 files changed, 59 insertions, 31 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 250b8caeba..f45437f653 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1768,15 +1768,15 @@ void debug_stethoscope(int mon)
(hab == HT_ROCK) ? "rock" :
(hab == HT_LAND) ? "floor"
: "unknown"),
- ((menv[i].behaviour == BEH_SLEEP) ? "sleep" :
- (menv[i].behaviour == BEH_WANDER) ? "wander" :
- (menv[i].behaviour == BEH_SEEK) ? "seek" :
- (menv[i].behaviour == BEH_FLEE) ? "flee" :
- (menv[i].behaviour == BEH_CORNERED) ? "cornered" :
- (menv[i].behaviour == BEH_PANIC) ? "panic" :
- (menv[i].behaviour == BEH_LEAVE) ? "leave" :
- (menv[i].behaviour == BEH_LURK) ? "lurk"
- : "unknown"),
+ (mons_is_sleeping(menv[i]) ? "sleep" :
+ mons_is_wandering(menv[i]) ? "wander" :
+ mons_is_seeking(menv[i]) ? "seek" :
+ mons_is_fleeing(menv[i]) ? "flee" :
+ mons_is_cornered(menv[i]) ? "cornered" :
+ mons_is_panicking(menv[i]) ? "panic" :
+ (menv[i].behaviour == BEH_LEAVE) ? "leave" :
+ mons_is_lurking(menv[i]) ? "lurk"
+ : "unknown"),
menv[i].behaviour,
((menv[i].foe == MHITYOU) ? "you" :
(menv[i].foe == MHITNOT) ? "none" :
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index dc7ed52ea4..92729148ef 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2736,7 +2736,7 @@ static void _catchup_monster_moves(monsters *mon, int turns)
}
else if (ranged_attack)
{
- // if we're doing short time movement and the monster has a
+ // If we're doing short time movement and the monster has a
// ranged attack (missile or spell), then the monster will
// flee to gain distance if its "too close", else it will
// just shift its position rather than charge the player. -- bwr
@@ -2744,18 +2744,18 @@ static void _catchup_monster_moves(monsters *mon, int turns)
{
mon->behaviour = BEH_FLEE;
- // if the monster is on the target square, fleeing won't work
+ // If the monster is on the target square, fleeing won't work.
if (mon->x == mon->target_x && mon->y == mon->target_y)
{
if (you.x_pos != mon->x || you.y_pos != mon->y)
{
- // flee from player's position if different
+ // Flee from player's position if different.
mon->target_x = you.x_pos;
mon->target_y = you.y_pos;
}
else
{
- // randomize the target so we have a direction to flee
+ // Randomize the target so we have a direction to flee.
mon->target_x += (random2(3) - 1);
mon->target_y += (random2(3) - 1);
}
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 4b6e615c5e..d2ebcec981 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -4181,10 +4181,9 @@ static bool scroll_modify_item(const scroll_type scroll)
case SCR_IDENTIFY:
// This can cause a stupid situation where you try to identify the
// very scroll you just read, causing you to waste the scroll.
- if ( !fully_identified(item) )
+ if (!fully_identified(item))
{
mpr("This is a scroll of identify!");
- set_ident_type( item, ID_KNOWN_TYPE );
identify(-1, item_slot);
return (true);
}
@@ -4597,7 +4596,7 @@ void read_scroll( int slot )
default:
mpr("Read a buggy scroll, please report this.");
break;
- } // end switch
+ }
set_ident_type( scroll,
(id_the_scroll) ? ID_KNOWN_TYPE : ID_TRIED_TYPE );
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index f12d833682..6049435031 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -568,8 +568,8 @@ bool item_is_critical(const item_def &item)
return (item.base_type == OBJ_MISCELLANY
&& item.sub_type == MISC_RUNE_OF_ZOT
- && (item.plus != RUNE_DEMONIC
- && item.plus != RUNE_ABYSSAL));
+ && item.plus != RUNE_DEMONIC
+ && item.plus != RUNE_ABYSSAL);
}
void set_ident_flags( item_def &item, unsigned long flags )
@@ -630,7 +630,7 @@ unsigned long full_ident_mask( const item_def& item )
break;
case OBJ_JEWELLERY:
flagset = (ISFLAG_KNOW_CURSE | ISFLAG_KNOW_TYPE);
- if ( ring_has_pluses(item) )
+ if (ring_has_pluses(item))
flagset |= ISFLAG_KNOW_PLUSES;
break;
case OBJ_MISSILES:
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index c1a9155ffd..e9e0e56d00 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2009,7 +2009,7 @@ void behaviour_event(monsters *mon, int event, int src,
|| ((wontAttack != sourceWontAttack || isSmart)
&& !mons_is_fleeing(mon) && !mons_is_panicking(mon)))
{
- // (Plain) plants and fungi cannot flee or fight back.
+ // (Plain) plants and fungi cannot fight back.
if (mon->type == MONS_FUNGUS || mon->type == MONS_PLANT)
return;
@@ -3008,8 +3008,13 @@ static void _handle_behaviour(monsters *mon)
mon->target_y = menv[mon->foe].y;
}
- if (isHurt && !isSmart && isMobile)
+ // Stupid monsters, plants or nonliving monsters cannot flee.
+ if (isHurt && !isSmart && isMobile
+ && mons_class_holiness(mon->type) != MH_PLANT
+ && mons_class_holiness(mon->type) != MH_NONLIVING)
+ {
new_beh = BEH_FLEE;
+ }
break;
case BEH_WANDER:
@@ -3366,6 +3371,13 @@ static void _handle_behaviour(monsters *mon)
break;
case BEH_CORNERED:
+ // Plants or nonliving monsters cannot fight back.
+ if (mons_class_holiness(mon->type) == MH_PLANT
+ || mons_class_holiness(mon->type) == MH_NONLIVING)
+ {
+ break;
+ }
+
if (isHealthy)
new_beh = BEH_SEEK;
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index f0e5882a14..64a89331bf 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -4470,7 +4470,7 @@ int scan_randarts(randart_prop_type which_property, bool calc_unid)
if (eq == -1)
continue;
- // only weapons give their effects when in our hands
+ // Only weapons give their effects when in our hands.
if (i == EQ_WEAPON && you.inv[ eq ].base_type != OBJ_WEAPONS)
continue;
@@ -4478,15 +4478,17 @@ int scan_randarts(randart_prop_type which_property, bool calc_unid)
continue;
// Ignore unidentified items [TileCrawl dump enhancements].
- if (!item_ident(you.inv[ eq ], ISFLAG_KNOW_PROPERTIES) &&
- !calc_unid)
+ if (!item_ident(you.inv[ eq ], ISFLAG_KNOW_PROPERTIES)
+ && !calc_unid)
+ {
continue;
+ }
retval += randart_wpn_property( you.inv[ eq ], which_property );
}
return (retval);
-} // end scan_randarts()
+}
void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
const char *cause, bool see_source)
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index aab5108603..37b08aaddc 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -423,7 +423,7 @@ void identify(int power, int item_slot)
{
int id_used = 1;
- // scrolls of identify *may* produce "extra" identifications {dlb}:
+ // Scrolls of identify *may* produce "extra" identifications.
if (power == -1 && one_chance_in(5))
id_used += (coinflip()? 1 : 2);
@@ -442,7 +442,7 @@ void identify(int power, int item_slot)
if (fully_identified(item))
{
mpr("Choose an unidentified item, or Esc to abort.");
- if ( Options.auto_list )
+ if (Options.auto_list)
more();
item_slot = -1;
continue;
@@ -451,7 +451,22 @@ void identify(int power, int item_slot)
set_ident_type( item, ID_KNOWN_TYPE );
set_ident_flags( item, ISFLAG_IDENT_MASK );
- // output identified item
+ // For scrolls, now id the scroll, unless already known.
+ if (power == -1
+ && get_ident_type(OBJ_SCROLLS, SCR_IDENTIFY) != ID_KNOWN_TYPE)
+ {
+ set_ident_type(OBJ_SCROLLS, SCR_IDENTIFY, ID_KNOWN_TYPE);
+
+ const int wpn = you.equip[EQ_WEAPON];
+ if (wpn != -1
+ && you.inv[wpn].base_type == OBJ_SCROLLS
+ && you.inv[wpn].sub_type == SCR_IDENTIFY)
+ {
+ you.wield_change = true;
+ }
+ }
+
+ // Output identified item.
mpr(item.name(DESC_INVENTORY_EQUIP).c_str());
if (item_slot == you.equip[EQ_WEAPON])
you.wield_change = true;
@@ -461,13 +476,13 @@ void identify(int power, int item_slot)
if (Options.auto_list && id_used > 0)
more();
- // in case we get to try again
+ // In case we get to try again.
item_slot = -1;
}
while (id_used > 0);
-} // end identify()
+}
-// return whether the spell was actually cast
+// Returns whether the spell was actually cast.
bool conjure_flame(int pow)
{
struct dist spelld;