Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2014, 8:38:07 PM (10 years ago)
Author:
noep
Message:

Cleaned up the process passing the collisionshape which was hit to the Pawn. Started implementation of ModularSpaceShip and ShipPart.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc

    r10007 r10011  
    250250    }
    251251
    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
    254259        // Applies multiplier given by the DamageBoost Pickup.
    255260        if (originator)
     
    280285    }
    281286
    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             else
    301             {
    302                 this->setShieldHealth(this->shieldHealth_ - shielddamage);
    303 
    304                 // remove remaining shieldAbsorpton-Part of damage from shield
    305                 shielddamage = damage * this->shieldAbsorption_;
    306                 shielddamage = std::min(this->getShieldHealth(),shielddamage);
    307                 this->setShieldHealth(this->shieldHealth_ - shielddamage);
    308 
    309                 // set remaining damage to health
    310                 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
    311             }
    312 
    313             this->lastHitOriginator_ = originator;
    314         }
    315     }
    316 
    317287// TODO: Still valid?
    318288/* HIT-Funktionen
     
    320290
    321291*/
    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)
    323293    {
    324294        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    325295        {
    326             this->damage(damage, healthdamage, shielddamage, originator);
     296            this->damage(damage, healthdamage, shielddamage, originator, cs);
    327297            this->setVelocity(this->getVelocity() + force);
    328298        }
    329299    }
    330300
    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)
    332302    {
    333303        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    334304        {
    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);
    356306
    357307            if ( this->getController() )
     
    620570    }
    621571
    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
    624573    int Pawn::isMyCollisionShape(const btCollisionShape* cs)
    625574    {
     
    628577
    629578        // e.g. "Box 4: Searching for CS 0x1ad49200"
    630         orxout() << this->getRadarName() << ": Searching for btCS* " << cs << endl;
     579        orxout() << this->getName() << ": Searching for btCS* " << cs << endl;
    631580        // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
    632         orxout() << "  " << this->getRadarName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
     581        orxout() << "  " << this->getName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
    633582        // e.g. "Box 4 is WorldEntity 0x126dd060"
    634         orxout() << "  " << this->getRadarName() << " is WorldEntity* " << this << endl;
     583        orxout() << "  " << this->getName() << " is WorldEntity* " << this << endl;
    635584        // e.g. "Box 4 is objectID 943"
    636         orxout() << "  " << this->getRadarName() << " is objectID " << this->getObjectID() << endl;
     585        orxout() << "  " << this->getName() << " is objectID " << this->getObjectID() << endl;
    637586
    638587        // List all attached Objects
    639         orxout() << "  " << this->getRadarName() << " has the following Objects attached:" << endl;
     588        orxout() << "  " << this->getName() << " has the following Objects attached:" << endl;
    640589        for (int i=0; i<10; i++)
    641590        {
    642591            if (this->getAttachedObject(i)==NULL)
    643592                break;
    644             orxout() << " " << i << ": " << this->getAttachedObject(i);
     593            orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")";
    645594            if(!orxonox_cast<Model*>(this->getAttachedObject(i)))
    646595                orxout() << " (SE)";
     
    648597        }
    649598
    650         if (this->health_ < 800)
    651             this->detach(this->getAttachedObject(2));
    652599
    653600        // print child shapes of this WECS
     
    656603        int temp = entityOfCollisionShape(cs);
    657604        if (temp==0)
    658             orxout() << this->getRadarName() << " has been hit on it's main body." << endl;
    659         else
    660             orxout() << this->getRadarName() << " 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;
    661608
    662609        // end
     
    680627
    681628                // 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;
    683630            }
    684631
Note: See TracChangeset for help on using the changeset viewer.