56 if (mode < 1 || mode > 4) {
67 for (i = 1; i < RP->
Xsize; i++)
68 for (j = 1; j < RP->
Ysize; j++) {
69 if (layout[i][j] == target) {
79 for (i = RP->
Xsize-2; i > 0; i--)
80 for (j = 1; j < RP->
Ysize-1; j++) {
81 if (layout[i][j] == target) {
91 for (i = 1; i < RP->
Xsize-1; i++)
92 for (j = RP->
Ysize-2; j > 0; j--) {
93 if (layout[i][j] == target) {
103 for (i = RP->
Xsize-2; i > 0; i--)
104 for (j = RP->
Ysize-2; j > 0; j--) {
105 if (layout[i][j] == target) {
146 char styledirname[256];
149 object *the_exit_down;
153 int cx = -1, cy = -1;
154 int upx = -1, upy = -1;
155 int downx = -1, downy = -1;
156 int final_map_exit = 1;
163 if (orientation == 0) {
164 orientation =
RANDOM()%6+1;
167 switch (orientation) {
169 snprintf(styledirname,
sizeof(styledirname),
"/styles/exitstyles/up");
170 style_map_up =
find_style(styledirname, exitstyle, -1);
171 snprintf(styledirname,
sizeof(styledirname),
"/styles/exitstyles/down");
172 style_map_down =
find_style(styledirname, exitstyle, -1);
177 snprintf(styledirname,
sizeof(styledirname),
"/styles/exitstyles/down");
178 style_map_up =
find_style(styledirname, exitstyle, -1);
179 snprintf(styledirname,
sizeof(styledirname),
"/styles/exitstyles/up");
180 style_map_down =
find_style(styledirname, exitstyle, -1);
185 snprintf(styledirname,
sizeof(styledirname),
"/styles/exitstyles/generic");
186 style_map_up =
find_style(styledirname, exitstyle, -1);
187 style_map_down = style_map_up;
192 if (style_map_up == NULL) {
194 if (exit_arch == NULL) {
213 }
else if (style_map_down == NULL) {
226 the_exit_down = NULL;
242 if (upx == -1 && cx != -1) {
243 if (cx > RP->
Xsize/2) {
248 if (cy > RP->
Ysize/2) {
255 if (upx == 1 && upy == 1) {
257 }
else if (upx == 1 && upy > 1) {
259 }
else if (upx > 1 && upy == 1) {
261 }
else if (upx > 1 && upy > 1) {
272 for (j = 1; j < 9; j++) {
276 snprintf(buf,
sizeof(buf),
"This is a random map.\nLevel: %d\n", (RP->
dungeon_level)-1);
285 maze[upx][upy] =
'<';
302 if (upx > RP->
Xsize/2) {
307 if (upy > RP->
Ysize/2) {
314 if (downx == 1 && downy == 1) {
316 }
else if (downx == 1 && downy > 1) {
318 }
else if (downx > 1 && downy == 1) {
320 }
else if (downx > 1 && downy > 1) {
366 if (final_map_exit == 1) {
369 the_exit_back->
stats.
hp = downx+freearr_x[i];
370 the_exit_back->
stats.
sp = downy+freearr_y[i];
386 maze[the_exit_down->
x][the_exit_down->
y] =
'>';
405 for (i = 0; i < RP->
Xsize; i++)
406 for (j = 0; j < RP->
Ysize; j++)
407 if (maze[i][j] ==
'>' || maze[i][j] ==
'<') {
void set_map_timeout(mapstruct *oldmap)
Enable swapping for the given map.
char final_exit_archetype[RM_SIZE]
If not empty, the archetype name of the exit leading to the final map.
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
struct archetype * arch
Pointer to archetype.
archetype * find_archetype(const char *name)
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
char final_map[RM_SIZE]
If not empty, the path of the final map this whole maze leads to.
void unblock_exits(mapstruct *map, char **maze, RMParms *RP)
This function unblocks the exits.
#define MAP_ENTER_X(m)
Default X coordinate for map enter.
sstring slaying
Which race to do double damage to.
sstring add_string(const char *str)
Share a string.
char exit_on_final_map[RM_SIZE]
If this is "no", then no exit will be made to the final map from the previous random map...
Random map related variables.
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
object_find_first_free_spot(archetype, mapstruct, x, y) works like object_find_free_spot(), but it will search max number of squares.
int16_t y
Position in the map for this object.
MoveType move_block
What movement types this blocks.
Global type definitions and header inclusions.
object * pick_random_object(mapstruct *style)
Picks a random object from a style map.
archetype * try_find_archetype(const char *name)
#define MOVE_ALL
Mask of all movement types.
sstring reset_group
For reset purpose, all maps in the same group reset at the same time.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
void place_exits(mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms *RP)
Place exits in the map.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
char path[HUGE_BUF]
Filename of the map.
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
#define MAP_ENTER_Y(m)
Default Y coordinate for map enter.
StringBuffer * write_map_parameters_to_string(const RMParms *RP)
Creates a suitable message for exit from RP.
living stats
Str, Con, Dex, etc.
void find_in_layout(int mode, char target, int *fx, int *fy, char **layout, RMParms *RP)
Find a character in the layout.
int wall_blocked(mapstruct *m, int x, int y)
Returns true if square x,y has P_NO_PASS set, which is true for walls and doors but not monsters...
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
char origin_map[RM_SIZE]
Path to the map this random map is generated from, to make an exit back.
#define UP_OBJ_CHANGE
Object changed.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
mapstruct * find_style(const char *dirname, const char *stylename, int difficulty)
Loads and returns the map requested.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
void object_update(object *op, int action)
object_update() updates the array which represents the map.
#define MOVE_BLOCK_DEFAULT
The normal assumption is that objects are walking/flying.
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.