summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2010-01-16 18:48:09 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2010-01-16 18:49:28 +1000
commit7423e92a652914c2085e76410d3dcbe914d59b6b (patch)
treedc0b9302d837195b74d1463d354def8278eab9dc /crawl-ref
parentdecb6b25c768d8e4ea0a2af37e5b4c699d86b036 (diff)
downloadcrawl-ref-7423e92a652914c2085e76410d3dcbe914d59b6b.tar.gz
crawl-ref-7423e92a652914c2085e76410d3dcbe914d59b6b.zip
Provide "waste of time" checks for Mislead, fake Mara summon, player ghost.
This moves the code out of the relevant functions and into the ms_waste_of_time function in mon-util.cc.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/mislead.cc16
-rw-r--r--crawl-ref/source/mislead.h4
-rw-r--r--crawl-ref/source/mon-cast.cc28
-rw-r--r--crawl-ref/source/mon-util.cc32
4 files changed, 48 insertions, 32 deletions
diff --git a/crawl-ref/source/mislead.cc b/crawl-ref/source/mislead.cc
index 64c574d97a..790a84886b 100644
--- a/crawl-ref/source/mislead.cc
+++ b/crawl-ref/source/mislead.cc
@@ -1,5 +1,5 @@
/* File: mislead.cc
- * Summary: Handling of the Mislead spell and stats
+ * Summary: Handling of Mara's Mislead spell and stats, plus fakes.
*/
#include "AppHdr.h"
@@ -83,9 +83,7 @@ void mons_cast_mislead(monsters *monster)
if (monster->foe != MHITYOU)
return;
- // Prevents Mislead spam by Mara and co. {due}
- if (you.duration[DUR_MISLED] > 10 && one_chance_in(3))
- return;
+ // We deal with pointless misleads in the right place now.
if (wearing_amulet(AMU_CLARITY))
{
@@ -124,4 +122,14 @@ void mons_cast_mislead(monsters *monster)
return;
}
+int count_mara_fakes()
+{
+ int count = 0;
+ for (monster_iterator mi; mi; ++mi)
+ {
+ if (mi->type == MONS_MARA_FAKE)
+ count++;
+ }
+ return count;
+}
diff --git a/crawl-ref/source/mislead.h b/crawl-ref/source/mislead.h
index 540ffea9b1..cc5d2ebed3 100644
--- a/crawl-ref/source/mislead.h
+++ b/crawl-ref/source/mislead.h
@@ -1,8 +1,10 @@
/* File: mislead.h
- * Summary: Handling of the Mislead spell and stats
+ * Summary: Handling of Mara's Mislead spell and stats, plus fakes.
*/
bool unsuitable_misled_monster(monster_type mons);
monster_type get_misled_monster (monsters *monster);
int update_mislead_monsters(monsters* caster);
bool update_mislead_monster(monsters* monster);
+int count_mara_fakes();
+
diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc
index 5b12e5394b..cf4721ef3e 100644
--- a/crawl-ref/source/mon-cast.cc
+++ b/crawl-ref/source/mon-cast.cc
@@ -1575,28 +1575,6 @@ void mons_cast_haunt(monsters *monster)
_pick_random_wraith, random_range(3, 6), GOD_NO_GOD, &fpos);
}
-int _count_mara_fakes()
-{
- int count = 0;
- for (monster_iterator mi; mi; ++mi)
- {
- if (mi->type == MONS_MARA_FAKE)
- count++;
- }
-
- return count;
-}
-
-bool _find_players_ghost ()
-{
- bool found = false;
- for (monster_iterator mi; mi; ++mi)
- if (mi->type == MONS_PLAYER_GHOST && mi->mname == you.your_name)
- found = true;
-
- return found;
-}
-
void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
bool do_noise, bool special_ability)
{
@@ -1785,10 +1763,6 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
if (crawl_state.arena)
return;
- // Only summon one ghost.
- if (_find_players_ghost())
- return;
-
mpr("There is a horrible, sudden wrenching feeling in your soul!", MSGCH_WARN);
create_monster(
@@ -1849,7 +1823,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast,
// We only want there to be two fakes, which, plus Mara, means
// a total of three Maras; if we already have two, give up, otherwise
// we want to summon either one more or two more.
- sumcount2 = 2 - _count_mara_fakes();
+ sumcount2 = 2 - count_mara_fakes();
for (sumcount = 0; sumcount < sumcount2; sumcount++)
{
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 0c47414cab..7821d0c1e8 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -21,7 +21,9 @@
#include "goditem.h"
#include "itemname.h"
#include "kills.h"
+#include "mislead.h"
#include "mon-behv.h"
+#include "mon-iter.h"
#include "mon-place.h"
#include "coord.h"
#include "mon-stuff.h"
@@ -2233,6 +2235,17 @@ static bool _beneficial_beam_flavour(beam_type flavour)
}
}
+// For SUMMON_PLAYER_GHOST.
+bool _find_players_ghost ()
+{
+ bool found = false;
+ for (monster_iterator mi; mi; ++mi)
+ if (mi->type == MONS_PLAYER_GHOST && mi->mname == you.your_name)
+ found = true;
+
+ return found;
+}
+
bool mons_should_fire(struct bolt &beam)
{
#ifdef DEBUG_DIAGNOSTICS
@@ -2582,6 +2595,25 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
break;
}
+ case SPELL_MISLEAD:
+ if (you.duration[DUR_MISLED] > 10 && one_chance_in(3))
+ ret = true;
+
+ break;
+
+ case SPELL_SUMMON_PLAYER_GHOST:
+ // Only ever want one at a time.
+ if (_find_players_ghost())
+ ret = true;
+
+ break;
+
+ case SPELL_FAKE_MARA_SUMMON:
+ if (count_mara_fakes() == 2)
+ ret = true;
+
+ break;
+
case SPELL_NO_SPELL:
ret = true;
break;