ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/treasure.C
(Generate patch)

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.74 by root, Mon Apr 21 23:35:24 2008 UTC vs.
Revision 1.86 by root, Mon Oct 12 14:00:57 2009 UTC

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.
45typedef std::tr1::unordered_map< 46typedef 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
54static tl_map_t tl_map; 54static tl_map_t tl_map;
55 55
56/* 56/*
255 return; 255 return;
256 } 256 }
257 257
258 op->expand_tail (); 258 op->expand_tail ();
259 259
260 if (op->blocked (creator->map, creator->x, creator->y)) 260 if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y))
261 op->destroy (); 261 op->destroy ();
262 else 262 else
263 { 263 {
264 SET_FLAG (op, FLAG_OBJ_ORIGINAL); 264 SET_FLAG (op, FLAG_OBJ_ORIGINAL);
265 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); 265 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON);
269 { 269 {
270 op = creator->insert (op); 270 op = creator->insert (op);
271 271
272 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) 272 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER))
273 monster_check_apply (creator, op); 273 monster_check_apply (creator, op);
274
275 if (flags & GT_UPDATE_INV)
276 if (object *tmp = creator->in_player ())
277 esrv_send_item (tmp, op);
278 } 274 }
279} 275}
280 276
281/* if there are change_xxx commands in the treasure, we include the changes 277/* if there are change_xxx commands in the treasure, we include the changes
282 * in the generated object 278 * in the generated object
446 442
447 if (ob->inv) 443 if (ob->inv)
448 LOG (llevError, "In generate treasure, created multiple objects.\n"); 444 LOG (llevError, "In generate treasure, created multiple objects.\n");
449 445
450 ob->destroy (); 446 ob->destroy ();
447
451 return tmp; 448 return tmp;
452} 449}
453 450
454/* 451/*
455 * 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
582 if (op->type == ARMOUR) 579 if (op->type == ARMOUR)
583 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; 580 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100;
584 581
585 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 582 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
586 magic = (-magic); 583 magic = (-magic);
584
587 op->weight = (op->arch->weight * (100 - magic * 10)) / 100; 585 op->weight = (op->arch->weight * (100 - magic * 10)) / 100;
588 } 586 }
589 else 587 else
590 { 588 {
591 if (op->type == ARMOUR) 589 if (op->type == ARMOUR)
592 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; 590 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100;
591
593 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 592 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
594 magic = (-magic); 593 magic = (-magic);
594
595 op->weight = (op->weight * (100 - magic * 10)) / 100; 595 op->weight = (op->weight * (100 - magic * 10)) / 100;
596 } 596 }
597} 597}
598 598
599/* 599/*
967 case AMULET: 967 case AMULET:
968 if (IS_ARCH (op->arch, amulet)) 968 if (IS_ARCH (op->arch, amulet))
969 op->value *= 5; /* Since it's not just decoration */ 969 op->value *= 5; /* Since it's not just decoration */
970 970
971 case RING: 971 case RING:
972 if (!op->arch) // wtf? schmorp
973 {
974 op->destroy ();
975 op = 0;
976 break;
977 }
978
979 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! */
980 break; 973 break;
981 974
982 if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) 975 if (!(flags & GT_ONLY_GOOD) && !(rndm (3)))
983 SET_FLAG (op, FLAG_CURSED); 976 SET_FLAG (op, FLAG_CURSED);
1004 op->value *= 5; 997 op->value *= 5;
1005 set_ring_bonus (op, d); 998 set_ring_bonus (op, d);
1006 } 999 }
1007 } 1000 }
1008 1001
1009 if (GET_ANIM_ID (op)) 1002 if (op->animation_id)
1010 SET_ANIMATION (op, rndm (NUM_ANIMATIONS (op))); 1003 op->set_anim_frame (rndm (op->anim_frames ()));
1011 1004
1012 break; 1005 break;
1013 1006
1014 case BOOK: 1007 case BOOK:
1015 /* Is it an empty book?, if yes lets make a special· 1008 /* Is it an empty book?, if yes lets make a special·
1355 * 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
1356 * this object. 1349 * this object.
1357 */ 1350 */
1358 if (op->type == HORN || op->type == POTION) 1351 if (op->type == HORN || op->type == POTION)
1359 { 1352 {
1360 object *tmp_obj;
1361
1362 /* Remove any spells this object currently has in it */ 1353 /* Remove any spells this object currently has in it */
1363 while (op->inv)
1364 op->inv->destroy (); 1354 op->destroy_inv (false);
1365 1355
1366 tmp_obj = arch_to_object (change->other_arch); 1356 object *tmp = arch_to_object (change->other_arch);
1367 insert_ob_in_ob (tmp_obj, op); 1357 insert_ob_in_ob (tmp, op);
1368 } 1358 }
1369 /* No harm setting this for potions/horns */ 1359 /* No harm setting this for potions/horns */
1370 op->other_arch = change->other_arch; 1360 op->other_arch = change->other_arch;
1371 } 1361 }
1372 1362
1577#if 1 1567#if 1
1578 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);
1579#endif 1569#endif
1580 return; 1570 return;
1581 } 1571 }
1582 if (!strcmp (art->item->name, "NONE")) 1572
1573 if (art->item->name == shstr_NONE)
1583 return; 1574 return;
1575
1584 if (FABS (op->magic) < art->item->magic) 1576 if (fabs (op->magic) < art->item->magic)
1585 continue; /* Not magic enough to be this item */ 1577 continue; /* Not magic enough to be this item */
1586 1578
1587 /* Map difficulty not high enough */ 1579 /* Map difficulty not high enough */
1588 if (difficulty < art->difficulty) 1580 if (difficulty < art->difficulty)
1589 continue; 1581 continue;
1640 item->level = donor->level; 1632 item->level = donor->level;
1641 1633
1642 /* if donor has some attacktypes, the flesh is poisonous */ 1634 /* if donor has some attacktypes, the flesh is poisonous */
1643 if (donor->attacktype & AT_POISON) 1635 if (donor->attacktype & AT_POISON)
1644 item->type = POISON; 1636 item->type = POISON;
1637
1645 if (donor->attacktype & AT_ACID) 1638 if (donor->attacktype & AT_ACID)
1646 item->stats.hp = -1 * item->stats.food; 1639 item->stats.hp = -1 * item->stats.food;
1640
1647 SET_FLAG (item, FLAG_NO_STEAL); 1641 SET_FLAG (item, FLAG_NO_STEAL);
1648 } 1642 }
1649} 1643}
1650 1644
1651/* special_potion() - so that old potion code is still done right. */ 1645/* special_potion() - so that old potion code is still done right. */
1688free_artifact (artifact *at) 1682free_artifact (artifact *at)
1689{ 1683{
1690 if (at->next) free_artifact (at->next); 1684 if (at->next) free_artifact (at->next);
1691 if (at->allowed) free_charlinks (at->allowed); 1685 if (at->allowed) free_charlinks (at->allowed);
1692 1686
1693 at->item->destroy (1); 1687 at->item->destroy ();
1694 1688
1695 sfree (at); 1689 sfree (at);
1696} 1690}
1697 1691
1698void 1692void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines