Changeset 9995 for code/branches/modularships/src/orxonox/worldentities
- Timestamp:
- Mar 9, 2014, 9:01:44 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox/worldentities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/worldentities/MovableEntity.cc
r9667 r9995 87 87 } 88 88 89 bool MovableEntity::customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 90 { 91 if (GameMode::isMaster() && enableCollisionDamage_) 92 { 93 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 94 if (victim) 95 { 96 float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length(); 97 victim->customHit(0, contactPoint, ownCollisionShape, damage); 98 } 99 } 100 101 return false; 102 } 103 89 104 90 105 void MovableEntity::registerVariables() -
code/branches/modularships/src/orxonox/worldentities/MovableEntity.h
r9667 r9995 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 50 virtual bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 50 51 51 52 using WorldEntity::setPosition; -
code/branches/modularships/src/orxonox/worldentities/WorldEntity.h
r9667 r9995 375 375 */ 376 376 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 377 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 378 379 virtual inline bool customCollidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 377 380 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 378 381 -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
r9950 r9995 274 274 } 275 275 276 void Pawn::customDamage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 277 { 278 // Applies multiplier given by the DamageBoost Pickup. 279 if (originator) 280 damage *= originator->getDamageMultiplier(); 281 282 orxout() << "damage(): Custom collision detected on CS: " << cs << endl; 283 284 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 285 { 286 if (shielddamage >= this->getShieldHealth()) 287 { 288 this->setShieldHealth(0); 289 this->setHealth(this->health_ - (healthdamage + damage)); 290 } 291 else 292 { 293 this->setShieldHealth(this->shieldHealth_ - shielddamage); 294 295 // remove remaining shieldAbsorpton-Part of damage from shield 296 shielddamage = damage * this->shieldAbsorption_; 297 shielddamage = std::min(this->getShieldHealth(),shielddamage); 298 this->setShieldHealth(this->shieldHealth_ - shielddamage); 299 300 // set remaining damage to health 301 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage); 302 } 303 304 this->lastHitOriginator_ = originator; 305 } 306 } 307 276 308 // TODO: Still valid? 277 309 /* HIT-Funktionen … … 288 320 } 289 321 322 void Pawn::customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 323 { 324 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 325 { 326 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 327 this->setVelocity(this->getVelocity() + force); 328 } 329 } 290 330 291 331 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) … … 294 334 { 295 335 this->damage(damage, healthdamage, shielddamage, originator); 336 337 if ( this->getController() ) 338 this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 339 } 340 } 341 342 void Pawn::customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 343 { 344 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 345 { 346 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 296 347 297 348 if ( this->getController() ) -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
r9948 r9995 127 127 //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 128 128 virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 129 virtual void customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 129 130 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 131 virtual void customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 130 132 131 133 virtual void kill(); … … 197 199 //virtual void damage(float damage, Pawn* originator = 0); 198 200 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL); 201 virtual void customDamage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 199 202 200 203 bool bAlive_;
Note: See TracChangeset
for help on using the changeset viewer.