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