- Timestamp:
- May 10, 2010, 4:23:29 PM (15 years ago)
- 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 64 64 this->maxHealth_ = 0; 65 65 this->initialHealth_ = 0; 66 this->shieldHealth_ = 0; 67 this->shieldAbsorption_ = 0; 66 68 67 69 this->lastHitOriginator_ = 0; … … 105 107 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 106 108 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 107 113 XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); 108 114 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); … … 116 122 void Pawn::registerVariables() 117 123 { 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); 123 131 } 124 132 … … 159 167 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 160 168 { 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 162 187 this->lastHitOriginator_ = originator; 163 188 … … 165 190 } 166 191 } 167 192 168 193 void Pawn::hit(Pawn* originator, const Vector3& force, float damage) 169 194 { -
code/branches/ppspickups3/src/orxonox/worldentities/pawns/Pawn.h
r6711 r6884 73 73 { return this->initialHealth_; } 74 74 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 75 85 inline ControllableEntity* getLastHitOriginator() const 76 86 { return this->lastHitOriginator_; } … … 141 151 float maxHealth_; 142 152 float initialHealth_; 153 float shieldHealth_; 154 float shieldAbsorption_; // Has to be between 0 and 1 143 155 144 156 Pawn* lastHitOriginator_;
Note: See TracChangeset
for help on using the changeset viewer.