- Timestamp:
- Apr 2, 2014, 8:38:07 PM (11 years ago)
- Location:
- code/branches/modularships/src/modules/weapons/projectiles
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.cc
r9995 r10011 78 78 @see Pawn.h 79 79 */ 80 bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint )80 bool BasicProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) 81 81 { 82 82 if (!this->bDestroy_ && GameMode::isMaster()) … … 96 96 if (victim) 97 97 { 98 victim->hit(this->getShooter(), contactPoint, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());98 victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage()); 99 99 victim->startReloadCountdown(); 100 100 } … … 141 141 } 142 142 143 bool BasicProjectile::customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)144 {145 if (!this->bDestroy_ && GameMode::isMaster())146 {147 if (otherObject == this->getShooter()) // Prevents you from shooting yourself148 return false;149 150 this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.151 // The projectile is destroyed by its tick()-function (in the following tick).152 153 Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is NULL154 155 WorldEntity* entity = orxonox_cast<WorldEntity*>(this);156 assert(entity); // The projectile must not be a WorldEntity.157 158 // If visual effects after destruction cause problems, put this block below the effects code block159 if (victim)160 {161 victim->customHit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());162 victim->startReloadCountdown();163 }164 165 // Visual effects for being hit, depending on whether the shield is hit or not166 if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed.167 {168 // Damping and explosion effect is only played if the victim is no Pawn (see cast above)169 // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health170 if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f)))171 {172 {173 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());174 effect->setPosition(entity->getPosition());175 effect->setOrientation(entity->getOrientation());176 effect->setDestroyAfterLife(true);177 effect->setSource("Orxonox/explosion3");178 effect->setLifetime(2.0f);179 }180 // Second effect with same condition181 {182 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());183 effect->setPosition(entity->getPosition());184 effect->setOrientation(entity->getOrientation());185 effect->setDestroyAfterLife(true);186 effect->setSource("Orxonox/smoke4");187 effect->setLifetime(3.0f);188 }189 }190 191 // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead192 if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f)193 {194 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());195 effect->setDestroyAfterLife(true);196 effect->setSource("Orxonox/Shield");197 effect->setLifetime(0.5f);198 victim->attach(effect);199 }200 }201 return true;202 }203 return false;204 }205 143 206 144 /** -
code/branches/modularships/src/modules/weapons/projectiles/BasicProjectile.h
r9995 r10011 119 119 120 120 protected: 121 bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint); 122 bool customProcessCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 121 bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 123 122 void destroyCheck(void); 124 123 -
code/branches/modularships/src/modules/weapons/projectiles/Projectile.cc
r9995 r10011 88 88 } 89 89 90 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)90 bool Projectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 91 91 { 92 return this->processCollision(otherObject, contactPoint); 93 } 94 95 bool Projectile::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 96 { 97 return this->customProcessCollision(otherObject, contactPoint, cs); 92 return this->processCollision(otherObject, contactPoint, cs); 98 93 } 99 94 -
code/branches/modularships/src/modules/weapons/projectiles/Projectile.h
r9995 r10011 64 64 65 65 virtual void tick(float dt); 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 69 68 private: -
code/branches/modularships/src/modules/weapons/projectiles/Rocket.cc
r9995 r10011 191 191 } 192 192 193 bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 194 { 195 return this->processCollision(otherObject, contactPoint); 196 } 197 198 bool Rocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 199 { 200 return this->customProcessCollision(otherObject, contactPoint, cs); 193 bool Rocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 194 { 195 return this->processCollision(otherObject, contactPoint, cs); 201 196 } 202 197 -
code/branches/modularships/src/modules/weapons/projectiles/Rocket.h
r9995 r10011 64 64 virtual void tick(float dt); //!< Defines which actions the Rocket has to take in each tick. 65 65 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 virtual void destroyObject(void); 69 68 void destructionEffect(); -
code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.cc
r9995 r10011 172 172 } 173 173 174 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 175 { 176 return this->processCollision(otherObject, contactPoint); 177 } 178 179 bool SimpleRocket::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 180 { 181 return this->customProcessCollision(otherObject, contactPoint, cs); 174 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 175 { 176 return this->processCollision(otherObject, contactPoint, cs); 182 177 } 183 178 -
code/branches/modularships/src/modules/weapons/projectiles/SimpleRocket.h
r9995 r10011 64 64 virtual void tick(float dt); 65 65 66 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 67 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 66 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 68 67 69 68 void disableFire(); //!< Method to disable the fire and stop all acceleration
Note: See TracChangeset
for help on using the changeset viewer.