summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-24 23:05:09 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-24 23:05:09 +0000
commit86878386c072b70e0e54c7176cdfae250564ddae (patch)
tree4b4ceaffa08a376a601c3579a295ce1fd9f7b923 /crawl-ref/source/monstuff.cc
parent6388931826b0bced2cd7f185b85e2f3d299b2f71 (diff)
downloadcrawl-ref-86878386c072b70e0e54c7176cdfae250564ddae.tar.gz
crawl-ref-86878386c072b70e0e54c7176cdfae250564ddae.zip
Fix blessing routine -- oops!
Fix choose_random_nearby_monster() to really pick a random monster rather than the first one that fits, and allow named monsters to get higher chances. Use this when deciding which monster to bless (only happens if the one doing the kill, usually the player, is not eligible for blessing). At high xp levels allow reinforcement (if there are no orcs nearby) to send in high xp orcs: orc warrior, orc knight, or orc warlord, rather than the normal ones (orc, orc wizard, orc priest). At xl 27 the probability for this happening is about 31%. Problem: From the code, it appears that scumming for large armies is possible by deliberately losing your followers somewhere and then killing monsters until you get the reinforcement effect. This will have to be controlled somehow, while still allowing for genuinely lost allies somewhere on the level. Maybe use recall instead or something like that. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4598 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc42
1 files changed, 35 insertions, 7 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 4b3a105d5f..03ce726c9e 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -872,16 +872,22 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
if (!created_friendly && gives_xp)
{
if (mons_holiness(monster) == MH_NATURAL)
+ {
did_god_conduct(DID_KILL_LIVING,
monster->hit_dice, true, monster);
+ }
if (mons_holiness(monster) == MH_UNDEAD)
+ {
did_god_conduct(DID_KILL_UNDEAD,
monster->hit_dice, true, monster);
+ }
if (mons_holiness(monster) == MH_DEMONIC)
+ {
did_god_conduct(DID_KILL_DEMON,
monster->hit_dice, true, monster);
+ }
if (mons_class_flag(monster->type, M_EVIL)
&& mons_holiness(monster) == MH_NATURAL)
@@ -891,18 +897,24 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
}
if (_is_mons_mutator_or_rotter(monster))
+ {
did_god_conduct(DID_KILL_MUTATOR_OR_ROTTER,
monster->hit_dice, true, monster);
+ }
// jmf: Trog hates wizards
if (mons_is_magic_user(monster))
+ {
did_god_conduct(DID_KILL_WIZARD,
monster->hit_dice, true, monster);
+ }
// Beogh hates priests of other gods.
if (mons_class_flag(monster->type, M_PRIEST))
+ {
did_god_conduct(DID_KILL_PRIEST,
monster->hit_dice, true, monster);
+ }
// Holy beings take their gear with them when they die.
if (mons_is_holy(monster))
@@ -2575,11 +2587,15 @@ 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.
int choose_random_nearby_monster(int weight,
- bool (*suitable)(const monsters* mon))
+ bool (*suitable)(const monsters* mon),
+ bool prefer_named)
{
int mons_count = weight;
int result = NON_MONSTER;
+ int mon;
int ystart = you.y_pos - 9, xstart = you.x_pos - 9;
int yend = you.y_pos + 9, xend = you.x_pos + 9;
@@ -2593,12 +2609,20 @@ int choose_random_nearby_monster(int weight,
for ( int x = xstart; x < xend; ++x )
if ( see_grid(x,y) && mgrd[x][y] != NON_MONSTER )
{
- result = mgrd[x][y];
-
- if ( suitable(&menv[result]) && one_chance_in(++mons_count) )
- break;
-
- result = NON_MONSTER;
+ mon = mgrd[x][y];
+ if (suitable(&menv[mon]))
+ {
+ if (prefer_named
+ && !get_unique_monster_name(&menv[mon]).empty())
+ {
+ mons_count += 2;
+ // named monsters have doubled chances
+ if (random2(mons_count) < 2)
+ result = mon;
+ }
+ else if (one_chance_in(++mons_count))
+ result = mon;
+ }
}
return result;
@@ -4706,11 +4730,15 @@ static void _handle_monster_move(int i, monsters *monster)
{
#if DEBUG
if (monster->speed_increment == old_energy)
+ {
mprf(MSGCH_DIAGNOSTICS, "'%s' has same energy as last loop",
monster->name(DESC_PLAIN, true).c_str());
+ }
else
+ {
mprf(MSGCH_DIAGNOSTICS, "'%s' has MORE energy than last loop",
monster->name(DESC_PLAIN, true).c_str());
+ }
#endif
monster->speed_increment = old_energy - 10;
old_energy = monster->speed_increment;