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.73 by root, Sun Apr 20 05:24:55 2008 UTC vs.
Revision 1.84 by root, Thu Jan 1 11:41:17 2009 UTC

32 32
33//#define TREASURE_VERBOSE 33//#define TREASURE_VERBOSE
34 34
35#include <global.h> 35#include <global.h>
36#include <treasure.h> 36#include <treasure.h>
37#include <funcpoint.h>
38#include <loader.h> 37#include <loader.h>
39 38
40extern char *spell_mapping[]; 39extern char *spell_mapping[];
41 40
42static treasurelist *first_treasurelist; 41static treasurelist *first_treasurelist;
46typedef std::tr1::unordered_map< 45typedef std::tr1::unordered_map<
47 const char *, 46 const char *,
48 treasurelist *, 47 treasurelist *,
49 str_hash, 48 str_hash,
50 str_equal, 49 str_equal,
51 slice_allocator< std::pair<const char *const, treasurelist *> >, 50 slice_allocator< std::pair<const char *const, treasurelist *> >
52 true
53> tl_map_t; 51> tl_map_t;
54 52
55static tl_map_t tl_map; 53static tl_map_t tl_map;
56 54
57/* 55/*
256 return; 254 return;
257 } 255 }
258 256
259 op->expand_tail (); 257 op->expand_tail ();
260 258
261 if (op->blocked (creator->map, creator->x, creator->y)) 259 if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y))
262 op->destroy (); 260 op->destroy ();
263 else 261 else
264 { 262 {
265 SET_FLAG (op, FLAG_OBJ_ORIGINAL); 263 SET_FLAG (op, FLAG_OBJ_ORIGINAL);
266 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); 264 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON);
270 { 268 {
271 op = creator->insert (op); 269 op = creator->insert (op);
272 270
273 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) 271 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER))
274 monster_check_apply (creator, op); 272 monster_check_apply (creator, op);
275
276 if (flags & GT_UPDATE_INV)
277 if (object *tmp = creator->in_player ())
278 esrv_send_item (tmp, op);
279 } 273 }
280} 274}
281 275
282/* if there are change_xxx commands in the treasure, we include the changes 276/* if there are change_xxx commands in the treasure, we include the changes
283 * in the generated object 277 * in the generated object
447 441
448 if (ob->inv) 442 if (ob->inv)
449 LOG (llevError, "In generate treasure, created multiple objects.\n"); 443 LOG (llevError, "In generate treasure, created multiple objects.\n");
450 444
451 ob->destroy (); 445 ob->destroy ();
446
452 return tmp; 447 return tmp;
453} 448}
454 449
455/* 450/*
456 * 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
583 if (op->type == ARMOUR) 578 if (op->type == ARMOUR)
584 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; 579 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100;
585 580
586 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 581 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
587 magic = (-magic); 582 magic = (-magic);
583
588 op->weight = (op->arch->weight * (100 - magic * 10)) / 100; 584 op->weight = (op->arch->weight * (100 - magic * 10)) / 100;
589 } 585 }
590 else 586 else
591 { 587 {
592 if (op->type == ARMOUR) 588 if (op->type == ARMOUR)
593 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; 589 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100;
590
594 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 591 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
595 magic = (-magic); 592 magic = (-magic);
593
596 op->weight = (op->weight * (100 - magic * 10)) / 100; 594 op->weight = (op->weight * (100 - magic * 10)) / 100;
597 } 595 }
598} 596}
599 597
600/* 598/*
968 case AMULET: 966 case AMULET:
969 if (IS_ARCH (op->arch, amulet)) 967 if (IS_ARCH (op->arch, amulet))
970 op->value *= 5; /* Since it's not just decoration */ 968 op->value *= 5; /* Since it's not just decoration */
971 969
972 case RING: 970 case RING:
973 if (!op->arch) // wtf? schmorp
974 {
975 op->destroy ();
976 op = 0;
977 break;
978 }
979
980 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! */
981 break; 972 break;
982 973
983 if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) 974 if (!(flags & GT_ONLY_GOOD) && !(rndm (3)))
984 SET_FLAG (op, FLAG_CURSED); 975 SET_FLAG (op, FLAG_CURSED);
1356 * 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
1357 * this object. 1348 * this object.
1358 */ 1349 */
1359 if (op->type == HORN || op->type == POTION) 1350 if (op->type == HORN || op->type == POTION)
1360 { 1351 {
1361 object *tmp_obj;
1362
1363 /* Remove any spells this object currently has in it */ 1352 /* Remove any spells this object currently has in it */
1364 while (op->inv)
1365 op->inv->destroy (); 1353 op->destroy_inv (false);
1366 1354
1367 tmp_obj = arch_to_object (change->other_arch); 1355 object *tmp = arch_to_object (change->other_arch);
1368 insert_ob_in_ob (tmp_obj, op); 1356 insert_ob_in_ob (tmp, op);
1369 } 1357 }
1370 /* No harm setting this for potions/horns */ 1358 /* No harm setting this for potions/horns */
1371 op->other_arch = change->other_arch; 1359 op->other_arch = change->other_arch;
1372 } 1360 }
1373 1361
1578#if 1 1566#if 1
1579 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);
1580#endif 1568#endif
1581 return; 1569 return;
1582 } 1570 }
1583 if (!strcmp (art->item->name, "NONE")) 1571
1572 if (art->item->name == shstr_NONE)
1584 return; 1573 return;
1574
1585 if (FABS (op->magic) < art->item->magic) 1575 if (fabs (op->magic) < art->item->magic)
1586 continue; /* Not magic enough to be this item */ 1576 continue; /* Not magic enough to be this item */
1587 1577
1588 /* Map difficulty not high enough */ 1578 /* Map difficulty not high enough */
1589 if (difficulty < art->difficulty) 1579 if (difficulty < art->difficulty)
1590 continue; 1580 continue;
1641 item->level = donor->level; 1631 item->level = donor->level;
1642 1632
1643 /* if donor has some attacktypes, the flesh is poisonous */ 1633 /* if donor has some attacktypes, the flesh is poisonous */
1644 if (donor->attacktype & AT_POISON) 1634 if (donor->attacktype & AT_POISON)
1645 item->type = POISON; 1635 item->type = POISON;
1636
1646 if (donor->attacktype & AT_ACID) 1637 if (donor->attacktype & AT_ACID)
1647 item->stats.hp = -1 * item->stats.food; 1638 item->stats.hp = -1 * item->stats.food;
1639
1648 SET_FLAG (item, FLAG_NO_STEAL); 1640 SET_FLAG (item, FLAG_NO_STEAL);
1649 } 1641 }
1650} 1642}
1651 1643
1652/* special_potion() - so that old potion code is still done right. */ 1644/* special_potion() - so that old potion code is still done right. */
1689free_artifact (artifact *at) 1681free_artifact (artifact *at)
1690{ 1682{
1691 if (at->next) free_artifact (at->next); 1683 if (at->next) free_artifact (at->next);
1692 if (at->allowed) free_charlinks (at->allowed); 1684 if (at->allowed) free_charlinks (at->allowed);
1693 1685
1694 at->item->destroy (1); 1686 at->item->destroy ();
1695 1687
1696 sfree (at); 1688 sfree (at);
1697} 1689}
1698 1690
1699void 1691void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines