… | |
… | |
258 | shstr_cmp name_ (name); |
258 | shstr_cmp name_ (name); |
259 | |
259 | |
260 | if (!name_) |
260 | if (!name_) |
261 | return 0; |
261 | return 0; |
262 | |
262 | |
263 | for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) |
263 | for (treasurelist *tl = first_treasurelist; tl != 0; tl = tl->next) |
264 | if (name_ == tl->name) |
264 | if (name_ == tl->name) |
265 | return tl; |
265 | return tl; |
266 | |
266 | |
267 | if (first_treasurelist) |
267 | if (first_treasurelist) |
268 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
268 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
… | |
… | |
280 | * being generated. |
280 | * being generated. |
281 | * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only |
281 | * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only |
282 | * abilities. This is used by summon spells, thus no summoned monsters |
282 | * abilities. This is used by summon spells, thus no summoned monsters |
283 | * start with equipment, but only their abilities). |
283 | * start with equipment, but only their abilities). |
284 | */ |
284 | */ |
285 | |
|
|
286 | |
|
|
287 | static void |
285 | static void |
288 | put_treasure (object *op, object *creator, int flags) |
286 | put_treasure (object *op, object *creator, int flags) |
289 | { |
287 | { |
290 | object *tmp; |
288 | object *tmp; |
291 | |
289 | |
… | |
… | |
294 | * this is the original object, or if this is an object that should be created |
292 | * this is the original object, or if this is an object that should be created |
295 | * by another object. |
293 | * by another object. |
296 | */ |
294 | */ |
297 | if (flags & GT_ENVIRONMENT && op->type != SPELL) |
295 | if (flags & GT_ENVIRONMENT && op->type != SPELL) |
298 | { |
296 | { |
299 | op->x = creator->x; |
|
|
300 | op->y = creator->y; |
|
|
301 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
297 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
302 | insert_ob_in_map (op, creator->map, op, INS_NO_MERGE | INS_NO_WALK_ON); |
298 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
303 | } |
299 | } |
304 | else |
300 | else |
305 | { |
301 | { |
306 | op = insert_ob_in_ob (op, creator); |
302 | op = creator->insert (op); |
|
|
303 | |
307 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
304 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
308 | monster_check_apply (creator, op); |
305 | monster_check_apply (creator, op); |
|
|
306 | |
309 | if ((flags & GT_UPDATE_INV) && (tmp = is_player_inv (creator)) != NULL) |
307 | if ((flags & GT_UPDATE_INV) && (tmp = creator->in_player ())) |
310 | esrv_send_item (tmp, op); |
308 | esrv_send_item (tmp, op); |
311 | } |
309 | } |
312 | } |
310 | } |
313 | |
311 | |
314 | /* if there are change_xxx commands in the treasure, we include the changes |
312 | /* if there are change_xxx commands in the treasure, we include the changes |
… | |
… | |
339 | if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) |
337 | if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) |
340 | { |
338 | { |
341 | if (t->name) |
339 | if (t->name) |
342 | { |
340 | { |
343 | if (strcmp (t->name, "NONE") && difficulty >= t->magic) |
341 | if (strcmp (t->name, "NONE") && difficulty >= t->magic) |
|
|
342 | { |
|
|
343 | treasurelist *tl = find_treasurelist (t->name); |
|
|
344 | if (tl) |
344 | create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); |
345 | create_treasure (tl, op, flag, difficulty, tries); |
|
|
346 | } |
345 | } |
347 | } |
346 | else |
348 | else |
347 | { |
349 | { |
348 | if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)) |
350 | if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)) |
349 | { |
351 | { |
… | |
… | |
397 | { |
399 | { |
398 | if (!strcmp (t->name, "NONE")) |
400 | if (!strcmp (t->name, "NONE")) |
399 | return; |
401 | return; |
400 | |
402 | |
401 | if (difficulty >= t->magic) |
403 | if (difficulty >= t->magic) |
|
|
404 | { |
|
|
405 | treasurelist *tl = find_treasurelist (t->name); |
|
|
406 | if (tl) |
402 | create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); |
407 | create_treasure (tl, op, flag, difficulty, tries); |
|
|
408 | } |
403 | else if (t->nrof) |
409 | else if (t->nrof) |
404 | create_one_treasure (tl, op, flag, difficulty, tries); |
410 | create_one_treasure (tl, op, flag, difficulty, tries); |
405 | |
411 | |
406 | return; |
412 | return; |
407 | } |
413 | } |
… | |
… | |
448 | * it instead takes a treasurelist. It is really just a wrapper around |
454 | * it instead takes a treasurelist. It is really just a wrapper around |
449 | * create_treasure. We create a dummy object that the treasure gets |
455 | * create_treasure. We create a dummy object that the treasure gets |
450 | * inserted into, and then return that treausre |
456 | * inserted into, and then return that treausre |
451 | */ |
457 | */ |
452 | object * |
458 | object * |
453 | generate_treasure (treasurelist * t, int difficulty) |
459 | generate_treasure (treasurelist *t, int difficulty) |
454 | { |
460 | { |
|
|
461 | difficulty = clamp (difficulty, 1, settings.max_level); |
|
|
462 | |
455 | object *ob = object::create (), *tmp; |
463 | object *ob = object::create (), *tmp; |
456 | |
464 | |
457 | create_treasure (t, ob, 0, difficulty, 0); |
465 | create_treasure (t, ob, 0, difficulty, 0); |
458 | |
466 | |
459 | /* Don't want to free the object we are about to return */ |
467 | /* Don't want to free the object we are about to return */ |
… | |
… | |
1262 | { |
1270 | { |
1263 | for (i = 0; i < depth; i++) |
1271 | for (i = 0; i < depth; i++) |
1264 | fprintf (logfile, " "); |
1272 | fprintf (logfile, " "); |
1265 | fprintf (logfile, "{ (list: %s)\n", &t->name); |
1273 | fprintf (logfile, "{ (list: %s)\n", &t->name); |
1266 | tl = find_treasurelist (t->name); |
1274 | tl = find_treasurelist (t->name); |
|
|
1275 | if (tl) |
1267 | dump_monster_treasure_rec (name, tl->items, depth + 2); |
1276 | dump_monster_treasure_rec (name, tl->items, depth + 2); |
1268 | for (i = 0; i < depth; i++) |
1277 | for (i = 0; i < depth; i++) |
1269 | fprintf (logfile, " "); |
1278 | fprintf (logfile, " "); |
1270 | fprintf (logfile, "} (end of list: %s)\n", &t->name); |
1279 | fprintf (logfile, "} (end of list: %s)\n", &t->name); |
1271 | } |
1280 | } |
1272 | else |
1281 | else |
… | |
… | |
1488 | CLEAR_FLAG (op, FLAG_ANIMATE); |
1497 | CLEAR_FLAG (op, FLAG_ANIMATE); |
1489 | /* so artifacts will join */ |
1498 | /* so artifacts will join */ |
1490 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1499 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1491 | op->speed = 0.0; |
1500 | op->speed = 0.0; |
1492 | |
1501 | |
1493 | update_ob_speed (op); |
1502 | op->set_speed (op->speed); |
1494 | } |
1503 | } |
1495 | |
1504 | |
1496 | if (change->nrof) |
1505 | if (change->nrof) |
1497 | op->nrof = RANDOM () % ((int) change->nrof) + 1; |
1506 | op->nrof = RANDOM () % ((int) change->nrof) + 1; |
1498 | |
1507 | |