diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plots.h | 3 | ||||
-rw-r--r-- | src/q_god.c | 97 | ||||
-rw-r--r-- | src/quest.pkg | 5 |
4 files changed, 106 insertions, 0 deletions
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(); |