… | |
… | |
1479 | * blocked() and wall() work properly), and these flags are updated by |
1479 | * blocked() and wall() work properly), and these flags are updated by |
1480 | * update_object(). |
1480 | * update_object(). |
1481 | */ |
1481 | */ |
1482 | |
1482 | |
1483 | /* 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 */ |
1484 | if (!(flag & INS_NO_WALK_ON) && op->head_ () == op) |
1484 | if (!(flag & INS_NO_WALK_ON) && op->is_head ()) |
1485 | { |
1485 | { |
1486 | if (check_move_on (op, originator)) |
1486 | if (check_move_on (op, originator)) |
1487 | return 0; |
1487 | return 0; |
1488 | |
1488 | |
1489 | /* 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 |
… | |
… | |
1704 | * on top. |
1704 | * on top. |
1705 | */ |
1705 | */ |
1706 | int |
1706 | int |
1707 | check_move_on (object *op, object *originator) |
1707 | check_move_on (object *op, object *originator) |
1708 | { |
1708 | { |
|
|
1709 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
|
|
1710 | return 0; |
|
|
1711 | |
1709 | object *tmp; |
1712 | object *tmp; |
1710 | maptile *m = op->map; |
1713 | maptile *m = op->map; |
1711 | int x = op->x, y = op->y; |
1714 | int x = op->x, y = op->y; |
1712 | |
1715 | |
1713 | MoveType move_on, move_slow, move_block; |
1716 | mapspace &ms = m->at (x, y); |
1714 | |
1717 | |
1715 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
1718 | ms.update (); |
1716 | return 0; |
|
|
1717 | |
1719 | |
1718 | move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); |
1720 | MoveType move_on = ms.move_on; |
1719 | move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); |
1721 | MoveType move_slow = ms.move_slow; |
1720 | move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); |
1722 | MoveType move_block = ms.move_block; |
1721 | |
1723 | |
1722 | /* 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, |
1723 | * 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 |
1724 | * 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 |
1725 | * as walking. |
1727 | * as walking. |
… | |
… | |
1736 | return 0; |
1738 | return 0; |
1737 | |
1739 | |
1738 | /* The objects have to be checked from top to bottom. |
1740 | /* The objects have to be checked from top to bottom. |
1739 | * Hence, we first go to the top: |
1741 | * Hence, we first go to the top: |
1740 | */ |
1742 | */ |
1741 | |
1743 | for (object *next, *tmp = ms.top; tmp; tmp = next) |
1742 | for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above) |
|
|
1743 | { |
|
|
1744 | /* Trim the search when we find the first other spell effect |
|
|
1745 | * this helps performance so that if a space has 50 spell objects, |
|
|
1746 | * we don't need to check all of them. |
|
|
1747 | */ |
|
|
1748 | if ((tmp->move_type & MOVE_FLY_LOW) && QUERY_FLAG (tmp, FLAG_NO_PICK)) |
|
|
1749 | break; |
|
|
1750 | } |
1744 | { |
|
|
1745 | next = tmp->below; |
1751 | |
1746 | |
1752 | for (; tmp; tmp = tmp->below) |
|
|
1753 | { |
|
|
1754 | if (tmp == op) |
1747 | if (tmp == op) |
1755 | continue; /* Can't apply yourself */ |
1748 | continue; /* Can't apply yourself */ |
1756 | |
1749 | |
1757 | /* 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. |
1758 | * Second check makes sure that the movement types not being slowed |
1751 | * Second check makes sure that the movement types not being slowed |
… | |
… | |
1763 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1756 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1764 | { |
1757 | { |
1765 | if ((!op->move_type && tmp->move_slow & MOVE_WALK) || |
1758 | if ((!op->move_type && tmp->move_slow & MOVE_WALK) || |
1766 | ((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)) |
1767 | { |
1760 | { |
1768 | |
|
|
1769 | float |
|
|
1770 | diff = tmp->move_slow_penalty * fabs (op->speed); |
1761 | float diff = tmp->move_slow_penalty * fabs (op->speed); |
1771 | |
1762 | |
1772 | if (op->is_player ()) |
1763 | if (op->is_player ()) |
1773 | 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)) || |
1774 | (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))) |
1775 | diff /= 4.0; |
1766 | diff /= 4.0; |
1776 | |
1767 | |
1777 | op->speed_left -= diff; |
1768 | op->speed_left -= diff; |
1778 | } |
1769 | } |
1779 | } |
1770 | } |