… | |
… | |
431 | object_freezer freezer; |
431 | object_freezer freezer; |
432 | op->write (freezer); |
432 | op->write (freezer); |
433 | return freezer.as_string (); |
433 | return freezer.as_string (); |
434 | } |
434 | } |
435 | |
435 | |
|
|
436 | char * |
|
|
437 | object::as_string () |
|
|
438 | { |
|
|
439 | return dump_object (this); |
|
|
440 | } |
|
|
441 | |
436 | /* |
442 | /* |
437 | * get_nearest_part(multi-object, object 2) returns the part of the |
443 | * get_nearest_part(multi-object, object 2) returns the part of the |
438 | * multi-object 1 which is closest to the second object. |
444 | * multi-object 1 which is closest to the second object. |
439 | * If it's not a multi-object, it is returned. |
445 | * If it's not a multi-object, it is returned. |
440 | */ |
446 | */ |
… | |
… | |
555 | update_stats (); |
561 | update_stats (); |
556 | |
562 | |
557 | new_draw_info_format (NDI_UNIQUE, 0, this, |
563 | new_draw_info_format (NDI_UNIQUE, 0, this, |
558 | "You try to balance all your items at once, " |
564 | "You try to balance all your items at once, " |
559 | "but the %s is just too much for your body. " |
565 | "but the %s is just too much for your body. " |
560 | "[You need to unapply some items first.]", &ob->name); |
566 | "[You need to unapply some items first - use the 'body' command to see " |
|
|
567 | "how many items you cna wera on a specific body part.]", &ob->name); |
561 | return false; |
568 | return false; |
562 | } |
569 | } |
563 | |
570 | |
564 | //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
571 | //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
565 | } |
572 | } |
… | |
… | |
831 | { |
838 | { |
832 | /* If already on active list, don't do anything */ |
839 | /* If already on active list, don't do anything */ |
833 | if (active) |
840 | if (active) |
834 | return; |
841 | return; |
835 | |
842 | |
836 | if (has_active_speed () && flag [FLAG_FREED]) LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D |
|
|
837 | if (has_active_speed () && flag [FLAG_DEBUG]) LOG (llevError | logBacktrace, "BUG: tried to activate DEBUG object %s\n", debug_desc ());//D temp |
|
|
838 | |
|
|
839 | if (has_active_speed ()) |
843 | if (has_active_speed ()) |
|
|
844 | { |
|
|
845 | if (flag [FLAG_FREED]) |
|
|
846 | LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D |
|
|
847 | |
840 | actives.insert (this); |
848 | actives.insert (this); |
|
|
849 | } |
841 | } |
850 | } |
842 | |
851 | |
843 | void |
852 | void |
844 | object::activate_recursive () |
853 | object::activate_recursive () |
845 | { |
854 | { |
… | |
… | |
1477 | * blocked() and wall() work properly), and these flags are updated by |
1486 | * blocked() and wall() work properly), and these flags are updated by |
1478 | * update_object(). |
1487 | * update_object(). |
1479 | */ |
1488 | */ |
1480 | |
1489 | |
1481 | /* if this is not the head or flag has been passed, don't check walk on status */ |
1490 | /* if this is not the head or flag has been passed, don't check walk on status */ |
1482 | if (!(flag & INS_NO_WALK_ON) && op->head_ () == op) |
1491 | if (!(flag & INS_NO_WALK_ON) && op->is_head ()) |
1483 | { |
1492 | { |
1484 | if (check_move_on (op, originator)) |
1493 | if (check_move_on (op, originator)) |
1485 | return 0; |
1494 | return 0; |
1486 | |
1495 | |
1487 | /* If we are a multi part object, lets work our way through the check |
1496 | /* If we are a multi part object, lets work our way through the check |
… | |
… | |
1702 | * on top. |
1711 | * on top. |
1703 | */ |
1712 | */ |
1704 | int |
1713 | int |
1705 | check_move_on (object *op, object *originator) |
1714 | check_move_on (object *op, object *originator) |
1706 | { |
1715 | { |
|
|
1716 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
|
|
1717 | return 0; |
|
|
1718 | |
1707 | object *tmp; |
1719 | object *tmp; |
1708 | maptile *m = op->map; |
1720 | maptile *m = op->map; |
1709 | int x = op->x, y = op->y; |
1721 | int x = op->x, y = op->y; |
1710 | |
1722 | |
1711 | MoveType move_on, move_slow, move_block; |
1723 | mapspace &ms = m->at (x, y); |
1712 | |
1724 | |
1713 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
1725 | ms.update (); |
1714 | return 0; |
|
|
1715 | |
1726 | |
1716 | move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); |
1727 | MoveType move_on = ms.move_on; |
1717 | move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); |
1728 | MoveType move_slow = ms.move_slow; |
1718 | move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); |
1729 | MoveType move_block = ms.move_block; |
1719 | |
1730 | |
1720 | /* if nothing on this space will slow op down or be applied, |
1731 | /* if nothing on this space will slow op down or be applied, |
1721 | * no need to do checking below. have to make sure move_type |
1732 | * no need to do checking below. have to make sure move_type |
1722 | * is set, as lots of objects don't have it set - we treat that |
1733 | * is set, as lots of objects don't have it set - we treat that |
1723 | * as walking. |
1734 | * as walking. |
… | |
… | |
1734 | return 0; |
1745 | return 0; |
1735 | |
1746 | |
1736 | /* The objects have to be checked from top to bottom. |
1747 | /* The objects have to be checked from top to bottom. |
1737 | * Hence, we first go to the top: |
1748 | * Hence, we first go to the top: |
1738 | */ |
1749 | */ |
1739 | |
1750 | for (object *next, *tmp = ms.top; tmp; tmp = next) |
1740 | for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above) |
|
|
1741 | { |
|
|
1742 | /* Trim the search when we find the first other spell effect |
|
|
1743 | * this helps performance so that if a space has 50 spell objects, |
|
|
1744 | * we don't need to check all of them. |
|
|
1745 | */ |
|
|
1746 | if ((tmp->move_type & MOVE_FLY_LOW) && QUERY_FLAG (tmp, FLAG_NO_PICK)) |
|
|
1747 | break; |
|
|
1748 | } |
1751 | { |
|
|
1752 | next = tmp->below; |
1749 | |
1753 | |
1750 | for (; tmp; tmp = tmp->below) |
|
|
1751 | { |
|
|
1752 | if (tmp == op) |
1754 | if (tmp == op) |
1753 | continue; /* Can't apply yourself */ |
1755 | continue; /* Can't apply yourself */ |
1754 | |
1756 | |
1755 | /* Check to see if one of the movement types should be slowed down. |
1757 | /* Check to see if one of the movement types should be slowed down. |
1756 | * Second check makes sure that the movement types not being slowed |
1758 | * Second check makes sure that the movement types not being slowed |
… | |
… | |
1761 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1763 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1762 | { |
1764 | { |
1763 | if ((!op->move_type && tmp->move_slow & MOVE_WALK) || |
1765 | if ((!op->move_type && tmp->move_slow & MOVE_WALK) || |
1764 | ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) |
1766 | ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) |
1765 | { |
1767 | { |
1766 | |
|
|
1767 | float |
|
|
1768 | diff = tmp->move_slow_penalty * fabs (op->speed); |
1768 | float diff = tmp->move_slow_penalty * fabs (op->speed); |
1769 | |
1769 | |
1770 | if (op->is_player ()) |
1770 | if (op->is_player ()) |
1771 | if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || |
1771 | if ((tmp->flag [FLAG_IS_HILLY ] && find_skill_by_number (op, SK_CLIMBING)) || |
1772 | (QUERY_FLAG (tmp, FLAG_IS_WOODED) && find_skill_by_number (op, SK_WOODSMAN))) |
1772 | (tmp->flag [FLAG_IS_WOODED] && find_skill_by_number (op, SK_WOODSMAN))) |
1773 | diff /= 4.0; |
1773 | diff /= 4.0; |
1774 | |
1774 | |
1775 | op->speed_left -= diff; |
1775 | op->speed_left -= diff; |
1776 | } |
1776 | } |
1777 | } |
1777 | } |
… | |
… | |
2547 | return splay (tmp); |
2547 | return splay (tmp); |
2548 | |
2548 | |
2549 | return 0; |
2549 | return 0; |
2550 | } |
2550 | } |
2551 | |
2551 | |
|
|
2552 | void |
|
|
2553 | object::force_set_timer (int duration) |
|
|
2554 | { |
|
|
2555 | this->duration = 1; |
|
|
2556 | this->speed_left = -1.f; |
|
|
2557 | |
|
|
2558 | this->set_speed (duration ? 1.f / duration : 0.f); |
|
|
2559 | } |
|
|
2560 | |
2552 | object * |
2561 | object * |
2553 | object::force_add (shstr_tmp name, int duration) |
2562 | object::force_add (shstr_tmp name, int duration) |
2554 | { |
2563 | { |
2555 | if (object *force = force_find (name)) |
2564 | if (object *force = force_find (name)) |
2556 | force->destroy (); |
2565 | force->destroy (); |
2557 | |
2566 | |
2558 | object *force = get_archetype (FORCE_NAME); |
2567 | object *force = get_archetype (FORCE_NAME); |
2559 | |
2568 | |
2560 | force->slaying = name; |
2569 | force->slaying = name; |
2561 | force->stats.food = 1; |
|
|
2562 | force->speed_left = -1.f; |
|
|
2563 | |
2570 | |
2564 | force->set_speed (duration ? 1.f / duration : 0.f); |
2571 | force->force_set_timer (duration); |
2565 | force->flag [FLAG_IS_USED_UP] = true; |
2572 | |
2566 | force->flag [FLAG_APPLIED] = true; |
2573 | force->flag [FLAG_APPLIED] = true; |
2567 | |
2574 | |
2568 | return insert (force); |
2575 | return insert (force); |
2569 | } |
2576 | } |
2570 | |
2577 | |