Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2014, 9:01:44 PM (11 years ago)
Author:
noep
Message:

Modified collision-detecting-process, such that collisions can be traced back to single child-CollisionShapes of Compound-CollisionShapes

File:
1 edited

Legend:

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

    r9950 r9995  
    274274    }
    275275
     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
    276308// TODO: Still valid?
    277309/* HIT-Funktionen
     
    288320    }
    289321
     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    }
    290330
    291331    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
     
    294334        {
    295335            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);
    296347
    297348            if ( this->getController() )
Note: See TracChangeset for help on using the changeset viewer.