diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-03-07 16:55:41 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-03-07 16:55:41 +0100 |
commit | 3e87db451cf70fc70ef4eab5ff2b525d48c4cc43 (patch) | |
tree | e0c59555cd3fc0df1b5266a1776c1fcee0148445 /src/q_bounty.cc | |
parent | 3f0def9ba628f6555a29517479acbd33c80e0097 (diff) |
Moved lua_get_new_bounty_monster() to q_bounty.cc
This is where it rightly belongs. Also remove the lua_ prefix
and make it static.
Diffstat (limited to 'src/q_bounty.cc')
-rw-r--r-- | src/q_bounty.cc | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/q_bounty.cc b/src/q_bounty.cc index dbd57df7..836c8a61 100644 --- a/src/q_bounty.cc +++ b/src/q_bounty.cc @@ -9,6 +9,60 @@ #define bounty_quest_monster (cquest.data[0]) +static bool_ lua_mon_hook_bounty(int r_idx) +{ + monster_race* r_ptr = &r_info[r_idx]; + + /* Reject uniques */ + if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE); + + /* Reject those who cannot leave anything */ + if (!(r_ptr->flags9 & RF9_DROP_CORPSE)) return (FALSE); + + /* Accept only monsters that can be generated */ + if (r_ptr->flags9 & RF9_SPECIAL_GENE) return (FALSE); + if (r_ptr->flags9 & RF9_NEVER_GENE) return (FALSE); + + /* Reject pets */ + if (r_ptr->flags7 & RF7_PET) return (FALSE); + + /* Reject friendly creatures */ + if (r_ptr->flags7 & RF7_FRIENDLY) return (FALSE); + + /* Accept only monsters that are not breeders */ + if (r_ptr->flags4 & RF4_MULTIPLY) return (FALSE); + + /* Forbid joke monsters */ + if (r_ptr->flags8 & RF8_JOKEANGBAND) return (FALSE); + + /* Accept only monsters that are not good */ + if (r_ptr->flags3 & RF3_GOOD) return (FALSE); + + /* The rest are acceptable */ + return (TRUE); +} + +static int get_new_bounty_monster(int lev) +{ + int r_idx; + + /* + * Set up the hooks -- no bounties on uniques or monsters + * with no corpses + */ + get_mon_num_hook = lua_mon_hook_bounty; + get_mon_num_prep(); + + /* Set up the quest monster. */ + r_idx = get_mon_num(lev); + + /* Undo the filters */ + get_mon_num_hook = NULL; + get_mon_num_prep(); + + return r_idx; +} + static bool_ bounty_item_tester_hook(object_type *o_ptr) { if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval2 == bounty_quest_monster)) @@ -34,7 +88,7 @@ bool_ quest_bounty_drop_item() if (cquest.status == QUEST_STATUS_UNTAKEN) { cquest.status = QUEST_STATUS_TAKEN; - bounty_quest_monster = lua_get_new_bounty_monster(3 + (p_ptr->lev * 3) / 2); + bounty_quest_monster = get_new_bounty_monster(3 + (p_ptr->lev * 3) / 2); monster_race_desc(mdesc, bounty_quest_monster, 0); snprintf(msg, sizeof(msg), "You must bring me back %s corpse.", mdesc); |