[Orxonox-commit 4484] r9155 - in code/branches/pickup2012: data/levels data/levels/includes data/levels/templates src/modules/pickup/items src/orxonox/worldentities/pawns

lkevin at orxonox.net lkevin at orxonox.net
Fri May 4 15:56:56 CEST 2012


Author: lkevin
Date: 2012-05-04 15:56:56 +0200 (Fri, 04 May 2012)
New Revision: 9155

Modified:
   code/branches/pickup2012/data/levels/includes/pickups.oxi
   code/branches/pickup2012/data/levels/pickups.oxw
   code/branches/pickup2012/data/levels/templates/pickupRepresentationTemplates.oxt
   code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.cc
   code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.h
   code/branches/pickup2012/src/modules/pickup/items/SpeedPickup.h
   code/branches/pickup2012/src/orxonox/worldentities/pawns/Pawn.cc
Log:
Changed pickup icon and xml for possible varieties of the pickup in the future.

Modified: code/branches/pickup2012/data/levels/includes/pickups.oxi
===================================================================
--- code/branches/pickup2012/data/levels/includes/pickups.oxi	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/data/levels/includes/pickups.oxi	2012-05-04 13:56:56 UTC (rev 9155)
@@ -209,6 +209,18 @@
     </pickup>
 </PickupRepresentation>
 
+<!-- DamageBoost Pickup -->
+
+<PickupRepresentation
+    pickupName = "DamageBoost Pickup"
+    pickupDescription = "Multiplies the ship damage."
+    spawnerTemplate = "damageboostpickupRepresentation"
+>
+    <pickup>
+        <DamageBoostPickup template=damageboostpickup />
+    </pickup>
+</PickupRepresentation>
+
 <!-- Shrink Pickup -->
 
 <PickupRepresentation

Modified: code/branches/pickup2012/data/levels/pickups.oxw
===================================================================
--- code/branches/pickup2012/data/levels/pickups.oxw	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/data/levels/pickups.oxw	2012-05-04 13:56:56 UTC (rev 9155)
@@ -170,9 +170,9 @@
     
     <!-- DamageBoost pickup -->
     
-    <PickupSpawner position="-100,300,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+    <PickupSpawner position="-50,75,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
       <pickup>
-        <DamageBoostPickup template=normaldamageboostpickup />
+        <DamageBoostPickup template=damageboostpickup />
       </pickup>
     </PickupSpawner>
     

Modified: code/branches/pickup2012/data/levels/templates/pickupRepresentationTemplates.oxt
===================================================================
--- code/branches/pickup2012/data/levels/templates/pickupRepresentationTemplates.oxt	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/data/levels/templates/pickupRepresentationTemplates.oxt	2012-05-04 13:56:56 UTC (rev 9155)
@@ -217,14 +217,14 @@
 
 <!-- DamageBoost pickups -->
 
-<Template name=normaldamageboostpickupRepresentation>
+<Template name=damageboostpickupRepresentation>
     <PickupRepresentation>
         <spawner-representation>
             <StaticEntity>
                 <attached>
-                    <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.5>
+                    <Billboard position="0,0,0" colour="0.10,0.20,0.30" material="Sphere2" scale=0.1 >
                         <attached>
-                            <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.5 />
+                            <Billboard position="0,0,0" colour="0.30,0.30,0.30" material="damage" scale=0.7 />
                         </attached>
                     </Billboard>
                 </attached>
@@ -233,9 +233,10 @@
     </PickupRepresentation>
 </Template>
 
-<Template name=normaldamageboostpickup>
+<Template name=damageboostpickup>
   <DamageBoostPickup
     duration = 10.0
+    damageMultiplier = 20.0
     activationType = "immediate"
     durationType = "continuous"
   />

Modified: code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.cc
===================================================================
--- code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.cc	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.cc	2012-05-04 13:56:56 UTC (rev 9155)
@@ -20,15 +20,15 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Eric Beier
+ *      Kevin Lengauer
  *   Co-authors:
  *      ...
  *
  */
 
 /**
-    @file SpeedPickup.cc
-    @brief Implementation of the SpeedPickup class.
+    @file DamageBoostPickup.cc
+    @brief Implementation of the DamageBoostPickup class.
 */
 
 #include "DamageBoostPickup.h"
@@ -70,7 +70,7 @@
     void DamageBoostPickup::initialize(void)
     {
         this->duration_ = 0.0f;
-        this->damageMultiplier_ = 20.0f;
+        this->damageMultiplier_ = 1.0f; //The default damage multiplier.
         //Defines who is allowed to pick up the pickup.
         this->addTarget(ClassIdentifier<SpaceShip>::getIdentifier());
     }
@@ -104,11 +104,22 @@
         SUPER(DamageBoostPickup, XMLPort, xmlelement, mode);
 
         XMLPortParam(DamageBoostPickup, "duration", setDuration, getDuration, xmlelement, mode);
