summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Kozlov <zaba@thorium.homeunix.org>2009-11-06 19:46:32 +0300
committerRobert Vollmert <rvollmert@gmx.net>2009-11-06 19:52:58 +0100
commitb4b8747ec41b3fa6543d7c51e02515b0cec1496f (patch)
treeefb1625c80d595b58b8bde933decd1dfc674ee04
parent22adbee6a63d3fb1ee05d0e6ff41e80e95b4afc7 (diff)
downloadcrawl-ref-b4b8747ec41b3fa6543d7c51e02515b0cec1496f.tar.gz
crawl-ref-b4b8747ec41b3fa6543d7c51e02515b0cec1496f.zip
Move mons_is_friendly to monsters::friendly.
Signed-off-by: Robert Vollmert <rvollmert@gmx.net>
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/arena.cc2
-rw-r--r--crawl-ref/source/attitude-change.cc4
-rw-r--r--crawl-ref/source/beam.cc6
-rw-r--r--crawl-ref/source/behold.cc2
-rw-r--r--crawl-ref/source/decks.cc2
-rw-r--r--crawl-ref/source/directn.cc20
-rw-r--r--crawl-ref/source/effects.cc4
-rw-r--r--crawl-ref/source/fight.cc16
-rw-r--r--crawl-ref/source/godabil.cc2
-rw-r--r--crawl-ref/source/menu.cc2
-rw-r--r--crawl-ref/source/misc.cc4
-rw-r--r--crawl-ref/source/mon-abil.cc16
-rw-r--r--crawl-ref/source/mon-act.cc20
-rw-r--r--crawl-ref/source/mon-behv.cc24
-rw-r--r--crawl-ref/source/mon-cast.cc14
-rw-r--r--crawl-ref/source/mon-info.cc2
-rw-r--r--crawl-ref/source/mon-util.cc19
-rw-r--r--crawl-ref/source/mon-util.h1
-rw-r--r--crawl-ref/source/monplace.cc6
-rw-r--r--crawl-ref/source/monspeak.cc6
-rw-r--r--crawl-ref/source/monster.cc31
-rw-r--r--crawl-ref/source/monster.h2
-rw-r--r--crawl-ref/source/monstuff.cc22
-rw-r--r--crawl-ref/source/monstuff.h2
-rw-r--r--crawl-ref/source/output.cc8
-rw-r--r--crawl-ref/source/player.cc2
-rw-r--r--crawl-ref/source/religion.cc8
-rw-r--r--crawl-ref/source/showsymb.cc2
-rw-r--r--crawl-ref/source/spells3.cc4
-rw-r--r--crawl-ref/source/spells4.cc2
-rw-r--r--crawl-ref/source/spl-mis.cc4
-rw-r--r--crawl-ref/source/stuff.cc6
-rw-r--r--crawl-ref/source/tilepick.cc4
-rw-r--r--crawl-ref/source/tilereg.cc2
-rw-r--r--crawl-ref/source/tilesdl.cc2
-rw-r--r--crawl-ref/source/traps.cc2
-rw-r--r--crawl-ref/source/tutorial.cc8
-rw-r--r--crawl-ref/source/view.cc4
-rw-r--r--crawl-ref/source/xom.cc2
40 files changed, 146 insertions, 145 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 2fc76337dd..cafcc35029 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -3074,7 +3074,7 @@ static bool _untrap_target(const coord_def move, bool check_confused)
monsters* mon = monster_at(target);
if (mon && player_can_hit_monster(mon))
{
- if (mon->caught() && mons_friendly(mon)
+ if (mon->caught() && mon->friendly()
&& player_can_open_doors() && !you.confused())
{
const std::string prompt =
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index 902407591f..ac02f2e7fd 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -145,7 +145,7 @@ namespace arena
if (!mon->alive())
continue;
- const bool friendly = mons_friendly(mon);
+ const bool friendly = mon->friendly();
// Set target to the opposite faction's home base.
mon->target = friendly ? place_b : place_a;
}
diff --git a/crawl-ref/source/attitude-change.cc b/crawl-ref/source/attitude-change.cc
index 0f3ba57b41..953bd164bb 100644
--- a/crawl-ref/source/attitude-change.cc
+++ b/crawl-ref/source/attitude-change.cc
@@ -77,7 +77,7 @@ void beogh_follower_convert(monsters *monster, bool orc_hit)
&& !mons_is_summoned(monster)
&& !mons_is_shapeshifter(monster)
&& !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT)
- && !mons_friendly(monster)
+ && !monster->friendly()
&& you.visible_to(monster) && !monster->asleep()
&& !mons_is_confused(monster) && !monster->paralysed())
{
@@ -111,7 +111,7 @@ void slime_convert(monsters* monster)
&& !mons_is_summoned(monster)
&& !mons_is_shapeshifter(monster)
&& !mons_neutral(monster)
- && !mons_friendly(monster)
+ && !monster->friendly()
&& !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT)
&& you.visible_to(monster) && !monster->asleep()
&& !mons_is_confused(monster) && !monster->paralysed())
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 95d2be232a..41736c6b16 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -127,7 +127,7 @@ kill_category bolt::whose_kill() const
if (!invalid_monster_index(beam_source))
{
const monsters *mon = &menv[beam_source];
- if (mons_friendly(mon))
+ if (mon->friendly())
return (KC_FRIENDLY);
}
}
@@ -2556,7 +2556,7 @@ static bool _monster_resists_mass_enchantment(monsters *monster,
// Assuming that the only mass charm is control undead.
if (wh_enchant == ENCH_CHARM)
{
- if (mons_friendly(monster))
+ if (monster->friendly())
return (true);
if (monster->holiness() != MH_UNDEAD)
@@ -4947,7 +4947,7 @@ bool _ench_flavour_affects_monster(beam_type flavour, const monsters* mon)
break;
case BEAM_ENSLAVE_DEMON:
- rc = (mon->holiness() == MH_DEMONIC && !mons_friendly(mon));
+ rc = (mon->holiness() == MH_DEMONIC && !mon->friendly());
break;
case BEAM_PAIN:
diff --git a/crawl-ref/source/behold.cc b/crawl-ref/source/behold.cc
index 8d76fe9d21..bcbacace1e 100644
--- a/crawl-ref/source/behold.cc
+++ b/crawl-ref/source/behold.cc
@@ -165,7 +165,7 @@ bool player::_possible_beholder(const monsters *mon) const
if (silenced(you.pos()))
return (false);
if (!mon->alive() || mons_genus(mon->type) != MONS_MERMAID
- || !mons_near(mon) || mons_friendly(mon)
+ || !mons_near(mon) || mon->friendly()
|| mon->submerged() || mon->confused() || mons_cannot_move(mon)
|| mon->asleep() || silenced(mon->pos()))
{
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index f7ebebf85e..afe7930862 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2518,7 +2518,7 @@ static void _crusade_card(int power, deck_rarity_type rarity)
monsters* const monster = &menv[i];
if (!monster->alive()
|| !mons_near(monster)
- || mons_friendly(monster)
+ || monster->friendly()
|| monster->holiness() != MH_NATURAL
|| mons_is_unique(monster->type)
|| mons_immune_magic(monster)
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 38ac8aa8bc..a40966326e 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -1076,7 +1076,7 @@ void direction(dist& moves, targetting_type restricts,
if (you.can_see(montarget)
// not made friendly since then
&& (mons_attitude(montarget) == ATT_HOSTILE
- || mode == TARG_ENEMY && !mons_friendly(montarget))
+ || mode == TARG_ENEMY && !montarget->friendly())
&& _is_target_in_range(montarget->pos(), range))
{
found_autotarget = true;
@@ -2081,10 +2081,10 @@ static bool _find_monster( const coord_def& where, int mode, bool need_path,
return (mons_attitude(mon) == ATT_HOSTILE);
if (mode == TARG_FRIEND)
- return (mons_friendly(mon));
+ return (mon->friendly());
ASSERT(mode == TARG_ENEMY);
- if (mons_friendly(mon))
+ if (mon->friendly())
return (false);
// Don't target zero xp monsters, unless target_zero_exp is set.
@@ -3140,7 +3140,7 @@ static std::string _get_monster_desc(const monsters *mon)
else if (mons_is_fleeing(mon))
text += pronoun + " is retreating.\n";
// hostile with target != you
- else if (!mons_friendly(mon) && !mons_neutral(mon)
+ else if (!mon->friendly() && !mons_neutral(mon)
&& mon->foe != MHITYOU && !crawl_state.arena_suspended)
{
// Special case: batty monsters get set to BEH_WANDER as
@@ -3248,7 +3248,7 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
if (print_attitude)
{
std::string str = "";
- if (mons_friendly(mon))
+ if (mon->friendly())
str = "friendly";
else if (mons_neutral(mon))
str = "neutral";
@@ -3288,7 +3288,7 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
// true rakshasa when it summons.
if (mon->type != MONS_DANCING_WEAPON
- && (mon->type != MONS_RAKSHASA || mons_friendly(mon)))
+ && (mon->type != MONS_RAKSHASA || mon->friendly()))
{
weap = _describe_monster_weapon(mon);
}
@@ -3301,15 +3301,15 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
}
// Print the rest of the equipment only for full descriptions.
- if (full_desc && (mon->type != MONS_RAKSHASA || mons_friendly(mon)))
+ if (full_desc && (mon->type != MONS_RAKSHASA || mon->friendly()))
{
const int mon_arm = mon->inv[MSLOT_ARMOUR];
const int mon_shd = mon->inv[MSLOT_SHIELD];
const int mon_qvr = mon->inv[MSLOT_MISSILE];
const int mon_alt = mon->inv[MSLOT_ALT_WEAPON];
- const bool need_quiver = (mon_qvr != NON_ITEM && mons_friendly(mon));
- const bool need_alt_wpn = (mon_alt != NON_ITEM && mons_friendly(mon)
+ const bool need_quiver = (mon_qvr != NON_ITEM && mon->friendly());
+ const bool need_alt_wpn = (mon_alt != NON_ITEM && mon->friendly()
&& !mons_wields_two_weapons(mon));
bool found_sth = !weap.empty();
@@ -3341,7 +3341,7 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc,
// For friendly monsters, also list quivered missiles
// and alternate weapon.
- if (mons_friendly(mon))
+ if (mon->friendly())
{
if (mon_qvr != NON_ITEM)
{
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 9dbced7c40..fb50a9b7ad 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2454,7 +2454,7 @@ static void _set_friendly_foes(bool allow_patrol = false)
for (int i = 0; i < MAX_MONSTERS; ++i)
{
monsters *mon(&menv[i]);
- if (!mon->alive() || !mons_near(mon) || !mons_friendly(mon)
+ if (!mon->alive() || !mons_near(mon) || !mon->friendly()
|| mon->mons_species() == MONS_GIANT_SPORE)
{
continue;
@@ -2474,7 +2474,7 @@ static void _set_allies_patrol_point(bool clear = false)
for (int i = 0; i < MAX_MONSTERS; ++i)
{
monsters *mon(&menv[i]);
- if (!mon->alive() || !mons_near(mon) || !mons_friendly(mon))
+ if (!mon->alive() || !mons_near(mon) || !mon->friendly())
continue;
// Berserking monsters cannot be ordered around.
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 524aabadd7..6f44616de8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -696,7 +696,7 @@ bool melee_attack::attack()
if (is_sanctuary(attacker->pos()) || is_sanctuary(defender->pos()))
{
if (attacker->atype() == ACT_PLAYER
- || mons_friendly(attacker_as_monster()))
+ || attacker_as_monster()->friendly())
{
remove_sanctuary(true);
}
@@ -2450,7 +2450,7 @@ void melee_attack::chaos_affects_defender()
clone.mark_summoned(6, true, MON_SUMM_CLONE);
// Monsters being cloned is interesting.
- xom_is_stimulated(mons_friendly(&clone) ? 16 : 32);
+ xom_is_stimulated(clone.friendly() ? 16 : 32);
}
break;
}
@@ -2481,7 +2481,7 @@ void melee_attack::chaos_affects_defender()
monster_polymorph(defender_as_monster(), RANDOM_MONSTER);
// Xom loves it if this happens!
- const int friend_factor = mons_friendly(defender_as_monster()) ? 1 : 2;
+ const int friend_factor = defender_as_monster()->friendly() ? 1 : 2;
const int glow_factor =
(defender_as_monster()->has_ench(ENCH_SHAPESHIFTER) ? 1 : 2);
xom_is_stimulated( 64 * friend_factor * glow_factor );
@@ -2565,7 +2565,7 @@ void melee_attack::chaos_affects_defender()
: attacker_as_monster()->confused_by_you() ? KILL_YOU_CONF
: KILL_MON;
- if (beam.thrower == KILL_YOU || mons_friendly(attacker_as_monster()))
+ if (beam.thrower == KILL_YOU || attacker_as_monster()->friendly())
beam.attitude = ATT_FRIENDLY;
beam.beam_source = attacker->mindex();
@@ -4090,7 +4090,7 @@ bool melee_attack::mons_attack_mons()
{
// Friendly monsters should only violate sanctuary if explicitly
// ordered to do so by the player.
- if (mons_friendly(attacker_as_monster()))
+ if (attacker_as_monster()->friendly())
{
if (you.pet_target == MHITYOU || you.pet_target == MHITNOT)
{
@@ -4140,7 +4140,7 @@ bool melee_attack::mons_attack_mons()
// already, but not if sanctuary is in effect (pet target must be
// set explicitly by the player during sanctuary).
if (perceived_attack && attacker->alive()
- && mons_friendly(defender_as_monster())
+ && defender_as_monster()->friendly()
&& !crawl_state.arena
&& !mons_wont_attack(attacker_as_monster())
&& you.pet_target == MHITNOT
@@ -4541,7 +4541,7 @@ void melee_attack::mons_do_napalm()
else
{
napalm_monster(defender_as_monster(),
- mons_friendly(attacker_as_monster()) ?
+ attacker_as_monster()->friendly() ?
KC_FRIENDLY : KC_OTHER,
std::min(4, 1 + random2(attacker->get_experience_level())/2));
}
@@ -5049,7 +5049,7 @@ void melee_attack::mons_perform_attack_rounds()
bool end = true;
for (adjacent_iterator i(attacker->pos()); i; ++i)
{
- if (*i == you.pos() && !mons_friendly(attacker_as_monster()))
+ if (*i == you.pos() && !attacker_as_monster()->friendly())
{
attacker_as_monster()->foe = MHITYOU;
attacker_as_monster()->target = you.pos();
diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc
index 496a4c5a9c..eaaa52e861 100644
--- a/crawl-ref/source/godabil.cc
+++ b/crawl-ref/source/godabil.cc
@@ -393,7 +393,7 @@ static int _lugonu_warp_monster(coord_def where, int pow, int, actor *)
if (mon == NULL)
return (0);
- if (!mons_friendly(mon))
+ if (!mon->friendly())
behaviour_event(mon, ME_ANNOY, MHITYOU);
if (mon->check_res_magic(pow * 2))
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 2733d2c7ff..df4e586665 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -811,7 +811,7 @@ bool MonsterMenuEntry::get_tiles(std::vector<tile_def>& tileset) const
}
}
- if (mons_friendly(m))
+ if (m->friendly())
tileset.push_back(tile_def(TILE_HEART, TEX_DEFAULT));
else if (mons_neutral(m))
tileset.push_back(tile_def(TILE_NEUTRAL, TEX_DEFAULT));
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f9613ac9c8..427255cfc8 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2952,7 +2952,7 @@ static void monster_threat_values(double *general, double *highest,
{
monster = &menv[it];
- if (monster->alive() && mons_near(monster) && !mons_friendly(monster))
+ if (monster->alive() && mons_near(monster) && !monster->friendly())
{
const int xp = exper_value(monster);
const double log_xp = log((double)xp);
@@ -3161,7 +3161,7 @@ bool stop_attack_prompt(const monsters *mon, bool beam_attack,
const bool inSanctuary = (is_sanctuary(you.pos())
|| is_sanctuary(mon->pos()));
const bool wontAttack = mons_wont_attack(mon);
- const bool isFriendly = mons_friendly(mon);
+ const bool isFriendly = mon->friendly();
const bool isNeutral = mons_neutral(mon);
const bool isUnchivalric = is_unchivalric_attack(&you, mon);
const bool isHoly = mons_is_holy(mon)
diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc
index 37207963de..0cd0b4e801 100644
--- a/crawl-ref/source/mon-abil.cc
+++ b/crawl-ref/source/mon-abil.cc
@@ -582,7 +582,7 @@ static bool _orc_battle_cry(monsters *chief)
int affected = 0;
if (foe
- && (foe != &you || !mons_friendly(chief))
+ && (foe != &you || !chief->friendly())
&& !silenced(chief->pos())
&& chief->can_see(foe)
&& coinflip())
@@ -645,7 +645,7 @@ static bool _orc_battle_cry(monsters *chief)
// Disabling detailed frenzy announcement because it's so spammy.
const msg_channel_type channel =
- mons_friendly(chief) ? MSGCH_MONSTER_ENCHANT
+ chief->friendly() ? MSGCH_MONSTER_ENCHANT
: MSGCH_FRIEND_ENCHANT;
if (!seen_affected.empty())
@@ -671,7 +671,7 @@ static bool _orc_battle_cry(monsters *chief)
who = get_monster_data(type)->name;
mprf(channel, "%s %s go into a battle-frenzy!",
- mons_friendly(chief) ? "Your" : "The",
+ chief->friendly() ? "Your" : "The",
pluralise(who).c_str());
}
}
@@ -683,7 +683,7 @@ static bool _orc_battle_cry(monsters *chief)
static bool _make_monster_angry(const monsters *mon, monsters *targ)
{
- if (mons_friendly(mon) != mons_friendly(targ))
+ if (mon->friendly() != targ->friendly())
return (false);
// targ is guaranteed to have a foe (needs_berserk checks this).
@@ -773,7 +773,7 @@ bool mon_special_ability(monsters *monster, bolt & beem)
return (false);
}
- const msg_channel_type spl = (mons_friendly(monster) ? MSGCH_FRIEND_SPELL
+ const msg_channel_type spl = (monster->friendly() ? MSGCH_FRIEND_SPELL
: MSGCH_MONSTER_SPELL);
spell_type spell = SPELL_NO_SPELL;
@@ -970,7 +970,7 @@ bool mon_special_ability(monsters *monster, bolt & beem)
break;
if (monster->foe == MHITNOT
- || monster->foe == MHITYOU && mons_friendly(monster))
+ || monster->foe == MHITYOU && monster->friendly())
{
break;
}
@@ -1011,7 +1011,7 @@ bool mon_special_ability(monsters *monster, bolt & beem)
switch (random2(4))
{
case 0:
- if (!mons_friendly(monster))
+ if (!monster->friendly())
{
make_mons_stop_fleeing(monster);
spell_cast = SPELL_SYMBOL_OF_TORMENT;
@@ -1181,7 +1181,7 @@ bool mon_special_ability(monsters *monster, bolt & beem)
if (monster->has_ench(ENCH_CONFUSION)
|| mons_is_fleeing(monster)
|| mons_is_pacified(monster)
- || mons_friendly(monster)
+ || monster->friendly()
|| !player_can_hear(monster->pos()))
{
break;
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc
index c901f06690..ca998d22a3 100644
--- a/crawl-ref/source/mon-act.cc
+++ b/crawl-ref/source/mon-act.cc
@@ -129,7 +129,7 @@ static bool _swap_monsters(monsters* mover, monsters* moved)
// Don't swap places if the player explicitly ordered their pet to
// attack monsters.
- if ((mons_friendly(mover) || mons_friendly(moved))
+ if ((mover->friendly() || moved->friendly())
&& you.pet_target != MHITYOU && you.pet_target != MHITNOT)
{
return (false);
@@ -316,7 +316,7 @@ static bool _mon_on_interesting_grid(monsters *mon)
static void _maybe_set_patrol_route(monsters *monster)
{
if (mons_is_wandering(monster)
- && !mons_friendly(monster)
+ && !monster->friendly()
&& !monster->is_patrolling()
&& _mon_on_interesting_grid(monster))
{
@@ -398,7 +398,7 @@ static void _handle_movement(monsters *monster)
mmov.y = (delta.y > 0) ? 1 : ((delta.y < 0) ? -1 : 0);
if (mons_is_fleeing(monster) && monster->travel_target != MTRAV_WALL
- && (!mons_friendly(monster)
+ && (!monster->friendly()
|| monster->target != you.pos()))
{
mmov *= -1;
@@ -987,7 +987,7 @@ static bool _handle_wand(monsters *monster, bolt &beem)
case WAND_INVISIBILITY:
if (!monster->has_ench(ENCH_INVIS)
&& !monster->has_ench(ENCH_SUBMERGED)
- && (!mons_friendly(monster) || you.can_see_invisible(false)))
+ && (!monster->friendly() || you.can_see_invisible(false)))
{
beem.target = monster->pos();
niceWand = true;
@@ -1105,7 +1105,7 @@ static bool _mons_throw(struct monsters *monster, struct bolt &pbolt,
// Dropping item copy, since the launched item might be different.
item_def item = mitm[hand_used];
item.quantity = 1;
- if (mons_friendly(monster))
+ if (monster->friendly())
item.flags |= ISFLAG_DROPPED_BY_ALLY;
// FIXME we should actually determine a sensible range here
@@ -1800,7 +1800,7 @@ static void _handle_monster_move(monsters *monster)
// Same for friendlies if friendly_pickup is set to "none".
if (!mons_neutral(monster) && !monster->has_ench(ENCH_CHARM)
|| (you.religion == GOD_JIYVA && mons_is_slime(monster))
- && (!mons_friendly(monster)
+ && (!monster->friendly()
|| you.friendly_pickup != FRIENDLY_PICKUP_NONE))
{
if (_handle_pickup(monster))
@@ -1922,7 +1922,7 @@ static void _handle_monster_move(monsters *monster)
// Prevents unfriendlies from nuking you from offscreen.
// How nice!
const bool friendly_or_near =
- mons_friendly(monster) || monster->near_foe();
+ monster->friendly() || monster->near_foe();
if (friendly_or_near
|| monster->type == MONS_TEST_SPAWNER
// Slime creatures can split when offscreen.
@@ -1982,7 +1982,7 @@ static void _handle_monster_move(monsters *monster)
{
ASSERT(!crawl_state.arena);
- if (!mons_friendly(monster))
+ if (!monster->friendly())
{
// If it steps into you, cancel other targets.
monster->foe = MHITYOU;
@@ -2169,7 +2169,7 @@ static bool _monster_eat_item(monsters *monster, bool nearby)
return (false);
// Friendly jellies won't eat (unless worshipping Jiyva).
- if (mons_friendly(monster) && you.religion != GOD_JIYVA)
+ if (monster->friendly() && you.religion != GOD_JIYVA)
return (false);
int hps_changed = 0;
@@ -2530,7 +2530,7 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where,
const bool player_knows_trap = (trap.is_known(&you));
// No friendly monsters will ever enter a Zot trap you know.
- if (player_knows_trap && mons_friendly(monster) && trap.type == TRAP_ZOT)
+ if (player_knows_trap && monster->friendly() && trap.type == TRAP_ZOT)
return (false);
// Dumb monsters don't care at all.
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index 779f5f8247..0d67baf782 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -162,7 +162,7 @@ static bool _try_pathfind(monsters *mon, const dungeon_feature_type can_move,
// pathfinding, and it's also not necessary if the monster
// is already adjacent to you.
if (potentially_blocking && mons_intel(mon) >= I_NORMAL
- && !mons_friendly(mon) && mons_has_los_ability(mon->type)
+ && !mon->friendly() && mons_has_los_ability(mon->type)
|| grid_distance(mon->pos(), you.pos()) == 1)
{
potentially_blocking = false;
@@ -180,7 +180,7 @@ static bool _try_pathfind(monsters *mon, const dungeon_feature_type can_move,
// realise that.
if (!potentially_blocking && !mons_flies(mon)
&& (mons_intel(mon) < I_NORMAL
- || mons_friendly(mon)
+ || mon->friendly()
|| (!mons_has_ranged_spell(mon, true)
&& !mons_has_ranged_attack(mon))))
{
@@ -787,7 +787,7 @@ static bool _handle_monster_patrolling(monsters *mon)
if (mons_intel(mon) == I_PLANT)
{
// Really stupid monsters forget where they're supposed to be.
- if (mons_friendly(mon))
+ if (mon->friendly())
{
// Your ally was told to wait, and wait it will!
// (Though possibly not where you told it to.)
@@ -1084,7 +1084,7 @@ static void _set_random_slime_target(monsters* mon)
void handle_behaviour(monsters *mon)
{
bool changed = true;
- bool isFriendly = mons_friendly(mon);
+ bool isFriendly = mon->friendly();
bool isNeutral = mons_neutral(mon);
bool wontAttack = mons_wont_attack(mon);
@@ -1160,7 +1160,7 @@ void handle_behaviour(monsters *mon)
const monsters& foe_monster = menv[mon->foe];
if (!foe_monster.alive())
mon->foe = MHITNOT;
- if (mons_friendly(&foe_monster) == isFriendly)
+ if (foe_monster.friendly() == isFriendly)
mon->foe = MHITNOT;
}
@@ -1250,7 +1250,7 @@ void handle_behaviour(monsters *mon)
const monsters& foe_monster = menv[mon->foe];
if (!foe_monster.alive())
mon->foe = MHITNOT;
- if (mons_friendly(&foe_monster) == isFriendly)
+ if (foe_monster.friendly() == isFriendly)
mon->foe = MHITNOT;
}
@@ -1605,7 +1605,7 @@ static bool _mons_check_foe(monsters *mon, const coord_def& p,
if (foe != mon
&& mon->can_see(foe)
&& (friendly || !is_sanctuary(p))
- && (mons_friendly(foe) != friendly
+ && (foe->friendly() != friendly
|| (neutral && !mons_neutral(foe))))
{
return (true);
@@ -1617,7 +1617,7 @@ static bool _mons_check_foe(monsters *mon, const coord_def& p,
// Choose random nearest monster as a foe.
void _set_nearest_monster_foe(monsters *mon)
{
- const bool friendly = mons_friendly(mon);
+ const bool friendly = mon->friendly();
const bool neutral = mons_neutral(mon);
for (int k = 1; k <= LOS_RADIUS; ++k)
@@ -1756,7 +1756,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src,
case ME_ALERT:
// Allow monsters falling asleep while patrolling (can happen if
// they're left alone for a long time) to be woken by this event.
- if (mons_friendly(mon) && mon->is_patrolling()
+ if (mon->friendly() && mon->is_patrolling()
&& !mon->asleep())
{
break;
@@ -1827,7 +1827,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src,
// scroll of fear, but enslaved ones will.
// Send friendlies off to a random target so they don't cling
// to you in fear.
- if (mons_friendly(mon))
+ if (mon->friendly())
{
breakCharm = true;
mon->foe = MHITNOT;
@@ -1836,7 +1836,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src,
else
setTarget = true;
}
- else if (mons_friendly(mon) && !crawl_state.arena)
+ else if (mon->friendly() && !crawl_state.arena)
mon->foe = MHITYOU;
if (see_cell(mon->pos()))
@@ -1855,7 +1855,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src,
// Just set behaviour... foe doesn't change.
if (!mons_is_cornered(mon))
{
- if (mons_friendly(mon) && !crawl_state.arena)
+ if (mon->friendly() && !crawl_state.arena)
{
mon->foe = MHITYOU;
simple_monster_message(mon, " returns to your side!");
diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc
index 4593802638..25d217e1dc 100644
--- a/crawl-ref/source/mon-cast.cc
+++ b/crawl-ref/source/mon-cast.cc
@@ -1232,7 +1232,7 @@ bool handle_mon_spell(monsters *monster, bolt &beem)
// Friendly monsters don't use polymorph other, for fear of harming
// the player.
- if (spell_cast == SPELL_POLYMORPH_OTHER && mons_friendly(monster))
+ if (spell_cast == SPELL_POLYMORPH_OTHER && monster->friendly())
return (false);
// Try to animate dead: if nothing rises, pretend we didn't cast it.
@@ -1836,7 +1836,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
return;
case SPELL_SYMBOL_OF_TORMENT:
- if (!monsterNearby || mons_friendly(monster))
+ if (!monsterNearby || monster->friendly())
return;
torment(monster_index(monster), monster->pos());
@@ -1911,7 +1911,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
if (!mons_near(monster))
return;
- const bool friendly = mons_friendly(monster);
+ const bool friendly = monster->friendly();
const bool buff_only = !friendly && is_sanctuary(you.pos());
const msg_channel_type channel = (friendly) ? MSGCH_FRIEND_ENCHANT
: MSGCH_MONSTER_ENCHANT;
@@ -2049,7 +2049,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
return;
}
case SPELL_CHAIN_LIGHTNING:
- if (!monsterNearby || mons_friendly(monster))
+ if (!monsterNearby || monster->friendly())
return;
cast_chain_lightning(4 * monster->hit_dice, monster);
return;
@@ -2477,9 +2477,9 @@ void mons_cast_noise(monsters *monster, bolt &pbolt, spell_type spell_cast)
msg = replace_all(msg, "@beam@", beam_name);
const msg_channel_type chan =
- (unseen ? MSGCH_SOUND :
- mons_friendly(monster) ? MSGCH_FRIEND_SPELL
- : MSGCH_MONSTER_SPELL);
+ (unseen ? MSGCH_SOUND :
+ monster->friendly() ? MSGCH_FRIEND_SPELL
+ : MSGCH_MONSTER_SPELL);
if (silent)
mons_speaks_msg(monster, msg, chan, true);
diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc
index 8aadc143b1..47a2f8564c 100644
--- a/crawl-ref/source/mon-info.cc
+++ b/crawl-ref/source/mon-info.cc
@@ -182,7 +182,7 @@ static std::string _verbose_info(const monsters* m)
return (" (wandering)");
}
if (m->foe == MHITNOT && !mons_is_batty(m) && !mons_neutral(m)
- && !mons_friendly(m))
+ && !m->friendly())
{
return (" (unaware)");
}
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index f071fad698..15f533452b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1974,11 +1974,6 @@ int mons_base_damage_brand(const monsters *m)
return (SPWPN_NORMAL);
}
-bool mons_friendly(const monsters *m)
-{
- return (m->attitude == ATT_FRIENDLY || m->has_ench(ENCH_CHARM));
-}
-
bool mons_neutral(const monsters *m)
{
return (m->attitude == ATT_NEUTRAL || m->has_ench(ENCH_NEUTRAL)
@@ -2003,7 +1998,7 @@ bool mons_is_pacified(const monsters *m)
bool mons_wont_attack(const monsters *m)
{
- return (mons_friendly(m) || mons_good_neutral(m) || mons_strict_neutral(m));
+ return (m->friendly() || mons_good_neutral(m) || mons_strict_neutral(m));
}
bool mons_att_wont_attack(mon_attitude_type fr)
@@ -2013,7 +2008,7 @@ bool mons_att_wont_attack(mon_attitude_type fr)
mon_attitude_type mons_attitude(const monsters *m)
{
- if (mons_friendly(m))
+ if (m->friendly())
return ATT_FRIENDLY;
else if (mons_good_neutral(m))
return ATT_GOOD_NEUTRAL;
@@ -2114,7 +2109,7 @@ bool mons_looks_stabbable(const monsters *m)
{
const unchivalric_attack_type uat = is_unchivalric_attack(&you, m);
return (mons_behaviour_perceptible(m)
- && !mons_friendly(m)
+ && !m->friendly()
&& (uat == UCAT_PARALYSED || uat == UCAT_SLEEPING));
}
@@ -2122,7 +2117,7 @@ bool mons_looks_distracted(const monsters *m)
{
const unchivalric_attack_type uat = is_unchivalric_attack(&you, m);
return (mons_behaviour_perceptible(m)
- && !mons_friendly(m)
+ && !m->friendly()
&& uat != UCAT_NO_ATTACK
&& uat != UCAT_PARALYSED
&& uat != UCAT_SLEEPING);
@@ -2229,7 +2224,7 @@ bool mons_should_fire(struct bolt &beam)
if (!invalid_monster_index(beam.beam_source))
{
monsters& m = menv[beam.beam_source];
- if (m.alive() && mons_friendly(&m) && beam.target == you.pos())
+ if (m.alive() && m.friendly() && beam.target == you.pos())
return (false);
}
@@ -2359,7 +2354,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
const actor *foe = mon->get_foe();
// Keep friendly summoners from spamming summons constantly.
- if (mons_friendly(mon)
+ if (mon->friendly()
&& (!foe || foe == &you)
&& spell_typematch(monspell, SPTYP_SUMMONING))
{
@@ -2438,7 +2433,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
case SPELL_INVISIBILITY:
if (mon->has_ench(ENCH_INVIS)
- || mons_friendly(mon) && !you.can_see_invisible(false))
+ || mon->friendly() && !you.can_see_invisible(false))
{
ret = true;
}
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index ec09c7167b..7c2f8dff69 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -608,7 +608,6 @@ const char *mons_pronoun(monster_type mon_type, pronoun_type variant,
bool mons_aligned(int m1, int m2);
bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2);
-bool mons_friendly(const monsters *m);
bool mons_neutral(const monsters *m);
bool mons_good_neutral(const monsters *m);
bool mons_strict_neutral(const monsters *m);
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 278dc511b0..942e4ac4af 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -3265,7 +3265,7 @@ bool monster_pathfind::mons_traversable(const coord_def p)
// Your friends only know about doors you know about, unless they feel
// at home in this branch.
- if (grd(p) == DNGN_SECRET_DOOR && mons_friendly(mons)
+ if (grd(p) == DNGN_SECRET_DOOR && mons->friendly()
&& (mons_intel(mons) < I_NORMAL || !mons_is_native_in_branch(mons)))
{
return (false);
@@ -3279,7 +3279,7 @@ bool monster_pathfind::mons_traversable(const coord_def p)
// Don't allow allies to pass over known (to them) Zot traps.
if (tt == TRAP_ZOT
&& ptrap->is_known(mons)
- && mons_friendly(mons))
+ && mons->friendly())
{
return (false);
}
@@ -3336,7 +3336,7 @@ int monster_pathfind::mons_travel_cost(coord_def npos)
{
// Your allies take extra precautions to avoid known alarm traps.
// Zot traps are considered intraversable.
- if (knows_trap && mons_friendly(mons))
+ if (knows_trap && mons->friendly())
return (3);
// To hostile monsters, these traps are completely harmless.
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 6ac5e4544c..f40a148903 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -412,7 +412,7 @@ bool mons_speaks(monsters *monster)
prefixes.push_back("neutral");
}
- else if (mons_friendly(monster) && !crawl_state.arena)
+ else if (monster->friendly() && !crawl_state.arena)
prefixes.push_back("friendly");
else
prefixes.push_back("hostile");
@@ -766,13 +766,13 @@ bool mons_speaks_msg(monsters *monster, const std::string &msg,
msg_type = MSGCH_TALK_VISUAL;
else if (param == "SPELL" && !silence || param == "VISUAL SPELL")
{
- msg_type = mons_friendly(monster) ? MSGCH_FRIEND_SPELL
+ msg_type = monster->friendly() ? MSGCH_FRIEND_SPELL
: MSGCH_MONSTER_SPELL;
}
else if (param == "ENCHANT" && !silence
|| param == "VISUAL ENCHANT")
{
- msg_type = mons_friendly(monster) ? MSGCH_FRIEND_ENCHANT
+ msg_type = monster->friendly() ? MSGCH_FRIEND_ENCHANT
: MSGCH_MONSTER_ENCHANT;
}
else if (param == "PLAIN")
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index affe0e3836..67de4d5e4d 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -677,7 +677,7 @@ static bool _needs_ranged_attack(const monsters *mon)
return (false);
// Same for summonings, but make an exception for friendlies.
- if (!mons_friendly(mon) && mon->has_spell_of_type(SPTYP_SUMMONING))
+ if (!mon->friendly() && mon->has_spell_of_type(SPTYP_SUMMONING))
return (false);
// Blademasters don't want to throw stuff.
@@ -1138,7 +1138,7 @@ bool monsters::drop_item(int eslot, int near)
if (on_floor)
{
- if (mons_friendly(this))
+ if (friendly())
pitem->flags |= ISFLAG_DROPPED_BY_ALLY;
if (need_message(near))
@@ -1396,7 +1396,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(slot)
- && (mons_is_wandering(this) || mons_friendly(this) && foe == MHITYOU)
+ && (mons_is_wandering(this) || friendly() && foe == MHITYOU)
&& pickup(item, slot, near, true))
{
return (true);
@@ -1605,7 +1605,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 (!mons_is_wandering(this)
- && (!mons_friendly(this) || foe != MHITYOU)
+ && (!friendly() || foe != MHITYOU)
&& (item.quantity < 5 || miss && miss->quantity >= 7))
{
return (false);
@@ -1749,7 +1749,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 = (mons_is_wandering(this)
- || mons_friendly(this) && foe == MHITYOU);
+ || friendly() && foe == MHITYOU);
const int itype = item.base_type;
// Weak(ened) monsters won't stop to pick up things as long as they
@@ -1760,7 +1760,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force)
return (false);
}
- if (mons_friendly(this))
+ if (friendly())
{
// Never pick up gold or misc. items, it'd only annoy the player.
if (itype == OBJ_MISCELLANY || itype == OBJ_GOLD)
@@ -1798,7 +1798,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force)
// While occupied, hostile monsters won't pick up items
// dropped or thrown by you. (You might have done that to
// distract them.)
- if (!mons_friendly(this)
+ if (!friendly()
&& (testbits(item.flags, ISFLAG_DROPPED)
|| testbits(item.flags, ISFLAG_THROWN)))
{
@@ -2071,7 +2071,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
if (!mons_is_unique(nametype)
&& (mon.mname.empty() || mons_genus(nametype) == MONS_HYDRA))
{
- const bool use_your = mons_friendly(&mon);
+ const bool use_your = mon.friendly();
switch (desc)
{
case DESC_CAP_THE:
@@ -2688,7 +2688,7 @@ void monsters::go_berserk(bool /* intentional */)
add_ench(mon_enchant(ENCH_MIGHT, 0, KC_OTHER, duration * 10));
if (simple_monster_message(this, " goes berserk!"))
// Xom likes monsters going berserk.
- xom_is_stimulated(mons_friendly(this) ? 32 : 128);
+ xom_is_stimulated(friendly() ? 32 : 128);
}
void monsters::expose_to_element(beam_type flavour, int strength)
@@ -2827,6 +2827,11 @@ bool monsters::petrified() const
return has_ench(ENCH_PETRIFIED);
}
+bool monsters::friendly() const
+{
+ return (attitude == ATT_FRIENDLY || has_ench(ENCH_CHARM));
+}
+
int monsters::shield_bonus() const
{
const item_def *shld = const_cast<monsters*>(this)->shield();
@@ -3418,7 +3423,7 @@ int monsters::hurt(const actor *agent, int amount, beam_type flavour,
// jelly).
kill_category whose = (agent == NULL) ? KC_OTHER :
(agent->atype() == ACT_PLAYER) ? KC_YOU :
- mons_friendly((monsters*)agent) ? KC_FRIENDLY :
+ ((monsters*)agent)->friendly() ? KC_FRIENDLY :
KC_OTHER;
react_to_damage(amount, flavour, whose);
}
@@ -4985,7 +4990,7 @@ void monsters::scale_hp(int num, int den)
kill_category monsters::kill_alignment() const
{
- return (mons_friendly(this) ? KC_FRIENDLY : KC_OTHER);
+ return (friendly() ? KC_FRIENDLY : KC_OTHER);
}
bool monsters::sicken(int amount)
@@ -5057,7 +5062,7 @@ actor *monsters::get_foe() const
if (foe == MHITNOT)
return (NULL);
else if (foe == MHITYOU)
- return (mons_friendly(this) ? NULL : &you);
+ return (friendly() ? NULL : &you);
// Must be a monster!
monsters *my_foe = &menv[foe];
@@ -5510,7 +5515,7 @@ bool monsters::should_drink_potion(potion_type ptype) const
// We're being nice: friendlies won't go invisible if the player
// won't be able to see them.
return (!has_ench(ENCH_INVIS)
- && (you.can_see_invisible(false) || !mons_friendly(this)));
+ && (you.can_see_invisible(false) || !friendly()));
default:
break;
}
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 5138f6b6f7..d07b4bd0ed 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -332,6 +332,8 @@ public:
bool haloed() const;
bool petrified() const;
+ bool friendly() const;
+
bool has_spells() const;
bool has_spell(spell_type spell) const;
bool has_evil_spell() const;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 9c2b3de63f..79c535e69c 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -256,7 +256,7 @@ void monster_drop_ething(monsters *monster, bool mark_item_origins,
}
else
{
- if (mons_friendly(monster) && mitm[item].is_valid())
+ if (monster->friendly() && mitm[item].is_valid())
mitm[item].flags |= ISFLAG_DROPPED_BY_ALLY;
move_item_to_grid(&item, monster->pos());
@@ -536,7 +536,7 @@ static void _give_monster_experience(monsters *victim,
if (!mon->alive())
return;
- if ((!victim_was_born_friendly || !mons_friendly(mon))
+ if ((!victim_was_born_friendly || !mon->friendly())
&& !mons_aligned(killer_index, monster_index(victim)))
{
if (mon->gain_exp(experience))
@@ -634,7 +634,7 @@ static bool _is_pet_kill(killer_type killer, int i)
return (false);
const monsters *m = &menv[i];
- if (mons_friendly(m)) // This includes enslaved monsters.
+ if (m->friendly()) // This includes enslaved monsters.
return (true);
// Check if the monster was confused by you or a friendly, which
@@ -653,7 +653,7 @@ static bool _ely_protect_ally(monsters *monster)
if (monster->holiness() != MH_NATURAL
&& monster->holiness() != MH_HOLY
- || !mons_friendly(monster)
+ || !monster->friendly()
|| !you.can_see(monster) // for simplicity
|| !one_chance_in(20))
{
@@ -686,13 +686,13 @@ static bool _ely_heal_monster(monsters *monster, killer_type killer, int i)
const int ely_penance = you.penance[god];
- if (mons_friendly(monster) || !one_chance_in(10))
+ if (monster->friendly() || !one_chance_in(10))
return (false);
if (MON_KILL(killer) && !invalid_monster_index(i))
{
monsters *mon = &menv[i];
- if (!mons_friendly(mon) || !one_chance_in(3))
+ if (!mon->friendly() || !one_chance_in(3))
return (false);
if (!mons_near(monster))
@@ -1372,7 +1372,7 @@ int monster_die(monsters *monster, killer_type killer,
if (!mons_reset && !crawl_state.arena && MONST_INTERESTING(monster))
{
take_note(Note(NOTE_KILL_MONSTER,
- monster->type, mons_friendly(monster),
+ monster->type, monster->friendly(),
monster->full_name(DESC_NOCAP_A).c_str()));
}
@@ -1688,7 +1688,7 @@ int monster_die(monsters *monster, killer_type killer,
// No piety loss if god gifts killed by other monsters.
// Also, dancing weapons aren't really friendlies.
- if (mons_friendly(monster)
+ if (monster->friendly()
&& monster->type != MONS_DANCING_WEAPON)
{
did_god_conduct(DID_FRIEND_DIED, 1 + (monster->hit_dice / 2),
@@ -1734,7 +1734,7 @@ int monster_die(monsters *monster, killer_type killer,
if (killer_holy == MH_UNDEAD)
{
const bool confused =
- anon ? false : !mons_friendly(killer_mon);
+ anon ? false : !killer_mon->friendly();
// Yes, these are hacks, but they make sure that
// confused monsters doing kills are not
@@ -1803,7 +1803,7 @@ int monster_die(monsters *monster, killer_type killer,
if (killer_holy == MH_UNDEAD)
{
const bool confused =
- anon ? false : !mons_friendly(killer_mon);
+ anon ? false : !killer_mon->friendly();
// Yes, this is a hack, but it makes sure that
// confused monsters doing kills are not
@@ -2427,7 +2427,7 @@ bool monster_polymorph(monsters *monster, monster_type targetc,
// Xom likes watching monsters being polymorphed.
xom_is_stimulated(mons_is_shapeshifter(monster) ? 16 :
- power == PPT_LESS || mons_friendly(monster) ? 32 :
+ power == PPT_LESS || monster->friendly() ? 32 :
power == PPT_SAME ? 64 : 128);
return (player_messaged);
diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h
index cd75d6b29f..9a81bbf280 100644
--- a/crawl-ref/source/monstuff.h
+++ b/crawl-ref/source/monstuff.h
@@ -48,7 +48,7 @@ public:
|| (x) == KILL_YOU_CONF)
#define MON_KILL(x) ((x) == KILL_MON || (x) == KILL_MON_MISSILE)
-#define SAME_ATTITUDE(x) (mons_friendly(x) ? BEH_FRIENDLY : \
+#define SAME_ATTITUDE(x) (x->friendly() ? BEH_FRIENDLY : \
mons_good_neutral(x) ? BEH_GOOD_NEUTRAL : \
mons_strict_neutral(x) ? BEH_STRICT_NEUTRAL : \
mons_neutral(x) ? BEH_NEUTRAL \
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index ca122c3237..8b0d4e9adb 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -1086,7 +1086,7 @@ void draw_border(void)
static bool _mons_hostile(const monsters *mon)
{
- return (!mons_friendly(mon) && !mons_neutral(mon));
+ return (!mon->friendly() && !mons_neutral(mon));
}
static std::string _get_monster_name(const monster_info& m,
@@ -1096,7 +1096,7 @@ static std::string _get_monster_name(const monster_info& m,
const monsters *mon = m.m_mon;
bool adj = false;
- if (mons_friendly(mon))
+ if (mon->friendly())
{
desc += "friendly ";
adj = true;
@@ -1138,13 +1138,13 @@ bool compare_monsters_attitude( const monsters *m1, const monsters *m2 )
if (mons_neutral(m1))
{
- if (mons_friendly(m2))
+ if (m2->friendly())
return (true);
if (_mons_hostile(m2))
return (false);
}
- if (mons_friendly(m1) && !mons_friendly(m2))
+ if (m1->friendly() && !m2->friendly())
return (false);
// If we get here then monsters have the same attitude.
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index b4b02a9c02..a7dda1eb12 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6163,7 +6163,7 @@ void player::attacking(actor *other)
if (other && other->atype() == ACT_MONSTER)
{
const monsters *mon = dynamic_cast<monsters*>(other);
- if (!mons_friendly(mon) && !mons_neutral(mon))
+ if (!mon->friendly() && !mons_neutral(mon))
pet_target = mon->mindex();
}
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index f0984b4607..64ff727b1c 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1465,12 +1465,12 @@ bool _has_jelly()
bool is_good_lawful_follower(const monsters* mon)
{
return (mon->alive() && !mon->is_evil() && !mon->is_chaotic()
- && mons_friendly(mon));
+ && mon->friendly());
}
bool is_good_follower(const monsters* mon)
{
- return (mon->alive() && !mon->is_evil() && mons_friendly(mon));
+ return (mon->alive() && !mon->is_evil() && mon->friendly());
}
bool is_follower(const monsters* mon)
@@ -1488,7 +1488,7 @@ bool is_follower(const monsters* mon)
else if (is_good_god(you.religion))
return (is_good_follower(mon));
else
- return (mon->alive() && mons_friendly(mon));
+ return (mon->alive() && mon->friendly());
}
static bool _blessing_wpn(monsters* mon)
@@ -3564,7 +3564,7 @@ void set_attack_conducts(god_conduct_trigger conduct[3], const monsters *mon,
{
const unsigned int midx = monster_index(mon);
- if (mons_friendly(mon))
+ if (mon->friendly())
{
if ((mon->flags & NEW_GIFT_FLAGS) == NEW_GIFT_FLAGS
&& mon->god != GOD_XOM)
diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc
index a8ed747f6a..711c53e974 100644
--- a/crawl-ref/source/showsymb.cc
+++ b/crawl-ref/source/showsymb.cc
@@ -198,7 +198,7 @@ int get_mons_colour(const monsters *mons)
if (mons->has_ench(ENCH_BERSERK))
col = RED;
- if (mons_friendly(mons))
+ if (mons->friendly())
{
col |= COLFLAG_FRIENDLY_MONSTER;
}
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 65da17abf6..6d49fae5d7 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1908,7 +1908,7 @@ bool cast_sanctuary(const int power)
// move towards the player.
if (monsters* mon = monster_at(pos))
{
- if (mons_friendly(mon))
+ if (mon->friendly())
{
mon->foe = MHITYOU;
mon->target = you.pos();
@@ -2102,7 +2102,7 @@ bool recall(char type_recalled)
if (monster->type == MONS_NO_MONSTER)
continue;
- if (!mons_friendly(monster))
+ if (!monster->friendly())
continue;
if (mons_class_is_stationary(monster->type))
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 3877f30dee..f08a824b89 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -451,7 +451,7 @@ static int _tame_beast_monsters(coord_def where, int pow, int, actor *)
if (monster == NULL)
return 0;
- if (!_is_domesticated_animal(monster->type) || mons_friendly(monster)
+ if (!_is_domesticated_animal(monster->type) || monster->friendly()
|| player_will_anger_monster(monster))
{
return 0;
diff --git a/crawl-ref/source/spl-mis.cc b/crawl-ref/source/spl-mis.cc
index 8dd1bc14b1..b7022461ec 100644
--- a/crawl-ref/source/spl-mis.cc
+++ b/crawl-ref/source/spl-mis.cc
@@ -161,14 +161,14 @@ void MiscastEffect::init()
kt = KILL_YOU_CONF;
}
else if (!death_curse && mon_source->confused_by_you()
- && !mons_friendly(mon_source))
+ && !mon_source->friendly())
{
kt = KILL_YOU_CONF;
}
else
kt = KILL_MON_MISSILE;
- if (mons_friendly(mon_source))
+ if (mon_source->friendly())
kc = KC_FRIENDLY;
else
kc = KC_OTHER;
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 691f50748a..4efd5e7839 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -190,7 +190,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)
+ if (!fmenv->friendly()
&& (!mons_is_seeking(fmenv) || fmenv->foe != MHITYOU))
{
return (false);
@@ -200,7 +200,7 @@ static bool _tag_follower_at(const coord_def &pos)
// stringent checks.
if ((pos - you.pos()).abs() > 2)
{
- if (!mons_friendly(fmenv))
+ if (!fmenv->friendly())
return (false);
// Undead will follow Yredelemnul worshippers, and orcs will
@@ -235,7 +235,7 @@ static int follower_tag_radius2()
for (adjacent_iterator ai; ai; ++ai)
{
if (const monsters *mon = monster_at(*ai))
- if (!mons_friendly(mon))
+ if (!mon->friendly())
return (2);
}
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index e1d910240f..aeda884ff2 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -1055,7 +1055,7 @@ int tileidx_monster(const monsters *mons, bool detected)
if (mons->has_ench(ENCH_STICKY_FLAME))
ch |= TILE_FLAG_FLAME;
- if (mons_friendly(mons))
+ if (mons->friendly())
ch |= TILE_FLAG_PET;
else if (mons_neutral(mons))
ch |= TILE_FLAG_NEUTRAL;
@@ -4655,7 +4655,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected)
else if (!mon->is_named())
return;
- if (pref != TAGPREF_NAMED && mons_friendly(mon))
+ if (pref != TAGPREF_NAMED && mon->friendly())
return;
// HACK. Names cover up pan demons in a weird way.
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index af94e89d57..a629e4df27 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1383,7 +1383,7 @@ bool DungeonRegion::update_tip_text(std::string& tip)
if (!cell_is_solid(m_cursor[CURSOR_MOUSE]))
{
const monsters *mon = monster_at(m_cursor[CURSOR_MOUSE]));
- if (!mon || mons_friendly(mon))
+ if (!mon || mon->friendly())
tip = "[L-Click] Move\n";
else if (mon)
{
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index 095ea2f1f7..bde6eb679c 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -1335,7 +1335,7 @@ void TilesFramework::update_minimap(int gx, int gy, map_feature f)
else if (monster_at(gc) && f == MF_MONS_HOSTILE)
{
const monsters *mon = monster_at(gc);
- if (mons_friendly(mon))
+ if (mon->friendly())
f = MF_MONS_FRIENDLY;
else if (mons_neutral(mon))
f = MF_MONS_NEUTRAL;
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index f5ae7076dd..97c5a0834f 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -410,7 +410,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed)
if (!you_know)
this->hide();
}
- else if (!(m && mons_friendly(m)))
+ else if (!(m && m->friendly()))
{
// Alarm traps aren't set off by hostile monsters, because
// that would be way too nasty for the player.
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 1ced3d7729..978ba69c17 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1208,7 +1208,7 @@ static std::string _colourize_glyph(int col, unsigned glyph)
static bool _mons_is_highlighted(const monsters *mons)
{
- return (mons_friendly(mons)
+ return (mons->friendly()
&& Options.friend_brand != CHATTR_NORMAL
|| mons_looks_stabbable(mons)
&& Options.stab_brand != CHATTR_NORMAL
@@ -1273,7 +1273,7 @@ void tutorial_first_monster(const monsters &mon)
if (_mons_is_highlighted(&mon))
learned_something_new(TUT_MONSTER_BRAND, mon.pos());
- if (mons_friendly(&mon))
+ if (mon.friendly())
learned_something_new(TUT_MONSTER_FRIENDLY, mon.pos());
if (you.religion == GOD_TROG && !you.duration[DUR_BERSERKER]
@@ -1390,7 +1390,7 @@ void tutorial_first_monster(const monsters &mon)
if (_mons_is_highlighted(&mon))
learned_something_new(TUT_MONSTER_BRAND, mon.pos());
- if (mons_friendly(&mon))
+ if (mon.friendly())
learned_something_new(TUT_MONSTER_FRIENDLY, mon.pos());
}
@@ -4532,7 +4532,7 @@ void tutorial_describe_monster(const monsters *mons)
}
// Monster is highlighted.
- if (mons_friendly(mons))
+ if (mons->friendly())
{
ostr << "Friendly monsters will follow you around and attempt to aid "
"you in battle. You can order your allies by <w>t</w>alking "
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 3383708825..3db47e723a 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -147,7 +147,7 @@ void handle_monster_shouts(monsters* monster, bool force)
return;
// Friendly or neutral monsters don't shout.
- if (!force && (mons_friendly(monster) || mons_neutral(monster)))
+ if (!force && (monster->friendly() || mons_neutral(monster)))
return;
// Get it once, since monster might be S_RANDOM, in which case
@@ -611,7 +611,7 @@ bool noisy(int loudness, const coord_def& where, const char *msg, int who,
if (where == you.pos())
behaviour_event( monster, ME_ALERT, MHITYOU, you.pos() );
else if (mermaid && mons_primary_habitat(monster) == HT_WATER
- && !mons_friendly(monster))
+ && !monster->friendly())
{
// Mermaids/sirens call (hostile) aquatic monsters.
behaviour_event( monster, ME_ALERT, MHITNOT, where );
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 7b038bb1e1..d596e28203 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -1027,7 +1027,7 @@ static void _do_chaos_upgrade(item_def &item, const monsters* mon)
{
seen = true;
- description_level_type desc = mons_friendly(mon) ? DESC_CAP_YOUR :
+ description_level_type desc = mon->friendly() ? DESC_CAP_YOUR :
DESC_CAP_THE;
std::string msg = apostrophise(mon->name(desc));