blob: 070b2a02259b683b5db4a640809610a1fd8c7749 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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);
}
|