From 529e80912f5a62eba69190aadf026a6cf1e27ea4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 10 Oct 2012 22:07:10 +0000 Subject: Made mines interact with any EntityDynamic or EntityControlable instead of just ships --- src/game/base/spacemine.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/game/base') diff --git a/src/game/base/spacemine.cc b/src/game/base/spacemine.cc index 74ad185..75fe8fa 100644 --- a/src/game/base/spacemine.cc +++ b/src/game/base/spacemine.cc @@ -66,20 +66,20 @@ void SpaceMine::collision(core::Entity *other) } // mines explode on impact - - if (other->moduletype() == ship_enttype) { - Ship *ship = static_cast(other); + if ((other->type() == core::Entity::Dynamic) || (other->type() == core::Entity::Controlable)) { - math::Vector3f explosion_direction(ship->location() - location()); + core::EntityDynamic *entity = static_cast(other); + + math::Vector3f explosion_direction(entity->location() - location()); explosion_direction.normalize(); math::Vector3f explosion_torque(math::randomf(2.0f) - 1.0f, math::randomf(2.0f) - 1.0f, math::randomf(2.0f) - 1.0f); + explosion_torque.normalize(); - // explosion force has the same magnitude as an impulse engine - // note: this has nothing to do with amount of damage - - ship->body()->applyCentralImpulse(math::to_btVector3(explosion_direction * ship->impulse_force() * 5.0f)); - ship->body()->applyTorqueImpulse(math::to_btVector3(explosion_torque * ship->impulse_force() * 0.1f)); + const float force = math::max(entity->mass(), entity->radius() * 100.0f); + + entity->body()->applyCentralImpulse(math::to_btVector3(explosion_direction * force )); + entity->body()->applyTorqueImpulse(math::to_btVector3(explosion_torque * force * 0.1f)); } set_state(core::Entity::Destroyed); -- cgit v1.2.3