… | |
… | |
45 | typedef std::tr1::unordered_map< |
45 | typedef std::tr1::unordered_map< |
46 | const char *, |
46 | const char *, |
47 | treasurelist *, |
47 | treasurelist *, |
48 | str_hash, |
48 | str_hash, |
49 | str_equal, |
49 | str_equal, |
50 | slice_allocator< std::pair<const char *const, treasurelist *> >, |
50 | slice_allocator< std::pair<const char *const, treasurelist *> > |
51 | true |
|
|
52 | > tl_map_t; |
51 | > tl_map_t; |
53 | |
52 | |
54 | static tl_map_t tl_map; |
53 | static tl_map_t tl_map; |
55 | |
54 | |
56 | /* |
55 | /* |
… | |
… | |
442 | |
441 | |
443 | if (ob->inv) |
442 | if (ob->inv) |
444 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
443 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
445 | |
444 | |
446 | ob->destroy (); |
445 | ob->destroy (); |
|
|
446 | |
447 | return tmp; |
447 | return tmp; |
448 | } |
448 | } |
449 | |
449 | |
450 | /* |
450 | /* |
451 | * This is a new way of calculating the chance for an item to have |
451 | * This is a new way of calculating the chance for an item to have |
… | |
… | |
966 | case AMULET: |
966 | case AMULET: |
967 | if (IS_ARCH (op->arch, amulet)) |
967 | if (IS_ARCH (op->arch, amulet)) |
968 | op->value *= 5; /* Since it's not just decoration */ |
968 | op->value *= 5; /* Since it's not just decoration */ |
969 | |
969 | |
970 | case RING: |
970 | case RING: |
971 | if (!op->arch) // wtf? schmorp |
|
|
972 | { |
|
|
973 | op->destroy (); |
|
|
974 | op = 0; |
|
|
975 | break; |
|
|
976 | } |
|
|
977 | |
|
|
978 | if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ |
971 | if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ |
979 | break; |
972 | break; |
980 | |
973 | |
981 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
974 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
982 | SET_FLAG (op, FLAG_CURSED); |
975 | SET_FLAG (op, FLAG_CURSED); |
… | |
… | |
1003 | op->value *= 5; |
996 | op->value *= 5; |
1004 | set_ring_bonus (op, d); |
997 | set_ring_bonus (op, d); |
1005 | } |
998 | } |
1006 | } |
999 | } |
1007 | |
1000 | |
1008 | if (GET_ANIM_ID (op)) |
1001 | if (op->animation_id) |
1009 | SET_ANIMATION (op, rndm (NUM_ANIMATIONS (op))); |
1002 | op->set_anim_frame (rndm (op->anim_frames ())); |
1010 | |
1003 | |
1011 | break; |
1004 | break; |
1012 | |
1005 | |
1013 | case BOOK: |
1006 | case BOOK: |
1014 | /* Is it an empty book?, if yes lets make a specialĀ· |
1007 | /* Is it an empty book?, if yes lets make a specialĀ· |
… | |
… | |
1354 | * to cast. So convert that to into a spell and put it into |
1347 | * to cast. So convert that to into a spell and put it into |
1355 | * this object. |
1348 | * this object. |
1356 | */ |
1349 | */ |
1357 | if (op->type == HORN || op->type == POTION) |
1350 | if (op->type == HORN || op->type == POTION) |
1358 | { |
1351 | { |
1359 | object *tmp_obj; |
|
|
1360 | |
|
|
1361 | /* Remove any spells this object currently has in it */ |
1352 | /* Remove any spells this object currently has in it */ |
1362 | while (op->inv) |
|
|
1363 | op->inv->destroy (); |
1353 | op->destroy_inv (false); |
1364 | |
1354 | |
1365 | tmp_obj = arch_to_object (change->other_arch); |
1355 | object *tmp = arch_to_object (change->other_arch); |
1366 | insert_ob_in_ob (tmp_obj, op); |
1356 | insert_ob_in_ob (tmp, op); |
1367 | } |
1357 | } |
1368 | /* No harm setting this for potions/horns */ |
1358 | /* No harm setting this for potions/horns */ |
1369 | op->other_arch = change->other_arch; |
1359 | op->other_arch = change->other_arch; |
1370 | } |
1360 | } |
1371 | |
1361 | |
… | |
… | |
1576 | #if 1 |
1566 | #if 1 |
1577 | LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type); |
1567 | LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type); |
1578 | #endif |
1568 | #endif |
1579 | return; |
1569 | return; |
1580 | } |
1570 | } |
1581 | if (!strcmp (art->item->name, "NONE")) |
1571 | |
|
|
1572 | if (art->item->name == shstr_NONE) |
1582 | return; |
1573 | return; |
|
|
1574 | |
1583 | if (FABS (op->magic) < art->item->magic) |
1575 | if (fabs (op->magic) < art->item->magic) |
1584 | continue; /* Not magic enough to be this item */ |
1576 | continue; /* Not magic enough to be this item */ |
1585 | |
1577 | |
1586 | /* Map difficulty not high enough */ |
1578 | /* Map difficulty not high enough */ |
1587 | if (difficulty < art->difficulty) |
1579 | if (difficulty < art->difficulty) |
1588 | continue; |
1580 | continue; |
… | |
… | |
1639 | item->level = donor->level; |
1631 | item->level = donor->level; |
1640 | |
1632 | |
1641 | /* if donor has some attacktypes, the flesh is poisonous */ |
1633 | /* if donor has some attacktypes, the flesh is poisonous */ |
1642 | if (donor->attacktype & AT_POISON) |
1634 | if (donor->attacktype & AT_POISON) |
1643 | item->type = POISON; |
1635 | item->type = POISON; |
|
|
1636 | |
1644 | if (donor->attacktype & AT_ACID) |
1637 | if (donor->attacktype & AT_ACID) |
1645 | item->stats.hp = -1 * item->stats.food; |
1638 | item->stats.hp = -1 * item->stats.food; |
|
|
1639 | |
1646 | SET_FLAG (item, FLAG_NO_STEAL); |
1640 | SET_FLAG (item, FLAG_NO_STEAL); |
1647 | } |
1641 | } |
1648 | } |
1642 | } |
1649 | |
1643 | |
1650 | /* special_potion() - so that old potion code is still done right. */ |
1644 | /* special_potion() - so that old potion code is still done right. */ |
… | |
… | |
1687 | free_artifact (artifact *at) |
1681 | free_artifact (artifact *at) |
1688 | { |
1682 | { |
1689 | if (at->next) free_artifact (at->next); |
1683 | if (at->next) free_artifact (at->next); |
1690 | if (at->allowed) free_charlinks (at->allowed); |
1684 | if (at->allowed) free_charlinks (at->allowed); |
1691 | |
1685 | |
1692 | at->item->destroy (1); |
1686 | at->item->destroy (); |
1693 | |
1687 | |
1694 | sfree (at); |
1688 | sfree (at); |
1695 | } |
1689 | } |
1696 | |
1690 | |
1697 | void |
1691 | void |