From 3ec5cfe6d308c420acb8b24b6c7df328d91244d0 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sat, 24 Jan 2009 23:37:25 +0000 Subject: Add miscellaneous minor cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8722 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 8 +++---- crawl-ref/source/monstuff.cc | 57 ++++++++++++++++++++++++++------------------ crawl-ref/source/religion.cc | 14 ++--------- crawl-ref/source/view.cc | 10 ++++---- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 2e9e677186..33c81a4036 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1970,7 +1970,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc, return (""); const bool arena_submerged = crawl_state.arena && !force_seen - && mons_is_submerged(&mon); + && mons_is_submerged(&mon); // Handle non-visible case first. if (!force_seen && !player_monster_visible(&mon) @@ -3243,7 +3243,7 @@ const char *mons_pronoun(monster_type mon_type, pronoun_type variant, if (!visible) gender = GENDER_NEUTER; - switch(variant) + switch (variant) { case PRONOUN_CAP: return ((gender == 0) ? "It" : @@ -3538,8 +3538,8 @@ bool monsters::floundering() const { const dungeon_feature_type grid = grd(pos()); return (grid_is_water(grid) - // Can't use monster_habitable_grid because that'll return true - // for non-water monsters in shallow water. + // Can't use monster_habitable_grid() because that'll return + // true for non-water monsters in shallow water. && mons_primary_habitat(this) != HT_WATER && !mons_amphibious(this) && !mons_flies(this) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 999bfab01b..ad250f3ab6 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -565,14 +565,15 @@ static bool _is_pet_kill(killer_type killer, int i) && (me.who == KC_YOU || me.who == KC_FRIENDLY)); } -// Elyvilon will occasionally (5% chance) protect the life of -// one of your allies. +// Elyvilon will occasionally (5% chance) protect the life of one of +// your allies. static bool _ely_protects_ally(monsters *monster) { - ASSERT(you.religion == GOD_ELYVILON); + if (you.religion != GOD_ELYVILON) + return (false); if (mons_holiness(monster) != MH_NATURAL - && mons_holiness(monster) != MH_HOLY + && mons_holiness(monster) != MH_HOLY || !mons_friendly(monster) || !mons_near(monster) || !player_monster_visible(monster) // for simplicity @@ -582,10 +583,11 @@ static bool _ely_protects_ally(monsters *monster) } monster->hit_points = 1; - snprintf(info, INFO_SIZE, " protects %s%s from harm!%s", - mons_is_unique(monster->type) ? "" : "your ", - monster->name(DESC_PLAIN).c_str(), - coinflip() ? "" : " You feel responsible."); + + snprintf(info, INFO_SIZE, " protects %s from harm!%s", + monster->name(DESC_NOCAP_THE).c_str(), + coinflip() ? "" : " You feel responsible."); + simple_god_message(info); lose_piety(1); @@ -596,7 +598,9 @@ static bool _ely_protects_ally(monsters *monster) // be killed by you or one of your friends. static bool _ely_heals_monster(monsters *monster, killer_type killer, int i) { - ASSERT(you.religion != GOD_ELYVILON); + if (you.religion == GOD_ELYVILON) + return (false); + god_type god = GOD_ELYVILON; if (!you.penance[god] || !god_hates_your_god(god)) @@ -643,6 +647,19 @@ static bool _ely_heals_monster(monsters *monster, killer_type killer, int i) return (true); } +static bool _yred_enslaves_soul(monsters *monster, killer_type killer) +{ + if (you.religion == GOD_YREDELEMNUL && mons_enslaved_body_and_soul(monster) + && mons_near(monster) && killer != KILL_RESET + && killer != KILL_DISMISSED) + { + yred_make_enslaved_soul(monster, player_under_penance()); + return (true); + } + + return (false); +} + static bool _monster_avoided_death(monsters *monster, killer_type killer, int i) { if (monster->hit_points < -25 @@ -654,10 +671,13 @@ static bool _monster_avoided_death(monsters *monster, killer_type killer, int i) } // Elyvilon specials - if (you.religion == GOD_ELYVILON && _ely_protects_ally(monster)) + if (_ely_protects_ally(monster)) + return (true); + if (_ely_heals_monster(monster, killer, i)) return (true); - if (you.religion != GOD_ELYVILON && _ely_heals_monster(monster, killer, i)) + // Yredelemnul special + if (_yred_enslaves_soul(monster, killer)) return (true); // Beogh special @@ -701,15 +721,6 @@ static bool _monster_avoided_death(monsters *monster, killer_type killer, int i) } } - // Yredelemnul special - if (you.religion == GOD_YREDELEMNUL && mons_enslaved_body_and_soul(monster) - && mons_near(monster) && killer != KILL_RESET - && killer != KILL_DISMISSED) - { - yred_make_enslaved_soul(monster, player_under_penance()); - return (true); - } - return (false); } @@ -7688,7 +7699,7 @@ void mons_check_pool(monsters *mons, const coord_def &oldpos, { const bool message = mons_near(mons); - // Don't worry about invisibility - you should be able to see if + // Don't worry about invisibility. You should be able to see if // something has fallen into the lava. if (message && (oldpos == mons->pos() || grd(oldpos) != grid)) { @@ -7700,8 +7711,8 @@ void mons_check_pool(monsters *mons, const coord_def &oldpos, if (grid == DNGN_LAVA && mons_res_fire(mons) >= 2) grid = DNGN_DEEP_WATER; - // Even fire resistant monsters perish in lava, but inanimate monsters - // can survive deep water. + // Even fire resistant monsters perish in lava, but inanimate + // monsters can survive deep water. if (grid == DNGN_LAVA || mons->can_drown()) { if (message) diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index dbdf544dca..14ef2b7f5d 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1810,24 +1810,14 @@ bool bless_follower(monsters *follower, blessing_done: - bool see_follower = false; - std::string whom = ""; if (!follower) whom = "you"; else { if (mons_near(follower) && player_monster_visible(follower)) - see_follower = true; - - if (see_follower) - { - if (follower->is_named()) - whom = follower->name(DESC_PLAIN); - else - whom = "your " + follower->name(DESC_PLAIN); - } - else // cannot see who was blessed + whom = follower->name(DESC_NOCAP_THE); + else whom = "a follower"; } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index d155f10004..6e7878946a 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -894,7 +894,7 @@ static void _good_god_follower_attitude_change(monsters *monster) int wpn = you.equip[EQ_WEAPON]; if (wpn != -1 && you.inv[wpn].base_type == OBJ_WEAPONS - && is_evil_item( you.inv[wpn] ) + && is_evil_item(you.inv[wpn]) && coinflip()) // 50% chance of conversion failing { msg::stream << monster->name(DESC_CAP_THE) @@ -928,13 +928,13 @@ void beogh_follower_convert(monsters *monster, bool orc_hit) const int hd = monster->hit_dice; - if (you.piety >= piety_breakpoint(2) && !player_under_penance() && - random2(you.piety / 15) + random2(4 + you.experience_level / 3) - > random2(hd) + hd + random2(5)) + if (you.piety >= piety_breakpoint(2) && !player_under_penance() + && random2(you.piety / 15) + random2(4 + you.experience_level / 3) + > random2(hd) + hd + random2(5)) { if (you.weapon() && you.weapon()->base_type == OBJ_WEAPONS - && get_weapon_brand( *you.weapon() ) == SPWPN_ORC_SLAYING + && get_weapon_brand(*you.weapon()) == SPWPN_ORC_SLAYING && coinflip()) // 50% chance of conversion failing { msg::stream << monster->name(DESC_CAP_THE) -- cgit v1.2.3-54-g00ecf