summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/god.lua51
-rw-r--r--lib/scpt/god.lua51
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/plots.h3
-rw-r--r--src/q_god.c97
-rw-r--r--src/quest.pkg5
6 files changed, 108 insertions, 100 deletions
diff --git a/lib/mods/theme/scpt/god.lua b/lib/mods/theme/scpt/god.lua
index 7567178c..71a85660 100644
--- a/lib/mods/theme/scpt/god.lua
+++ b/lib/mods/theme/scpt/god.lua
@@ -114,7 +114,7 @@ add_quest
god_quest.quests_given = god_quest.quests_given + 1
-- actually place the dungeon in a random place
- place_rand_dung()
+ quest_god_place_rand_dung()
-- store the variables of the coords where the player was given the quest
god_quest.player_y, god_quest.player_x = player.get_wild_coord()
@@ -277,55 +277,6 @@ add_quest
},
}
--- this function places the lost temple at a randomly determined place.
-function place_rand_dung()
- local tries, grid
-
- -- erase old dungeon
- if (god_quest.quests_given > 0) then
- place_dungeon(god_quest.dung_y, god_quest.dung_x)
-
- -- erase old recall level
- max_dlv[god_quest.DUNGEON_GOD + 1] = 0
- end
-
- -- initialise tries variable
- tries = 1000
-
- while tries > 0 do
-
- tries = tries - 1
- -- get grid coordinates, within a range which prevents dungeon being generated at the very edge of the wilderness (would crash the game).
- god_quest.dung_x = rand_range(1, max_wild_x-2)
- god_quest.dung_y = rand_range(1, max_wild_y-2)
-
- -- Is there a town/dungeon/potentially impassable feature there, ?
- if (wild_map(god_quest.dung_y, god_quest.dung_x).entrance ~= 0)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).entrance ~= 0)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_EDGE)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_DEEP_WATER)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_TREES)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_SHALLOW_LAVA)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_DEEP_LAVA)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_MOUNTAIN) then
- -- try again
- else
- --neither player, nor wall, then stop this 'while'
- break
- end
- end
-
- -- Uhuh BAD ! lets use the default location up bree
- if tries == 0 then
- god_quest.dung_x = 32
- god_quest.dung_y = 19
- end
-
- -- create god dungeon in that place
- place_dungeon(god_quest.dung_y, god_quest.dung_x, god_quest.DUNGEON_GOD)
-
-end
-
-- this function generates the relic at a randomly determined place in the temple.
function generate_relic()
local tries, grid, x, y, relic
diff --git a/lib/scpt/god.lua b/lib/scpt/god.lua
index 3f32888b..cc8b8fff 100644
--- a/lib/scpt/god.lua
+++ b/lib/scpt/god.lua
@@ -106,7 +106,7 @@ add_quest
god_quest.quests_given = god_quest.quests_given + 1
-- actually place the dungeon in a random place
- place_rand_dung()
+ quest_god_place_rand_dung()
-- store the variables of the coords where the player was given the quest
god_quest.player_y, god_quest.player_x = player.get_wild_coord()
@@ -269,55 +269,6 @@ add_quest
},
}
--- this function places the lost temple at a randomly determined place.
-function place_rand_dung()
- local tries, grid
-
- -- erase old dungeon
- if (god_quest.quests_given > 0) then
- place_dungeon(god_quest.dung_y, god_quest.dung_x)
-
- -- erase old recall level
- max_dlv[god_quest.DUNGEON_GOD + 1] = 0
- end
-
- -- initialise tries variable
- tries = 1000
-
- while tries > 0 do
-
- tries = tries - 1
- -- get grid coordinates, within a range which prevents dungeon being generated at the very edge of the wilderness (would crash the game).
- god_quest.dung_x = rand_range(1, max_wild_x-2)
- god_quest.dung_y = rand_range(1, max_wild_y-2)
-
- -- Is there a town/dungeon/potentially impassable feature there, ?
- if (wild_map(god_quest.dung_y, god_quest.dung_x).entrance ~= 0)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).entrance ~= 0)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_EDGE)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_DEEP_WATER)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_TREES)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_SHALLOW_LAVA)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_DEEP_LAVA)
- or (wild_feat(wild_map(god_quest.dung_y, god_quest.dung_x)).terrain_idx == TERRAIN_MOUNTAIN) then
- -- try again
- else
- --neither player, nor wall, then stop this 'while'
- break
- end
- end
-
- -- Uhuh BAD ! lets use the default location up bree
- if tries == 0 then
- god_quest.dung_x = 32
- god_quest.dung_y = 19
- end
-
- -- create god dungeon in that place
- place_dungeon(god_quest.dung_y, god_quest.dung_x, god_quest.DUNGEON_GOD)
-
-end
-
-- this function generates the relic at a randomly determined place in the temple.
function generate_relic()
local tries, grid, x, y, relic
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c2ed88a3..a453e573 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(SRCS
z-rand.c z-util.c z-form.c z-virt.c z-term.c
variable.c tables.c plots.c util.c cave.c dungeon.c
melee1.c melee2.c modules.c
+ q_god.c
object1.c object2.c randart.c squeltch.c traps.c
monster1.c monster2.c monster3.c
xtra1.c xtra2.c skills.c powers.c gods.c
diff --git a/src/plots.h b/src/plots.h
index f1dcce8c..eaeeb818 100644
--- a/src/plots.h
+++ b/src/plots.h
@@ -62,3 +62,6 @@ extern void quest_library_building(bool_ *paid, bool_ *recreate);
extern void quest_fireproof_building(bool_ *paid, bool_ *recreate);
extern bool_ quest_fireproof_init_hook(int q);
extern bool_ quest_fireproof_describe(FILE *fff);
+
+/******* Plot God Quest **************/
+extern void quest_god_place_rand_dung();
diff --git a/src/q_god.c b/src/q_god.c
new file mode 100644
index 00000000..070b2a02
--- /dev/null
+++ b/src/q_god.c
@@ -0,0 +1,97 @@
+#include "angband.h"
+#include <assert.h>
+
+/* d_idx of the god_quest (Lost Temple) dungeon */
+#define DUNGEON_GOD 30
+
+static int get_quests_given()
+{
+ return get_lua_int("god_quest.quests_given");
+}
+
+static int get_dung_y()
+{
+ return get_lua_int("god_quest.dung_y");
+}
+
+static int get_dung_x()
+{
+ return get_lua_int("god_quest.dung_x");
+}
+
+static void set_dung_y(int y)
+{
+ exec_lua(format("god_quest.dung_y = %d", y));
+}
+
+static void set_dung_x(int x)
+{
+ exec_lua(format("god_quest.dung_x = %d", x));
+}
+
+void quest_god_place_rand_dung()
+{
+ int x = -1, y = -1, tries;
+
+ /* erase old dungeon */
+ if (get_quests_given() > 0)
+ {
+ wild_map[get_dung_y()][get_dung_x()].entrance = 0;
+
+ /* erase old recall level */
+ max_dlv[DUNGEON_GOD] = 0;
+ }
+
+ /* initialise tries variable */
+ tries = 1000;
+ while (tries > 0)
+ {
+ wilderness_map *w_ptr = NULL;
+ wilderness_type_info *wf_ptr = NULL;
+ tries = tries - 1;
+
+ /* get grid coordinates, within a range which prevents
+ * dungeon being generated at the very edge of the
+ * wilderness (would crash the game). */
+ x = rand_range(1, max_wild_x-2);
+ y = rand_range(1, max_wild_y-2);
+
+ /* Is there a town/dungeon/potentially impassable feature there, ? */
+ w_ptr = &wild_map[y][x];
+ wf_ptr = &wf_info[w_ptr->feat];
+
+ if ((w_ptr->entrance != 0) ||
+ (wf_ptr->entrance != 0) ||
+ (wf_ptr->terrain_idx == TERRAIN_EDGE) ||
+ (wf_ptr->terrain_idx == TERRAIN_DEEP_WATER) ||
+ (wf_ptr->terrain_idx == TERRAIN_TREES) ||
+ (wf_ptr->terrain_idx == TERRAIN_SHALLOW_LAVA) ||
+ (wf_ptr->terrain_idx == TERRAIN_DEEP_LAVA) ||
+ (wf_ptr->terrain_idx == TERRAIN_MOUNTAIN))
+ {
+ /* try again */
+ }
+ else
+ {
+ /* either player, nor wall, then stop this 'while' */
+ break;
+ }
+ }
+
+ assert(x >= 0);
+ assert(y >= 0);
+
+ if (tries == 0)
+ {
+ /* Use Bree as last resort */
+ x = 32;
+ y = 19;
+ }
+
+ /* create god dungeon in that place */
+ wild_map[y][x].entrance = 1000 + DUNGEON_GOD;
+
+ /* set quest variables */
+ set_dung_x(x);
+ set_dung_y(y);
+}
diff --git a/src/quest.pkg b/src/quest.pkg
index 487c62af..3b8fc922 100644
--- a/src/quest.pkg
+++ b/src/quest.pkg
@@ -159,3 +159,8 @@ 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);
+
+/*
+ * God quest
+ */
+extern void quest_god_place_rand_dung();