Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-10-10 22:07:10 +0000
committerStijn Buys <ingar@osirion.org>2012-10-10 22:07:10 +0000
commit529e80912f5a62eba69190aadf026a6cf1e27ea4 (patch)
treeb79749bf7b110a26874254a90149f22d769247d2 /src/game/base
parentfe77356f14255d86fe61130d1939243ce7fc59b1 (diff)
Made mines interact with any EntityDynamic or EntityControlable instead of just ships
Diffstat (limited to 'src/game/base')
-rw-r--r--src/game/base/spacemine.cc18
1 files changed, 9 insertions, 9 deletions
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<Ship *>(other);
+ if ((other->type() == core::Entity::Dynamic) || (other->type() == core::Entity::Controlable)) {
- math::Vector3f explosion_direction(ship->location() - location());
+ core::EntityDynamic *entity = static_cast<core::EntityDynamic *>(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);