Changeset 6998 for code/branches/presentation3/src/orxonox
- Timestamp:
- May 27, 2010, 11:50:24 PM (14 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
/code/branches/ppspickups3 (added) merged: 6869,6884,6887,6892-6896,6980,6985
- Property svn:mergeinfo changed
-
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 66 66 this->maxHealth_ = 0; 67 67 this->initialHealth_ = 0; 68 this->shieldHealth_ = 0; 69 this->shieldAbsorption_ = 0.5; 68 70 69 71 this->lastHitOriginator_ = 0; … … 80 82 else 81 83 this->weaponSystem_ = 0; 82 84 83 85 this->setCarrierName("Pawn"); 84 86 … … 107 109 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 108 110 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 109 115 XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); 110 116 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); … … 118 124 void Pawn::registerVariables() 119 125 { 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); 125 133 } 126 134 … … 164 172 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 165 173 { 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 167 192 this->lastHitOriginator_ = originator; 168 193 -
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.h
r6711 r6998 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.