summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 01:32:57 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 01:32:57 +0000
commit70b49eb0667159b6a079e8decd5dc37ddfcef60f (patch)
tree1d7803404eebb41c7dd5d0abee6a2e071c5b782c /crawl-ref
parent6da9dc107ac5c8eac196c44d61105d1e412c9761 (diff)
downloadcrawl-ref-70b49eb0667159b6a079e8decd5dc37ddfcef60f.tar.gz
crawl-ref-70b49eb0667159b6a079e8decd5dc37ddfcef60f.zip
Expand bless_follower() to allow explicitly picking the follower as well
as picking one randomly, fix a potential problem with the display of the blessing message, and add a piety-dependent chance that followers will be specifically blessed when gaining levels. Hook the last of these up to Beogh for now (since the random chance on piety gain occurs less and less often as piety goes up). TSO should also get this eventually. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3821 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/mgrow.cc14
-rw-r--r--crawl-ref/source/monstuff.cc11
-rw-r--r--crawl-ref/source/religion.cc29
-rw-r--r--crawl-ref/source/religion.h3
5 files changed, 42 insertions, 17 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index a24a2f4b5c..7c510225d3 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1064,7 +1064,7 @@ public:
void lose_energy(energy_use_type et);
void scale_hp(int num, int den);
- void gain_exp(int exp);
+ bool gain_exp(int exp);
void add_enchantment_effect(const mon_enchant &me, bool quiet = false);
void remove_enchantment_effect(const mon_enchant &me, bool quiet = false);
diff --git a/crawl-ref/source/mgrow.cc b/crawl-ref/source/mgrow.cc
index 57b3edc0cf..aacacfe3d1 100644
--- a/crawl-ref/source/mgrow.cc
+++ b/crawl-ref/source/mgrow.cc
@@ -181,22 +181,22 @@ void monsters::init_experience()
experience = mexplevs[std::min(hit_dice, MAX_MONS_HD)];
}
-void monsters::gain_exp(int exp)
+bool monsters::gain_exp(int exp)
{
if (!alive())
- return;
+ return false;
init_experience();
if (hit_dice >= MAX_MONS_HD)
- return;
+ return false;
// Only natural monsters can level-up.
if (holiness() != MH_NATURAL)
- return;
-
+ return false;
+
// Avoid wrap-around.
if (experience + exp < experience)
- return;
+ return false;
experience += exp;
@@ -218,4 +218,6 @@ void monsters::gain_exp(int exp)
if (hit_dice < MAX_MONS_HD && experience >= mexplevs[hit_dice + 1])
experience = (mexplevs[hit_dice] + mexplevs[hit_dice + 1]) / 2;
+
+ return (levels_gained > 0);
}
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 9bcb773088..4b9058d11a 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -406,7 +406,16 @@ static void _give_monster_experience( monsters *victim,
if ((!victim_was_born_friendly || !mons_friendly(mons))
&& !mons_aligned(killer_index, monster_index(victim)))
{
- mons->gain_exp(experience);
+ if (mons->gain_exp(experience))
+ {
+ // Blessings for followers.
+ if (you.religion == GOD_BEOGH
+ && you.piety >= piety_breakpoint(2)
+ && random2(you.piety) >= piety_breakpoint(0))
+ {
+ bless_follower(GOD_BEOGH, is_orcish_follower, mons);
+ }
+ }
}
}
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index bff047e0d2..b15bf4f23d 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -827,19 +827,32 @@ static bool blessing_healing(monsters *mon, bool extra)
return heal_monster(mon, mon->max_hit_points, extra);
}
+// Bless a follower within sight of the player.
void bless_follower(god_type god,
- bool (*suitable)(const monsters* mon))
+ bool (*suitable)(const monsters* mon),
+ monsters* follower)
{
+ // If there are no monsters (including followers) in sight, get out.
if (!there_are_monsters_nearby())
return;
- int monster = choose_random_nearby_monster(0, suitable);
+ monsters *mon;
- if (monster == NON_MONSTER)
- return;
+ // If a follower was specified, and it's suitable, pick it.
+ if (follower && suitable(follower))
+ mon = follower;
+ // Otherwise, pick a random follower.
+ else
+ {
+ int monster = choose_random_nearby_monster(0, suitable);
+
+ if (monster == NON_MONSTER)
+ return;
+
+ mon = &menv[monster];
+ }
- monsters* mon = &menv[monster];
- const char *blessed = mon->name(DESC_NOCAP_A).c_str();
+ const char *blessed = mon->name(DESC_NOCAP_THE).c_str();
const char *result;
int chance = random2(20);
@@ -906,8 +919,8 @@ void bless_follower(god_type god,
}
blessing_done:
- mprf(MSGCH_GOD, "%s blesses %s with %s.", god_name(god).c_str(),
- blessed, result);
+ snprintf(info, INFO_SIZE, " blesses %s with %s.", blessed, result);
+ simple_god_message(info);
}
static void do_god_gift(bool prayed_for)
diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h
index b21a525f90..765bdec408 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -72,7 +72,8 @@ bool trog_burn_books();
bool tso_stab_safe_monster(const actor *act);
void bless_follower(god_type god,
- bool (*suitable)(const monsters* mon));
+ bool (*suitable)(const monsters* mon),
+ monsters* follower = NULL);
bool is_orcish_follower(const monsters* mon);
bool god_hates_attacking_friend(god_type god, const actor *fr);