|
|
1 | |
1 | /* |
2 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
3 | CrossFire, A Multiplayer game for X-windows |
3 | |
4 | |
|
|
5 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
7 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
8 | |
7 | This program is free software; you can redistribute it and/or modify |
9 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
10 | it under the terms of the GNU General Public License as published by |
… | |
… | |
194 | insert_ob_in_map (potion, map, NULL, 0); |
196 | insert_ob_in_map (potion, map, NULL, 0); |
195 | |
197 | |
196 | } |
198 | } |
197 | |
199 | |
198 | void |
200 | void |
199 | place_special_exit (maptile *map, int hole_type, random_map_params * RP) |
201 | place_special_exit (maptile *map, int hole_type, random_map_params *RP) |
200 | { |
202 | { |
201 | int ix, iy, i = -1; |
203 | int ix, iy, i = -1; |
202 | char buf[HUGE_BUF], *style, *decor, *mon; |
204 | char buf[HUGE_BUF], *style, *decor, *mon; |
203 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
205 | maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); |
204 | int g_xsize, g_ysize; |
206 | int g_xsize, g_ysize; |
… | |
… | |
225 | if (!hole_type) |
227 | if (!hole_type) |
226 | hole_type = RANDOM () % NR_OF_HOLE_TYPES + 1; |
228 | hole_type = RANDOM () % NR_OF_HOLE_TYPES + 1; |
227 | |
229 | |
228 | switch (hole_type) |
230 | switch (hole_type) |
229 | { |
231 | { |
230 | case GLORY_HOLE: /* treasures */ |
232 | case GLORY_HOLE: /* treasures */ |
231 | { |
233 | { |
232 | g_xsize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
234 | g_xsize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
233 | g_ysize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
235 | g_ysize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
234 | style = "onion"; |
236 | style = "onion"; |
235 | decor = "wealth2"; |
237 | decor = "wealth2"; |
236 | mon = "none"; |
238 | mon = "none"; |
237 | break; |
239 | break; |
238 | } |
240 | } |
239 | |
241 | |
240 | case ORC_ZONE: /* hole with orcs in it. */ |
242 | case ORC_ZONE: /* hole with orcs in it. */ |
241 | { |
243 | { |
242 | g_xsize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
244 | g_xsize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
243 | g_ysize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
245 | g_ysize = RANDOM () % 3 + 4 + RP->difficulty / 4; |
244 | style = "onion"; |
246 | style = "onion"; |
245 | decor = "wealth2"; |
247 | decor = "wealth2"; |
246 | mon = "orc"; |
248 | mon = "orc"; |
247 | break; |
249 | break; |
248 | } |
250 | } |
249 | |
251 | |
250 | case MINING_ZONE: /* hole with orcs in it. */ |
252 | case MINING_ZONE: /* hole with orcs in it. */ |
251 | { |
253 | { |
252 | g_xsize = RANDOM () % 9 + 4 + RP->difficulty / 4; |
254 | g_xsize = RANDOM () % 9 + 4 + RP->difficulty / 4; |
253 | g_ysize = RANDOM () % 9 + 4 + RP->difficulty / 4; |
255 | g_ysize = RANDOM () % 9 + 4 + RP->difficulty / 4; |
254 | style = "maze"; |
256 | style = "maze"; |
255 | decor = "minerals2"; |
257 | decor = "minerals2"; |
256 | mon = "none"; |
258 | mon = "none"; |
257 | break; |
259 | break; |
258 | } |
260 | } |
259 | |
261 | |
260 | default: /* undefined */ |
262 | default: /* undefined */ |
261 | LOG (llevError, "place_special_exit: undefined hole type %d\n", hole_type); |
263 | LOG (llevError, "place_special_exit: undefined hole type %d\n", hole_type); |
262 | return; |
264 | return; |
263 | break; |
265 | break; |
264 | } |
266 | } |
265 | |
267 | |
266 | /* Need to be at least this size, otherwise the load |
268 | /* Need to be at least this size, otherwise the load |
267 | * code will generate new size values which are too large. |
269 | * code will generate new size values which are too large. |
268 | */ |
270 | */ |
… | |
… | |
281 | insert_ob_in_map (the_exit, map, NULL, 0); |
283 | insert_ob_in_map (the_exit, map, NULL, 0); |
282 | } |
284 | } |
283 | |
285 | |
284 | |
286 | |
285 | void |
287 | void |
286 | place_specials_in_map (maptile *map, char **layout, random_map_params * RP) |
288 | place_specials_in_map (maptile *map, char **layout, random_map_params *RP) |
287 | { |
289 | { |
288 | maptile *special_map; |
290 | maptile *special_map; |
289 | int ix, iy; /* map insertion locatons */ |
291 | int ix, iy; /* map insertion locatons */ |
290 | int special_type; /* type of special to make */ |
292 | int special_type; /* type of special to make */ |
291 | |
293 | |
292 | |
294 | |
293 | special_type = RANDOM () % NUM_OF_SPECIAL_TYPES; |
295 | special_type = RANDOM () % NUM_OF_SPECIAL_TYPES; |
294 | switch (special_type) |
296 | switch (special_type) |
295 | { |
297 | { |
296 | |
298 | |
297 | /* includes a special map into the random map being made. */ |
299 | /* includes a special map into the random map being made. */ |
298 | case SPECIAL_SUBMAP: |
300 | case SPECIAL_SUBMAP: |
299 | { |
301 | { |
300 | special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); |
302 | special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); |
301 | if (special_map == NULL) |
303 | if (special_map == NULL) |
302 | return; |
304 | return; |
303 | |
305 | |
304 | if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height)) |
306 | if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height)) |
305 | include_map_in_map (map, special_map, ix, iy); |
307 | include_map_in_map (map, special_map, ix, iy); |
306 | break; |
308 | break; |
307 | } |
309 | } |
308 | |
310 | |
309 | /* Make a special fountain: an unpickable potion disguised as |
311 | /* Make a special fountain: an unpickable potion disguised as |
310 | a fountain, or rather, colocated with a fountain. */ |
312 | a fountain, or rather, colocated with a fountain. */ |
311 | case SPECIAL_FOUNTAIN: |
313 | case SPECIAL_FOUNTAIN: |
312 | { |
314 | { |
313 | place_fountain_with_specials (map); |
315 | place_fountain_with_specials (map); |
314 | break; |
316 | break; |
315 | } |
317 | } |
316 | |
318 | |
317 | /* Make an exit to another random map, e.g. a gloryhole. */ |
319 | /* Make an exit to another random map, e.g. a gloryhole. */ |
318 | case SPECIAL_EXIT: |
320 | case SPECIAL_EXIT: |
319 | { |
321 | { |
320 | place_special_exit (map, 0, RP); |
322 | place_special_exit (map, 0, RP); |
321 | break; |
323 | break; |
322 | } |
324 | } |
323 | } |
325 | } |
324 | |
326 | |
325 | } |
327 | } |