summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc4
-rw-r--r--crawl-ref/source/directn.cc7
-rw-r--r--crawl-ref/source/effects.cc16
-rw-r--r--crawl-ref/source/fight.cc21
-rw-r--r--crawl-ref/source/monstuff.cc5
5 files changed, 27 insertions, 26 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 5df920a6e4..cc29d7f736 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -4393,7 +4393,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item)
if (you.religion == GOD_BEOGH
&& mons_species(mon->type) == MONS_ORC
- && mon->behaviour == BEH_SLEEP && !player_under_penance()
+ && mons_is_sleeping(mon) && !player_under_penance()
&& you.piety >= piety_breakpoint(2) && mons_near(mon))
{
hit_woke_orc = true;
@@ -4578,7 +4578,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item)
}
if (you.religion == GOD_BEOGH && mons_species(mon->type) == MONS_ORC
- && mon->behaviour == BEH_SLEEP && YOU_KILL(beam.thrower)
+ && mons_is_sleeping(mon) && YOU_KILL(beam.thrower)
&& !player_under_penance() && you.piety >= piety_breakpoint(2)
&& mons_near(mon))
{
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index be41c25177..6e395a802a 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -2124,19 +2124,20 @@ static void _describe_monster(const monsters *mon)
if (!mons_is_mimic(mon->type) && mons_behaviour_perceptible(mon))
{
- if (mon->behaviour == BEH_SLEEP)
+ if (mons_is_sleeping(mon))
{
mprf(MSGCH_EXAMINE, "%s appears to be resting.",
mon->pronoun(PRONOUN_CAP).c_str());
}
// Applies to both friendlies and hostiles
- else if (mon->behaviour == BEH_FLEE)
+ else if (mons_is_fleeing(mon))
{
mprf(MSGCH_EXAMINE, "%s is retreating.",
mon->pronoun(PRONOUN_CAP).c_str());
}
// hostile with target != you
- else if (!mons_friendly(mon) && !mons_neutral(mon) && mon->foe != MHITYOU)
+ else if (!mons_friendly(mon) && !mons_neutral(mon)
+ && mon->foe != MHITYOU)
{
// special case: batty monsters get set to BEH_WANDER as
// part of their special behaviour.
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 9190e4bf3f..d06129f7cd 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2691,16 +2691,16 @@ static void _catchup_monster_moves(monsters *mon, int turns)
return;
// Don't move non-land or stationary monsters around.
- if (mons_habitat( mon ) != HT_LAND
- || mons_is_zombified( mon )
+ if (mons_habitat(mon) != HT_LAND
+ || mons_is_zombified(mon)
&& mons_habitat_by_type(mon->base_monster) != HT_LAND
- || mons_is_stationary( mon ))
+ || mons_is_stationary(mon))
{
return;
}
// Let sleeping monsters lie.
- if (mon->behaviour == BEH_SLEEP || mons_is_paralysed(mon))
+ if (mons_is_sleeping(mon) || mons_is_paralysed(mon))
return;
const int range = (turns * mon->speed) / 10;
@@ -2725,9 +2725,9 @@ static void _catchup_monster_moves(monsters *mon, int turns)
return;
if (long_time
- && (mon->behaviour == BEH_FLEE
- || mon->behaviour == BEH_CORNERED
- || testbits( mon->flags, MF_BATTY )
+ && (mons_is_fleeing(mon)
+ || mons_is_cornered(mon)
+ || mons_is_batty(mon)
|| ranged_attack
|| coinflip()))
{
@@ -2793,7 +2793,7 @@ static void _catchup_monster_moves(monsters *mon, int turns)
coord_def inc(mon->target_pos() - pos);
inc = coord_def(sgn(inc.x), sgn(inc.y));
- if (mon->behaviour == BEH_FLEE)
+ if (mons_is_fleeing(mon))
inc *= -1;
if (pos.x + inc.x < 0 || pos.x + inc.x >= GXM)
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 970b2b5fcd..b9c5052a16 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -295,7 +295,7 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
{
// Distracted (but not batty); this only applies to players.
if (attacker->atype() == ACT_PLAYER && def->foe != MHITYOU
- && !testbits(def->flags, MF_BATTY))
+ && !mons_is_batty(def))
{
unchivalric = UCAT_DISTRACTED;
}
@@ -308,7 +308,7 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
}
// fleeing
- if (def->behaviour == BEH_FLEE)
+ if (mons_is_fleeing(def))
unchivalric = UCAT_FLEEING;
// invisible
@@ -316,7 +316,7 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
unchivalric = UCAT_INVISIBLE;
// held in a net
- if (def->has_ench(ENCH_HELD) || def->has_ench(ENCH_PETRIFYING))
+ if (mons_is_caught(def) || mons_is_petrifying(def))
unchivalric = UCAT_HELD_IN_NET;
// paralysed
@@ -324,7 +324,7 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
unchivalric = UCAT_PARALYSED;
// sleeping
- if (def->behaviour == BEH_SLEEP)
+ if (mons_is_sleeping(def))
unchivalric = UCAT_SLEEPING;
}
@@ -787,7 +787,7 @@ bool melee_attack::player_attack()
bool hit_woke_orc = false;
if (you.religion == GOD_BEOGH && mons_species(def->type) == MONS_ORC
- && def->behaviour == BEH_SLEEP && !player_under_penance()
+ && mons_is_sleeping(def) && !player_under_penance()
&& you.piety >= piety_breakpoint(2) && mons_near(def))
{
hit_woke_orc = true;
@@ -1287,8 +1287,8 @@ void melee_attack::player_warn_miss()
did_hit = false;
// Upset only non-sleeping monsters if we missed.
- if (def->behaviour != BEH_SLEEP)
- behaviour_event( def, ME_WHACK, MHITYOU );
+ if (!mons_is_sleeping(def))
+ behaviour_event(def, ME_WHACK, MHITYOU);
msg::stream << player_why_missed()
<< def->name(DESC_NOCAP_THE)
@@ -1305,7 +1305,7 @@ bool melee_attack::player_hits_monster()
return (to_hit >= def->ev
|| one_chance_in(20)
- || ((mons_cannot_act(def) || def->behaviour == BEH_SLEEP)
+ || ((mons_cannot_act(def) || mons_is_sleeping(def))
&& !one_chance_in(10 + you.skills[SK_STABBING]))
|| mons_is_petrifying(def)
&& !one_chance_in(2 + you.skills[SK_STABBING]));
@@ -1514,10 +1514,9 @@ int melee_attack::player_stab(int damage)
if (stab_bonus)
{
// Lets make sure we have some damage to work with...
- if (damage < 1)
- damage = 1;
+ damage = std::max(1, damage);
- if (def->behaviour == BEH_SLEEP)
+ if (mons_is_sleeping(def))
{
// Sleeping moster wakes up when stabbed but may be groggy.
if (random2(200) <= you.skills[SK_STABBING] + you.dex)
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 5fb1ea3617..fba957a54e 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -3225,7 +3225,8 @@ static void _handle_behaviour(monsters *mon)
}
else if (proxFoe)
{
- // Try to flee _from_ the correct position.
+ // Special-cased below so that it will flee *from* the
+ // correct position.
mon->target_x = foe_x;
mon->target_y = foe_y;
}
@@ -3686,7 +3687,7 @@ static void _handle_nearby_ability(monsters *monster)
case MONS_EYE_OF_DRAINING:
if (coinflip() && !mons_friendly(monster)
&& monster->behaviour != BEH_WANDER
- && monster->behaviour != BEH_FLEE)
+ && mons_is_fleeing(monster))
{
simple_monster_message(monster, " stares at you.");