summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-06-27 20:56:05 +0200
committerBardur Arantsson <bardur@scientician.net>2012-06-27 20:56:05 +0200
commit2384dff0de2858e8c97fa7b18634aca0ec4f5a8e (patch)
tree5706dc414b2f32669277af7098376c4b8786b405
parentbcbdb77ad85255f788b2fb37a13d100428f883b1 (diff)
Remove ALLOW_FEAR preprocessor define
Remove duplicate fear-handling code while we're at it
-rw-r--r--src/config.h5
-rw-r--r--src/externs.h1
-rw-r--r--src/melee2.c30
-rw-r--r--src/xtra2.c55
4 files changed, 21 insertions, 70 deletions
diff --git a/src/config.h b/src/config.h
index 889b3574..3e0076de 100644
--- a/src/config.h
+++ b/src/config.h
@@ -119,11 +119,6 @@
/*
- * OPTION: Allow monsters to "flee" when hit hard
- */
-#define ALLOW_FEAR
-
-/*
* OPTION: Allow monsters to "flee" from strong players
*/
#define ALLOW_TERROR
diff --git a/src/externs.h b/src/externs.h
index 33a74266..86127f25 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -985,6 +985,7 @@ extern errr rd_savefile_new(void);
/* melee2.c */
extern int monst_spell_monst_spell;
extern bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note);
+extern void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear);
extern int check_hit2(int power, int level, int ac);
extern int get_attack_power(int effect);
extern bool_ carried_make_attack_normal(int r_idx);
diff --git a/src/melee2.c b/src/melee2.c
index 5443a214..91be521d 100644
--- a/src/melee2.c
+++ b/src/melee2.c
@@ -166,7 +166,21 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note)
}
-#ifdef ALLOW_FEAR
+ /* Apply fear */
+ mon_handle_fear(m_ptr, dam, fear);
+
+ /* Not dead yet */
+ return (FALSE);
+}
+
+
+void mon_handle_fear(monster_type *m_ptr, int dam, bool_ *fear)
+{
+ monster_race *r_ptr = NULL;
+
+ assert(m_ptr != NULL);
+
+ r_ptr = race_inf(m_ptr);
/* Mega-Hack -- Pain cancels fear */
if (m_ptr->monfear && (dam > 0))
@@ -200,9 +214,9 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note)
percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
/*
- * Run (sometimes) if at 10% or less of max hit points,
- * or (usually) when hit for half its current hit points
- */
+ * Run (sometimes) if at 10% or less of max hit points,
+ * or (usually) when hit for half its current hit points
+ */
if (((percentage <= 10) && (rand_int(10) < percentage)) ||
((dam >= m_ptr->hp) && (rand_int(100) < 80)))
{
@@ -215,17 +229,9 @@ bool_ mon_take_hit_mon(int s_idx, int m_idx, int dam, bool_ *fear, cptr note)
20 : ((11 - percentage) * 5)));
}
}
-
-#endif /* ALLOW_FEAR */
-
- /* Not dead yet */
- return (FALSE);
}
-
-
-
/*
* And now for Intelligent monster attacks (including spells).
*
diff --git a/src/xtra2.c b/src/xtra2.c
index 6594e482..ef753b3a 100644
--- a/src/xtra2.c
+++ b/src/xtra2.c
@@ -3452,59 +3452,8 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
return (TRUE);
}
-
-#ifdef ALLOW_FEAR
-
- /* Mega-Hack -- Pain cancels fear */
- if (m_ptr->monfear && (dam > 0))
- {
- int tmp = randint(dam);
-
- /* Cure a little fear */
- if (tmp < m_ptr->monfear)
- {
- /* Reduce fear */
- m_ptr->monfear -= tmp;
- }
-
- /* Cure all the fear */
- else
- {
- /* Cure fear */
- m_ptr->monfear = 0;
-
- /* No more fear */
- (*fear) = FALSE;
- }
- }
-
- /* Sometimes a monster gets scared by damage */
- if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
- {
- int percentage;
-
- /* Percentage of fully healthy */
- percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
-
- /*
- * Run (sometimes) if at 10% or less of max hit points,
- * or (usually) when hit for half its current hit points
- */
- if (((percentage <= 10) && (rand_int(10) < percentage)) ||
- ((dam >= m_ptr->hp) && (rand_int(100) < 80)))
- {
- /* Hack -- note fear */
- (*fear) = TRUE;
-
- /* XXX XXX XXX Hack -- Add some timed fear */
- m_ptr->monfear = (randint(10) +
- (((dam >= m_ptr->hp) && (percentage > 7)) ?
- 20 : ((11 - percentage) * 5)));
- }
- }
-
-#endif
-
+ /* Apply fear */
+ mon_handle_fear(m_ptr, dam, fear);
/* Not dead yet */
return (FALSE);