summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-08 17:52:16 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-08 18:19:35 +0200
commit1a33c8c5f7eb8d36642c59c37284cc8f06c3e102 (patch)
treed3419f5386e4aa663afcc9ccd35a8ec2223b0aa6
parent61da8b12362ed22ca3c1d82ebec953035cd2f8d9 (diff)
Lua: Library quest: Move more generation code to C
-rw-r--r--lib/mods/theme/scpt/library.lua13
-rw-r--r--lib/scpt/library.lua13
-rw-r--r--src/plots.h2
-rw-r--r--src/q_library.c23
-rw-r--r--src/util.pkg2
5 files changed, 26 insertions, 27 deletions
diff --git a/lib/mods/theme/scpt/library.lua b/lib/mods/theme/scpt/library.lua
index d2851a23..fca935fb 100644
--- a/lib/mods/theme/scpt/library.lua
+++ b/lib/mods/theme/scpt/library.lua
@@ -98,18 +98,7 @@ add_quest
end,
[HOOK_GEN_QUEST] = function()
- -- Only if player doing this quest
- if (player.inside_quest ~= LIBRARY_QUEST) then
- return FALSE
- end
-
- load_map("library.map", 2, 2)
- level_flags2 = DF2_NO_GENO
-
- -- generate monsters
- quest_library_gen_hook()
-
- return TRUE
+ return quest_library_gen_hook()
end,
[HOOK_STAIR] = function()
local ret
diff --git a/lib/scpt/library.lua b/lib/scpt/library.lua
index ad546b54..202ba268 100644
--- a/lib/scpt/library.lua
+++ b/lib/scpt/library.lua
@@ -95,18 +95,7 @@ add_quest
end,
[HOOK_GEN_QUEST] = function()
- -- Only if player doing this quest
- if (player.inside_quest ~= LIBRARY_QUEST) then
- return FALSE
- end
-
- load_map("library.map", 2, 2)
- level_flags2 = DF2_NO_GENO
-
- -- generate monsters
- quest_library_gen_hook()
-
- return TRUE
+ return quest_library_gen_hook()
end,
[HOOK_STAIR] = function()
local ret
diff --git a/src/plots.h b/src/plots.h
index 702bb55e..da8a6cd2 100644
--- a/src/plots.h
+++ b/src/plots.h
@@ -54,7 +54,7 @@ extern bool_ quest_bounty_get_item();
extern bool_ quest_bounty_describe(FILE *fff);
/******* Plot Library Quest *******/
-extern void quest_library_gen_hook();
+extern bool_ quest_library_gen_hook();
extern void quest_library_building(bool_ *paid, bool_ *recreate);
/******* Plot Fireproof Quest *********/
diff --git a/src/q_library.c b/src/q_library.c
index 6bb8baaa..d7a098cd 100644
--- a/src/q_library.c
+++ b/src/q_library.c
@@ -7,6 +7,11 @@
#define MONSTER_IRON_GOLEM 367
#define MONSTER_MITHRIL_GOLEM 464
+static int LIBRARY_QUEST()
+{
+ return get_lua_int("LIBRARY_QUEST");
+}
+
static s16b library_quest_place_random(int minY, int minX, int maxY, int maxX, int r_idx)
{
int y = randint(maxY - minY + 1) + minY;
@@ -214,8 +219,22 @@ void library_quest_fill_book()
screen_load();
}
-void quest_library_gen_hook()
+bool_ quest_library_gen_hook()
{
+ /* Only if player doing this quest */
+ if (p_ptr->inside_quest != LIBRARY_QUEST())
+ {
+ return FALSE;
+ }
+
+ {
+ int y = 2;
+ int x = 2;
+ load_map("library.map", &y, &x);
+ dungeon_flags2 = DF2_NO_GENO;
+ }
+
+ /* Generate monsters */
library_quest_place_nrandom(
4, 4, 14, 37, MONSTER_LICH, damroll(4,2));
@@ -239,6 +258,8 @@ void quest_library_gen_hook()
library_quest_place_nrandom(
10, 10, 37, 67, MONSTER_MITHRIL_GOLEM, 1);
+
+ return TRUE;
}
static int get_status()
diff --git a/src/util.pkg b/src/util.pkg
index 0be3cb8b..49924e7f 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -2473,7 +2473,7 @@ extern void lite_spot(int y, int x);
extern bool drop_text_left(byte c, cptr s, int y, int o);
extern bool drop_text_right(byte c, cptr s, int y, int o);
-extern void quest_library_gen_hook();
+extern bool quest_library_gen_hook();
/**
* Mimicry