… | |
… | |
328 | // the player inventory itself is always visible |
328 | // the player inventory itself is always visible |
329 | if (env->is_player ()) |
329 | if (env->is_player ()) |
330 | return env; |
330 | return env; |
331 | |
331 | |
332 | // else a player could have our env open |
332 | // else a player could have our env open |
333 | object *envest = env->outer_env (); |
333 | object *envest = env->outer_env_or_self (); |
334 | |
334 | |
335 | // the player itself is always on a map, so we will find him here |
335 | // the player itself is always on a map, so we will find him here |
336 | // even if our inv is in a player. |
336 | // even if our inv is in a player. |
337 | if (envest->is_on_map ()) |
337 | if (envest->is_on_map ()) |
338 | if (object *pl = envest->ms ().player ()) |
338 | if (object *pl = envest->ms ().player ()) |
… | |
… | |
831 | { |
831 | { |
832 | /* If already on active list, don't do anything */ |
832 | /* If already on active list, don't do anything */ |
833 | if (active) |
833 | if (active) |
834 | return; |
834 | return; |
835 | |
835 | |
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 ()) |
836 | if (has_active_speed ()) |
|
|
837 | { |
|
|
838 | if (flag [FLAG_FREED]) |
|
|
839 | LOG (llevError | logBacktrace, "BUG: tried to activate freed object %s\n", debug_desc ());//D |
|
|
840 | |
840 | actives.insert (this); |
841 | actives.insert (this); |
|
|
842 | } |
841 | } |
843 | } |
842 | |
844 | |
843 | void |
845 | void |
844 | object::activate_recursive () |
846 | object::activate_recursive () |
845 | { |
847 | { |
… | |
… | |
1477 | * blocked() and wall() work properly), and these flags are updated by |
1479 | * blocked() and wall() work properly), and these flags are updated by |
1478 | * update_object(). |
1480 | * update_object(). |
1479 | */ |
1481 | */ |
1480 | |
1482 | |
1481 | /* if this is not the head or flag has been passed, don't check walk on status */ |
1483 | /* 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) |
1484 | if (!(flag & INS_NO_WALK_ON) && op->is_head ()) |
1483 | { |
1485 | { |
1484 | if (check_move_on (op, originator)) |
1486 | if (check_move_on (op, originator)) |
1485 | return 0; |
1487 | return 0; |
1486 | |
1488 | |
1487 | /* If we are a multi part object, lets work our way through the check |
1489 | /* If we are a multi part object, lets work our way through the check |
… | |
… | |
1702 | * on top. |
1704 | * on top. |
1703 | */ |
1705 | */ |
1704 | int |
1706 | int |
1705 | check_move_on (object *op, object *originator) |
1707 | check_move_on (object *op, object *originator) |
1706 | { |
1708 | { |
|
|
1709 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
|
|
1710 | return 0; |
|
|
1711 | |
1707 | object *tmp; |
1712 | object *tmp; |
1708 | maptile *m = op->map; |
1713 | maptile *m = op->map; |
1709 | int x = op->x, y = op->y; |
1714 | int x = op->x, y = op->y; |
1710 | |
1715 | |
1711 | MoveType move_on, move_slow, move_block; |
1716 | mapspace &ms = m->at (x, y); |
1712 | |
1717 | |
1713 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
1718 | ms.update (); |
1714 | return 0; |
|
|
1715 | |
1719 | |
1716 | move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); |
1720 | MoveType move_on = ms.move_on; |
1717 | move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); |
1721 | MoveType move_slow = ms.move_slow; |
1718 | move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); |
1722 | MoveType move_block = ms.move_block; |
1719 | |
1723 | |
1720 | /* if nothing on this space will slow op down or be applied, |
1724 | /* 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 |
1725 | * 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 |
1726 | * is set, as lots of objects don't have it set - we treat that |
1723 | * as walking. |
1727 | * as walking. |
… | |
… | |
1734 | return 0; |
1738 | return 0; |
1735 | |
1739 | |
1736 | /* The objects have to be checked from top to bottom. |
1740 | /* The objects have to be checked from top to bottom. |
1737 | * Hence, we first go to the top: |
1741 | * Hence, we first go to the top: |
1738 | */ |
1742 | */ |
1739 | |
1743 | 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 | } |
1744 | { |
|
|
1745 | next = tmp->below; |
1749 | |
1746 | |
1750 | for (; tmp; tmp = tmp->below) |
|
|
1751 | { |
|
|
1752 | if (tmp == op) |
1747 | if (tmp == op) |
1753 | continue; /* Can't apply yourself */ |
1748 | continue; /* Can't apply yourself */ |
1754 | |
1749 | |
1755 | /* Check to see if one of the movement types should be slowed down. |
1750 | /* 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 |
1751 | * Second check makes sure that the movement types not being slowed |
… | |
… | |
1761 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1756 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1762 | { |
1757 | { |
1763 | if ((!op->move_type && tmp->move_slow & MOVE_WALK) || |
1758 | 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)) |
1759 | ((op->move_type & tmp->move_slow) && (op->move_type & ~tmp->move_slow & ~tmp->move_block) == 0)) |
1765 | { |
1760 | { |
1766 | |
|
|
1767 | float |
|
|
1768 | diff = tmp->move_slow_penalty * fabs (op->speed); |
1761 | float diff = tmp->move_slow_penalty * fabs (op->speed); |
1769 | |
1762 | |
1770 | if (op->is_player ()) |
1763 | if (op->is_player ()) |
1771 | if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || |
1764 | 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))) |
1765 | (tmp->flag [FLAG_IS_WOODED] && find_skill_by_number (op, SK_WOODSMAN))) |
1773 | diff /= 4.0; |
1766 | diff /= 4.0; |
1774 | |
1767 | |
1775 | op->speed_left -= diff; |
1768 | op->speed_left -= diff; |
1776 | } |
1769 | } |
1777 | } |
1770 | } |