summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-03 18:55:00 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-04 09:25:24 -0700
commit6b684f55be020bffc5144b583acf79c7d4404a4f (patch)
treebc7280515d5404ac8b2659d0b882d0d69db2797d /crawl-ref/source/effects.cc
parent67595e7541aca42ea7068a239cbf4bd2ec232e38 (diff)
downloadcrawl-ref-6b684f55be020bffc5144b583acf79c7d4404a4f.tar.gz
crawl-ref-6b684f55be020bffc5144b583acf79c7d4404a4f.zip
Remove x
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc46
1 files changed, 27 insertions, 19 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 4e937d0ad2..ae107cbfe9 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2253,6 +2253,31 @@ void handle_time()
}
}
+/**
+ * Return the number of turns it takes for monsters to forget about the player
+ * 50% of the time.
+ *
+ * @param The intelligence of the monster.
+ * @return An average number of turns before the monster forgets.
+ */
+static int _mon_forgetfulness_time(mon_intel_type intelligence)
+{
+ switch (intelligence)
+ {
+ case I_HIGH:
+ return 1000;
+ case I_NORMAL:
+ default:
+ return 500;
+ case I_ANIMAL:
+ case I_REPTILE:
+ case I_INSECT:
+ return 250;
+ case I_PLANT:
+ return 125;
+ }
+}
+
// Move monsters around to fake them walking around while player was
// off-level.
static void _catchup_monster_moves(monster* mon, int turns)
@@ -2314,27 +2339,10 @@ static void _catchup_monster_moves(monster* mon, int turns)
// After x turns, half of the monsters will have forgotten about the
// player. A given monster has a 95% chance of forgetting the player after
// 4*x turns.
- int x = 0; // Quiet unitialized variable compiler warning.
- switch (mons_intel(mon))
- {
- case I_HIGH:
- x = 1000;
- break;
- case I_NORMAL:
- x = 500;
- break;
- case I_ANIMAL:
- case I_REPTILE:
- case I_INSECT:
- x = 250;
- break;
- case I_PLANT:
- x = 125;
- break;
- }
+ const int forgetfulness_time = _mon_forgetfulness_time(mons_intel(mon));
bool changed = false;
- for (int i = 0; i < range/x; i++)
+ for (int i = 0; i < range/forgetfulness_time; i++)
{
if (mon->behaviour == BEH_SLEEP)
break;