diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 22:10:00 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:28:25 +0200 |
commit | 3215bb6521aca21af4d48f0598e1322ef8d8773c (patch) | |
tree | a7d53e5689b35f04c7ae0bdea67a6b289b508f09 /src | |
parent | 65a41a0ef06a606927a6b2866e0172f0d5c98e11 (diff) |
Lua: Move Bounty Hunter quest to C
Diffstat (limited to 'src')
-rw-r--r-- | src/bldg.c | 12 | ||||
-rw-r--r-- | src/defines.h | 5 | ||||
-rw-r--r-- | src/plots.c | 3 | ||||
-rw-r--r-- | src/plots.h | 6 | ||||
-rw-r--r-- | src/q_bounty.c | 111 | ||||
-rw-r--r-- | src/quest.pkg | 9 | ||||
-rw-r--r-- | src/tables.c | 17 | ||||
-rw-r--r-- | src/variable.c | 2 |
8 files changed, 154 insertions, 11 deletions
@@ -2030,6 +2030,18 @@ bool_ bldg_process_command(store_type *s_ptr, int i) break; } + case BACT_DROP_ITEM: + { + quest_bounty_drop_item(); + break; + } + + case BACT_GET_ITEM: + { + quest_bounty_get_item(); + break; + } + default: { if (process_hooks_ret(HOOK_BUILDING_ACTION, "dd", "(d)", bact)) diff --git a/src/defines.h b/src/defines.h index a75df305..1569012b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4039,6 +4039,8 @@ #define BACT_REQUEST_ITEM 51 #define BACT_GET_LOAN 52 #define BACT_PAY_BACK_LOAN 53 +#define BACT_DROP_ITEM 54 +#define BACT_GET_ITEM 55 /* If one adds new BACT_ do NOT forget to increase max_bact in variables.c */ @@ -4406,7 +4408,8 @@ #define QUEST_DRAGONS 23 #define QUEST_HAUNTED 24 #define QUEST_EVIL 25 -#define MAX_Q_IDX_INIT 26 +#define QUEST_BOUNTY 26 +#define MAX_Q_IDX_INIT 27 #define PLOT_MAIN 0 #define PLOT_BREE 1 diff --git a/src/plots.c b/src/plots.c index 53d3e1bc..2fb1cbb1 100644 --- a/src/plots.c +++ b/src/plots.c @@ -471,3 +471,6 @@ bool_ quest_null_hook(int q) /*************************** Other plot ***************************/ #include "q_narsil.c" #include "q_thrain.c" + +/*************************** Bounty Quest *************************/ +#include "q_bounty.c" diff --git a/src/plots.h b/src/plots.h index a1a11e6c..903ffcef 100644 --- a/src/plots.h +++ b/src/plots.h @@ -46,3 +46,9 @@ extern bool_ quest_evil_init_hook(int q_idx); /******* Plot Other *********/ extern bool_ quest_narsil_init_hook(int q_idx); extern bool_ quest_thrain_init_hook(int q_idx); + +/******* Plot Bounty Quest ********/ +extern bool_ quest_bounty_init_hook(int q_idx); +extern bool_ quest_bounty_drop_item(); +extern bool_ quest_bounty_get_item(); +extern bool_ quest_bounty_describe(FILE *fff); diff --git a/src/q_bounty.c b/src/q_bounty.c new file mode 100644 index 00000000..01b119be --- /dev/null +++ b/src/q_bounty.c @@ -0,0 +1,111 @@ +#undef cquest +#define cquest (quest[QUEST_BOUNTY]) + +#define bounty_quest_monster (cquest.data[0]) + +static bool_ bounty_item_tester_hook(object_type *o_ptr) +{ + if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval2 == bounty_quest_monster)) + { + return TRUE; + } + else + { + return FALSE; + } +} + +bool_ quest_bounty_init_hook(int dummy) +{ + return FALSE; +} + +bool_ quest_bounty_drop_item() +{ + char mdesc[512]; + char msg[512]; + + 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); + + monster_race_desc(mdesc, bounty_quest_monster, 0); + snprintf(msg, sizeof(msg), "You must bring me back %s corpse.", mdesc); + msg_print(msg); + } + else + { + monster_race_desc(mdesc, bounty_quest_monster, 0); + snprintf(msg, sizeof(msg), "You still must bring me back %s corpse.", mdesc); + msg_print(msg); + } + return FALSE; +} + +bool_ quest_bounty_get_item() +{ + if (cquest.status != QUEST_STATUS_TAKEN) + { + msg_print("You do not have any bounty quest yet."); + return FALSE; + } + + // Get the corpse. + item_tester_hook = bounty_item_tester_hook; + int item = -1; + bool_ ret = + get_item(&item, + "What corpse to return?", + "You have no corpse to return.", + USE_INVEN); + if (!ret) { + return FALSE; + } + + // Take the corpse from the inventory + inven_item_increase(item, -1); + inven_item_optimize(item); + + msg_print("Ah well done adventurer!"); + msg_print("As a reward I will teach you a bit of monster lore."); + + skill_type *lore = &s_info[SKILL_LORE]; + skill_type *preservation = &s_info[SKILL_PRESERVATION]; + + if (lore->mod == 0) { + lore->mod = 900; + lore->dev = TRUE; + } + lore->value += lore->mod; + + if (preservation->mod == 0) { + preservation->value = 800; + preservation->mod = 800; + preservation->dev = TRUE; + msg_print("I see you don't know the corpse preservation skill, I shall teach you it too."); + } + + // Need to ask for new quest. + cquest.status = QUEST_STATUS_UNTAKEN; + bounty_quest_monster = 0; + return FALSE; +} + +bool_ quest_bounty_describe(FILE *fff) +{ + char mdesc[512]; + + if (cquest.status == QUEST_STATUS_TAKEN) + { + monster_race_desc(mdesc, bounty_quest_monster, 0); + + fprintf(fff, "#####yBounty quest!\n"); + fprintf(fff, "You must bring back %s corpse to the beastmaster.\n", mdesc); + fprintf(fff, "\n"); + + return TRUE; + } + + return FALSE; +} diff --git a/src/quest.pkg b/src/quest.pkg index 4ba93b7a..487c62af 100644 --- a/src/quest.pkg +++ b/src/quest.pkg @@ -159,12 +159,3 @@ extern s16b add_new_quest @ new_quest(char *name); * @note (see file lua_bind.c) */ extern void desc_quest @ quest_desc(int q_idx, int d, char *desc); - -/** @fn get_new_bounty_monster(int lev); - * @brief Find a good random bounty monster.\n - * @param lev Number \n the level of the bounty monster. - * @brief Monster level - * @return Number \n The index of the monster in the r_info array. - * @note (see file lua_bind.c) - */ -extern int lua_get_new_bounty_monster@get_new_bounty_monster(int lev); diff --git a/src/tables.c b/src/tables.c index 569acd93..e7a81f11 100644 --- a/src/tables.c +++ b/src/tables.c @@ -4248,6 +4248,23 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] = {0, 0}, NULL, }, + /* Bounty */ + { + FALSE, + TRUE, + "Bounty quest", + { + "", /* dynamic desc */ + }, + QUEST_STATUS_UNTAKEN, + -1, + NULL, + HOOK_TYPE_C, + quest_bounty_init_hook, + {0, 0, 0, 0}, + quest_bounty_describe, + }, + }; diff --git a/src/variable.c b/src/variable.c index c00e1e42..c6a23758 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1537,7 +1537,7 @@ int cli_total = 0; /* * max_bact, only used so that lua scripts can add new bacts without worrying about the numbers */ -int max_bact = 54; +int max_bact = 56; /* * Max corruptions |