Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2011, 9:28:29 PM (13 years ago)
Author:
dafrick
Message:

Reverse merge to revert last, failed, merge. Apparently you can't partially commit a merge.

File:
1 edited

Legend:

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

    r8578 r8579  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      simonmie
     25 *      ...
    2626 *
    2727 */
     
    6464        this->maxHealth_ = 0;
    6565        this->initialHealth_ = 0;
    66 
    6766        this->shieldHealth_ = 0;
    68         this->initialShieldHealth_ = 0;
    69         this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
    7067        this->shieldAbsorption_ = 0.5;
    71 
    72         this->reloadRate_ = 0;
    73         this->reloadWaitTime_ = 1.0f;
    74         this->reloadWaitCountdown_ = 0;
    7568
    7669        this->lastHitOriginator_ = 0;
     
    116109
    117110        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
    118         XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
    119         XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
    120111        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
    121112
     
    127118        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    128119        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    129 
    130         XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    131         XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
    132120    }
    133121
     
    136124        registerVariable(this->bAlive_,           VariableDirection::ToClient);
    137125        registerVariable(this->health_,           VariableDirection::ToClient);
    138         registerVariable(this->maxHealth_,        VariableDirection::ToClient);
     126        registerVariable(this->initialHealth_,    VariableDirection::ToClient);
    139127        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
    140         registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    141128        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    142129        registerVariable(this->bReload_,          VariableDirection::ToServer);
     
    150137        this->bReload_ = false;
    151138
    152         // TODO: use the existing timer functions instead
    153         if(this->reloadWaitCountdown_ > 0)
    154         {
    155             this->decreaseReloadCountdownTime(dt);
    156         }
    157         else
    158         {
    159             this->addShieldHealth(this->getReloadRate() * dt);
    160             this->resetReloadCountdown();
    161         }
    162 
    163139        if (GameMode::isMaster())
    164         {
    165140            if (this->health_ <= 0 && bAlive_)
    166141            {
    167                 this->fireEvent(); // Event to notify anyone who wants to know about the death.
     142                this->fireEvent(); // Event to notify anyone who want's to know about the death.
    168143                this->death();
    169144            }
    170         }
    171145    }
    172146
     
    194168    }
    195169
    196 
    197170    void Pawn::setHealth(float health)
    198171    {
    199         this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit
    200     }
    201 
    202     void Pawn::setShieldHealth(float shieldHealth)
    203     {
    204         this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
    205     }
    206 
    207     void Pawn::setMaxShieldHealth(float maxshieldhealth)
    208     {
    209         this->maxShieldHealth_ = maxshieldhealth;
    210     }
    211 
    212     void Pawn::setReloadRate(float reloadrate)
    213     {
    214         this->reloadRate_ = reloadrate;
    215     }
    216 
    217     void Pawn::setReloadWaitTime(float reloadwaittime)
    218     {
    219         this->reloadWaitTime_ = reloadwaittime;
    220     }
    221 
    222     void Pawn::decreaseReloadCountdownTime(float dt)
    223     {
    224         this->reloadWaitCountdown_ -= dt;
    225     }
    226 
    227     void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     172        this->health_ = std::min(health, this->maxHealth_);
     173    }
     174
     175    void Pawn::damage(float damage, Pawn* originator)
    228176    {
    229177        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    230178        {
    231             if (shielddamage >= this->getShieldHealth())
     179            //share the dealt damage to the shield and the Pawn.
     180            float shielddamage = damage*this->shieldAbsorption_;
     181            float healthdamage = damage*(1-this->shieldAbsorption_);
     182
     183            // In case the shield can not take all the shield damage.
     184            if (shielddamage > this->getShieldHealth())
    232185            {
     186                healthdamage += shielddamage-this->getShieldHealth();
    233187                this->setShieldHealth(0);
    234                 this->setHealth(this->health_ - (healthdamage + damage));
    235188            }
    236             else
     189
     190            this->setHealth(this->health_ - healthdamage);
     191
     192            if (this->getShieldHealth() > 0)
    237193            {
    238194                this->setShieldHealth(this->shieldHealth_ - shielddamage);
    239 
    240                 // remove remaining shieldAbsorpton-Part of damage from shield
    241                 shielddamage = damage * this->shieldAbsorption_;
    242                 shielddamage = std::min(this->getShieldHealth(),shielddamage);
    243                 this->setShieldHealth(this->shieldHealth_ - shielddamage);
    244 
    245                 // set remaining damage to health
    246                 this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
    247195            }
    248196
    249197            this->lastHitOriginator_ = originator;
    250         }
    251     }
    252 
    253 // TODO: Still valid?
    254 /* HIT-Funktionen
    255     Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
    256 
    257 */
    258 
    259     void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
     198
     199            // play damage effect
     200        }
     201    }
     202
     203    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    260204    {
    261205        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    262206        {
    263             this->damage(damage, healthdamage, shielddamage, originator);
     207            this->damage(damage, originator);
    264208            this->setVelocity(this->getVelocity() + force);
    265         }
    266     }
    267 
    268 
    269     void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
     209
     210            // play hit effect
     211        }
     212    }
     213
     214    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
    270215    {
    271216        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    272217        {
    273             this->damage(damage, healthdamage, shielddamage, originator);
     218            this->damage(damage, originator);
    274219
    275220            if ( this->getController() )
    276                 this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
    277         }
    278     }
    279 
     221                this->getController()->hit(originator, contactpoint, damage);
     222
     223            // play hit effect
     224        }
     225    }
    280226
    281227    void Pawn::kill()
Note: See TracChangeset for help on using the changeset viewer.