1 | |
|
|
2 | /* |
|
|
3 | * static char *rcs_treasure_c = |
|
|
4 | * "$Id: treasure.C,v 1.17 2006/09/12 18:15:34 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #define ALLOWED_COMBINATION |
24 | #define ALLOWED_COMBINATION |
31 | |
25 | |
32 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
26 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
… | |
… | |
58 | { |
52 | { |
59 | int prev_warn = warn_archetypes; |
53 | int prev_warn = warn_archetypes; |
60 | |
54 | |
61 | warn_archetypes = 1; |
55 | warn_archetypes = 1; |
62 | if (ring_arch == NULL) |
56 | if (ring_arch == NULL) |
63 | ring_arch = find_archetype ("ring"); |
57 | ring_arch = archetype::find ("ring"); |
64 | if (amulet_arch == NULL) |
58 | if (amulet_arch == NULL) |
65 | amulet_arch = find_archetype ("amulet"); |
59 | amulet_arch = archetype::find ("amulet"); |
66 | if (staff_arch == NULL) |
60 | if (staff_arch == NULL) |
67 | staff_arch = find_archetype ("staff"); |
61 | staff_arch = archetype::find ("staff"); |
68 | if (crown_arch == NULL) |
62 | if (crown_arch == NULL) |
69 | crown_arch = find_archetype ("crown"); |
63 | crown_arch = archetype::find ("crown"); |
70 | warn_archetypes = prev_warn; |
64 | warn_archetypes = prev_warn; |
71 | } |
65 | } |
72 | |
66 | |
73 | /* |
67 | /* |
74 | * Allocate and return the pointer to an empty treasurelist structure. |
68 | * Allocate and return the pointer to an empty treasurelist structure. |
… | |
… | |
119 | while (isspace (*cp)) /* Skip blanks */ |
113 | while (isspace (*cp)) /* Skip blanks */ |
120 | cp++; |
114 | cp++; |
121 | |
115 | |
122 | if (sscanf (cp, "arch %s", variable)) |
116 | if (sscanf (cp, "arch %s", variable)) |
123 | { |
117 | { |
124 | if ((t->item = find_archetype (variable)) == NULL) |
118 | if ((t->item = archetype::find (variable)) == NULL) |
125 | LOG (llevError, "Treasure lacks archetype: %s\n", variable); |
119 | LOG (llevError, "Treasure lacks archetype: %s\n", variable); |
126 | } |
120 | } |
127 | else if (sscanf (cp, "list %s", variable)) |
121 | else if (sscanf (cp, "list %s", variable)) |
128 | t->name = variable; |
122 | t->name = variable; |
129 | else if (sscanf (cp, "change_name %s", variable)) |
123 | else if (sscanf (cp, "change_name %s", variable)) |
… | |
… | |
162 | * so that the treasure name can be printed out |
156 | * so that the treasure name can be printed out |
163 | */ |
157 | */ |
164 | static void |
158 | static void |
165 | check_treasurelist (const treasure *t, const treasurelist * tl) |
159 | check_treasurelist (const treasure *t, const treasurelist * tl) |
166 | { |
160 | { |
167 | if (t->item == NULL && t->name == NULL) |
|
|
168 | LOG (llevError, "Treasurelist %s has element with no name or archetype\n", &tl->name); |
|
|
169 | if (t->chance >= 100 && t->next_yes && (t->next || t->next_no)) |
161 | if (t->chance >= 100 && t->next_yes && (t->next || t->next_no)) |
170 | LOG (llevError, "Treasurelist %s has element that has 100%% generation, next_yes field as well as next or next_no\n", &tl->name); |
162 | LOG (llevError, "Treasurelist %s has element that has 100%% generation, next_yes field as well as next or next_no\n", &tl->name); |
171 | /* find_treasurelist will print out its own error message */ |
163 | /* find_treasurelist will print out its own error message */ |
172 | if (t->name && *t->name) |
164 | if (t->name && *t->name) |
173 | (void) find_treasurelist (t->name); |
165 | find_treasurelist (t->name); |
174 | if (t->next) |
166 | if (t->next) |
175 | check_treasurelist (t->next, tl); |
167 | check_treasurelist (t->next, tl); |
176 | if (t->next_yes) |
168 | if (t->next_yes) |
177 | check_treasurelist (t->next_yes, tl); |
169 | check_treasurelist (t->next_yes, tl); |
178 | if (t->next_no) |
170 | if (t->next_no) |
… | |
… | |
264 | shstr_cmp name_ (name); |
256 | shstr_cmp name_ (name); |
265 | |
257 | |
266 | if (!name_) |
258 | if (!name_) |
267 | return 0; |
259 | return 0; |
268 | |
260 | |
269 | for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) |
261 | for (treasurelist *tl = first_treasurelist; tl != 0; tl = tl->next) |
270 | if (name_ == tl->name) |
262 | if (name_ == tl->name) |
271 | return tl; |
263 | return tl; |
272 | |
264 | |
273 | if (first_treasurelist) |
265 | if (first_treasurelist) |
274 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
266 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
… | |
… | |
286 | * being generated. |
278 | * being generated. |
287 | * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only |
279 | * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only |
288 | * abilities. This is used by summon spells, thus no summoned monsters |
280 | * abilities. This is used by summon spells, thus no summoned monsters |
289 | * start with equipment, but only their abilities). |
281 | * start with equipment, but only their abilities). |
290 | */ |
282 | */ |
291 | |
|
|
292 | |
|
|
293 | static void |
283 | static void |
294 | put_treasure (object *op, object *creator, int flags) |
284 | put_treasure (object *op, object *creator, int flags) |
295 | { |
285 | { |
296 | object *tmp; |
286 | object *tmp; |
297 | |
287 | |
… | |
… | |
300 | * this is the original object, or if this is an object that should be created |
290 | * this is the original object, or if this is an object that should be created |
301 | * by another object. |
291 | * by another object. |
302 | */ |
292 | */ |
303 | if (flags & GT_ENVIRONMENT && op->type != SPELL) |
293 | if (flags & GT_ENVIRONMENT && op->type != SPELL) |
304 | { |
294 | { |
305 | op->x = creator->x; |
|
|
306 | op->y = creator->y; |
|
|
307 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
295 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
308 | insert_ob_in_map (op, creator->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
296 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
309 | } |
297 | } |
310 | else |
298 | else |
311 | { |
299 | { |
312 | op = insert_ob_in_ob (op, creator); |
300 | op = creator->insert (op); |
|
|
301 | |
313 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
302 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
314 | monster_check_apply (creator, op); |
303 | monster_check_apply (creator, op); |
|
|
304 | |
315 | if ((flags & GT_UPDATE_INV) && (tmp = is_player_inv (creator)) != NULL) |
305 | if ((flags & GT_UPDATE_INV) && (tmp = creator->in_player ())) |
316 | esrv_send_item (tmp, op); |
306 | esrv_send_item (tmp, op); |
317 | } |
307 | } |
318 | } |
308 | } |
319 | |
309 | |
320 | /* if there are change_xxx commands in the treasure, we include the changes |
310 | /* if there are change_xxx commands in the treasure, we include the changes |
… | |
… | |
344 | |
334 | |
345 | if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) |
335 | if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) |
346 | { |
336 | { |
347 | if (t->name) |
337 | if (t->name) |
348 | { |
338 | { |
349 | if (strcmp (t->name, "NONE") && difficulty >= t->magic) |
339 | if (difficulty >= t->magic) |
|
|
340 | { |
|
|
341 | treasurelist *tl = find_treasurelist (t->name); |
|
|
342 | if (tl) |
350 | create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); |
343 | create_treasure (tl, op, flag, difficulty, tries); |
|
|
344 | } |
351 | } |
345 | } |
352 | else |
346 | else |
353 | { |
347 | { |
354 | if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)) |
348 | if (t->item && (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE))) |
355 | { |
349 | { |
356 | tmp = arch_to_object (t->item); |
350 | tmp = arch_to_object (t->item); |
357 | if (t->nrof && tmp->nrof <= 1) |
351 | if (t->nrof && tmp->nrof <= 1) |
358 | tmp->nrof = RANDOM () % ((int) t->nrof) + 1; |
352 | tmp->nrof = RANDOM () % ((int) t->nrof) + 1; |
359 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
353 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
… | |
… | |
399 | return; |
393 | return; |
400 | } |
394 | } |
401 | |
395 | |
402 | if (t->name) |
396 | if (t->name) |
403 | { |
397 | { |
404 | if (!strcmp (t->name, "NONE")) |
|
|
405 | return; |
|
|
406 | |
|
|
407 | if (difficulty >= t->magic) |
398 | if (difficulty >= t->magic) |
|
|
399 | { |
|
|
400 | treasurelist *tl = find_treasurelist (t->name); |
|
|
401 | if (tl) |
408 | create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); |
402 | create_treasure (tl, op, flag, difficulty, tries); |
|
|
403 | } |
409 | else if (t->nrof) |
404 | else if (t->nrof) |
410 | create_one_treasure (tl, op, flag, difficulty, tries); |
405 | create_one_treasure (tl, op, flag, difficulty, tries); |
411 | |
406 | |
412 | return; |
407 | return; |
413 | } |
408 | } |
414 | |
409 | |
415 | if ((t->item && t->item->clone.invisible != 0) || flag != GT_INVISIBLE) |
410 | if (t->item && (t->item->clone.invisible != 0 || flag != GT_INVISIBLE)) |
416 | { |
411 | { |
417 | object *tmp = arch_to_object (t->item); |
412 | object *tmp = arch_to_object (t->item); |
418 | |
413 | |
419 | if (!tmp) |
414 | if (!tmp) |
420 | return; |
415 | return; |
… | |
… | |
434 | * list transitions, or so that excessively good treasure will not be |
429 | * list transitions, or so that excessively good treasure will not be |
435 | * created on weak maps, because it will exceed the number of allowed tries |
430 | * created on weak maps, because it will exceed the number of allowed tries |
436 | * to do that. |
431 | * to do that. |
437 | */ |
432 | */ |
438 | void |
433 | void |
439 | create_treasure (treasurelist * t, object *op, int flag, int difficulty, int tries) |
434 | create_treasure (treasurelist *tl, object *op, int flag, int difficulty, int tries) |
440 | { |
435 | { |
441 | |
436 | |
442 | if (tries++ > 100) |
437 | if (tries++ > 100) |
443 | { |
438 | { |
444 | LOG (llevDebug, "createtreasure: tries exceeded 100, returning without making treasure\n"); |
439 | LOG (llevDebug, "createtreasure: tries exceeded 100, returning without making treasure\n"); |
445 | return; |
440 | return; |
446 | } |
441 | } |
447 | if (t->total_chance) |
442 | if (tl->total_chance) |
448 | create_one_treasure (t, op, flag, difficulty, tries); |
443 | create_one_treasure (tl, op, flag, difficulty, tries); |
449 | else |
444 | else |
450 | create_all_treasures (t->items, op, flag, difficulty, tries); |
445 | create_all_treasures (tl->items, op, flag, difficulty, tries); |
451 | } |
446 | } |
452 | |
447 | |
453 | /* This is similar to the old generate treasure function. However, |
448 | /* This is similar to the old generate treasure function. However, |
454 | * it instead takes a treasurelist. It is really just a wrapper around |
449 | * it instead takes a treasurelist. It is really just a wrapper around |
455 | * create_treasure. We create a dummy object that the treasure gets |
450 | * create_treasure. We create a dummy object that the treasure gets |
456 | * inserted into, and then return that treausre |
451 | * inserted into, and then return that treausre |
457 | */ |
452 | */ |
458 | object * |
453 | object * |
459 | generate_treasure (treasurelist * t, int difficulty) |
454 | generate_treasure (treasurelist *tl, int difficulty) |
460 | { |
455 | { |
|
|
456 | difficulty = clamp (difficulty, 1, settings.max_level); |
|
|
457 | |
461 | object *ob = get_object (), *tmp; |
458 | object *ob = object::create (), *tmp; |
462 | |
459 | |
463 | create_treasure (t, ob, 0, difficulty, 0); |
460 | create_treasure (tl, ob, 0, difficulty, 0); |
464 | |
461 | |
465 | /* Don't want to free the object we are about to return */ |
462 | /* Don't want to free the object we are about to return */ |
466 | tmp = ob->inv; |
463 | tmp = ob->inv; |
467 | if (tmp != NULL) |
464 | if (tmp != NULL) |
468 | remove_ob (tmp); |
465 | tmp->remove (); |
|
|
466 | |
469 | if (ob->inv) |
467 | if (ob->inv) |
470 | { |
|
|
471 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
468 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
472 | } |
469 | |
473 | free_object (ob); |
470 | ob->destroy (); |
474 | return tmp; |
471 | return tmp; |
475 | } |
472 | } |
476 | |
473 | |
477 | /* |
474 | /* |
478 | * This is a new way of calculating the chance for an item to have |
475 | * This is a new way of calculating the chance for an item to have |
… | |
… | |
855 | } |
852 | } |
856 | |
853 | |
857 | if (difficulty < 1) |
854 | if (difficulty < 1) |
858 | difficulty = 1; |
855 | difficulty = 1; |
859 | |
856 | |
|
|
857 | if (INVOKE_OBJECT (ADD_BONUS, op, |
|
|
858 | ARG_OBJECT (creator != op ? creator : 0), |
|
|
859 | ARG_INT (difficulty), ARG_INT (max_magic), |
|
|
860 | ARG_INT (flags))) |
|
|
861 | return; |
|
|
862 | |
860 | if (!(flags & GT_MINIMAL)) |
863 | if (!(flags & GT_MINIMAL)) |
861 | { |
864 | { |
862 | if (op->arch == crown_arch) |
865 | if (op->arch == crown_arch) |
863 | { |
866 | { |
864 | set_magic (difficulty, op, max_magic, flags); |
867 | set_magic (difficulty, op, max_magic, flags); |
… | |
… | |
999 | op->value *= 5; /* Since it's not just decoration */ |
1002 | op->value *= 5; /* Since it's not just decoration */ |
1000 | |
1003 | |
1001 | case RING: |
1004 | case RING: |
1002 | if (op->arch == NULL) |
1005 | if (op->arch == NULL) |
1003 | { |
1006 | { |
1004 | remove_ob (op); |
1007 | op->destroy (); |
1005 | free_object (op); |
|
|
1006 | op = NULL; |
1008 | op = 0; |
1007 | break; |
1009 | break; |
1008 | } |
1010 | } |
1009 | |
1011 | |
1010 | if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ |
1012 | if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ |
1011 | break; |
1013 | break; |
… | |
… | |
1169 | */ |
1171 | */ |
1170 | |
1172 | |
1171 | static artifactlist * |
1173 | static artifactlist * |
1172 | get_empty_artifactlist (void) |
1174 | get_empty_artifactlist (void) |
1173 | { |
1175 | { |
1174 | artifactlist *tl = (artifactlist *) malloc (sizeof (artifactlist)); |
1176 | artifactlist *al = (artifactlist *) malloc (sizeof (artifactlist)); |
1175 | |
1177 | |
1176 | if (tl == NULL) |
1178 | if (al == NULL) |
1177 | fatal (OUT_OF_MEMORY); |
1179 | fatal (OUT_OF_MEMORY); |
1178 | tl->next = NULL; |
1180 | al->next = NULL; |
1179 | tl->items = NULL; |
1181 | al->items = NULL; |
1180 | tl->total_chance = 0; |
1182 | al->total_chance = 0; |
1181 | return tl; |
1183 | return al; |
1182 | } |
1184 | } |
1183 | |
1185 | |
1184 | /* |
1186 | /* |
1185 | * Allocate and return the pointer to an empty artifact structure. |
1187 | * Allocate and return the pointer to an empty artifact structure. |
1186 | */ |
1188 | */ |
1187 | |
1189 | |
1188 | static artifact * |
1190 | static artifact * |
1189 | get_empty_artifact (void) |
1191 | get_empty_artifact (void) |
1190 | { |
1192 | { |
1191 | artifact *t = (artifact *) malloc (sizeof (artifact)); |
1193 | artifact *a = (artifact *) malloc (sizeof (artifact)); |
1192 | |
1194 | |
1193 | if (t == NULL) |
1195 | if (a == NULL) |
1194 | fatal (OUT_OF_MEMORY); |
1196 | fatal (OUT_OF_MEMORY); |
1195 | t->item = NULL; |
1197 | a->item = NULL; |
1196 | t->next = NULL; |
1198 | a->next = NULL; |
1197 | t->chance = 0; |
1199 | a->chance = 0; |
1198 | t->difficulty = 0; |
1200 | a->difficulty = 0; |
1199 | t->allowed = NULL; |
1201 | a->allowed = NULL; |
1200 | return t; |
1202 | return a; |
1201 | } |
1203 | } |
1202 | |
1204 | |
1203 | /* |
1205 | /* |
1204 | * Searches the artifact lists and returns one that has the same type |
1206 | * Searches the artifact lists and returns one that has the same type |
1205 | * of objects on it. |
1207 | * of objects on it. |
… | |
… | |
1255 | treasurelist *tl; |
1257 | treasurelist *tl; |
1256 | int i; |
1258 | int i; |
1257 | |
1259 | |
1258 | if (depth > 100) |
1260 | if (depth > 100) |
1259 | return; |
1261 | return; |
1260 | while (t != NULL) |
1262 | while (t) |
1261 | { |
1263 | { |
1262 | if (t->name != NULL) |
1264 | if (t->name) |
1263 | { |
1265 | { |
1264 | for (i = 0; i < depth; i++) |
1266 | for (i = 0; i < depth; i++) |
1265 | fprintf (logfile, " "); |
1267 | fprintf (logfile, " "); |
1266 | fprintf (logfile, "{ (list: %s)\n", &t->name); |
1268 | fprintf (logfile, "{ (list: %s)\n", &t->name); |
1267 | tl = find_treasurelist (t->name); |
1269 | tl = find_treasurelist (t->name); |
|
|
1270 | if (tl) |
1268 | dump_monster_treasure_rec (name, tl->items, depth + 2); |
1271 | dump_monster_treasure_rec (name, tl->items, depth + 2); |
1269 | for (i = 0; i < depth; i++) |
1272 | for (i = 0; i < depth; i++) |
1270 | fprintf (logfile, " "); |
1273 | fprintf (logfile, " "); |
1271 | fprintf (logfile, "} (end of list: %s)\n", &t->name); |
1274 | fprintf (logfile, "} (end of list: %s)\n", &t->name); |
1272 | } |
1275 | } |
1273 | else |
1276 | else |
1274 | { |
1277 | { |
1275 | for (i = 0; i < depth; i++) |
1278 | for (i = 0; i < depth; i++) |
1276 | fprintf (logfile, " "); |
1279 | fprintf (logfile, " "); |
1277 | if (t->item->clone.type == FLESH) |
1280 | if (t->item && t->item->clone.type == FLESH) |
1278 | fprintf (logfile, "%s's %s\n", name, &t->item->clone.name); |
1281 | fprintf (logfile, "%s's %s\n", name, &t->item->clone.name); |
1279 | else |
1282 | else |
1280 | fprintf (logfile, "%s\n", &t->item->clone.name); |
1283 | fprintf (logfile, "%s\n", &t->item->clone.name); |
1281 | } |
1284 | } |
|
|
1285 | |
1282 | if (t->next_yes != NULL) |
1286 | if (t->next_yes) |
1283 | { |
1287 | { |
1284 | for (i = 0; i < depth; i++) |
1288 | for (i = 0; i < depth; i++) |
1285 | fprintf (logfile, " "); |
1289 | fprintf (logfile, " "); |
1286 | fprintf (logfile, " (if yes)\n"); |
1290 | fprintf (logfile, " (if yes)\n"); |
1287 | dump_monster_treasure_rec (name, t->next_yes, depth + 1); |
1291 | dump_monster_treasure_rec (name, t->next_yes, depth + 1); |
1288 | } |
1292 | } |
|
|
1293 | |
1289 | if (t->next_no != NULL) |
1294 | if (t->next_no) |
1290 | { |
1295 | { |
1291 | for (i = 0; i < depth; i++) |
1296 | for (i = 0; i < depth; i++) |
1292 | fprintf (logfile, " "); |
1297 | fprintf (logfile, " "); |
1293 | fprintf (logfile, " (if no)\n"); |
1298 | fprintf (logfile, " (if no)\n"); |
1294 | dump_monster_treasure_rec (name, t->next_no, depth + 1); |
1299 | dump_monster_treasure_rec (name, t->next_no, depth + 1); |
1295 | } |
1300 | } |
|
|
1301 | |
1296 | t = t->next; |
1302 | t = t->next; |
1297 | } |
1303 | } |
1298 | } |
1304 | } |
1299 | |
1305 | |
1300 | /* |
1306 | /* |
… | |
… | |
1390 | art->chance = (uint16) value; |
1396 | art->chance = (uint16) value; |
1391 | else if (sscanf (cp, "difficulty %d", &value)) |
1397 | else if (sscanf (cp, "difficulty %d", &value)) |
1392 | art->difficulty = (uint8) value; |
1398 | art->difficulty = (uint8) value; |
1393 | else if (!strncmp (cp, "Object", 6)) |
1399 | else if (!strncmp (cp, "Object", 6)) |
1394 | { |
1400 | { |
1395 | art->item = get_object (); |
1401 | art->item = object::create (); |
1396 | |
1402 | |
1397 | if (!load_object (thawer, art->item, 0)) |
1403 | if (!load_object (thawer, art->item, 0)) |
1398 | LOG (llevError, "Init_Artifacts: Could not load object.\n"); |
1404 | LOG (llevError, "Init_Artifacts: Could not load object.\n"); |
1399 | |
1405 | |
1400 | art->item->name = strchr (cp, ' ') + 1; |
1406 | art->item->name = strchr (cp, ' ') + 1; |
… | |
… | |
1489 | CLEAR_FLAG (op, FLAG_ANIMATE); |
1495 | CLEAR_FLAG (op, FLAG_ANIMATE); |
1490 | /* so artifacts will join */ |
1496 | /* so artifacts will join */ |
1491 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1497 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1492 | op->speed = 0.0; |
1498 | op->speed = 0.0; |
1493 | |
1499 | |
1494 | update_ob_speed (op); |
1500 | op->set_speed (op->speed); |
1495 | } |
1501 | } |
1496 | |
1502 | |
1497 | if (change->nrof) |
1503 | if (change->nrof) |
1498 | op->nrof = RANDOM () % ((int) change->nrof) + 1; |
1504 | op->nrof = RANDOM () % ((int) change->nrof) + 1; |
1499 | |
1505 | |
… | |
… | |
1511 | { |
1517 | { |
1512 | object *tmp_obj; |
1518 | object *tmp_obj; |
1513 | |
1519 | |
1514 | /* Remove any spells this object currently has in it */ |
1520 | /* Remove any spells this object currently has in it */ |
1515 | while (op->inv) |
1521 | while (op->inv) |
1516 | { |
1522 | op->inv->destroy (); |
1517 | tmp_obj = op->inv; |
|
|
1518 | remove_ob (tmp_obj); |
|
|
1519 | free_object (tmp_obj); |
|
|
1520 | } |
|
|
1521 | |
1523 | |
1522 | tmp_obj = arch_to_object (change->other_arch); |
1524 | tmp_obj = arch_to_object (change->other_arch); |
1523 | insert_ob_in_ob (tmp_obj, op); |
1525 | insert_ob_in_ob (tmp_obj, op); |
1524 | } |
1526 | } |
1525 | /* No harm setting this for potions/horns */ |
1527 | /* No harm setting this for potions/horns */ |
… | |
… | |
1562 | op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; |
1564 | op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; |
1563 | |
1565 | |
1564 | op->item_power = change->item_power; |
1566 | op->item_power = change->item_power; |
1565 | |
1567 | |
1566 | for (i = 0; i < NROFATTACKS; i++) |
1568 | for (i = 0; i < NROFATTACKS; i++) |
1567 | { |
|
|
1568 | if (change->resist[i]) |
1569 | if (change->resist[i]) |
1569 | { |
|
|
1570 | op->resist[i] += change->resist[i]; |
1570 | op->resist[i] += change->resist[i]; |
1571 | } |
|
|
1572 | } |
|
|
1573 | |
1571 | |
1574 | if (change->stats.dam) |
1572 | if (change->stats.dam) |
1575 | { |
1573 | { |
1576 | if (change->stats.dam < 0) |
1574 | if (change->stats.dam < 0) |
1577 | op->stats.dam = (-change->stats.dam); |
1575 | op->stats.dam = (-change->stats.dam); |
… | |
… | |
1808 | /* special_potion() - so that old potion code is still done right. */ |
1806 | /* special_potion() - so that old potion code is still done right. */ |
1809 | |
1807 | |
1810 | int |
1808 | int |
1811 | special_potion (object *op) |
1809 | special_potion (object *op) |
1812 | { |
1810 | { |
1813 | |
|
|
1814 | int i; |
|
|
1815 | |
|
|
1816 | if (op->attacktype) |
1811 | if (op->attacktype) |
1817 | return 1; |
1812 | return 1; |
1818 | |
1813 | |
1819 | if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha) |
1814 | if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha) |
1820 | return 1; |
1815 | return 1; |
1821 | |
1816 | |
1822 | for (i = 0; i < NROFATTACKS; i++) |
1817 | for (int i = 0; i < NROFATTACKS; i++) |
1823 | if (op->resist[i]) |
1818 | if (op->resist[i]) |
1824 | return 1; |
1819 | return 1; |
1825 | |
1820 | |
1826 | return 0; |
1821 | return 0; |
1827 | } |
1822 | } |
… | |
… | |
1855 | free_artifact (at->next); |
1850 | free_artifact (at->next); |
1856 | |
1851 | |
1857 | if (at->allowed) |
1852 | if (at->allowed) |
1858 | free_charlinks (at->allowed); |
1853 | free_charlinks (at->allowed); |
1859 | |
1854 | |
1860 | at->item->free (1); |
1855 | at->item->destroy (1); |
1861 | |
1856 | |
1862 | delete at; |
1857 | delete at; |
1863 | } |
1858 | } |
1864 | |
1859 | |
1865 | void |
1860 | void |
1866 | free_artifactlist (artifactlist * al) |
1861 | free_artifactlist (artifactlist * al) |
1867 | { |
1862 | { |
1868 | artifactlist *nextal; |
1863 | artifactlist *nextal; |
1869 | |
1864 | |
1870 | for (al = first_artifactlist; al != NULL; al = nextal) |
1865 | for (al = first_artifactlist; al; al = nextal) |
1871 | { |
1866 | { |
1872 | nextal = al->next; |
1867 | nextal = al->next; |
1873 | |
1868 | |
1874 | if (al->items) |
1869 | if (al->items) |
1875 | free_artifact (al->items); |
1870 | free_artifact (al->items); |