summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-17 01:11:57 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-17 01:11:57 +0000
commitc607c2f3f8e17f4471bd4d774fb6faa6aa26ded1 (patch)
tree0de559526859a0f985f8690dc224bed3b99e1c3e
parenta041cf61134ad4f96e06bdadccb4782546fbddc3 (diff)
downloadcrawl-ref-c607c2f3f8e17f4471bd4d774fb6faa6aa26ded1.tar.gz
crawl-ref-c607c2f3f8e17f4471bd4d774fb6faa6aa26ded1.zip
Make yet more use of wrappers.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5900 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/effects.cc2
-rw-r--r--crawl-ref/source/mon-util.cc18
-rw-r--r--crawl-ref/source/mon-util.h2
-rw-r--r--crawl-ref/source/monstuff.cc18
-rw-r--r--crawl-ref/source/stuff.cc2
-rw-r--r--crawl-ref/source/view.cc8
6 files changed, 31 insertions, 19 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index d06129f7cd..0deb563c7e 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2731,7 +2731,7 @@ static void _catchup_monster_moves(monsters *mon, int turns)
|| ranged_attack
|| coinflip()))
{
- if (mon->behaviour != BEH_WANDER)
+ if (!mons_is_wandering(mon))
{
mon->behaviour = BEH_WANDER;
mon->foe = MHITNOT;
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 1dbf56f850..3fc6b12094 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2175,6 +2175,16 @@ bool mons_is_sleeping(const monsters *m)
return (m->behaviour == BEH_SLEEP);
}
+bool mons_is_wandering(const monsters *m)
+{
+ return (m->behaviour == BEH_WANDER);
+}
+
+bool mons_is_seeking(const monsters *m)
+{
+ return (m->behaviour == BEH_SEEK);
+}
+
bool mons_is_fleeing(const monsters *m)
{
return (m->behaviour == BEH_FLEE);
@@ -3652,7 +3662,7 @@ bool monsters::pickup_throwable_weapon(item_def &item, int near)
// If occupied, don't pick up a throwable weapons if it would just
// stack with an existing one. (Upgrading is possible.)
if (mslot_item(MSLOT_MISSILE)
- && (behaviour == BEH_WANDER || mons_friendly(this) && foe == MHITYOU)
+ && (mons_is_wandering(this) || mons_friendly(this) && foe == MHITYOU)
&& pickup(item, MSLOT_MISSILE, near, true))
{
return (true);
@@ -3875,7 +3885,7 @@ bool monsters::pickup_missile(item_def &item, int near, bool force)
// Monsters in a fight will only pick up missiles if doing so
// is worthwhile.
- if (behaviour != BEH_WANDER && (!mons_friendly(this) || foe != MHITYOU)
+ if (!mons_is_wandering(this) && (!mons_friendly(this) || foe != MHITYOU)
&& (item.quantity < 5 || miss && miss->quantity >= 7))
{
return (false);
@@ -4046,7 +4056,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force)
{
// If a monster isn't otherwise occupied (has a foe, is fleeing, etc.)
// it is considered wandering.
- bool wandering = (behaviour == BEH_WANDER
+ bool wandering = (mons_is_wandering(this)
|| mons_friendly(this) && foe == MHITYOU);
const int itype = item.base_type;
@@ -5259,7 +5269,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
break;
case ENCH_SUBMERGED:
- if (behaviour == BEH_WANDER)
+ if (mons_is_wandering(this))
{
behaviour = BEH_SEEK;
behaviour_event(this, ME_EVAL);
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index ed666cdb6a..7914e5f360 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -652,6 +652,8 @@ bool mons_is_poisoner(const monsters *mon);
bool mons_is_confused(const monsters *m);
bool mons_is_caught(const monsters *m);
bool mons_is_sleeping(const monsters *m);
+bool mons_is_wandering(const monsters *m);
+bool mons_is_seeking(const monsters *m);
bool mons_is_fleeing(const monsters *m);
bool mons_is_panicking(const monsters *m);
bool mons_is_cornered(const monsters *m);
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 45cac15ee8..9a7f37597c 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2025,7 +2025,7 @@ void behaviour_event( monsters *mon, int event, int src,
// monsters who aren't otherwise occupied will at
// least consider the (apparent) source of the noise
// interesting for a moment. -- bwr
- if (!isSmart || mon->foe == MHITNOT || mon->behaviour == BEH_WANDER)
+ if (!isSmart || mon->foe == MHITNOT || mons_is_wandering(mon))
{
if (mon->is_patrolling())
break;
@@ -2114,7 +2114,7 @@ void behaviour_event( monsters *mon, int event, int src,
}
// Just set behaviour... foe doesn't change.
- if (mon->behaviour != BEH_CORNERED)
+ if (!mons_is_cornered(mon))
simple_monster_message(mon, " turns to fight!");
mon->behaviour = BEH_CORNERED;
@@ -3473,7 +3473,7 @@ static bool _mon_on_interesting_grid(monsters *mon)
// if it left it for fighting, seeking etc.
static void _maybe_set_patrol_route(monsters *monster)
{
- if (monster->behaviour == BEH_WANDER
+ if (mons_is_wandering(monster)
&& !mons_friendly(monster)
&& !monster->is_patrolling()
&& _mon_on_interesting_grid(monster))
@@ -3610,7 +3610,7 @@ static void _handle_nearby_ability(monsters *monster)
#define MON_SPEAK_CHANCE 21
if (mons_class_flag(monster->type, M_SPEAKS)
- && (monster->behaviour != BEH_WANDER || monster->attitude == ATT_NEUTRAL)
+ && (!mons_is_wandering(monster) || monster->attitude == ATT_NEUTRAL)
&& one_chance_in(MON_SPEAK_CHANCE))
{
mons_speaks(monster);
@@ -3673,7 +3673,7 @@ static void _handle_nearby_ability(monsters *monster)
case MONS_GIANT_EYEBALL:
if (coinflip() && !mons_friendly(monster)
- && monster->behaviour != BEH_WANDER
+ && !mons_is_wandering(monster)
&& mons_is_fleeing(monster))
{
simple_monster_message(monster, " stares at you.");
@@ -3686,7 +3686,7 @@ static void _handle_nearby_ability(monsters *monster)
case MONS_EYE_OF_DRAINING:
if (coinflip() && !mons_friendly(monster)
- && monster->behaviour != BEH_WANDER
+ && !mons_is_wandering(monster)
&& mons_is_fleeing(monster))
{
simple_monster_message(monster, " stares at you.");
@@ -4965,7 +4965,7 @@ static bool _handle_spell( monsters *monster, bolt & beem )
{
// Forces the casting of dig when player not visible - this is EVIL!
if (monster->has_spell(SPELL_DIG)
- && monster->behaviour == BEH_SEEK)
+ && mons_is_seeking(monster))
{
spell_cast = SPELL_DIG;
finalAnswer = true;
@@ -5589,7 +5589,7 @@ static void _handle_monster_move(int i, monsters *monster)
// every single movement, and we want these monsters to
// hit and run. -- bwr
if (monster->foe != MHITNOT
- && monster->behaviour == BEH_WANDER
+ && mons_is_wandering(monster)
&& mons_is_batty(monster))
{
monster->behaviour = BEH_SEEK;
@@ -5828,7 +5828,7 @@ static void _handle_monster_move(int i, monsters *monster)
beem.target_y = monster->target_y;
if (!mons_is_sleeping(monster)
- && monster->behaviour != BEH_WANDER
+ && !mons_is_wandering(monster)
// Berserking monsters are limited to running up and
// hitting their foes.
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index a0236de6c2..df64a4e24d 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -307,7 +307,7 @@ static bool tag_follower_at(const coord_def &pos)
// Only friendly monsters, or those actively seeking the
// player, will follow up/down stairs.
if (!mons_friendly(fmenv)
- && (fmenv->behaviour != BEH_SEEK || fmenv->foe != MHITYOU))
+ && (!mons_is_seeking(fmenv) || fmenv->foe != MHITYOU))
{
return (false);
}
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index d1562d57dc..9720b171c5 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -1128,8 +1128,8 @@ void monster_grid(bool do_updates)
if (monster->type != -1 && mons_near(monster))
{
- if (do_updates && (monster->behaviour == BEH_SLEEP
- || monster->behaviour == BEH_WANDER)
+ if (do_updates && mons_is_sleeping(monster)
+ || mons_is_wandering(monster))
&& check_awaken(monster))
{
behaviour_event( monster, ME_ALERT, MHITYOU );
@@ -1240,7 +1240,7 @@ bool check_awaken(monsters* monster)
// still actively on guard for the player, even if they can't see you.
// Give them a large bonus -- handle_behaviour() will nuke 'foe' after
// a while, removing this bonus.
- if (monster->behaviour == BEH_WANDER && monster->foe == MHITYOU)
+ if (mons_is_wandering(monster) && monster->foe == MHITYOU)
mons_perc += 15;
if (!mons_player_visible(monster))
@@ -1249,7 +1249,7 @@ bool check_awaken(monsters* monster)
unnatural_stealthy = true;
}
- if (monster->behaviour == BEH_SLEEP)
+ if (mons_is_sleeping(monster))
{
if (mon_holy == MH_NATURAL)
{