1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | /* Specials in this file: |
24 | /* Specials in this file: |
26 | included maps */ |
25 | included maps */ |
27 | |
26 | |
… | |
… | |
66 | break; |
65 | break; |
67 | } |
66 | } |
68 | } |
67 | } |
69 | } |
68 | } |
70 | |
69 | |
71 | |
|
|
72 | |
|
|
73 | /* copy in_map into dest_map at point x,y */ |
70 | /* copy in_map into dest_map at point x,y */ |
74 | |
|
|
75 | |
|
|
76 | void |
71 | void |
77 | include_map_in_map (maptile *dest_map, maptile *in_map, int x, int y) |
72 | include_map_in_map (maptile *dest_map, maptile *in_map, int x, int y) |
78 | { |
73 | { |
79 | int i, j; |
74 | int i, j; |
80 | object *tmp; |
75 | object *tmp; |
… | |
… | |
145 | for (m = j; m < j + ysize; m++) |
140 | for (m = j; m < j + ysize; m++) |
146 | if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') |
141 | if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') |
147 | is_occupied |= 1; |
142 | is_occupied |= 1; |
148 | } |
143 | } |
149 | } |
144 | } |
|
|
145 | |
150 | if (is_occupied) |
146 | if (is_occupied) |
151 | return 0; |
147 | return 0; |
|
|
148 | |
152 | *ix = i; |
149 | *ix = i; |
153 | *iy = j; |
150 | *iy = j; |
154 | return 1; |
151 | return 1; |
155 | } |
152 | } |
156 | |
153 | |
157 | |
|
|
158 | void |
154 | void |
159 | place_fountain_with_specials (maptile *map) |
155 | place_fountain_with_specials (maptile *map) |
160 | { |
156 | { |
161 | int ix, iy, i = -1, tries = 0; |
157 | int ix, iy, i = -1, tries = 0; |
162 | maptile *fountain_style = find_style ("/styles/misc", "fountains", -1); |
158 | maptile *fountain_style = find_style ("/styles/misc", "fountains", -1); |
… | |
… | |
168 | } |
164 | } |
169 | |
165 | |
170 | object *fountain = get_archetype ("fountain"); |
166 | object *fountain = get_archetype ("fountain"); |
171 | object *potion = object::create (); |
167 | object *potion = object::create (); |
172 | |
168 | |
173 | pick_random_object (fountain_style)->copy_to (potion); |
169 | fountain_style->pick_random_object ()->copy_to (potion); |
174 | |
170 | |
175 | while (i < 0 && tries < 10) |
171 | while (i < 0 && tries < 10) |
176 | { |
172 | { |
177 | ix = rndm (map->width - 2) + 1; |
173 | ix = rndm (map->width - 2) + 1; |
178 | iy = rndm (map->height - 2) + 1; |
174 | iy = rndm (map->height - 2) + 1; |
… | |
… | |
204 | |
200 | |
205 | void |
201 | void |
206 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
202 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
207 | { |
203 | { |
208 | int ix, iy, i = -1; |
204 | int ix, iy, i = -1; |
|
|
205 | char buf[16384]; |
209 | char buf[16384], *style, *decor, *mon; |
206 | const char *style, *decor, *mon; |
210 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
207 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
211 | int g_xsize, g_ysize; |
208 | int g_xsize, g_ysize; |
212 | |
209 | |
213 | if (!exit_style) |
210 | if (!exit_style) |
214 | { |
211 | { |
… | |
… | |
219 | object *the_exit = object::create (); |
216 | object *the_exit = object::create (); |
220 | |
217 | |
221 | if (!exit_style) |
218 | if (!exit_style) |
222 | return; |
219 | return; |
223 | |
220 | |
224 | pick_random_object (exit_style)->copy_to (the_exit); |
221 | exit_style->pick_random_object ()->copy_to (the_exit); |
225 | |
222 | |
226 | while (i < 0) |
223 | // put an upper bound here, just in case |
|
|
224 | for (int repeat = 8192; --repeat; ) |
227 | { |
225 | { |
228 | ix = rndm (map->width - 2) + 1; |
226 | ix = rndm (map->width - 2) + 1; |
229 | iy = rndm (map->height - 2) + 1; |
227 | iy = rndm (map->height - 2) + 1; |
|
|
228 | |
230 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
229 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
231 | } |
230 | if (i >= 0) |
232 | |
231 | { |
233 | ix += freearr_x[i]; |
232 | ix += freearr_x[i]; |
234 | iy += freearr_y[i]; |
233 | iy += freearr_y[i]; |
|
|
234 | break; |
|
|
235 | } |
|
|
236 | } |
|
|
237 | |
235 | the_exit->x = ix; |
238 | the_exit->x = ix; |
236 | the_exit->y = iy; |
239 | the_exit->y = iy; |
237 | |
240 | |
238 | if (!hole_type) |
241 | if (!hole_type) |
239 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |
242 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |
… | |
… | |
277 | } |
280 | } |
278 | |
281 | |
279 | /* Need to be at least this size, otherwise the load |
282 | /* Need to be at least this size, otherwise the load |
280 | * code will generate new size values which are too large. |
283 | * code will generate new size values which are too large. |
281 | */ |
284 | */ |
282 | if (g_xsize < MIN_RANDOM_MAP_SIZE) |
285 | if (g_xsize < MIN_RANDOM_MAP_SIZE) g_xsize = MIN_RANDOM_MAP_SIZE; |
283 | g_xsize = MIN_RANDOM_MAP_SIZE; |
286 | if (g_ysize < MIN_RANDOM_MAP_SIZE) g_ysize = MIN_RANDOM_MAP_SIZE; |
284 | if (g_ysize < MIN_RANDOM_MAP_SIZE) |
|
|
285 | g_ysize = MIN_RANDOM_MAP_SIZE; |
|
|
286 | |
287 | |
287 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
288 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
288 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
289 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
289 | RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, |
290 | RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, |
290 | RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); |
291 | RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); |
… | |
… | |
292 | the_exit->msg = buf; |
293 | the_exit->msg = buf; |
293 | |
294 | |
294 | insert_ob_in_map (the_exit, map, NULL, 0); |
295 | insert_ob_in_map (the_exit, map, NULL, 0); |
295 | } |
296 | } |
296 | |
297 | |
297 | |
|
|
298 | void |
298 | void |
299 | place_specials_in_map (maptile *map, char **layout, random_map_params *RP) |
299 | place_specials_in_map (maptile *map, char **layout, random_map_params *RP) |
300 | { |
300 | { |
301 | maptile *special_map; |
301 | maptile *special_map; |
302 | int ix, iy; /* map insertion locatons */ |
302 | int ix, iy; /* map insertion locatons */ |
… | |
… | |
327 | case SPECIAL_EXIT: |
327 | case SPECIAL_EXIT: |
328 | /* Make an exit to another random map, e.g. a gloryhole. */ |
328 | /* Make an exit to another random map, e.g. a gloryhole. */ |
329 | place_special_exit (map, 0, RP); |
329 | place_special_exit (map, 0, RP); |
330 | break; |
330 | break; |
331 | } |
331 | } |
332 | |
|
|
333 | } |
332 | } |
|
|
333 | |