[Orxonox-commit 3879] r8553 - code/branches/gameimmersion/src/orxonox/worldentities/pawns
simonmie at orxonox.net
simonmie at orxonox.net
Mon May 23 18:41:25 CEST 2011
Author: simonmie
Date: 2011-05-23 18:41:25 +0200 (Mon, 23 May 2011)
New Revision: 8553
Modified:
code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
Log:
added more comments, removed code marks, changed strange (wrong?) hit call
Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc 2011-05-23 16:35:35 UTC (rev 8552)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc 2011-05-23 16:41:25 UTC (rev 8553)
@@ -151,7 +151,7 @@
this->bReload_ = false;
-////////me
+ // TODO: use the existing timer functions instead
if(this->reloadWaitCountdown_ > 0)
{
this->decreaseReloadCountdownTime(dt);
@@ -162,13 +162,14 @@
this->resetReloadCountdown();
}
-////////end me
if (GameMode::isMaster())
+ {
if (this->health_ <= 0 && bAlive_)
{
this->fireEvent(); // Event to notify anyone who wants to know about the death.
this->death();
}
+ }
}
void Pawn::preDestroy()
@@ -194,22 +195,15 @@
ControllableEntity::removePlayer();
}
-//////////////////me
- void Pawn::setReloadRate(float reloadrate)
- {
- this->reloadRate_ = reloadrate;
- //COUT(2) << "RELOAD RATE SET TO " << this->reloadRate_ << endl;
- }
- void Pawn::setReloadWaitTime(float reloadwaittime)
+ void Pawn::setHealth(float health)
{
- this->reloadWaitTime_ = reloadwaittime;
- //COUT(2) << "RELOAD WAIT TIME SET TO " << this->reloadWaitTime_ << endl;
+ 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
}
- void Pawn::decreaseReloadCountdownTime(float dt)
+ void Pawn::setShieldHealth(float shieldHealth)
{
- this->reloadWaitCountdown_ -= dt;
+ this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
}
void Pawn::setMaxShieldHealth(float maxshieldhealth)
@@ -217,22 +211,26 @@
this->maxShieldHealth_ = maxshieldhealth;
}
- void Pawn::setShieldHealth(float shieldHealth)
+ void Pawn::setReloadRate(float reloadrate)
{
- this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
+ this->reloadRate_ = reloadrate;
}
-///////////////end me
+ void Pawn::setReloadWaitTime(float reloadwaittime)
+ {
+ this->reloadWaitTime_ = reloadwaittime;
+ }
- void Pawn::setHealth(float health)
+ void Pawn::decreaseReloadCountdownTime(float dt)
{
- 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
+ this->reloadWaitCountdown_ -= dt;
}
-//////////////////me edit
+ /* Old damage function.
+ * For effects causing only damage not specifically to shield or health
+ */
void Pawn::damage(float damage, Pawn* originator)
{
- COUT(3) << "### alte damage-funktion ###" << endl;
if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
{
//share the dealt damage to the shield and the Pawn.
@@ -246,8 +244,6 @@
this->setShieldHealth(0);
}
- // else { COUT(3) << "## SHIELD : " << this->getShieldHealth() << endl; }
-
this->setHealth(this->health_ - healthdamage);
if (this->getShieldHealth() > 0)
@@ -260,10 +256,10 @@
// play damage effect
}
}
-////////////////////end edit
-
-/////////////////////me override
+ /* Does damage to the pawn, splits it up to shield and health.
+ * Sets lastHitOriginator.
+ */
void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
{
if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
@@ -290,18 +286,16 @@
// play damage effect
}
- //COUT(3) << "neue damage-Funktion wurde aufgerufen // " << "Shield:" << this->getShieldHealth() << endl;
}
-/////////////end me
-
/* HIT-Funktionen
- Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden!
+ Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
*/
-
+ /* Old hit function, calls the old damage function and changes velocity vector
+ */
void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
{
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
@@ -313,10 +307,10 @@
}
}
-/////////////me override
+ /* calls the damage function and adds the force that hit the pawn to the velocity vector
+ */
void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
{
-// COUT(3) << "neue hit-Funktion wurde aufgerufen // " << std::flush;
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
{
this->damage(damage, healthdamage, shielddamage, originator);
@@ -325,8 +319,9 @@
// play hit effect
}
}
-/////////////end me
+ /* Old hit (2) function, calls the old damage function and hits controller
+ */
void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
{
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
@@ -340,22 +335,22 @@
}
}
-/////////////me override
+ /* Hit (2) function, calls the damage function and hits controller
+ */
void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
{
-// COUT(3) << "neue hit2-Funktion wurde aufgerufen // shielddamage: " << shielddamage << std::flush;
if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
{
this->damage(damage, healthdamage, shielddamage, originator);
if ( this->getController() )
- this->getController()->hit(originator, contactpoint, shielddamage);
+ this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
// play hit effect
}
}
-/////////////end me
+
void Pawn::kill()
{
this->damage(this->health_);
More information about the Orxonox-commit
mailing list