From 6ac1ce6fcd8bfc6d3cd47786d707cdaf8bf7a728 Mon Sep 17 00:00:00 2001 From: dolorous Date: Thu, 20 Mar 2008 22:58:37 +0000 Subject: Expand follower blessing code to potentially allow for more than just healing. Also add a routine to promote ordinary monsters to priests, mostly based on code in monster_polymorph(), and (rarely) use it as a blessing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3771 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/religion.cc | 113 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 23 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 594e5ff7a3..9804abfb6f 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -754,6 +754,49 @@ static void give_nemelex_gift() } } +static bool promote_to_priest(monsters* mon) +{ + monster_type priest_type = MONS_PROGRAM_BUG; + + // Possible promotions. + if (mon->type == MONS_ORC) + priest_type = MONS_ORC_PRIEST; + + if (priest_type != MONS_PROGRAM_BUG) + { + // Turn an ordinary monster into a priestly monster, preserving + // important characteristics. Keep this as generic as possible, + // in case more promotions are added. + const unsigned long old_flags = mon->flags; + const int old_hp = mon->hit_points; + const int old_hp_max = mon->max_hit_points; + const char old_ench_countdown = mon->ench_countdown; + mon_enchant abj = mon->get_ench(ENCH_ABJ); + mon_enchant shifter = mon->get_ench(ENCH_GLOWING_SHAPESHIFTER, + ENCH_SHAPESHIFTER); + const bool old_mon_caught = mons_is_caught(mon); + + mon->type = priest_type; + define_monster(monster_index(mon)); + + mon->flags = old_flags; + mon->hit_points = mon->max_hit_points * + ((old_hp * 100) / old_hp_max) / 100; + mon->ench_countdown = old_ench_countdown; + mon->add_ench(abj); + mon->add_ench(shifter); + if (old_mon_caught) + mon->add_ench(ENCH_HELD); + if (mons_class_flag(mon->type, M_INVIS)) + mon->add_ench(ENCH_INVIS); + mon->fix_speed(); + + return true; + } + + return false; +} + void bless_follower(god_type god, bool (*suitable)(const monsters* mon)) { @@ -761,39 +804,63 @@ void bless_follower(god_type god, return; int monster = choose_random_nearby_monster(0, suitable); - monsters* mon = (monster != NON_MONSTER) ? &menv[monster] : NULL; - if (mon) - { - const char *result; - bool healing = false; - bool vigour = true; + if (monster == NON_MONSTER) + return; + + monsters* mon = &menv[monster]; + const char *blessed = mon->name(DESC_NOCAP_A).c_str(); + const char *result = NULL; - // Full healing. - healing = heal_monster(mon, mon->max_hit_points, false); + switch (random2(100)) + { + // 5% chance: Turn a monster into a priestly monster, if + // possible. This is currently only used for Beogh. + case 0: + case 1: + case 2: + case 3: + case 4: + if (god == GOD_BEOGH && promote_to_priest(mon)) + { + result = "priesthood"; + break; + } + // Deliberate fall through. - if (!healing || coinflip()) + // 95% chance: full healing. + default: { - // Full healing, plus one added hit point. - heal_monster(mon, mon->max_hit_points, true); + bool healing = false; + bool vigour = true; - if (coinflip()) - // Full healing, plus another added hit point. + healing = heal_monster(mon, mon->max_hit_points, false); + + if (!healing || coinflip()) + { + // Full healing, plus one added hit point. heal_monster(mon, mon->max_hit_points, true); - vigour = true; - } + if (coinflip()) + // Full healing, plus another added hit point. + heal_monster(mon, mon->max_hit_points, true); - if (healing && vigour) - result = "healing and extra vigour"; - else if (healing) - result = "healing"; - else - result = "extra vigour"; + vigour = true; + } - mprf(MSGCH_GOD, "%s blesses %s with %s.", god_name(god).c_str(), - mon->name(DESC_NOCAP_A).c_str(), result); + if (healing && vigour) + result = "healing and extra vigour"; + else if (healing) + result = "healing"; + else + result = "extra vigour"; + + break; + } } + + mprf(MSGCH_GOD, "%s blesses %s with %s.", god_name(god).c_str(), + blessed, result); } static void do_god_gift(bool prayed_for) -- cgit v1.2.3-54-g00ecf