diff options
author | Bardur Arantsson <bardur@scientician.net> | 2013-07-16 07:51:08 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2013-08-08 16:33:29 +0200 |
commit | 97f71585f5dc7c7ea8636cf277404e41f76b0706 (patch) | |
tree | a48d10dfe6d2a8f2235cfe0455d34bd60d0e322c | |
parent | a8a33056a073cb3f4213a1e845fe036dd3d53e0b (diff) |
Prevent friendly quest monsters in Theme
-rw-r--r-- | src/birth.c | 10 | ||||
-rw-r--r-- | src/externs.h | 1 | ||||
-rw-r--r-- | src/modules.c | 6 | ||||
-rw-r--r-- | src/tables.c | 4 | ||||
-rw-r--r-- | src/types.h | 5 |
5 files changed, 23 insertions, 3 deletions
diff --git a/src/birth.c b/src/birth.c index 9e7629c2..85939b8e 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1375,6 +1375,16 @@ static void gen_random_quests(int n) /* Accept only monsters that are not good */ if (r_ptr->flags3 & RF3_GOOD) continue; + /* If module says a monster race is friendly, then skip */ + if (modules[game_module_idx].race_status != NULL) + { + s16b *status = (*modules[game_module_idx].race_status)(q_ptr->r_idx); + if ((status != NULL) && (*status >= 0)) + { + continue; + } + } + /* Assume no explosion attacks */ ok = TRUE; diff --git a/src/externs.h b/src/externs.h index 45734ac1..8fd9e5e5 100644 --- a/src/externs.h +++ b/src/externs.h @@ -2302,6 +2302,7 @@ extern bool_ select_module(void); extern bool_ module_savefile_loadable(cptr savefile_mod); extern void tome_intro(); extern void theme_intro(); +extern s16b *theme_race_status(int r_idx); extern void init_hooks_module(); extern int find_module(cptr name); diff --git a/src/modules.c b/src/modules.c index 088dfbd7..26c3f271 100644 --- a/src/modules.c +++ b/src/modules.c @@ -770,7 +770,7 @@ static bool_ race_in_list(int r_idx, int race_idxs[]) /* * Monster racial alignment from Theme. */ -static s16b *compute_monster_status(int r_idx) +s16b *theme_race_status(int r_idx) { static s16b FRIEND_ = MSTATUS_FRIEND; static s16b *FRIEND = &FRIEND_; @@ -1107,7 +1107,7 @@ static bool_ theme_level_end_gen(void *data, void *in, void *out) { monster_type *m_ptr = &m_list[i]; int r_idx = m_ptr->r_idx; - s16b *status = compute_monster_status(r_idx); + s16b *status = theme_race_status(r_idx); if (status) { m_ptr->status = *status; @@ -1120,7 +1120,7 @@ static bool_ theme_level_end_gen(void *data, void *in, void *out) static bool_ theme_new_monster_end(void *data, void *in_, void *out) { hook_new_monster_end_in *in = (hook_new_monster_end_in *) in_; - s16b *status = compute_monster_status(in->m_ptr->r_idx); + s16b *status = theme_race_status(in->m_ptr->r_idx); if (status) { diff --git a/src/tables.c b/src/tables.c index dec13e70..1d5f1c49 100644 --- a/src/tables.c +++ b/src/tables.c @@ -4704,6 +4704,8 @@ module_type modules[MAX_MODULES] = { 6, 4, }, /* Intro function */ tome_intro, + /* Race status function: ToME requires no special handling */ + NULL }, { @@ -4724,6 +4726,8 @@ module_type modules[MAX_MODULES] = { 6, 5, }, /* Intro function */ theme_intro, + /* Race status function */ + theme_race_status } }; diff --git a/src/types.h b/src/types.h index bddb304b..d9cae3cf 100644 --- a/src/types.h +++ b/src/types.h @@ -2718,6 +2718,11 @@ struct module_type /* Function to show introduction to module */ void (*intro)(); + + /* Function to compute race status, i.e. whether monsters + are friendly/neutral towards the player. Returns NULL + to indicate that no override happens. */ + s16b *(*race_status)(int r_idx); }; /** |