1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * 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 Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* Specials in this file: |
25 | /* Specials in this file: |
… | |
… | |
76 | continue; |
77 | continue; |
77 | |
78 | |
78 | object *new_ob = tmp->deep_clone (); |
79 | object *new_ob = tmp->deep_clone (); |
79 | |
80 | |
80 | if (QUERY_FLAG (tmp, FLAG_IS_LINKED)) |
81 | if (QUERY_FLAG (tmp, FLAG_IS_LINKED)) |
81 | add_button_link (new_ob, dest_map, tmp->path_attuned); |
82 | new_ob->add_link (dest_map, tmp->find_link ()->id); |
82 | |
83 | |
83 | dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); |
84 | dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); |
84 | } |
85 | } |
85 | } |
86 | } |
86 | |
87 | |
… | |
… | |
98 | for (int tries = 0; tries < 20; tries++) |
99 | for (int tries = 0; tries < 20; tries++) |
99 | { |
100 | { |
100 | blocked = 0; |
101 | blocked = 0; |
101 | |
102 | |
102 | /* pick a random location in the layout */ |
103 | /* pick a random location in the layout */ |
103 | i = rmg_rndm (map->width - xsize - 2) + 1; |
104 | i = rmg_rndm (1, map->width - xsize - 2); |
104 | j = rmg_rndm (map->height - ysize - 2) + 1; |
105 | j = rmg_rndm (1, map->height - ysize - 2); |
105 | |
106 | |
106 | for (int l = i; l < i + xsize; l++) |
107 | for (int l = i; l < i + xsize; l++) |
107 | for (int m = j; m < j + ysize; m++) |
108 | for (int m = j; m < j + ysize; m++) |
108 | { |
109 | { |
109 | blocked = 1; |
110 | blocked = 1; |
… | |
… | |
118 | if (blocked) |
119 | if (blocked) |
119 | { /* failure, try a relaxed placer. */ |
120 | { /* failure, try a relaxed placer. */ |
120 | /* pick a random location in the layout */ |
121 | /* pick a random location in the layout */ |
121 | for (int tries = 0; tries < 10; tries++) |
122 | for (int tries = 0; tries < 10; tries++) |
122 | { |
123 | { |
123 | i = rmg_rndm (map->width - xsize - 2) + 1; |
124 | i = rmg_rndm (1, map->width - xsize - 2); |
124 | j = rmg_rndm (map->height - ysize - 2) + 1; |
125 | j = rmg_rndm (1, map->height - ysize - 2); |
125 | |
126 | |
126 | blocked = 0; |
127 | blocked = 0; |
127 | |
128 | |
128 | for (int l = i; l < i + xsize; l++) |
129 | for (int l = i; l < i + xsize; l++) |
129 | for (int m = j; m < j + ysize; m++) |
130 | for (int m = j; m < j + ysize; m++) |
… | |
… | |
177 | ix += freearr_x[i]; |
178 | ix += freearr_x[i]; |
178 | iy += freearr_y[i]; |
179 | iy += freearr_y[i]; |
179 | potion->face = fountain->face; |
180 | potion->face = fountain->face; |
180 | SET_FLAG (potion, FLAG_NO_PICK); |
181 | SET_FLAG (potion, FLAG_NO_PICK); |
181 | SET_FLAG (potion, FLAG_IDENTIFIED); |
182 | SET_FLAG (potion, FLAG_IDENTIFIED); |
182 | potion->name = potion->name_pl = "fountain"; |
183 | potion->name = potion->name_pl = shstr_fountain; |
183 | potion->x = ix; |
184 | potion->x = ix; |
184 | potion->y = iy; |
185 | potion->y = iy; |
185 | potion->materialname = "adamantium"; |
186 | potion->material = name_to_material (shstr_adamantium); |
186 | fountain->x = ix; |
187 | fountain->x = ix; |
187 | fountain->y = iy; |
188 | fountain->y = iy; |
188 | insert_ob_in_map (fountain, map, NULL, 0); |
189 | insert_ob_in_map (fountain, map, NULL, 0); |
189 | insert_ob_in_map (potion, map, NULL, 0); |
190 | insert_ob_in_map (potion, map, NULL, 0); |
190 | } |
191 | } |
… | |
… | |
210 | object *the_exit = exit_style->pick_random_object (rmg_rndm)->clone (); |
211 | object *the_exit = exit_style->pick_random_object (rmg_rndm)->clone (); |
211 | |
212 | |
212 | // put an upper bound here, just in case |
213 | // put an upper bound here, just in case |
213 | for (int repeat = 8192; --repeat; ) |
214 | for (int repeat = 8192; --repeat; ) |
214 | { |
215 | { |
215 | ix = rmg_rndm (map->width - 2) + 1; |
216 | ix = rmg_rndm (1, map->width - 2); |
216 | iy = rmg_rndm (map->height - 2) + 1; |
217 | iy = rmg_rndm (1, map->height - 2); |
217 | |
218 | |
218 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
219 | i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); |
219 | if (i >= 0) |
220 | if (i >= 0) |
220 | { |
221 | { |
221 | ix += freearr_x[i]; |
222 | ix += freearr_x[i]; |
… | |
… | |
276 | |
277 | |
277 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
278 | write_parameters_to_string (buf, g_xsize, g_ysize, RP->wallstyle, RP->floorstyle, mon, |
278 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
279 | "none", style, decor, "none", RP->exitstyle, 0, 0, 0, |
279 | RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, |
280 | RMOPT_WALLS_ONLY, 0, 0, 1, RP->dungeon_level, RP->dungeon_level, |
280 | RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); |
281 | RP->difficulty, RP->difficulty, -1, 1, 0, 0, 0, 0, RP->difficulty_increase); |
281 | the_exit->slaying = "/!"; |
282 | the_exit->slaying = shstr_random_map_exit; |
282 | the_exit->msg = buf; |
283 | the_exit->msg = buf; |
283 | |
284 | |
284 | insert_ob_in_map (the_exit, map, NULL, 0); |
285 | insert_ob_in_map (the_exit, map, NULL, 0); |
285 | } |
286 | } |
286 | |
287 | |