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,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,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 it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
33 | |
33 | |
34 | //#define TREASURE_VERBOSE |
34 | //#define TREASURE_VERBOSE |
35 | |
35 | |
36 | #include <global.h> |
36 | #include <global.h> |
37 | #include <treasure.h> |
37 | #include <treasure.h> |
38 | #include <loader.h> |
|
|
39 | |
38 | |
40 | extern char *spell_mapping[]; |
39 | extern char *spell_mapping[]; |
41 | |
40 | |
42 | static treasurelist *first_treasurelist; |
41 | static treasurelist *first_treasurelist; |
43 | |
42 | |
… | |
… | |
310 | } |
309 | } |
311 | else |
310 | else |
312 | { |
311 | { |
313 | if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) |
312 | if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) |
314 | { |
313 | { |
315 | object *tmp = arch_to_object (t->item); |
314 | object *tmp = t->item->instance (); |
316 | |
315 | |
317 | if (t->nrof && tmp->nrof <= 1) |
316 | if (t->nrof && tmp->nrof <= 1) |
318 | tmp->nrof = rndm (t->nrof) + 1; |
317 | tmp->nrof = rndm (t->nrof) + 1; |
319 | |
318 | |
320 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
319 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
… | |
… | |
367 | else if (t->nrof) |
366 | else if (t->nrof) |
368 | create_one_treasure (tl, op, flag, difficulty, tries); |
367 | create_one_treasure (tl, op, flag, difficulty, tries); |
369 | } |
368 | } |
370 | else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) |
369 | else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) |
371 | { |
370 | { |
372 | if (object *tmp = arch_to_object (t->item)) |
371 | if (object *tmp = t->item->instance ()) |
373 | { |
372 | { |
374 | if (t->nrof && tmp->nrof <= 1) |
373 | if (t->nrof && tmp->nrof <= 1) |
375 | tmp->nrof = rndm (t->nrof) + 1; |
374 | tmp->nrof = rndm (t->nrof) + 1; |
376 | |
375 | |
377 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
376 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
… | |
… | |
1210 | |
1209 | |
1211 | const char *cp = f.get_str (); |
1210 | const char *cp = f.get_str (); |
1212 | char *next; |
1211 | char *next; |
1213 | do |
1212 | do |
1214 | { |
1213 | { |
1215 | if ((next = strchr (cp, ','))) |
1214 | if ((next = (char *)strchr (cp, ','))) |
1216 | *next++ = '\0'; |
1215 | *next++ = '\0'; |
1217 | |
1216 | |
1218 | linked_char *tmp = new linked_char; |
1217 | linked_char *tmp = new linked_char; |
1219 | |
1218 | |
1220 | tmp->name = cp; |
1219 | tmp->name = cp; |
… | |
… | |
1367 | if (op->type == HORN || op->type == POTION) |
1366 | if (op->type == HORN || op->type == POTION) |
1368 | { |
1367 | { |
1369 | /* Remove any spells this object currently has in it */ |
1368 | /* Remove any spells this object currently has in it */ |
1370 | op->destroy_inv (false); |
1369 | op->destroy_inv (false); |
1371 | |
1370 | |
1372 | object *tmp = arch_to_object (change->other_arch); |
1371 | object *tmp = change->other_arch->instance (); |
1373 | insert_ob_in_ob (tmp, op); |
1372 | insert_ob_in_ob (tmp, op); |
1374 | } |
1373 | } |
1375 | /* No harm setting this for potions/horns */ |
1374 | /* No harm setting this for potions/horns */ |
1376 | op->other_arch = change->other_arch; |
1375 | op->other_arch = change->other_arch; |
1377 | } |
1376 | } |