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); |
… | |
… | |
165 | { |
161 | { |
166 | LOG (llevError, "unable to load stylemap /styles/misc fountains\n"); |
162 | LOG (llevError, "unable to load stylemap /styles/misc fountains\n"); |
167 | return; |
163 | return; |
168 | } |
164 | } |
169 | |
165 | |
170 | object *fountain = get_archetype ("fountain"); |
166 | object *fountain = archetype::get ("fountain"); |
171 | object *potion = object::create (); |
167 | object *potion = fountain_style->pick_random_object ()->clone (); |
172 | |
|
|
173 | pick_random_object (fountain_style)->copy_to (potion); |
|
|
174 | |
168 | |
175 | while (i < 0 && tries < 10) |
169 | while (i < 0 && tries < 10) |
176 | { |
170 | { |
177 | ix = rndm (map->width - 2) + 1; |
171 | ix = rndm (map->width - 2) + 1; |
178 | iy = rndm (map->height - 2) + 1; |
172 | iy = rndm (map->height - 2) + 1; |
… | |
… | |
204 | |
198 | |
205 | void |
199 | void |
206 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
200 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
207 | { |
201 | { |
208 | int ix, iy, i = -1; |
202 | int ix, iy, i = -1; |
|
|
203 | char buf[16384]; |
209 | char buf[16384], *style, *decor, *mon; |
204 | const char *style, *decor, *mon; |
210 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
205 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
211 | int g_xsize, g_ysize; |
206 | int g_xsize, g_ysize; |
212 | |
207 | |
213 | if (!exit_style) |
208 | if (!exit_style) |
214 | { |
209 | { |
215 | LOG (llevError, "unabel to load stylemap /styles/misc obscure_exits\n"); |
210 | LOG (llevError, "unable to load stylemap /styles/misc obscure_exits\n"); |
216 | return; |
211 | return; |
217 | } |
212 | } |
218 | |
|
|
219 | object *the_exit = object::create (); |
|
|
220 | |
213 | |
221 | if (!exit_style) |
214 | if (!exit_style) |
222 | return; |
215 | return; |
223 | |
216 | |
224 | pick_random_object (exit_style)->copy_to (the_exit); |
217 | object *the_exit = exit_style->pick_random_object ()->clone (); |
225 | |
218 | |
226 | while (i < 0) |
219 | // put an upper bound here, just in case |
|
|
220 | for (int repeat = 8192; --repeat; ) |
227 | { |
221 | { |
228 | ix = rndm (map->width - 2) + 1; |
222 | ix = rndm (map->width - 2) + 1; |
229 | iy = rndm (map->height - 2) + 1; |
223 | iy = rndm (map->height - 2) + 1; |
|
|
224 | |
230 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
225 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
231 | } |
226 | if (i >= 0) |
232 | |
227 | { |
233 | ix += freearr_x[i]; |
228 | ix += freearr_x[i]; |
234 | iy += freearr_y[i]; |
229 | iy += freearr_y[i]; |
|
|
230 | break; |
|
|
231 | } |
|
|
232 | } |
|
|
233 | |
235 | the_exit->x = ix; |
234 | the_exit->x = ix; |
236 | the_exit->y = iy; |
235 | the_exit->y = iy; |
237 | |
236 | |
238 | if (!hole_type) |
237 | if (!hole_type) |
239 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |
238 | hole_type = rndm (NR_OF_HOLE_TYPES) + 1; |
… | |
… | |
277 | } |
276 | } |
278 | |
277 | |
279 | /* Need to be at least this size, otherwise the load |
278 | /* Need to be at least this size, otherwise the load |
280 | * code will generate new size values which are too large. |
279 | * code will generate new size values which are too large. |
281 | */ |
280 | */ |
282 | if (g_xsize < MIN_RANDOM_MAP_SIZE) |
281 | if (g_xsize < MIN_RANDOM_MAP_SIZE) g_xsize = MIN_RANDOM_MAP_SIZE; |
283 | g_xsize = MIN_RANDOM_MAP_SIZE; |
282 | 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 | |
283 | |
287 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
284 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
288 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
285 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
289 | RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, |
286 | 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); |
287 | RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); |
… | |
… | |
292 | the_exit->msg = buf; |
289 | the_exit->msg = buf; |
293 | |
290 | |
294 | insert_ob_in_map (the_exit, map, NULL, 0); |
291 | insert_ob_in_map (the_exit, map, NULL, 0); |
295 | } |
292 | } |
296 | |
293 | |
297 | |
|
|
298 | void |
294 | void |
299 | place_specials_in_map (maptile *map, char **layout, random_map_params *RP) |
295 | place_specials_in_map (maptile *map, char **layout, random_map_params *RP) |
300 | { |
296 | { |
301 | maptile *special_map; |
297 | maptile *special_map; |
302 | int ix, iy; /* map insertion locatons */ |
298 | int ix, iy; /* map insertion locatons */ |
… | |
… | |
327 | case SPECIAL_EXIT: |
323 | case SPECIAL_EXIT: |
328 | /* Make an exit to another random map, e.g. a gloryhole. */ |
324 | /* Make an exit to another random map, e.g. a gloryhole. */ |
329 | place_special_exit (map, 0, RP); |
325 | place_special_exit (map, 0, RP); |
330 | break; |
326 | break; |
331 | } |
327 | } |
332 | |
|
|
333 | } |
328 | } |
|
|
329 | |