Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2010, 11:50:24 PM (14 years ago)
Author:
dafrick
Message:

Merged pickup branch into presentation3 branch.
Seems to be working just fine so not much changes at all. (Except for some representations that had the parameters 'name' instead of 'pickupName' and 'description' instead of 'pickupDescription').

Location:
code/branches/presentation3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3

  • code/branches/presentation3/src/orxonox/controllers/AIController.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc

    r6942 r6998  
    6666        this->maxHealth_ = 0;
    6767        this->initialHealth_ = 0;
     68        this->shieldHealth_ = 0;
     69        this->shieldAbsorption_ = 0.5;
    6870
    6971        this->lastHitOriginator_ = 0;
     
    8082        else
    8183            this->weaponSystem_ = 0;
    82        
     84
    8385        this->setCarrierName("Pawn");
    8486
     
    107109        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    108110        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     111
     112        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
     113        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
     114
    109115        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
    110116        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     
    118124    void Pawn::registerVariables()
    119125    {
    120         registerVariable(this->bAlive_,        VariableDirection::ToClient);
    121         registerVariable(this->health_,        VariableDirection::ToClient);
    122         registerVariable(this->initialHealth_, VariableDirection::ToClient);
    123         registerVariable(this->bReload_,       VariableDirection::ToServer);
    124         registerVariable(this->aimPosition_,   Bidirectionality::ServerMaster, 0, true);
     126        registerVariable(this->bAlive_,           VariableDirection::ToClient);
     127        registerVariable(this->health_,           VariableDirection::ToClient);
     128        registerVariable(this->initialHealth_,    VariableDirection::ToClient);
     129        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
     130        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
     131        registerVariable(this->bReload_,          VariableDirection::ToServer);
     132        registerVariable(this->aimPosition_,      Bidirectionality::ServerMaster, 0, true);
    125133    }
    126134
     
    164172        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    165173        {
    166             this->setHealth(this->health_ - damage);
     174            //share the dealt damage to the shield and the Pawn.
     175            float shielddamage = damage*this->shieldAbsorption_;
     176            float healthdamage = damage*(1-this->shieldAbsorption_);
     177
     178            // In case the shield can not take all the shield damage.
     179            if (shielddamage > this->getShieldHealth())
     180            {
     181                healthdamage += shielddamage-this->getShieldHealth();
     182                this->setShieldHealth(0);
     183            }
     184
     185            this->setHealth(this->health_ - healthdamage);
     186
     187            if (this->getShieldHealth() > 0)
     188            {
     189                this->setShieldHealth(this->shieldHealth_ - shielddamage);
     190            }
     191
    167192            this->lastHitOriginator_ = originator;
    168193
  • code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h

    r6711 r6998  
    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.