| 1706 | } |
| 1707 | |
| 1708 | void bump_two_objects(object *object0, object *object1, vector *collision_point, vector *collision_normal, |
| 1709 | int damage_flag) { |
| 1710 | object *t = nullptr; |
| 1711 | object *other = nullptr; |
| 1712 | |
| 1713 | // Determine if a moving object hits a non-moving object |
| 1714 | if ((object0->movement_type != MT_PHYSICS && object0->movement_type != MT_WALKING) || |
| 1715 | (object0->movement_type == MT_PHYSICS && object0->mtype.phys_info.velocity == Zero_vector && |
| 1716 | (object0->mtype.phys_info.flags & PF_LOCK_MASK) && (object0->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { |
| 1717 | t = object1; |
| 1718 | other = object0; |
| 1719 | *collision_normal *= -1.0f; |
| 1720 | } |
| 1721 | if ((object1->movement_type != MT_PHYSICS && object1->movement_type != MT_WALKING) || |
| 1722 | (object1->movement_type == MT_PHYSICS && object1->mtype.phys_info.velocity == Zero_vector && |
| 1723 | (object1->mtype.phys_info.flags & PF_LOCK_MASK) && (object1->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { |
| 1724 | t = object0; |
| 1725 | other = object1; |
| 1726 | } |
| 1727 | |
| 1728 | // If we hit a non-moving object... |
| 1729 | if (t) { |
| 1730 | // chrishack -- walker hack |
| 1731 | if (t->movement_type != MT_PHYSICS && t->movement_type != MT_WALKING) { |
| 1732 | t->mtype.phys_info.velocity = Zero_vector; |
| 1733 | return; |
| 1734 | } |
| 1735 | |
| 1736 | if (t->mtype.phys_info.flags & PF_PERSISTENT) |
| 1737 | return; |
| 1738 | |
| 1739 | vector moved_v; |
| 1740 | float wall_part; |
| 1741 | |
| 1742 | float luke_test; |
| 1743 | |
| 1744 | if (t->type == OBJ_PLAYER) { |
| 1745 | luke_test = vm_GetMagnitude(&t->mtype.phys_info.velocity); |
| 1746 | } |
| 1747 | |
| 1748 | if (!(t->flags & OF_DEAD)) { |
| 1749 | // Find hit speed |
| 1750 | moved_v = t->pos - t->last_pos; |
| 1751 | wall_part = *collision_normal * t->mtype.phys_info.velocity; |
| 1752 | |
| 1753 | if (t->mtype.phys_info.flags & PF_BOUNCE) { |
| 1754 | wall_part *= 2.0; // Subtract out wall part twice to achieve bounce |
| 1755 | |
| 1756 | // New bounceness code |
| 1757 | if ((t->mtype.phys_info.flags & PF_BOUNCE) && (t->mtype.phys_info.num_bounces != PHYSICS_UNLIMITED_BOUNCE)) { |
| 1758 | if (t->mtype.phys_info.num_bounces == 0) { |
| 1759 | ASSERT(t->type != OBJ_PLAYER); |
| 1760 | if (t->flags & OF_DYING) { |
| 1761 | ASSERT((t->control_type == CT_DYING) || (t->control_type == CT_DYING_AND_AI)); |
| 1762 | DestroyObject(t, 50.0, t->ctype.dying_info.death_flags); |
| 1763 | } else |
| 1764 | SetObjectDeadFlag(t); |
| 1765 | } |
no test coverage detected