Changeset 7163 for code/trunk/src/orxonox/worldentities/pawns
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/worldentities/pawns/CMakeLists.txt
r5781 r7163 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 FpsPlayer.cc 2 3 Spectator.cc 3 4 Pawn.cc -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r6864 r7163 53 53 CreateFactory(Pawn); 54 54 55 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) 55 Pawn::Pawn(BaseObject* creator) 56 : ControllableEntity(creator) 57 , RadarViewable(creator, static_cast<WorldEntity*>(this)) 56 58 { 57 59 RegisterObject(Pawn); … … 64 66 this->maxHealth_ = 0; 65 67 this->initialHealth_ = 0; 68 this->shieldHealth_ = 0; 69 this->shieldAbsorption_ = 0.5; 66 70 67 71 this->lastHitOriginator_ = 0; … … 78 82 else 79 83 this->weaponSystem_ = 0; 80 81 this->setCarrierName("Pawn");82 84 83 85 this->setRadarObjectColour(ColourValue::Red); … … 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_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server 123 131 } 124 132 … … 162 170 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 163 171 { 164 this->setHealth(this->health_ - damage); 172 //share the dealt damage to the shield and the Pawn. 173 float shielddamage = damage*this->shieldAbsorption_; 174 float healthdamage = damage*(1-this->shieldAbsorption_); 175 176 // In case the shield can not take all the shield damage. 177 if (shielddamage > this->getShieldHealth()) 178 { 179 healthdamage += shielddamage-this->getShieldHealth(); 180 this->setShieldHealth(0); 181 } 182 183 this->setHealth(this->health_ - healthdamage); 184 185 if (this->getShieldHealth() > 0) 186 { 187 this->setShieldHealth(this->shieldHealth_ - shielddamage); 188 } 189 165 190 this->lastHitOriginator_ = originator; 166 191 … … 336 361 { 337 362 if (this->weaponSystem_) 363 { 338 364 this->weaponSystem_->addWeaponPack(wPack); 365 this->addedWeaponPack(wPack); 366 } 339 367 } 340 368 … … 342 370 { 343 371 if (this->weaponSystem_) 372 { 344 373 if (!this->weaponSystem_->addWeaponPack(wPack)) 345 374 wPack->destroy(); 375 else 376 this->addedWeaponPack(wPack); 377 } 346 378 } 347 379 -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r6711 r7163 50 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 51 51 virtual void tick(float dt); 52 void registerVariables();53 52 54 53 inline bool isAlive() const … … 73 72 { return this->initialHealth_; } 74 73 74 inline void setShieldHealth(float shieldHealth) 75 { this->shieldHealth_ = shieldHealth; } 76 inline float getShieldHealth() 77 { return this->shieldHealth_; } 78 79 inline void setShieldAbsorption(float shieldAbsorption) 80 { this->shieldAbsorption_ = shieldAbsorption; } 81 inline float getShieldAbsorption() 82 { return this->shieldAbsorption_; } 83 75 84 inline ControllableEntity* getLastHitOriginator() const 76 85 { return this->lastHitOriginator_; } … … 91 100 void addWeaponPackXML(WeaponPack * wPack); 92 101 WeaponPack * getWeaponPack(unsigned int index) const; 102 103 virtual void addedWeaponPack(WeaponPack* wPack) {} 93 104 94 105 inline const WorldEntity* getWorldEntity() const … … 116 127 Vector3 getAimPosition() 117 128 { return this->aimPosition_; } 118 129 119 130 virtual const Vector3& getCarrierPosition(void) 120 131 { return this->getWorldPosition(); }; … … 141 152 float maxHealth_; 142 153 float initialHealth_; 154 float shieldHealth_; 155 float shieldAbsorption_; // Has to be between 0 and 1 143 156 144 157 Pawn* lastHitOriginator_; … … 152 165 153 166 private: 167 void registerVariables(); 154 168 inline void setWeaponSystem(WeaponSystem* weaponsystem) 155 169 { this->weaponSystem_ = weaponsystem; } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
r6711 r7163 47 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 48 virtual void tick(float dt); 49 void registerVariables();50 49 void setConfigValues(); 51 50 … … 99 98 100 99 private: 100 void registerVariables(); 101 101 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 102 102 103 private:104 103 void loadEngineTemplate(); 105 104 -
code/trunk/src/orxonox/worldentities/pawns/Spectator.h
r6417 r7163 44 44 45 45 void setConfigValues(); 46 void registerVariables();47 46 virtual void tick(float dt); 48 47 … … 63 62 64 63 private: 64 void registerVariables(); 65 65 void changedGreeting(); 66 66 void changedFlareVisibility();
Note: See TracChangeset
for help on using the changeset viewer.