summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/bounty.lua90
-rw-r--r--lib/mods/theme/scpt/init.lua1
-rw-r--r--lib/scpt/bounty.lua90
-rw-r--r--lib/scpt/init.lua1
-rw-r--r--src/bldg.c12
-rw-r--r--src/defines.h5
-rw-r--r--src/plots.c3
-rw-r--r--src/plots.h6
-rw-r--r--src/q_bounty.c111
-rw-r--r--src/quest.pkg9
-rw-r--r--src/tables.c17
-rw-r--r--src/variable.c2
12 files changed, 154 insertions, 193 deletions
diff --git a/lib/mods/theme/scpt/bounty.lua b/lib/mods/theme/scpt/bounty.lua
deleted file mode 100644
index 94c15598..00000000
--- a/lib/mods/theme/scpt/bounty.lua
+++ /dev/null
@@ -1,90 +0,0 @@
--- The bounty quest! bring back corpses to increase your monster lore skill
-
-add_quest
-{
- ["global"] = "BOUNTY_QUEST",
- ["name"] = "Bounty quest",
- ["desc"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_TAKEN then
- print_hook("#####yBounty quest!\n")
- print_hook("You must bring back "..monster_race_desc(bounty_quest_monster, 0).." corpse to the beastmaster.\n")
- print_hook("\n")
- end
- end,
- ["level"] = -1,
- ["data"] = {
- ["bounty_quest_monster"] = 0,
- },
- ["hooks"] = {
- -- Start the game without the quest, need to request it
- [HOOK_BIRTH_OBJECTS] = function()
- quest(BOUNTY_QUEST).status = QUEST_STATUS_UNTAKEN
- end,
- },
-}
-
-add_building_action
-{
- -- Index is used in ba_info.txt to set the actions
- ["index"] = 54,
- ["action"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_UNTAKEN then
- quest(BOUNTY_QUEST).status = QUEST_STATUS_TAKEN
- bounty_quest_monster = get_new_bounty_monster(3 + ((player.lev * 3) / 2))
-
- msg_print("You must bring me back "..monster_race_desc(bounty_quest_monster, 0).." corpse.")
- else
- msg_print("You still must bring me back "..monster_race_desc(bounty_quest_monster, 0).." corpse.")
- end
- end
-}
-
-add_building_action
-{
- -- Index is used in ba_info.txt to set the actions
- ["index"] = 55,
- ["action"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_TAKEN then
- local ret, item
-
- -- Ask for an item
- ret, item = get_item("What corpse to return?",
- "You have no corpse to return.",
- bor(USE_INVEN),
- function (obj)
- if (obj.tval == TV_CORPSE) and (obj.pval2 == bounty_quest_monster) then
- return TRUE
- end
- return FALSE
- end
- )
-
- -- Ok we got the corpse!
- if ret == TRUE then
- -- 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.")
-
- if skill(SKILL_LORE).mod == 0 then
- skill(SKILL_LORE).mod = 900
- skill(SKILL_LORE).dev = TRUE
- end
- skill(SKILL_LORE).value = skill(SKILL_LORE).value + skill(SKILL_LORE).mod
- if skill(SKILL_PRESERVATION).mod == 0 then
- skill(SKILL_PRESERVATION).value = 800
- skill(SKILL_PRESERVATION).mod = 800
- skill(SKILL_PRESERVATION).dev = TRUE
- msg_print("I see you don't know the corpse preservation skill, I shall teach you it too.")
- end
-
- quest(BOUNTY_QUEST).status = QUEST_STATUS_UNTAKEN
- bounty_quest_monster = 0
- end
- else
- msg_print("You do not have any bounty quest yet.")
- end
- end
-}
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index 958d8f7d..19649da7 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -31,7 +31,6 @@ tome_dofile("gods_new.lua")
tome_dofile("spells.lua")
-- Add some quests
-tome_dofile("bounty.lua")
tome_dofile("god.lua")
tome_dofile("fireprof.lua")
tome_dofile("library.lua")
diff --git a/lib/scpt/bounty.lua b/lib/scpt/bounty.lua
deleted file mode 100644
index 94c15598..00000000
--- a/lib/scpt/bounty.lua
+++ /dev/null
@@ -1,90 +0,0 @@
--- The bounty quest! bring back corpses to increase your monster lore skill
-
-add_quest
-{
- ["global"] = "BOUNTY_QUEST",
- ["name"] = "Bounty quest",
- ["desc"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_TAKEN then
- print_hook("#####yBounty quest!\n")
- print_hook("You must bring back "..monster_race_desc(bounty_quest_monster, 0).." corpse to the beastmaster.\n")
- print_hook("\n")
- end
- end,
- ["level"] = -1,
- ["data"] = {
- ["bounty_quest_monster"] = 0,
- },
- ["hooks"] = {
- -- Start the game without the quest, need to request it
- [HOOK_BIRTH_OBJECTS] = function()
- quest(BOUNTY_QUEST).status = QUEST_STATUS_UNTAKEN
- end,
- },
-}
-
-add_building_action
-{
- -- Index is used in ba_info.txt to set the actions
- ["index"] = 54,
- ["action"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_UNTAKEN then
- quest(BOUNTY_QUEST).status = QUEST_STATUS_TAKEN
- bounty_quest_monster = get_new_bounty_monster(3 + ((player.lev * 3) / 2))
-
- msg_print("You must bring me back "..monster_race_desc(bounty_quest_monster, 0).." corpse.")
- else
- msg_print("You still must bring me back "..monster_race_desc(bounty_quest_monster, 0).." corpse.")
- end
- end
-}
-
-add_building_action
-{
- -- Index is used in ba_info.txt to set the actions
- ["index"] = 55,
- ["action"] = function()
- if quest(BOUNTY_QUEST).status == QUEST_STATUS_TAKEN then
- local ret, item
-
- -- Ask for an item
- ret, item = get_item("What corpse to return?",
- "You have no corpse to return.",
- bor(USE_INVEN),
- function (obj)
- if (obj.tval == TV_CORPSE) and (obj.pval2 == bounty_quest_monster) then
- return TRUE
- end
- return FALSE
- end
- )
-
- -- Ok we got the corpse!
- if ret == TRUE then
- -- 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.")
-
- if skill(SKILL_LORE).mod == 0 then
- skill(SKILL_LORE).mod = 900
- skill(SKILL_LORE).dev = TRUE
- end
- skill(SKILL_LORE).value = skill(SKILL_LORE).value + skill(SKILL_LORE).mod
- if skill(SKILL_PRESERVATION).mod == 0 then
- skill(SKILL_PRESERVATION).value = 800
- skill(SKILL_PRESERVATION).mod = 800
- skill(SKILL_PRESERVATION).dev = TRUE
- msg_print("I see you don't know the corpse preservation skill, I shall teach you it too.")
- end
-
- quest(BOUNTY_QUEST).status = QUEST_STATUS_UNTAKEN
- bounty_quest_monster = 0
- end
- else
- msg_print("You do not have any bounty quest yet.")
- end
- end
-}
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index a6f3f8ab..8b288f17 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -30,7 +30,6 @@ tome_dofile("spells.lua")
tome_dofile("gods.lua")
-- Add some quests
-tome_dofile("bounty.lua")
tome_dofile("god.lua")
tome_dofile("fireprof.lua")
tome_dofile("library.lua")
diff --git a/src/bldg.c b/src/bldg.c
index 48e94e9f..1845e838 100644
--- a/src/bldg.c
+++ b/src/bldg.c
@@ -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