Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2009, 3:21:12 AM (15 years ago)
Author:
landauf
Message:

added TeamGametype

File:
1 edited

Legend:

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

    r2662 r2768  
    140140    void Pawn::damage(float damage, Pawn* originator)
    141141    {
    142         this->setHealth(this->health_ - damage);
    143         this->lastHitOriginator_ = originator;
    144 
    145         // play damage effect
     142        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
     143        {
     144            this->setHealth(this->health_ - damage);
     145            this->lastHitOriginator_ = originator;
     146
     147            // play damage effect
     148        }
    146149    }
    147150
    148151    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    149152    {
    150         this->damage(damage, originator);
    151         this->setVelocity(this->getVelocity() + force);
    152 
    153         // play hit effect
     153        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
     154        {
     155            this->damage(damage, originator);
     156            this->setVelocity(this->getVelocity() + force);
     157
     158            // play hit effect
     159        }
    154160    }
    155161
     
    176182    void Pawn::death()
    177183    {
    178         // Set bAlive_ to false and wait for PawnManager to do the destruction
    179         this->bAlive_ = false;
    180 
    181         this->setDestroyWhenPlayerLeft(false);
    182 
    183         if (this->getGametype())
    184             this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
    185 
    186         if (this->getPlayer())
    187             this->getPlayer()->stopControl(this);
    188 
    189         if (Core::isMaster())
    190             this->deatheffect();
     184        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
     185        {
     186            // Set bAlive_ to false and wait for PawnManager to do the destruction
     187            this->bAlive_ = false;
     188
     189            this->setDestroyWhenPlayerLeft(false);
     190
     191            if (this->getGametype())
     192                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
     193
     194            if (this->getPlayer())
     195                this->getPlayer()->stopControl(this);
     196
     197            if (Core::isMaster())
     198                this->deatheffect();
     199        }
     200        else
     201            this->setHealth(1);
    191202    }
    192203
Note: See TracChangeset for help on using the changeset viewer.