[Orxonox-commit 3497] r8183 - in code/branches/gameimmersion: data/levels src/modules/weapons/projectiles src/orxonox/worldentities/pawns
simonmie at orxonox.net
simonmie at orxonox.net
Mon Apr 4 14:14:25 CEST 2011
Author: simonmie
Date: 2011-04-04 14:14:25 +0200 (Mon, 04 Apr 2011)
New Revision: 8183
Modified:
code/branches/gameimmersion/data/levels/test-immersion-shield-01.oxw
code/branches/gameimmersion/src/modules/weapons/projectiles/Projectile.cc
code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h
Log:
Added countdown time before shield reload starts
Modified: code/branches/gameimmersion/data/levels/test-immersion-shield-01.oxw
===================================================================
--- code/branches/gameimmersion/data/levels/test-immersion-shield-01.oxw 2011-04-04 11:37:50 UTC (rev 8182)
+++ code/branches/gameimmersion/data/levels/test-immersion-shield-01.oxw 2011-04-04 12:14:25 UTC (rev 8183)
@@ -43,6 +43,7 @@
shieldabsorption= 1
reloadrate= "10"
+ reloadwaittime= 5
>
<attached>
Modified: code/branches/gameimmersion/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/branches/gameimmersion/src/modules/weapons/projectiles/Projectile.cc 2011-04-04 11:37:50 UTC (rev 8182)
+++ code/branches/gameimmersion/src/modules/weapons/projectiles/Projectile.cc 2011-04-04 12:14:25 UTC (rev 8183)
@@ -93,6 +93,7 @@
this->destroy();
}
+//////////////////////////me edit
bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
if (!this->bDestroy_ && GameMode::isMaster())
@@ -102,11 +103,11 @@
this->bDestroy_ = true;
- Pawn* victim = orxonox_cast<Pawn*>(otherObject);
+ Pawn* victim = orxonox_cast<Pawn*>(otherObject); //if otherObject isn't a Pawn, then victim is NULL
if (this->owner_)
{
- if (victim && !victim->hasShield())
+ if (!victim || (victim && !victim->hasShield())) //same like below
{
ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
effect->setPosition(this->getPosition());
@@ -115,7 +116,7 @@
effect->setSource("Orxonox/explosion3");
effect->setLifetime(2.0f);
}
- if (victim && !victim->hasShield())
+ if (!victim || (victim && !victim->hasShield())) //same like above
{
ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
effect->setPosition(this->getPosition());
@@ -136,10 +137,14 @@
}
if (victim)
+ {
victim->hit(this->owner_, contactPoint, this->damage_);
+ victim->startReloadCountdown();
+ }
}
return false;
}
+//////////////////////////////////////////////////////////////////////end edit
void Projectile::setOwner(Pawn* owner)
{
Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc 2011-04-04 11:37:50 UTC (rev 8182)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc 2011-04-04 12:14:25 UTC (rev 8183)
@@ -67,6 +67,11 @@
this->initialHealth_ = 0;
this->shieldHealth_ = 0;
this->shieldAbsorption_ = 0.5;
+////////////////////////me
+ this->reloadRate_ = 0;
+ this->reloadWaitTime_ = 1.0f;
+ this->reloadWaitCountdown_ = 0;
+////////////////////////end me
this->lastHitOriginator_ = 0;
@@ -120,6 +125,7 @@
/////// me
XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
+ XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
/////// end me
@@ -143,7 +149,16 @@
this->bReload_ = false;
////////me
- this->addShieldHealth(this->getReloadRate() * dt);
+ if(this->reloadWaitCountdown_ > 0)
+ {
+ this->decreaseReloadCountdownTime(dt);
+ }
+ else
+ {
+ this->addShieldHealth(this->getReloadRate() * dt);
+ this->resetReloadCountdown();
+ }
+
// TODO max. shield hinzufuegen
////////end me
if (GameMode::isMaster())
@@ -184,7 +199,18 @@
COUT(2) << "RELOAD RATE SET TO " << this->reloadRate_ << endl;
}
+ void Pawn::setReloadWaitTime(float reloadwaittime)
+ {
+ this->reloadWaitTime_ = reloadwaittime;
+ COUT(2) << "RELOAD WAIT TIME SET TO " << this->reloadWaitTime_ << endl;
+ }
+ void Pawn::decreaseReloadCountdownTime(float dt)
+ {
+ this->reloadWaitCountdown_ -= dt;
+ }
+
+
///////////////end me
void Pawn::setHealth(float health)
Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h 2011-04-04 11:37:50 UTC (rev 8182)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h 2011-04-04 12:14:25 UTC (rev 8183)
@@ -64,6 +64,18 @@
inline bool hasShield()
{ return (this->getShieldHealth() > 0); }
+ virtual void setReloadWaitTime(float reloadwaittime);
+ inline float getReloadWaitTime() const
+ { return this->reloadWaitTime_; }
+
+ inline void resetReloadCountdown()
+ { this->reloadWaitCountdown_ = 0; }
+
+ inline void startReloadCountdown()
+ { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } //in projectile.cc einbauen!!!!!!1111!!111!
+
+ virtual void decreaseReloadCountdownTime(float dt);
+
///////////////////////////////// end me
virtual void setHealth(float health);
@@ -165,6 +177,8 @@
/////////////////////////// me
float reloadRate_;
+ float reloadWaitTime_;
+ float reloadWaitCountdown_;
////////////////////////// end me
More information about the Orxonox-commit
mailing list