- Timestamp:
- Apr 2, 2014, 8:38:07 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox/worldentities/pawns
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/worldentities/pawns/CMakeLists.txt
r7163 r10011 4 4 Pawn.cc 5 5 SpaceShip.cc 6 ModularSpaceShip.cc 6 7 TeamBaseMatchBase.cc 7 8 Destroyer.cc -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
r10007 r10011 250 250 } 251 251 252 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 253 { 252 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 253 { 254 orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl; 255 256 int collisionShapeIndex = this->isMyCollisionShape(cs); 257 orxout() << collisionShapeIndex << endl; 258 254 259 // Applies multiplier given by the DamageBoost Pickup. 255 260 if (originator) … … 280 285 } 281 286 282 void Pawn::customDamage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)283 {284 orxout() << "damage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;285 286 int collisionShapeIndex = this->isMyCollisionShape(cs);287 orxout() << collisionShapeIndex << endl;288 289 // Applies multiplier given by the DamageBoost Pickup.290 if (originator)291 damage *= originator->getDamageMultiplier();292 293 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))294 {295 if (shielddamage >= this->getShieldHealth())296 {297 this->setShieldHealth(0);298 this->setHealth(this->health_ - (healthdamage + damage));299 }300 else301 {302 this->setShieldHealth(this->shieldHealth_ - shielddamage);303 304 // remove remaining shieldAbsorpton-Part of damage from shield305 shielddamage = damage * this->shieldAbsorption_;306 shielddamage = std::min(this->getShieldHealth(),shielddamage);307 this->setShieldHealth(this->shieldHealth_ - shielddamage);308 309 // set remaining damage to health310 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);311 }312 313 this->lastHitOriginator_ = originator;314 }315 }316 317 287 // TODO: Still valid? 318 288 /* HIT-Funktionen … … 320 290 321 291 */ 322 void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)292 void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 323 293 { 324 294 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 325 295 { 326 this->damage(damage, healthdamage, shielddamage, originator );296 this->damage(damage, healthdamage, shielddamage, originator, cs); 327 297 this->setVelocity(this->getVelocity() + force); 328 298 } 329 299 } 330 300 331 void Pawn:: customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)301 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 332 302 { 333 303 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 334 304 { 335 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 336 this->setVelocity(this->getVelocity() + force); 337 } 338 } 339 340 void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) 341 { 342 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 343 { 344 this->damage(damage, healthdamage, shielddamage, originator); 345 346 if ( this->getController() ) 347 this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 348 } 349 } 350 351 void Pawn::customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 352 { 353 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 354 { 355 this->customDamage(damage, healthdamage, shielddamage, originator, cs); 305 this->damage(damage, healthdamage, shielddamage, originator, cs); 356 306 357 307 if ( this->getController() ) … … 620 570 } 621 571 622 // WIP function that (once I get it working) determines to which attached entity a collisionshape belongs. 623 // Shame that this doesn't seem to work as intended. It behaves differently (different number of childshapes) every reload. D: 572 624 573 int Pawn::isMyCollisionShape(const btCollisionShape* cs) 625 574 { … … 628 577 629 578 // e.g. "Box 4: Searching for CS 0x1ad49200" 630 orxout() << this->get RadarName() << ": Searching for btCS* " << cs << endl;579 orxout() << this->getName() << ": Searching for btCS* " << cs << endl; 631 580 // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060" 632 orxout() << " " << this->get RadarName() << " is WorldEntityCollisionShape* " << ownWECS << endl;581 orxout() << " " << this->getName() << " is WorldEntityCollisionShape* " << ownWECS << endl; 633 582 // e.g. "Box 4 is WorldEntity 0x126dd060" 634 orxout() << " " << this->get RadarName() << " is WorldEntity* " << this << endl;583 orxout() << " " << this->getName() << " is WorldEntity* " << this << endl; 635 584 // e.g. "Box 4 is objectID 943" 636 orxout() << " " << this->get RadarName() << " is objectID " << this->getObjectID() << endl;585 orxout() << " " << this->getName() << " is objectID " << this->getObjectID() << endl; 637 586 638 587 // List all attached Objects 639 orxout() << " " << this->get RadarName() << " has the following Objects attached:" << endl;588 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 640 589 for (int i=0; i<10; i++) 641 590 { 642 591 if (this->getAttachedObject(i)==NULL) 643 592 break; 644 orxout() << " " << i << ": " << this->getAttachedObject(i) ;593 orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")"; 645 594 if(!orxonox_cast<Model*>(this->getAttachedObject(i))) 646 595 orxout() << " (SE)"; … … 648 597 } 649 598 650 if (this->health_ < 800)651 this->detach(this->getAttachedObject(2));652 599 653 600 // print child shapes of this WECS … … 656 603 int temp = entityOfCollisionShape(cs); 657 604 if (temp==0) 658 orxout() << this->get RadarName() << " has been hit on it's main body." << endl;659 else 660 orxout() << this->get RadarName() << " has been hit on the attached entity no. " << temp << endl;605 orxout() << this->getName() << " has been hit on it's main body." << endl; 606 else 607 orxout() << this->getName() << " has been hit on the attached entity no. " << temp << endl; 661 608 662 609 // end … … 680 627 681 628 // pointer to the btCollisionShape 682 printSpaces(indent+2); orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << endl;629 printSpaces(indent+2); orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << " (name_: " << ((BaseObject*)(cs->getChildShape(i)->getUserPointer()))->getName() << ")" << endl; 683 630 } 684 631 -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
r10007 r10011 126 126 //virtual void hit(Pawn* originator, const Vector3& force, float damage); 127 127 //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 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); 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); 128 virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 129 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 132 130 133 131 virtual void kill(); … … 198 196 199 197 //virtual void damage(float damage, Pawn* originator = 0); 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); 198 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 202 199 203 200 bool bAlive_;
Note: See TracChangeset
for help on using the changeset viewer.