From 9338556ebf846bbc4176134e3846ef6699e8434b Mon Sep 17 00:00:00 2001 From: Vsevolod Kozlov Date: Mon, 9 Nov 2009 14:33:06 +0300 Subject: Replace mons_wont_attack with monsters::wont_attack. --- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/attitude-change.cc | 12 ++++++------ crawl-ref/source/beam.cc | 6 +++--- crawl-ref/source/delay.cc | 2 +- crawl-ref/source/describe.cc | 4 ++-- crawl-ref/source/fight.cc | 4 ++-- crawl-ref/source/files.cc | 2 +- crawl-ref/source/item_use.cc | 2 +- crawl-ref/source/misc.cc | 4 ++-- crawl-ref/source/mon-abil.cc | 2 +- crawl-ref/source/mon-act.cc | 26 +++++++++++++------------- crawl-ref/source/mon-behv.cc | 12 ++++++------ crawl-ref/source/mon-cast.cc | 10 +++++----- crawl-ref/source/mon-util.cc | 11 +++-------- crawl-ref/source/mon-util.h | 1 - crawl-ref/source/monplace.cc | 2 +- crawl-ref/source/monspeak.cc | 4 ++-- crawl-ref/source/monster.cc | 5 +++++ crawl-ref/source/monster.h | 1 + crawl-ref/source/monstuff.cc | 8 ++++---- crawl-ref/source/ouch.cc | 2 +- crawl-ref/source/religion.cc | 2 +- crawl-ref/source/spells1.cc | 4 ++-- crawl-ref/source/spells3.cc | 2 +- crawl-ref/source/spl-cast.cc | 2 +- crawl-ref/source/traps.cc | 4 ++-- crawl-ref/source/view.cc | 4 ++-- crawl-ref/source/xom.cc | 10 +++++----- 28 files changed, 75 insertions(+), 75 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index c37003891e..c66132f260 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3915,7 +3915,7 @@ static void _move_player(coord_def move) // you're not confused, or if both of you are inside a sanctuary. const bool can_swap_places = targ_monst && !mons_is_stationary(targ_monst) - && (mons_wont_attack(targ_monst) + && (targ_monst->wont_attack() && !you.confused() || is_sanctuary(you.pos()) && is_sanctuary(targ)); diff --git a/crawl-ref/source/attitude-change.cc b/crawl-ref/source/attitude-change.cc index 957a4f7713..ffc3b6b612 100644 --- a/crawl-ref/source/attitude-change.cc +++ b/crawl-ref/source/attitude-change.cc @@ -37,7 +37,7 @@ void good_god_follower_attitude_change(monsters *monster) && monster->foe == MHITYOU && monster->holiness() == MH_HOLY && !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT) - && !mons_wont_attack(monster) + && !monster->wont_attack() && you.visible_to(monster) && !monster->asleep() && !mons_is_confused(monster) && !monster->paralysed()) { @@ -159,7 +159,7 @@ static bool _holy_beings_on_level_attitude_change() // If you worship a good god, you get another chance to make // neutral and hostile holy beings good neutral. - if (is_good_god(you.religion) && !mons_wont_attack(monster)) + if (is_good_god(you.religion) && !monster->wont_attack()) { if (testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT)) { @@ -171,7 +171,7 @@ static bool _holy_beings_on_level_attitude_change() // If you don't worship a good god, you make all friendly // and good neutral holy beings that worship a good god // hostile. - else if (!is_good_god(you.religion) && mons_wont_attack(monster) + else if (!is_good_god(you.religion) && monster->wont_attack() && is_good_god(monster->god)) { monster->attitude = ATT_HOSTILE; @@ -212,7 +212,7 @@ static bool _evil_beings_on_level_attitude_change() // If you worship a good god, you make all friendly and good // neutral evil and unholy beings hostile. - if (is_good_god(you.religion) && mons_wont_attack(monster)) + if (is_good_god(you.religion) && monster->wont_attack()) { monster->attitude = ATT_HOSTILE; monster->del_ench(ENCH_CHARM, true); @@ -251,7 +251,7 @@ static bool _chaotic_beings_on_level_attitude_change() // If you worship Zin, you make all friendly and good neutral // chaotic beings hostile. - if (you.religion == GOD_ZIN && mons_wont_attack(monster)) + if (you.religion == GOD_ZIN && monster->wont_attack()) { monster->attitude = ATT_HOSTILE; monster->del_ench(ENCH_CHARM, true); @@ -290,7 +290,7 @@ static bool _magic_users_on_level_attitude_change() // If you worship Trog, you make all friendly and good neutral // magic users hostile. - if (you.religion == GOD_TROG && mons_wont_attack(monster)) + if (you.religion == GOD_TROG && monster->wont_attack()) { monster->attitude = ATT_HOSTILE; monster->del_ench(ENCH_CHARM, true); diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 2650e495b6..1a6706447c 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2234,7 +2234,7 @@ void bolt::do_fire() // sanctuary when pet_target can only be explicitly changed by // the player. const monsters *mon = &menv[beam_source]; - if (foe_info.hurt > 0 && !mons_wont_attack(mon) && !crawl_state.arena + if (foe_info.hurt > 0 && !mon->wont_attack() && !crawl_state.arena && you.pet_target == MHITNOT && env.sanctuary_time <= 0) { you.pet_target = beam_source; @@ -4547,7 +4547,7 @@ void bolt::monster_post_hit(monsters* mon, int dmg) // Don't annoy friendlies or good neutrals if the player's beam // did no damage. Hostiles will still take umbrage. - if (dmg > 0 || !mons_wont_attack(mon) || !YOU_KILL(thrower)) + if (dmg > 0 || !mon->wont_attack() || !YOU_KILL(thrower)) behaviour_event(mon, ME_ANNOY, beam_source_as_target()); // Sticky flame. @@ -5860,7 +5860,7 @@ bool bolt::nasty_to(const monsters *mon) const // Friendly and good neutral monsters don't mind being teleported. if (flavour == BEAM_TELEPORT) - return (!mons_wont_attack(mon)); + return (!mon->wont_attack()); // degeneration / sleep / enslave soul if (flavour == BEAM_DEGENERATE diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index a3b1e8553e..a891ea6f94 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -78,7 +78,7 @@ static bool _recite_mons_useless(const monsters *mon) || mons_is_stationary(mon) || mons_is_fleeing(mon) || mon->asleep() - || mons_wont_attack(mon) + || mon->wont_attack() || mon->neutral() || mons_is_confused(mon) || mon->paralysed() diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 7114f173ee..f1e22443d4 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2815,12 +2815,12 @@ void get_monster_db_desc(const monsters& mons, describe_info &inf, case MONS_VAMPIRE: case MONS_VAMPIRE_KNIGHT: case MONS_VAMPIRE_MAGE: - if (you.is_undead == US_ALIVE && !mons_wont_attack(&mons)) + if (you.is_undead == US_ALIVE && !mons.wont_attack()) inf.body << "$It wants to drink your blood!$"; break; case MONS_REAPER: - if (you.is_undead == US_ALIVE && !mons_wont_attack(&mons)) + if (you.is_undead == US_ALIVE && !mons.wont_attack()) inf.body << "$It has come for your soul!$"; break; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index fb21540279..5775f0ab6a 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -4261,7 +4261,7 @@ bool melee_attack::mons_attack_mons() if (perceived_attack && attacker->alive() && defender_as_monster()->friendly() && !crawl_state.arena - && !mons_wont_attack(attacker_as_monster()) + && !attacker_as_monster()->wont_attack() && you.pet_target == MHITNOT && env.sanctuary_time <= 0) { @@ -5729,7 +5729,7 @@ bool monster_attack(monsters* attacker, bool allow_unarmed) ASSERT(!crawl_state.arena); // Friendly and good neutral monsters won't attack unless confused. - if (mons_wont_attack(attacker) && !mons_is_confused(attacker)) + if (attacker->wont_attack() && !mons_is_confused(attacker)) return (false); // In case the monster hasn't noticed you, bumping into it will diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index a9c5484777..4afaf1039f 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1065,7 +1065,7 @@ static void _grab_followers() if (fmenv == NULL) continue; - if (mons_wont_attack(fmenv) && !mons_can_use_stairs(fmenv)) + if (fmenv->wont_attack() && !mons_can_use_stairs(fmenv)) non_stair_using_allies++; if (fmenv->type == MONS_PLAYER_GHOST diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index b4d0457fd2..bd431202fc 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -5014,7 +5014,7 @@ static void _vulnerability_scroll() mon->add_ench(lowered_mr); // Annoying but not enough to turn friendlies against you. - if (!mons_wont_attack(mon)) + if (!mon->wont_attack()) behaviour_event(mon, ME_ANNOY, MHITYOU); } } diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 64e2b9c7f0..55a02e4e43 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2772,7 +2772,7 @@ bool mons_is_safe(const monsters *mon, bool want_move, { int dist = grid_distance(you.pos(), mon->pos()); - bool is_safe = (mons_wont_attack(mon) + bool is_safe = (mon->wont_attack() || mons_class_flag(mon->type, M_NO_EXP_GAIN) && mon->type != MONS_KRAKEN_TENTACLE || mons_is_pacified(mon) && dist > 1 @@ -3170,7 +3170,7 @@ bool stop_attack_prompt(const monsters *mon, bool beam_attack, const bool mon_target = (beam_target == mon->pos()); const bool inSanctuary = (is_sanctuary(you.pos()) || is_sanctuary(mon->pos())); - const bool wontAttack = mons_wont_attack(mon); + const bool wontAttack = mon->wont_attack(); const bool isFriendly = mon->friendly(); const bool isNeutral = mon->neutral(); const bool isUnchivalric = is_unchivalric_attack(&you, mon); diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc index ea3c87dc18..ab5c2669b2 100644 --- a/crawl-ref/source/mon-abil.cc +++ b/crawl-ref/source/mon-abil.cc @@ -484,7 +484,7 @@ static bool _siren_movement_effect(const monsters *monster) if (mon) { coord_def swapdest; - if (mons_wont_attack(mon) + if (mon->wont_attack() && !mons_is_stationary(mon) && !mon->cannot_act() && !mon->asleep() diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index a72fb6703e..b60dbea05f 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -124,7 +124,7 @@ static bool _swap_monsters(monsters* mover, monsters* moved) // A friendly or good-neutral monster moving past a fleeing hostile // or neutral monster, or vice versa. - if (mons_wont_attack(mover) == mons_wont_attack(moved) + if (mover->wont_attack() == moved->wont_attack() || mons_is_fleeing(mover) == mons_is_fleeing(moved)) { return (false); @@ -216,7 +216,7 @@ static bool _ranged_allied_monster_in_dir(monsters *mon, coord_def p) { // Hostile monsters of normal intelligence only move aside for // monsters of the same type. - if (mons_intel(mon) <= I_NORMAL && !mons_wont_attack(mon) + if (mons_intel(mon) <= I_NORMAL && !mon->wont_attack() && mons_genus(mon->type) != mons_genus(ally->type)) { return (false); @@ -258,7 +258,7 @@ static bool _allied_monster_at(monsters *mon, coord_def a, coord_def b, // Hostile monsters of normal intelligence only move aside for // monsters of the same genus. - if (mons_intel(mon) <= I_NORMAL && !mons_wont_attack(mon) + if (mons_intel(mon) <= I_NORMAL && !mon->wont_attack() && mons_genus(mon->type) != mons_genus(ally->type)) { continue; @@ -561,7 +561,7 @@ static void _handle_movement(monsters *monster) coord_def(-mmov.x, 0), coord_def(-mmov.x, 1)) || mons_intel(monster) >= I_NORMAL - && !mons_wont_attack(monster) + && !monster->wont_attack() && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, 0)))) { @@ -579,7 +579,7 @@ static void _handle_movement(monsters *monster) coord_def(0, -mmov.y), coord_def(1, -mmov.y)) || mons_intel(monster) >= I_NORMAL - && !mons_wont_attack(monster) + && !monster->wont_attack() && _ranged_allied_monster_in_dir(monster, coord_def(0, -mmov.y)))) { @@ -598,7 +598,7 @@ static void _handle_movement(monsters *monster) coord_def(-mmov.x, 0), coord_def(-mmov.x, 1)) || mons_intel(monster) >= I_NORMAL - && !mons_wont_attack(monster) + && !monster->wont_attack() && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, -mmov.y)))) { @@ -610,7 +610,7 @@ static void _handle_movement(monsters *monster) coord_def(0, -mmov.y), coord_def(1, -mmov.y)) || mons_intel(monster) >= I_NORMAL - && !mons_wont_attack(monster) + && !monster->wont_attack() && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, -mmov.y)))) { @@ -2420,7 +2420,7 @@ static bool _monster_eat_food(monsters *monster, bool nearby) if (!is_food && !is_corpse) continue; - if ((mons_wont_attack(monster) + if ((monster->wont_attack() || grid_distance(monster->pos(), you.pos()) > 1) && coinflip()) { @@ -2624,7 +2624,7 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where, // Friendly and good neutral monsters don't enjoy Zot trap perks; // handle accordingly. In the arena Zot traps affect all monsters. - if (mons_wont_attack(monster) || crawl_state.arena) + if (monster->wont_attack() || crawl_state.arena) { return (mechanical ? mons_flies(monster) : !trap.is_known(monster) || trap.type != TRAP_ZOT); @@ -2768,7 +2768,7 @@ static bool _mon_can_move_to_pos(const monsters *monster, // Non-friendly and non-good neutral monsters won't enter // sanctuaries. - if (!mons_wont_attack(monster) + if (!monster->wont_attack() && is_sanctuary(targ) && !is_sanctuary(monster->pos())) { @@ -2891,7 +2891,7 @@ static bool _mon_can_move_to_pos(const monsters *monster, // Friendlies shouldn't try to move onto the player's // location, if they are aiming for some other target. - if (mons_wont_attack(monster) + if (monster->wont_attack() && monster->foe != MHITYOU && (monster->foe != MHITNOT || monster->is_patrolling()) && targ == you.pos()) @@ -3220,8 +3220,8 @@ static bool _monster_move(monsters *monster) newpos = moves[i]; const monsters *mon2 = monster_at(newpos); - if (newpos == you.pos() && mons_wont_attack(monster) - || (mon2 && mons_wont_attack(monster) == mons_wont_attack(mon2))) + if (newpos == you.pos() && monster->wont_attack() + || (mon2 && monster->wont_attack() == mon2->wont_attack())) { simple_monster_message(monster, " flops around on dry land!"); diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc index 8566f6a5a9..62cf3b992c 100644 --- a/crawl-ref/source/mon-behv.cc +++ b/crawl-ref/source/mon-behv.cc @@ -1085,7 +1085,7 @@ void handle_behaviour(monsters *mon) bool changed = true; bool isFriendly = mon->friendly(); bool isNeutral = mon->neutral(); - bool wontAttack = mons_wont_attack(mon); + bool wontAttack = mon->wont_attack(); // Whether the player is in LOS of the monster and can see // or has guessed the player's location. @@ -1096,7 +1096,7 @@ void handle_behaviour(monsters *mon) #ifdef WIZARD // If stealth is greater than actually possible (wizmode level) // pretend the player isn't there, but only for hostile monsters. - if (proxPlayer && you.skills[SK_STEALTH] > 27 && !mons_wont_attack(mon)) + if (proxPlayer && you.skills[SK_STEALTH] > 27 && !mon->wont_attack()) proxPlayer = false; #endif bool proxFoe; @@ -1221,7 +1221,7 @@ void handle_behaviour(monsters *mon) // Friendly and good neutral monsters do not attack other friendly // and good neutral monsters. if (mon->foe != MHITNOT && mon->foe != MHITYOU - && wontAttack && mons_wont_attack(&menv[mon->foe])) + && wontAttack && menv[mon->foe].wont_attack()) { mon->foe = MHITNOT; } @@ -1659,7 +1659,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, const beh_type old_behaviour = mon->behaviour; bool isSmart = (mons_intel(mon) > I_ANIMAL); - bool wontAttack = mons_wont_attack(mon); + bool wontAttack = mon->wont_attack(); bool sourceWontAttack = false; bool setTarget = false; bool breakCharm = false; @@ -1668,7 +1668,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, if (src == MHITYOU) sourceWontAttack = true; else if (src != MHITNOT) - sourceWontAttack = mons_wont_attack(&menv[src]); + sourceWontAttack = menv[src].wont_attack(); if (is_sanctuary(mon->pos()) && mons_is_fleeing_sanctuary(mon)) { @@ -1891,7 +1891,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, // If it woke up and you're its new foe, it might shout. if (was_sleeping && !mon->asleep() && allow_shout - && mon->foe == MHITYOU && !mons_wont_attack(mon)) + && mon->foe == MHITYOU && !mon->wont_attack()) { handle_monster_shouts(mon); } diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc index 873f7275c9..2da19d2b8f 100644 --- a/crawl-ref/source/mon-cast.cc +++ b/crawl-ref/source/mon-cast.cc @@ -955,7 +955,7 @@ bool handle_mon_spell(monsters *monster, bolt &beem) && mons_class_flag(monster->type, M_SPEAKS) && monster->has_spells()); - if (is_sanctuary(monster->pos()) && !mons_wont_attack(monster)) + if (is_sanctuary(monster->pos()) && !monster->wont_attack()) return (false); // Yes, there is a logic to this ordering {dlb}: @@ -1100,7 +1100,7 @@ bool handle_mon_spell(monsters *monster, bolt &beem) { // If nothing found by now, safe friendlies and good // neutrals will rarely cast. - if (mons_wont_attack(monster) && !mon_enemies_around(monster) + if (monster->wont_attack() && !mon_enemies_around(monster) && !one_chance_in(10)) { return (false); @@ -1308,7 +1308,7 @@ static int _monster_abjure_square(const coord_def &pos, return (0); if (!target->alive() - || ((bool)wont_attack == mons_wont_attack(target))) + || ((bool)wont_attack == target->wont_attack())) { return (0); } @@ -1397,7 +1397,7 @@ static int _apply_radius_around_square( const coord_def &c, int radius, static int _monster_abjuration(const monsters *caster, bool actual) { - const bool wont_attack = mons_wont_attack(caster); + const bool wont_attack = caster->wont_attack(); int maffected = 0; if (actual) @@ -2405,7 +2405,7 @@ void mons_cast_noise(monsters *monster, bolt &pbolt, spell_type spell_cast) // Be egotistical and assume that the monster is aiming at // the player, rather than the player being in the path of // a beam aimed at an ally. - if (!mons_wont_attack(monster)) + if (!monster->wont_attack()) { targ_prep = "at"; target = "you"; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 834f6a9e90..64e6e167ff 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1956,11 +1956,6 @@ bool mons_is_pacified(const monsters *m) return (m->attitude == ATT_NEUTRAL && testbits(m->flags, MF_GOT_HALF_XP)); } -bool mons_wont_attack(const monsters *m) -{ - return (m->friendly() || m->good_neutral() || m->strict_neutral()); -} - bool mons_att_wont_attack(mon_attitude_type fr) { return (fr == ATT_FRIENDLY || fr == ATT_GOOD_NEUTRAL || fr == ATT_STRICT_NEUTRAL); @@ -2018,7 +2013,7 @@ bool mons_is_lurking(const monsters *m) bool mons_is_influenced_by_sanctuary(const monsters *m) { - return (!mons_wont_attack(m) + return (!m->wont_attack() && (m->holiness() != MH_PLANT || mons_is_stationary(m))); } @@ -2309,7 +2304,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell ) return (true); } - if (!mons_wont_attack(mon)) + if (!mon->wont_attack()) { if (spell_harms_area(monspell) && env.sanctuary_time > 0) return (true); @@ -2986,7 +2981,7 @@ std::string do_mon_str_replacements(const std::string &in_msg, { std::string msg = in_msg; - const actor* foe = (mons_wont_attack(monster) + const actor* foe = (monster->wont_attack() && invalid_monster_index(monster->foe)) ? &you : monster->get_foe(); diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 664a557031..969c283e78 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -606,7 +606,6 @@ bool mons_aligned(int m1, int m2); bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2); bool mons_is_pacified(const monsters *m); -bool mons_wont_attack(const monsters *m); bool mons_att_wont_attack(mon_attitude_type fr); mon_attitude_type mons_attitude(const monsters *m); diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index f7c1b7fb10..f12e78df77 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -2617,7 +2617,7 @@ bool player_angers_monster(monsters *mon) // Get the drawbacks, not the benefits... (to prevent e.g. demon-scumming). if (player_will_anger_monster(mon, &holy, &unholy, &lawful, &antimagical) - && mons_wont_attack(mon)) + && mon->wont_attack()) { mon->attitude = ATT_HOSTILE; mon->del_ench(ENCH_CHARM); diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc index ef0547010a..3241200ae1 100644 --- a/crawl-ref/source/monspeak.cc +++ b/crawl-ref/source/monspeak.cc @@ -430,7 +430,7 @@ bool mons_speaks(monsters *monster) if (confused) prefixes.push_back("confused"); - const actor* foe = (!crawl_state.arena && mons_wont_attack(monster) + const actor* foe = (!crawl_state.arena && monster->wont_attack() && invalid_monster_index(monster->foe)) ? &you : monster->get_foe(); const monsters* m_foe = (foe && foe->atype() == ACT_MONSTER) ? @@ -494,7 +494,7 @@ bool mons_speaks(monsters *monster) const bool no_foe = (foe == NULL); const bool no_player = crawl_state.arena - || (!mons_wont_attack(monster) + || (!monster->wont_attack() && (!foe || foe->atype() != ACT_PLAYER)); const bool mon_foe = (m_foe != NULL); const bool no_god = no_foe || (mon_foe && foe->deity() == GOD_NO_GOD); diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index ee0e81d37d..b237a8ace3 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -2866,6 +2866,11 @@ bool monsters::strict_neutral() const return (attitude == ATT_STRICT_NEUTRAL); } +bool monsters::wont_attack() const +{ + return (friendly() || good_neutral() || strict_neutral()); +} + int monsters::shield_bonus() const { const item_def *shld = const_cast(this)->shield(); diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index e98fdb5f6c..9b8742e3c2 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -342,6 +342,7 @@ public: bool neutral() const; bool good_neutral() const; bool strict_neutral() const; + bool wont_attack() const; bool has_spells() const; bool has_spell(spell_type spell) const; diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 563e6aec1b..e9e42685a3 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1998,7 +1998,7 @@ int monster_die(monsters *monster, killer_type killer, // Make sure Boris has a foe to address. if (monster->foe == MHITNOT) { - if (!mons_wont_attack(monster) && !crawl_state.arena) + if (!monster->wont_attack() && !crawl_state.arena) monster->foe = MHITYOU; else if (!invalid_monster_index(killer_index)) monster->foe = killer_index; @@ -2525,7 +2525,7 @@ static coord_def _random_monster_nearby_habitable_space(const monsters& mon, bool allow_adjacent, bool respect_los) { - const bool respect_sanctuary = mons_wont_attack(&mon); + const bool respect_sanctuary = mon.wont_attack(); coord_def target; int tries; @@ -3017,7 +3017,7 @@ bool simple_monster_message(const monsters *monster, const char *event, msg += event; msg = apostrophise_fixup(msg); - if (channel == MSGCH_PLAIN && mons_wont_attack(monster)) + if (channel == MSGCH_PLAIN && monster->wont_attack()) channel = MSGCH_FRIEND_ACTION; mpr(msg.c_str(), channel, param); @@ -3693,7 +3693,7 @@ void monster_teleport(monsters *monster, bool instan, bool silent) mgrd(oldplace) = NON_MONSTER; coord_def newpos; - if (monster_random_space(monster, newpos, !mons_wont_attack(monster))) + if (monster_random_space(monster, newpos, !monster->wont_attack())) monster->moveto(newpos); mgrd(monster->pos()) = monster_index(monster); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 507a57e837..82fa411e66 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -792,7 +792,7 @@ static void _xom_checks_damage(kill_method_type death_type, if (!monster->alive()) return; - if (mons_wont_attack(monster)) + if (monster->wont_attack()) { // Xom thinks collateral damage is funny. xom_is_stimulated(255 * dam / (dam + you.hp)); diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 6a5b6d3999..590a1ce345 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -5452,7 +5452,7 @@ int get_tension(god_type god, bool count_travelling) if (you.see_cell(mons->pos())) { // Monster is nearby. - if (!nearby_monster && !mons_wont_attack(mons)) + if (!nearby_monster && !mons->wont_attack()) nearby_monster = true; } else if (count_travelling) diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 4cb64dcd99..b3222f3817 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -688,7 +688,7 @@ void big_cloud(cloud_type cl_type, kill_category whose, killer_type killer, static bool _mons_hostile(const monsters *mon) { // Needs to be done this way because of friendly/neutral enchantments. - return (!mons_wont_attack(mon) && !mon->neutral()); + return (!mon->wont_attack() && !mon->neutral()); } static bool _can_pacify_monster(const monsters *mon, const int healed) @@ -1138,7 +1138,7 @@ void abjuration(int pow) if (monster->type == MONS_NO_MONSTER || !mons_near(monster)) continue; - if (mons_wont_attack(monster)) + if (monster->wont_attack()) continue; int duration; diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 35365fd302..3266512406 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1910,7 +1910,7 @@ bool cast_sanctuary(const int power) mon->behaviour = BEH_SEEK; behaviour_event(mon, ME_EVAL, MHITYOU); } - else if (!mons_wont_attack(mon)) + else if (!mon->wont_attack()) { if (mons_is_mimic(mon->type)) { diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index c7df5d907b..c605a7bda2 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -660,7 +660,7 @@ static int _get_dist_to_nearest_monster() if (mons_class_flag(mon->type, M_NO_EXP_GAIN)) continue; - if (mons_wont_attack(mon)) + if (mon->wont_attack()) continue; int dist = grid_distance(you.pos(), *ri); diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 09740d196e..d34f66b9b1 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -168,7 +168,7 @@ bool trap_def::is_known(const actor* act) const rc = (intel >= I_NORMAL && (mons_is_native_in_branch(monster) - || mons_wont_attack(monster) && player_knows + || monster->wont_attack() && player_knows || intel >= I_HIGH && one_chance_in(3))); } return (rc); @@ -607,7 +607,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) if (!you_know) this->hide(); - if (mons_wont_attack(m) || crawl_state.arena) + if (m->wont_attack() || crawl_state.arena) { MiscastEffect( m, ZOT_TRAP_MISCAST, SPTYP_RANDOM, 3, "the power of Zot" ); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 99a7b0cb17..a97911d0ba 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -547,7 +547,7 @@ bool check_awaken(monsters* monster) && you.can_see(monster) // to avoid leaking information && you.burden_state == BS_UNENCUMBERED && !you.attribute[ATTR_SHADOWS] - && !mons_wont_attack(monster) + && !monster->wont_attack() && !mons_class_flag(monster->type, M_NO_EXP_GAIN) // If invisible, training happens much more rarely. && (!unnatural_stealthy && one_chance_in(25) || one_chance_in(100))) @@ -1010,7 +1010,7 @@ bool mon_enemies_around(const monsters *monster) // we don't have one. return (false); } - else if (mons_wont_attack(monster)) + else if (monster->wont_attack()) { // Additionally, if an ally is nearby and *you* have a foe, // consider it as the ally's enemy too. diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 513291e174..5eb31d082b 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -1204,7 +1204,7 @@ static int _xom_confuse_monsters(int sever, bool debug = false) monster = &menv[i]; if (monster->type == MONS_NO_MONSTER || !mons_near(monster) - || mons_wont_attack(monster) + || monster->wont_attack() || !mons_class_is_confusable(monster->type) || one_chance_in(20)) { @@ -1425,7 +1425,7 @@ static int _xom_polymorph_nearby_monster(bool helpful, bool debug = false) : ENCH_SHAPESHIFTER); } - const bool powerup = !(mons_wont_attack(mon) ^ helpful); + const bool powerup = !(mon->wont_attack() ^ helpful); monster_polymorph(mon, RANDOM_MONSTER, powerup ? PPT_MORE : PPT_LESS); @@ -1552,7 +1552,7 @@ static int _xom_swap_weapons(bool debug = false) if (!you.see_cell(m->pos())) continue; - if (!wpn || mons_wont_attack(m) || m->is_summoned() + if (!wpn || m->wont_attack() || m->is_summoned() || mons_itemuse(m) < MONUSE_STARTING_EQUIPMENT || (m->flags & MF_HARD_RESET)) { @@ -1752,7 +1752,7 @@ static int _xom_animate_monster_weapon(int sever, bool debug = false) if (!you.see_cell(m->pos())) continue; - if (mons_wont_attack(m) || m->is_summoned() + if (m->wont_attack() || m->is_summoned() || mons_itemuse(m) < MONUSE_STARTING_EQUIPMENT || (m->flags & MF_HARD_RESET)) { @@ -1926,7 +1926,7 @@ static int _xom_throw_divine_lightning(bool debug = false) { if (monsters* mon = monster_at(*ri)) { - if (!mons_wont_attack(mon)) + if (!mon->wont_attack()) { found_hostile = true; break; -- cgit v1.2.3-54-g00ecf