diff options
author | Stijn Buys <ingar@osirion.org> | 2014-12-24 21:11:43 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2014-12-24 21:11:43 +0000 |
commit | 0c6499e6789db9686bcea3bb3b7f782c2f659eb7 (patch) | |
tree | 3ffe09ff82fa1f8ffd27c9b6c522993d854cd649 /src/core | |
parent | f330ae5ed3bd73c7b5b582cccde6cdd91d3c6e5b (diff) |
Prevent projectiles from hitting the enity that fired it, prevent projectiles from hitting each other.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/entityprojectile.cc | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/core/entityprojectile.cc b/src/core/entityprojectile.cc index 440c46b..ac016e0 100644 --- a/src/core/entityprojectile.cc +++ b/src/core/entityprojectile.cc @@ -60,13 +60,28 @@ void EntityProjectile::upkeep(const unsigned long timestamp) void EntityProjectile::collision(Entity *other) { - if (state() == Entity::Destroyed) { + if (state() == Entity::Destroyed) + { return; - } else { - if ((other->type() == Dynamic) || (other->type() == Controlable)) { - static_cast<EntityDynamic *>(other)->hit(this); + } else + { + if (other->id() == projectile_spawn_id) + { + // don't shoot yourself + return; + } + switch(other->type()) + { + case Projectile: + return; + break; + case Dynamic: + case Controlable: + static_cast<EntityDynamic *>(other)->hit(this); + default: + set_state(Entity::Destroyed); + break; } - set_state(Entity::Destroyed); } } @@ -171,7 +186,7 @@ void EntityProjectile::reset() // point the bullet user pointer to the entity entity_body->setUserPointer((void *) this); // enable custom collision callback - entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); + entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK | btCollisionObject::CF_NO_CONTACT_RESPONSE); //entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); if (entity_mass) { |