diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/arena.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/beam.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 23 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 59 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.h | 8 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 19 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/traps.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 12 |
14 files changed, 88 insertions, 60 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index e436af3be6..074f99518b 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -106,7 +106,7 @@ namespace arena if (!mon->alive()) continue; - const bool friendly = mons_friendly(mon); + const bool friendly = mons_friendly_real(mon); // Set target to the opposite faction's home base. mon->target = friendly ? place_b : place_a; } @@ -570,6 +570,7 @@ namespace arena delay(Options.arena_delay); mesclr(); dump_messages(); + ASSERT(you.pet_target == MHITNOT); } viewwindow(true, false); } diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 22182655b1..6cedc53a2b 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -113,7 +113,7 @@ kill_category bolt::whose_kill() const if (!invalid_monster_index(beam_source)) { const monsters *mon = &menv[beam_source]; - if (mons_friendly(mon)) + if (mons_friendly_real(mon)) return (KC_FRIENDLY); } } @@ -2034,7 +2034,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) + if (foe_info.hurt > 0 && !mons_wont_attack(mon) && !crawl_state.arena && you.pet_target == MHITNOT && env.sanctuary_time <= 0) { you.pet_target = beam_source; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 1921f62de4..025c97d392 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1976,7 +1976,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) || !mons_friendly_real(mon)) continue; mon->foe = (allow_patrol && mon->is_patrolling() ? MHITNOT @@ -1989,7 +1989,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) || !mons_friendly_real(mon)) continue; mon->patrol_point = (clear ? coord_def(0, 0) : mon->pos()); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 4aeec6e54a..fb6ea3a03d 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -4195,7 +4195,8 @@ void melee_attack::mons_do_napalm() napalm_player(random2avg(7, 3) + 1); else { - napalm_monster(def, mons_friendly(atk) ? KC_FRIENDLY : KC_OTHER, + napalm_monster(def, mons_friendly_real(atk) ? KC_FRIENDLY + : KC_OTHER, std::min(4, 1 + random2(atk->hit_dice) / 2)); } } diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index a6d22b8bd2..dd5765ecf3 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -3093,6 +3093,8 @@ std::string your_hand(bool plural) bool stop_attack_prompt(const monsters *mon, bool beam_attack, bool beam_target) { + ASSERT(!crawl_state.arena); + if (you.confused() || !you.can_see(mon)) return (false); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 0318073ef4..ccd4fdf97c 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1981,7 +1981,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc, // (Uniques don't get this, because their names are proper nouns.) if (!mons_is_unique(mon.type)) { - const bool use_your = !crawl_state.arena && mons_friendly(&mon); + const bool use_your = mons_friendly(&mon); switch (desc) { case DESC_CAP_THE: @@ -2450,6 +2450,14 @@ mon_attitude_type monsters::temp_attitude() const bool mons_friendly(const monsters *m) { + if (crawl_state.arena) + return (false); + + return (m->attitude == ATT_FRIENDLY || m->has_ench(ENCH_CHARM)); +} + +bool mons_friendly_real(const monsters *m) +{ return (m->attitude == ATT_FRIENDLY || m->has_ench(ENCH_CHARM)); } @@ -2474,6 +2482,11 @@ bool mons_wont_attack(const monsters *m) return (mons_friendly(m) || mons_good_neutral(m)); } +bool mons_wont_attack_real(const monsters *m) +{ + return (mons_friendly_real(m) || mons_good_neutral(m)); +} + bool mons_att_wont_attack(mon_attitude_type fr) { return (fr == ATT_FRIENDLY || fr == ATT_GOOD_NEUTRAL); @@ -2481,7 +2494,7 @@ bool mons_att_wont_attack(mon_attitude_type fr) mon_attitude_type mons_attitude(const monsters *m) { - if (mons_friendly(m)) + if (mons_friendly_real(m)) return ATT_FRIENDLY; else if (mons_good_neutral(m)) return ATT_GOOD_NEUTRAL; @@ -4845,7 +4858,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force) return (false); } - if (mons_friendly(this) && !crawl_state.arena) + if (mons_friendly(this)) { // Never pick up gold or misc. items, it'd only annoy the player. if (itype == OBJ_MISCELLANY || itype == OBJ_GOLD) @@ -7097,7 +7110,7 @@ void monsters::scale_hp(int num, int den) kill_category monsters::kill_alignment() const { - return (mons_friendly(this)? KC_FRIENDLY : KC_OTHER); + return (mons_friendly_real(this)? KC_FRIENDLY : KC_OTHER); } bool monsters::sicken(int amount) @@ -7958,7 +7971,7 @@ std::string do_mon_str_replacements(const std::string &in_msg, { std::string msg = in_msg; - const actor* foe = (!crawl_state.arena && mons_wont_attack(monster) + const actor* foe = (mons_wont_attack(monster) && invalid_monster_index(monster->foe)) ? &you : monster->get_foe(); const monsters* m_foe = (foe && foe->atype() == ACT_MONSTER) ? diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 7ce3388565..f2d7fcb60c 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -738,10 +738,12 @@ bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2); * *********************************************************************** */ size_type mons_size(const monsters *m); bool mons_friendly(const monsters *m); +bool mons_friendly_real(const monsters *m); bool mons_neutral(const monsters *m); bool mons_good_neutral(const monsters *m); bool mons_is_pacified(const monsters *m); bool mons_wont_attack(const monsters *m); +bool mons_wont_attack_real(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/monstuff.cc b/crawl-ref/source/monstuff.cc index 0aba21ff15..0e01bbc293 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1046,15 +1046,10 @@ void monster_die(monsters *monster, killer_type killer, killer = KILL_YOU_CONF; // Well, it was confused in a sense... (jpeg) // Take note! - if (!mons_reset) - { - if (MONST_INTERESTING(monster)) - { - take_note(Note(NOTE_KILL_MONSTER, - monster->type, mons_friendly(monster), - monster->name(DESC_NOCAP_A, true).c_str())); - } - } + if (!mons_reset && !crawl_state.arena && MONST_INTERESTING(monster)) + take_note(Note(NOTE_KILL_MONSTER, + monster->type, mons_friendly(monster), + monster->name(DESC_NOCAP_A, true).c_str())); // From time to time Trog gives you a little bonus if (killer == KILL_YOU && you.duration[DUR_BERSERKER]) @@ -1571,8 +1566,6 @@ void monster_die(monsters *monster, killer_type killer, // Make sure Boris has a foe to address if (monster->foe == MHITNOT) { - // Hostile monsters outside of the arena always have you as a - // foe. if (!mons_wont_attack(monster) && !crawl_state.arena) monster->foe = MHITYOU; else if (!invalid_monster_index(killer_index)) @@ -2400,7 +2393,7 @@ void behaviour_event(monsters *mon, int event, int src, beh_type old_behaviour = mon->behaviour; bool isSmart = (mons_intel(mon) > I_ANIMAL); - bool wontAttack = mons_wont_attack(mon); + bool wontAttack = mons_wont_attack_real(mon); bool sourceWontAttack = false; bool setTarget = false; bool breakCharm = false; @@ -2408,7 +2401,7 @@ void behaviour_event(monsters *mon, int event, int src, if (src == MHITYOU) sourceWontAttack = true; else if (src != MHITNOT) - sourceWontAttack = mons_wont_attack( &menv[src] ); + sourceWontAttack = mons_wont_attack_real( &menv[src] ); switch (event) { @@ -3644,8 +3637,8 @@ static void _handle_behaviour(monsters *mon) bool changed = true; bool isFriendly = mons_friendly(mon); bool isNeutral = mons_neutral(mon); - bool wontAttack = mons_wont_attack(mon); - bool proxPlayer = mons_near(mon); + bool wontAttack = mons_wont_attack_real(mon); + bool proxPlayer = mons_near(mon) && !crawl_state.arena; bool trans_wall_block = trans_wall_blocking(mon->pos()); #ifdef WIZARD @@ -3771,7 +3764,7 @@ static 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 && mons_wont_attack_real(&menv[mon->foe])) { mon->foe = MHITNOT; } @@ -4173,7 +4166,7 @@ static bool _mons_check_set_foe(monsters *mon, const coord_def& p, // Choose nearest monster as a foe. (Used for berserking monsters.) void _set_nearest_monster_foe(monsters *mon) { - const bool friendly = mons_friendly(mon); + const bool friendly = mons_friendly_real(mon); const bool neutral = mons_neutral(mon); std::vector<coord_def> d; @@ -4286,7 +4279,7 @@ bool simple_monster_message(const monsters *monster, const char *event, snprintf( buff, sizeof(buff), "%s%s", monster->name(descrip).c_str(), event ); - if (channel == MSGCH_PLAIN && mons_wont_attack(monster)) + if (channel == MSGCH_PLAIN && mons_wont_attack_real(monster)) channel = MSGCH_FRIEND_ACTION; mpr( buff, channel, param ); @@ -4376,7 +4369,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 type. - if (mons_intel(mon) <= I_NORMAL && !mons_wont_attack(mon) + if (mons_intel(mon) <= I_NORMAL && !mons_wont_attack_real(mon) && mons_genus(mon->type) != mons_genus((&menv[mgrd(pos[i])])->type)) { continue; @@ -4470,7 +4463,8 @@ static void _handle_movement(monsters *monster) { delta = monster->target - monster->pos(); - if (crawl_state.arena && Options.arena_force_ai) + if (crawl_state.arena && Options.arena_force_ai + && !mons_is_stationary(monster)) { const bool ranged = mons_has_ranged_attack(monster) @@ -4644,7 +4638,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) + && !mons_wont_attack_real(monster) && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, 0)))) { @@ -4662,7 +4656,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) + && !mons_wont_attack_real(monster) && _ranged_allied_monster_in_dir(monster, coord_def(0, -mmov.y)))) { @@ -4681,7 +4675,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) + && !mons_wont_attack_real(monster) && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, -mmov.y)))) { @@ -4693,7 +4687,7 @@ static void _handle_movement(monsters *monster) coord_def(0, -mmov.x), coord_def(1, -mmov.x)) || mons_intel(monster) >= I_NORMAL - && !mons_wont_attack(monster) + && !mons_wont_attack_real(monster) && _ranged_allied_monster_in_dir(monster, coord_def(-mmov.x, -mmov.y)))) { @@ -6536,7 +6530,7 @@ static bool _swap_monsters(const int mover_idx, const int moved_idx) // 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 (mons_wont_attack_real(mover) == mons_wont_attack_real(moved) || mons_is_fleeing(mover) == mons_is_fleeing(moved)) { return (false); @@ -6828,8 +6822,7 @@ static void _handle_monster_move(int i, monsters *monster) // Same for friendlies if friendly_pickup is set to "none". if (!mons_neutral(monster) && !monster->has_ench(ENCH_CHARM) && (!mons_friendly(monster) - || you.friendly_pickup > FRIENDLY_PICKUP_NONE - || crawl_state.arena)) + || you.friendly_pickup > FRIENDLY_PICKUP_NONE)) { if (_handle_pickup(monster)) { @@ -6964,9 +6957,11 @@ static void _handle_monster_move(int i, monsters *monster) // hitting their foes. && !monster->has_ench(ENCH_BERSERK)) { + const bool friendly_or_near = + mons_friendly(monster) || mons_near(monster, monster->foe); // Prevents unfriendlies from nuking you from offscreen. // How nice! - if (mons_friendly(monster) || mons_near(monster, monster->foe)) + if (friendly_or_near || monster->type == MONS_TEST_SPAWNER) { // [ds] Special abilities shouldn't overwhelm spellcasting // in monsters that have both. This aims to give them both @@ -6980,7 +6975,10 @@ static void _handle_monster_move(int i, monsters *monster) DEBUG_ENERGY_USE("spell or special"); continue; } + } + if (friendly_or_near) + { if (_handle_potion(monster, beem)) { DEBUG_ENERGY_USE("_handle_potion()"); @@ -7049,6 +7047,7 @@ static void _handle_monster_move(int i, monsters *monster) if (monster->pos() + mmov == you.pos()) { + ASSERT(!crawl_state.arena); bool isFriendly = mons_friendly(monster); bool attacked = false; @@ -7642,8 +7641,8 @@ 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. - if (mons_wont_attack(monster)) + // handle accordingly. In the arena Zot traps affect all monsters. + if (mons_wont_attack(monster) || crawl_state.arena) { return (mechanical ? mons_flies(monster) : !trap.is_known(monster) || trap.type != TRAP_ZOT); diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h index f362d867b4..382b435c5a 100644 --- a/crawl-ref/source/monstuff.h +++ b/crawl-ref/source/monstuff.h @@ -51,10 +51,10 @@ public: #define MON_KILL(x) ((x) == KILL_MON || (x) == KILL_MON_MISSILE) // useful macro -#define SAME_ATTITUDE(x) (mons_friendly(x) ? BEH_FRIENDLY : \ - mons_good_neutral(x) ? BEH_GOOD_NEUTRAL : \ - mons_neutral(x) ? BEH_NEUTRAL \ - : BEH_HOSTILE) +#define SAME_ATTITUDE(x) (mons_friendly_real(x) ? BEH_FRIENDLY : \ + mons_good_neutral(x) ? BEH_GOOD_NEUTRAL : \ + mons_neutral(x) ? BEH_NEUTRAL \ + : BEH_HOSTILE) #define MONST_INTERESTING(x) (x->flags & MF_INTERESTING) diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 76adfe9066..150720696e 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -897,9 +897,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 : + mons_friendly_real(monster) ? MSGCH_FRIEND_SPELL : + MSGCH_MONSTER_SPELL); if (silent) { @@ -2285,8 +2285,11 @@ static int _monster_abjure_square(const coord_def &pos, return (0); monsters *target = &menv[mindex]; - if (!target->alive() || ((bool)wont_attack == mons_wont_attack(target))) + if (!target->alive() + || ((bool)wont_attack == mons_wont_attack_real(target))) + { return (0); + } int duration; @@ -2367,7 +2370,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 = mons_wont_attack_real(caster); int maffected = 0; if (actual) @@ -2510,8 +2513,8 @@ 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 - : MSGCH_FRIEND_ENCHANT; + mons_friendly_real(chief) ? MSGCH_MONSTER_ENCHANT + : MSGCH_FRIEND_ENCHANT; if (!seen_affected.empty()) { @@ -2548,7 +2551,7 @@ bool orc_battle_cry(monsters *chief) static bool _make_monster_angry(const monsters *mon, monsters *targ) { - if (mons_friendly(mon) != mons_friendly(targ)) + if (mons_friendly_real(mon) != mons_friendly_real(targ)) return (false); // targ is guaranteed to have a foe (needs_berserk checks this). diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index 8b35f2fc20..ee493e26ff 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -1020,7 +1020,7 @@ int tileidx_monster(const monsters *mons, bool detected) if (mons->has_ench(ENCH_POISON)) ch |= TILE_FLAG_POISON; - if (mons_friendly(mons)) + if (mons_friendly_real(mons)) ch |= TILE_FLAG_PET; else if (mons_neutral(mons)) ch |= TILE_FLAG_NEUTRAL; @@ -4385,7 +4385,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected) if (foreground) { env.tile_fg[ep.x-1][ep.y-1] = t; - if (menv[idx].is_named() && !mons_friendly(&menv[idx]) + if (menv[idx].is_named() && !mons_friendly_real(&menv[idx]) && menv[idx].type != MONS_PANDEMONIUM_DEMON) { if (menv[idx].type == MONS_PLAYER_GHOST) diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 81a2ecc863..035fa1de0d 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -1119,7 +1119,7 @@ void TilesFramework::update_minimap(int gx, int gy, map_feature f) else if (f == MF_MONS_HOSTILE && mgrd[gx][gy] != NON_MONSTER) { const int grid = mgrd[gx][gy]; - if (mons_friendly(&menv[grid])) + if (mons_friendly_real(&menv[grid])) f = MF_MONS_FRIENDLY; else if (mons_neutral(&menv[grid])) f = MF_MONS_NEUTRAL; diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 6176c1554b..7be9b3e3ed 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -37,6 +37,7 @@ REVISION("$Rev$"); #include "spells3.h" #include "spl-mis.h" #include "spl-util.h" +#include "state.h" #include "stuff.h" #include "terrain.h" #include "transfor.h" @@ -589,7 +590,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) if (!you_know) this->hide(); - if (mons_wont_attack(m)) + if (mons_wont_attack(m) || 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 1c552ec1f0..465f294115 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -828,7 +828,7 @@ int get_mons_colour(const monsters *mons) if (mons->has_ench(ENCH_BERSERK)) col = RED; - if (mons_friendly(mons)) + if (mons_friendly_real(mons)) { col |= COLFLAG_FRIENDLY_MONSTER; } @@ -917,7 +917,7 @@ static void _good_god_follower_attitude_change(monsters *monster) void beogh_follower_convert(monsters *monster, bool orc_hit) { - if (you.species != SP_HILL_ORC) + if (you.species != SP_HILL_ORC || crawl_state.arena) return; // For followers of Beogh, decide whether orcs will join you. @@ -3960,7 +3960,13 @@ bool mon_enemies_around(const monsters *monster) if (monster->foe != MHITNOT && monster->foe != MHITYOU) return (true); - if (mons_wont_attack(monster)) + if (crawl_state.arena) + { + // If the arena-mode code in _handle_behaviour() hasn't set a foe then + // we don't have one. + return (false); + } + else if (mons_wont_attack(monster)) { // Additionally, if an ally is nearby and *you* have a foe, // consider it as the ally's enemy too. |