From 4a746253d5b490b74bf195038b943583fe4c1017 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 25 Apr 2008 23:35:17 +0000 Subject: Two changes: 1.) If Beogh can't find a nearby follower in LOS to bless, try again without the LOS restriction (but still nearby). If this also fails, recall a small amount of followers (1 + rnd(4) + rnd(4)) on the level. I don't think there's much harm in Beogh actively doing something you already have as an invocation as long as it doesn't make the invocation superfluous (and this doesn't). In this case, the chance of this happening should probably be lowered, and actual reinforcement should be rarer still. 2.) Identify magical staves if you have at least 4 skill levels in the corresponding spell school when wielding it, or gain the 4th level while wielding it. (I decided on 4 because that is what most mages start out with in their special school, and it seems a good enough treshold.) Prior to that, there's still the random identification chance at casting an appropriate spell, as before. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4639 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/religion.cc | 125 +++++++++++++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 27 deletions(-) (limited to 'crawl-ref/source/religion.cc') diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index c224c73827..a2bf4caab9 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1015,6 +1015,60 @@ static bool _tso_blessing_friendliness(monsters *mon) return true; } +// If there are no nearby followers, try to recall some on the level. +static int _beogh_blessing_recalling() +{ + std::vector recalled; + + FixedVector < char, 2 > empty; + empty[0] = empty[1] = 0; + + monsters *mon; + for (int loopy = 0; loopy < MAX_MONSTERS; loopy++) + { + mon = &menv[loopy]; + + if (mon->type == -1) + continue; + + if (!is_orcish_follower(mon)) + continue; + + recalled.push_back(loopy); + } + if (recalled.empty()) + return 0; + + int count_recalled = 0; + int total = recalled.size(); + int amount = 1 + random2(4) + random2(4); + bool recall_all = (total <= amount); + + for (unsigned int loopy = 0; loopy < recalled.size(); loopy++) + { + mon = &menv[recalled[loopy]]; + + if (!recall_all && total == amount) + recall_all = true; + + if (recall_all || random2(total) < amount) + { + if (empty_surrounds(you.x_pos, you.y_pos, DNGN_FLOOR, 3, + false, empty) + && mon->move_to_pos( coord_def(empty[0], empty[1])) ) + { + count_recalled++; + amount--; + } + else + break; // no more room to place monsters + } + total--; + } + + return (count_recalled); +} + // If you don't currently have any followers, send a small band to help // you out. static bool _beogh_blessing_reinforcement() @@ -1101,43 +1155,54 @@ bool bless_follower(int follower, // Otherwise, pick a random follower within sight of the player. if (follower == -1 || (!force && !suitable(&menv[follower]))) { + if (god != GOD_BEOGH) + return false; + // Choose a random follower in LOS, preferably a named one. - follower = choose_random_nearby_monster(0, suitable, true); + follower = choose_random_nearby_monster(0, suitable, true, true); if (follower == NON_MONSTER) { - switch (god) + // Try again, without the LOS restriction. + follower = choose_random_nearby_monster(0, suitable, false, true); + } + + if (follower == NON_MONSTER) + { + // If no follower was chosen, either send + // reinforcement or get out. + + // First, try to recall orcish followers on level. + int recalled = _beogh_blessing_recalling(); + bool reinforced = false; + + if (recalled < 3) { - case GOD_BEOGH: + reinforced = _beogh_blessing_reinforcement(); + + if (!reinforced || !recalled && coinflip()) { - // If no follower was chosen, either send - // reinforcement or get out. - bool reinforced = _beogh_blessing_reinforcement(); + // Try again, or possibly send more reinforcement. + if (_beogh_blessing_reinforcement()) + reinforced = true; + } + } - if (!reinforced || coinflip()) - { - // Try again, or possibly send more reinforcement. - if (_beogh_blessing_reinforcement()) - reinforced = true; - } + if (recalled || reinforced) + { + pronoun = ""; + blessed = "you"; - if (reinforced) - { - pronoun = ""; - blessed = "you"; - result = "reinforcement"; - goto blessing_done; - } - break; - } + if (recalled) + result = "recalling"; + else if (reinforced) + result = "reinforcement"; + else + result = "recalling and reinforcement"; - default: - break; + goto blessing_done; } - - return false; } - } mon = &menv[follower]; @@ -1304,8 +1369,14 @@ bool bless_follower(int follower, blessing_done: std::string whom = ""; + if (follower != NON_MONSTER) - whom = get_unique_monster_name(mon); + { + if (!mons_near(mon) || !player_monster_visible(mon)) + whom = "a follower"; + else + whom = get_unique_monster_name(mon); + } if (whom.empty()) whom = pronoun + blessed; -- cgit v1.2.3-54-g00ecf