summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bldg.c6
-rw-r--r--src/defines.h1
-rw-r--r--src/plots.h1
-rw-r--r--src/q_library.c65
-rw-r--r--src/variable.c2
5 files changed, 74 insertions, 1 deletions
diff --git a/src/bldg.c b/src/bldg.c
index 1845e838..66ca9d9d 100644
--- a/src/bldg.c
+++ b/src/bldg.c
@@ -2042,6 +2042,12 @@ bool_ bldg_process_command(store_type *s_ptr, int i)
break;
}
+ case BACT_LIBRARY_QUEST:
+ {
+ quest_library_building(&paid, &recreate);
+ break;
+ }
+
default:
{
if (process_hooks_ret(HOOK_BUILDING_ACTION, "dd", "(d)", bact))
diff --git a/src/defines.h b/src/defines.h
index f716e326..d78ed058 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4046,6 +4046,7 @@
#define BACT_PAY_BACK_LOAN 53
#define BACT_DROP_ITEM 54
#define BACT_GET_ITEM 55
+#define BACT_LIBRARY_QUEST 61
/* If one adds new BACT_ do NOT forget to increase max_bact in variables.c */
diff --git a/src/plots.h b/src/plots.h
index 2d78ee02..73e4b8a8 100644
--- a/src/plots.h
+++ b/src/plots.h
@@ -55,3 +55,4 @@ extern bool_ quest_bounty_describe(FILE *fff);
/******* Plot Library Quest *******/
extern void quest_library_gen_hook();
+extern void quest_library_building(bool_ *paid, bool_ *recreate);
diff --git a/src/q_library.c b/src/q_library.c
index 25f20717..6bb8baaa 100644
--- a/src/q_library.c
+++ b/src/q_library.c
@@ -240,3 +240,68 @@ void quest_library_gen_hook()
library_quest_place_nrandom(
10, 10, 37, 67, MONSTER_MITHRIL_GOLEM, 1);
}
+
+static int get_status()
+{
+ return exec_lua("return quest(LIBRARY_QUEST).status");
+}
+
+static void set_status(int new_status)
+{
+ exec_lua(format("quest(LIBRARY_QUEST).status = %d", new_status));
+}
+
+void quest_library_building(bool_ *paid, bool_ *recreate)
+{
+ int status = get_status();
+
+ /* the quest hasn't been requested already, right? */
+ if (status == QUEST_STATUS_UNTAKEN)
+ {
+ /* quest has been taken now */
+ set_status(QUEST_STATUS_TAKEN);
+
+ /* issue instructions */
+ msg_print("I need get some stock from my main library, but it is infested with monsters!");
+ msg_print("Please use the side entrance and vanquish the intruders for me.");
+
+ *paid = FALSE;
+ *recreate = TRUE;
+ }
+
+ /* if quest completed */
+ else if (status == QUEST_STATUS_COMPLETED)
+ {
+ msg_print("Thank you! Let me make a special book for you.");
+ msg_print("Tell me three spells and I will write them in the book.");
+ library_quest_fill_book();
+ if (library_quest_book_slots_left() == 0)
+ {
+ set_status(QUEST_STATUS_REWARDED);
+
+ {
+ object_type forge;
+ object_type *q_ptr = &forge;
+ object_prep(q_ptr, lookup_kind(TV_BOOK, 61));
+ q_ptr->art_name = quark_add(player_name);
+ q_ptr->found = OBJ_FOUND_REWARD;
+ object_aware(q_ptr);
+ object_known(q_ptr);
+ inven_carry(q_ptr, FALSE);
+ }
+ }
+ }
+
+ /* if the player asks for a quest when they already have it,
+ * but haven't failed it, give them some extra instructions */
+ else if (status == QUEST_STATUS_TAKEN)
+ {
+ msg_print("Please use the side entrance and vanquish the intruders for me.");
+ }
+
+ /* quest failed or completed, then give no more quests */
+ else if ((status == QUEST_STATUS_FAILED) || (status == QUEST_STATUS_REWARDED))
+ {
+ msg_print("I have no more quests for you.");
+ }
+}
diff --git a/src/variable.c b/src/variable.c
index 52e16e01..c4388457 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1533,7 +1533,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 = 56;
+int max_bact = 127;
/*
* Ingame contextual help