[Orxonox-commit 3459] r8145 - code/branches/gameimmersion/src/orxonox/worldentities/pawns

simonmie at orxonox.net simonmie at orxonox.net
Mon Mar 28 15:55:04 CEST 2011


Author: simonmie
Date: 2011-03-28 15:55:04 +0200 (Mon, 28 Mar 2011)
New Revision: 8145

Modified:
   code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
   code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h
Log:
First try of self-reloading shield


Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc	2011-03-28 13:31:45 UTC (rev 8144)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.cc	2011-03-28 13:55:04 UTC (rev 8145)
@@ -117,6 +117,12 @@
         XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
         XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
+
+/////// me
+        XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
+
+/////// end me
+
     }
 
     void Pawn::registerVariables()
@@ -136,10 +142,13 @@
 
         this->bReload_ = false;
 
+////////me
+        this->addShieldHealth(this->getReloadRate() * dt);
+////////end me
         if (GameMode::isMaster())
             if (this->health_ <= 0 && bAlive_)
             {
-                this->fireEvent(); // Event to notify anyone who want's to know about the death.
+                this->fireEvent(); // Event to notify anyone who wants to know about the death.
                 this->death();
             }
     }
@@ -167,6 +176,16 @@
         ControllableEntity::removePlayer();
     }
 
+//////////////////me
+    void Pawn::setReloadRate(float reloadrate)
+    {
+        this->reloadRate_ = reloadrate;
+        COUT(2) << "RELOAD RATE SET TO " << this->reloadRate_ << endl;
+    }
+
+
+///////////////end me
+
     void Pawn::setHealth(float health)
     {
         this->health_ = std::min(health, this->maxHealth_);
@@ -185,8 +204,11 @@
             {
                 healthdamage += shielddamage-this->getShieldHealth();
                 this->setShieldHealth(0);
+                COUT(3) << "### SHIELD KAPUTT ###" << endl;
             }
 
+            else { COUT(3) << "## SHIELD : " << this->getShieldHealth() << endl; }
+
             this->setHealth(this->health_ - healthdamage);
 
             if (this->getShieldHealth() > 0)

Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h	2011-03-28 13:31:45 UTC (rev 8144)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h	2011-03-28 13:55:04 UTC (rev 8145)
@@ -53,6 +53,16 @@
             inline bool isAlive() const
                 { return this->bAlive_; }
 
+///////////////////////////////// me
+            virtual void setReloadRate(float reloadrate);
+            inline float getReloadRate() const
+                { return this->reloadRate_; }
+
+            inline void addShieldHealth(float amount)
+            { this->setShieldHealth(this->shieldHealth_ + amount); }
+
+///////////////////////////////// end me
+
             virtual void setHealth(float health);
             inline void addHealth(float health)
                 { this->setHealth(this->health_ + health); }
@@ -150,6 +160,11 @@
             virtual PickupCarrier* getCarrierParent(void) const
                 { return NULL; }
 
+/////////////////////////// me
+            float reloadRate_;
+
+////////////////////////// end me
+
             float health_;
             float maxHealth_;
             float initialHealth_;




More information about the Orxonox-commit mailing list