diff options
-rw-r--r-- | crawl-ref/source/debug.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 80 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 14 |
5 files changed, 94 insertions, 20 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 39d194001b..d7b040207c 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -220,7 +220,7 @@ static int debug_prompt_for_skill( const char *prompt ) { if (ptr == sk_name && strlen(specs) > 0) { - // we prefer prefixes over partial matches + // We prefer prefixes over partial matches. skill = i; break; } diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 868db37481..3cec070520 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2511,9 +2511,15 @@ std::string cloud_name(cloud_type type) bool mons_is_safe(const struct monsters *mon, bool want_move) { + int dist = grid_distance(you.x_pos, you.y_pos, mon->x, mon->y); + bool is_safe = (mons_wont_attack(mon) || mons_class_flag(mon->type, M_NO_EXP_GAIN) - // only seen through glass walls +#ifdef WIZARD + // Wizmode skill setting enforces hiddenness. + || you.skills[SK_STEALTH] > 27 && dist > 2 +#endif + // Only seen through glass walls? || !see_grid_no_trans(mon->x, mon->y) && !mons_has_ranged_spell(mon) && !mons_has_los_ability(mon->type)); @@ -2525,8 +2531,6 @@ bool mons_is_safe(const struct monsters *mon, bool want_move) || you.running < RMODE_NOT_RUNNING || want_move); - int dist = grid_distance(you.x_pos, you.y_pos, - mon->x, mon->y); bool result = is_safe; if (clua.callfn("ch_mon_is_safe", "Mbbd>b", diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 3f46f0d00e..bd820eb618 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2248,6 +2248,12 @@ static void _handle_behaviour(monsters *mon) bool isNeutral = mons_neutral(mon); bool wontAttack = mons_wont_attack(mon); bool proxPlayer = mons_near(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)) + proxPlayer = false; +#endif bool proxFoe; bool isHurt = (mon->hit_points <= mon->max_hit_points / 4 - 1); bool isHealthy = (mon->hit_points > mon->max_hit_points / 2); @@ -2277,9 +2283,8 @@ static void _handle_behaviour(monsters *mon) { if (!mons_player_visible( mon )) proxPlayer = false; - - // must be able to see each other - if (!see_grid(mon->x, mon->y)) + // Must be able to see each other. + else if (!see_grid(mon->x, mon->y)) proxPlayer = false; const int intel = mons_intel(mon->type); @@ -2710,8 +2715,8 @@ bool choose_any_monster(const monsters* mon) // Find a nearby monster and return its index, including you as a // possibility with probability weight. suitable() should return true // for the type of monster wanted. -// If prefer_named is true, named monsters (including uniques) are twice as -// likely to get chosen compared with non-named ones. +// If prefer_named is true, named monsters (including uniques) are twice +// as likely to get chosen compared to non-named ones. monsters *choose_random_nearby_monster(int weight, bool (*suitable)(const monsters* mon), bool in_sight, bool prefer_named) @@ -2765,7 +2770,7 @@ monsters *choose_random_monster_on_level(int weight, if (prefer_named && mon->is_named()) { mons_count += 2; - // named monsters have doubled chances + // Named monsters have doubled chances. if (random2(mons_count) < 2) chosen = mon; } @@ -2805,6 +2810,63 @@ bool simple_monster_message(const monsters *monster, const char *event, return (false); } // end simple_monster_message() +// Altars as well as branch entrances are considered interesting +// for some monster types. +static bool _mon_on_interesting_grid(monsters *mon) +{ + // Patrolling shouldn't happen all the time. + if (one_chance_in(4)) + return (false); + + const dungeon_feature_type feat = grd[mon->x][mon->y]; + + switch (feat) + { + // Holy beings will tend to patrol around altars to the good gods. + case DNGN_ALTAR_ELYVILON: + if (!one_chance_in(3)) + return (false); + // else fall through + case DNGN_ALTAR_ZIN: + case DNGN_ALTAR_SHINING_ONE: + return (mons_holiness(mon) == MH_HOLY); + + // Orcs will tend to patrol around altars to Beogh, and guard the + // stairway from and to the Orcish Mines. + case DNGN_ALTAR_BEOGH: + case DNGN_ENTER_ORCISH_MINES: + case DNGN_RETURN_FROM_ORCISH_MINES: + return (mons_species(mon->type) == MONS_ORC); + + // Same for elves and the Elven Halls. + case DNGN_ENTER_ELVEN_HALLS: + case DNGN_RETURN_FROM_ELVEN_HALLS: + return (mons_species(mon->type) == MONS_ELF); + + // Killer bees always return to their hive. + case DNGN_ENTER_HIVE: + return (mons_species(mon->type == MONS_KILLER_BEE) + || mons_species(mon->type == MONS_KILLER_BEE_LARVA)); + + default: + return (false); + } +} + +// If a hostile monster finds itself on a grid of an "interesting" feature, +// while unoccupied, it will remain in that area, and try to return to it +// if it left it for fighting, seeking etc. +static void _maybe_set_patrol_route(monsters *monster) +{ + if (monster->behaviour == BEH_WANDER + && !mons_friendly(monster) + && !monster->is_patrolling() + && _mon_on_interesting_grid(monster)) + { + monster->patrol_point = coord_def(monster->x, monster->y); + } +} + //--------------------------------------------------------------- // // handle_movement @@ -2816,6 +2878,8 @@ static void _handle_movement(monsters *monster) { int dx, dy; + _maybe_set_patrol_route(monster); + // Monsters will try to flee out of a sanctuary. if (is_sanctuary(monster->x, monster->y) && !mons_friendly(monster) && !mons_is_fleeing(monster) @@ -2846,7 +2910,7 @@ static void _handle_movement(monsters *monster) dy = monster->target_y - monster->y; } - // move the monster: + // Move the monster. mmov_x = (dx > 0) ? 1 : ((dx < 0) ? -1 : 0); mmov_y = (dy > 0) ? 1 : ((dy < 0) ? -1 : 0); @@ -6772,7 +6836,7 @@ bool message_current_target() if (crawl_state.is_replaying_keys()) { if (you.prev_targ == MHITNOT || you.prev_targ == MHITYOU) - return false; + return (false); const monsters *montarget = &menv[you.prev_targ]; return (you.prev_targ != MHITNOT && you.prev_targ != MHITYOU diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index e0b7e6ac79..be84bed2a0 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -3480,11 +3480,17 @@ void level_change(bool skip_attribute_increase) } // end level_change() -// here's a question for you: does the ordering of mods make a difference? +// Here's a question for you: does the ordering of mods make a difference? // (yes) -- are these things in the right order of application to stealth? // - 12mar2000 {dlb} int check_stealth(void) { +#ifdef WIZARD + // Extreme stealthiness can be enforced by wizmode stealth setting. + if (you.skills[SK_STEALTH] > 27) + return (1000); +#endif + if (you.special_wield == SPWLD_SHADOW || you.duration[DUR_BERSERKER]) return (0); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b44b8588e5..a0cc13a032 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -1183,7 +1183,7 @@ bool check_awaken(monsters* monster) if (monster->has_ench(ENCH_SLEEPY)) return (false); - // berserkers aren't really concerned about stealth + // Berserkers aren't really concerned about stealth. if (you.duration[DUR_BERSERKER]) return (true); @@ -1194,16 +1194,16 @@ bool check_awaken(monsters* monster) if (you.duration[DUR_REPEL_UNDEAD] && mons_is_unholy(monster)) return (true); - // I assume that creatures who can sense invisible are very perceptive + // I assume that creatures who can sense invisible are very perceptive. mons_perc = 10 + (mons_intel(monster->type) * 4) + monster->hit_dice + mons_sense_invis(monster) * 5; bool unnatural_stealthy = false; // "stealthy" only because of invisibility? - // critters that are wandering still have MHITYOU as their foe are - // still actively on guard for the player, even if they can't see - // him. Give them a large bonus (handle_behaviour() will nuke 'foe' - // after a while, removing this bonus. + // Critters that are wandering but still have MHITYOU as their foe are + // still actively on guard for the player, even if they can't see you. + // Give them a large bonus -- handle_behaviour() will nuke 'foe' after + // a while, removing this bonus. if (monster->behaviour == BEH_WANDER && monster->foe == MHITYOU) mons_perc += 15; @@ -1217,7 +1217,7 @@ bool check_awaken(monsters* monster) { if (mon_holy == MH_NATURAL) { - // monster is "hibernating"... reduce chance of waking + // Monster is "hibernating"... reduce chance of waking. if (monster->has_ench(ENCH_SLEEP_WARY)) mons_perc -= 10; } |