Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2010, 4:23:29 PM (14 years ago)
Author:
benedict
Message:

did the shield pickup. upload for testing

Location:
code/branches/ppspickups3/src/orxonox/worldentities/pawns
Files:
2 edited

Legend:

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

    r6711 r6884  
    6464        this->maxHealth_ = 0;
    6565        this->initialHealth_ = 0;
     66        this->shieldHealth_ = 0;
     67        this->shieldAbsorption_ = 0;
    6668
    6769        this->lastHitOriginator_ = 0;
     
    105107        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    106108        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     109       
     110        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
     111        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
     112       
    107113        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
    108114        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     
    116122    void Pawn::registerVariables()
    117123    {
    118         registerVariable(this->bAlive_,        VariableDirection::ToClient);
    119         registerVariable(this->health_,        VariableDirection::ToClient);
    120         registerVariable(this->initialHealth_, VariableDirection::ToClient);
    121         registerVariable(this->bReload_,       VariableDirection::ToServer);
    122         registerVariable(this->aimPosition_,   Bidirectionality::ServerMaster, 0, true);
     124        registerVariable(this->bAlive_,           VariableDirection::ToClient);
     125        registerVariable(this->health_,           VariableDirection::ToClient);
     126        registerVariable(this->initialHealth_,    VariableDirection::ToClient);
     127        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
     128        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
     129        registerVariable(this->bReload_,          VariableDirection::ToServer);
     130        registerVariable(this->aimPosition_,      Bidirectionality::ServerMaster, 0, true);
    123131    }
    124132
     
    159167        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    160168        {
    161             this->setHealth(this->health_ - damage);
     169            //share the dealt damage to the shield and the Pawn.
     170            float shielddamage = damage*this->shieldAbsorption_;
     171            float healthdamage = damage*(1-this->shieldAbsorption_);
     172           
     173            // In case the shield can not take all the shield damage.
     174            if (shielddamage > this->getShieldHealth())
     175            {
     176                healthdamage += shielddamage-this->getShieldHealth();
     177                this->setShieldHealth(0);
     178            }
     179
     180            this->setHealth(this->health_ - healthdamage);
     181           
     182            if (this->getShieldHealth() > 0)
     183            {
     184                this->setShieldHealth(this->shieldHealth_ - shielddamage);
     185            }
     186
    162187            this->lastHitOriginator_ = originator;
    163188
     
    165190        }
    166191    }
    167 
     192   
    168193    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    169194    {
  • code/branches/ppspickups3/src/orxonox/worldentities/pawns/Pawn.h

    r6711 r6884  
    7373                { return this->initialHealth_; }
    7474
     75            inline void setShieldHealth(float shieldHealth)
     76            { this->shieldHealth_ = shieldHealth; }
     77            inline float getShieldHealth()
     78            { return this->shieldHealth_; }
     79           
     80            inline void setShieldAbsorption(float shieldAbsorption)
     81            { this->shieldAbsorption_ = shieldAbsorption; }
     82            inline float getShieldAbsorption()
     83            { return this->shieldAbsorption_; }
     84
    7585            inline ControllableEntity* getLastHitOriginator() const
    7686                { return this->lastHitOriginator_; }
     
    141151            float maxHealth_;
    142152            float initialHealth_;
     153            float shieldHealth_;
     154            float shieldAbsorption_; // Has to be between 0 and 1
    143155
    144156            Pawn* lastHitOriginator_;
Note: See TracChangeset for help on using the changeset viewer.