-        XMLPortParam(DamageBoostPickup, "damageMultiplier", setDefaultDamageMultiplier, getDefaultDamageMultiplier, xmlelement, mode);
+        XMLPortParam(DamageBoostPickup, "damageMultiplier", setDamageMultiplier, getDamageMultiplier, xmlelement, mode);
 
         this->initializeIdentifier();
     }
 
+    // Work in Progress setDamage Function
+    void DamageBoostPickup::setDamageMultiplier(float damageMultiplier)
+    {
+        if(damageMultiplier >= 1.0f)
+        {
+            this->damageMultiplier_ = damageMultiplier;
+            orxout() << "Set Damage " << damageMultiplier << endl;
+        }
+    }
+
+
     /**
     @brief
         Is called when the pickup has transited from used to unused or the other way around.
@@ -137,10 +148,10 @@
                     this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&DamageBoostPickup::pickupTimerCallback, this)));
                 }
             }
-            // NOTE: commented this since its use was not apparent
-            // ship->getCreator();
 
+            // Saves the old default Damage that is needed to restore the original damage
             this->olddamageMultiplier_ = ship->getDamageMultiplier();
+            // Sets the new Damage with the damage multiplier.
             ship->setDamageMultiplier( this->damageMultiplier_ );
         }
         else
@@ -213,21 +224,15 @@
         }
         else
         {
-            orxout(internal_error, context::pickups) << "Invalid duration in SpeedPickup." << endl;
+            orxout(internal_error, context::pickups) << "Invalid duration in DamagePickup." << endl;
             this->duration_ = 0.0f;
         }
     }
 
-   /* void DamageBoostPickup::setDamageBoost(float damageBoost)
-       {
-
-       }
-    void DamageBoostPickup::setDamageSave(float damageSave)
-    {
-
-    }
+    /**
+    @brief
+        Helper method. Is called by the Timer as soon as it expires.
     */
-
     void DamageBoostPickup::pickupTimerCallback(void)
     {
         this->setUsed(false);

Modified: code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.h
===================================================================
--- code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.h	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/src/modules/pickup/items/DamageBoostPickup.h	2012-05-04 13:56:56 UTC (rev 9155)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Damian 'Mozork' Frick
+ *      Kevin Lengauer
  *   Co-authors:
  *      ...
  *
@@ -52,21 +52,10 @@
             virtual ~DamageBoostPickup(); //!< Destructor.
 
             virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a DamageBoostPickup object through XML.
-            // commented out cuz was not used
-            // virtual void tick(float dt); //!< Is called every tick.
 
             virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
 
-            /**
-            @brief Get the damageboost that is transferred to the Pawn upon usage of this pickup.
-            @return Returns the damageboost.
-            */
-            // Commentend, may not be used
-            // inline float setDamageMultiplier(void) const
-            //    { ship->setMultiplier(); }
-
-
     	    /**
             @brief Get the time the DamagePickup lasts.
             @return Returns the time in seconds the DamagePickup lasts.
@@ -76,11 +65,12 @@
             inline void setDuration( float duration );
 
 
-            // we need these methods to set the default damage multiplier from XML
-            // not that beautiful yet
-            inline void setDefaultDamageMultiplier(float multiplier)
-                { this->damageMultiplier_ = multiplier; }
-            inline float getDefaultDamageMultiplier()
+
+            /**
+             @brief set Damage multiplier
+             @param multiplier The default damage multiplier to set
+             */
+            inline float getDamageMultiplier()
                 { return this->damageMultiplier_; }
 
 
@@ -88,14 +78,13 @@
 
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+            void setDamageMultiplier(float damageMultiplier);
 
-            // void setDamageBoost(float damageBoost);//!< Sets the damage boost.
-            // void setDamageSave(float damageSave); //!< Saves the original damage.
 
         private:
             void initialize(void); //!< Initializes the member variables.
             Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
-            SpaceShip* carrierToSpaceShipHelper(void);
+            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
             void pickupTimerCallback(void);
 
 

Modified: code/branches/pickup2012/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/branches/pickup2012/src/modules/pickup/items/SpeedPickup.h	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/src/modules/pickup/items/SpeedPickup.h	2012-05-04 13:56:56 UTC (rev 9155)
@@ -111,7 +111,7 @@
 
         private:
             void initialize(void); //!< Initializes the member variables.
-            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceSHip, and throw an error message if the conversion fails.
+            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
 
             Timer durationTimer_; //!< Timer.
 

Modified: code/branches/pickup2012/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/pickup2012/src/orxonox/worldentities/pawns/Pawn.cc	2012-05-04 12:51:44 UTC (rev 9154)
+++ code/branches/pickup2012/src/orxonox/worldentities/pawns/Pawn.cc	2012-05-04 13:56:56 UTC (rev 9155)
@@ -233,7 +233,9 @@
         // apply multiplier
     	Pawn *test = dynamic_cast<Pawn *>(originator);
     	if( test != NULL )
+    	{ orxout() << "Test " << damage << endl;
     	  damage *= originator->getDamageMultiplier();
+    	}
 
     	if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
         {




More information about the Orxonox-commit mailing list