… | |
… | |
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 | |
40 | extern char *spell_mapping[]; |
39 | extern char *spell_mapping[]; |
41 | |
40 | |
42 | static treasurelist *first_treasurelist; |
41 | static treasurelist *first_treasurelist; |
… | |
… | |
46 | typedef std::tr1::unordered_map< |
45 | typedef 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 | |
55 | static tl_map_t tl_map; |
53 | static 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 |
… | |
… | |
583 | if (op->type == ARMOUR) |
577 | if (op->type == ARMOUR) |
584 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; |
578 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; |
585 | |
579 | |
586 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
580 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
587 | magic = (-magic); |
581 | magic = (-magic); |
|
|
582 | |
588 | op->weight = (op->arch->weight * (100 - magic * 10)) / 100; |
583 | op->weight = (op->arch->weight * (100 - magic * 10)) / 100; |
589 | } |
584 | } |
590 | else |
585 | else |
591 | { |
586 | { |
592 | if (op->type == ARMOUR) |
587 | if (op->type == ARMOUR) |
593 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; |
588 | ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; |
|
|
589 | |
594 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
590 | if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ |
595 | magic = (-magic); |
591 | magic = (-magic); |
|
|
592 | |
596 | op->weight = (op->weight * (100 - magic * 10)) / 100; |
593 | op->weight = (op->weight * (100 - magic * 10)) / 100; |
597 | } |
594 | } |
598 | } |
595 | } |
599 | |
596 | |
600 | /* |
597 | /* |