[Orxonox-commit 5968] r10627 - in code/branches/towerdefenseFabien: data/levels src/modules/weapons/munitions src/modules/weapons/projectiles src/modules/weapons/weaponmodes

fvultier at orxonox.net fvultier at orxonox.net
Tue Oct 6 21:37:12 CEST 2015


Author: fvultier
Date: 2015-10-06 21:37:11 +0200 (Tue, 06 Oct 2015)
New Revision: 10627

Added:
   code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.cc
   code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.h
   code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.cc
   code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.h
Modified:
   code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
   code/branches/towerdefenseFabien/src/modules/weapons/munitions/CMakeLists.txt
   code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
   code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
   code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc
   code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
   code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
Log:
Minor improvements. Use of the Munition class.

Modified: code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
===================================================================
--- code/branches/towerdefenseFabien/data/levels/towerDefense.oxw	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/data/levels/towerDefense.oxw	2015-10-06 19:37:11 UTC (rev 10627)
@@ -142,7 +142,7 @@
           <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
         </links>
         <Weapon>
-          <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 />
+          <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 damagereduction=3.0 />
         </Weapon>
       </WeaponPack>
     </weapons>

Modified: code/branches/towerdefenseFabien/src/modules/weapons/munitions/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/munitions/CMakeLists.txt	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/munitions/CMakeLists.txt	2015-10-06 19:37:11 UTC (rev 10627)
@@ -3,4 +3,6 @@
   LaserMunition.cc
   FusionMunition.cc
   RocketMunition.cc
+  SplitMunition.cc
+  IceMunition.cc
 )

Added: code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.cc	                        (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.cc	2015-10-06 19:37:11 UTC (rev 10627)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file IceMunition.h
+    @brief Implementation of the IceMunition class.
+*/
+
+#include "IceMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterClass(IceMunition);
+
+    IceMunition::IceMunition(Context* context) : Munition(context)
+    {
+        RegisterObject(IceMunition);
+
+        this->maxMunitionPerMagazine_ = 1;
+        this->maxMagazines_ = 50;
+        this->magazines_ = 25;
+
+        this->bUseSeparateMagazines_ = false;
+        this->bStackMunition_ = true;
+
+        this->bAllowMunitionRefilling_ = false;
+        this->bAllowMultiMunitionRemovementUnderflow_ = false;
+    }
+}

Added: code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.h	                        (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/munitions/IceMunition.h	2015-10-06 19:37:11 UTC (rev 10627)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file IceMunition.h
+    @brief Definition of the IceMunition class.
+*/
+
+#ifndef _IceMunition_H__
+#define _IceMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        IceMunition.
+    @author
+        Fabien Vultier
+    @ingroup WeaponsMunitions
+    */
+    class _WeaponsExport IceMunition : public Munition
+    {
+        public:
+            IceMunition(Context* context);
+            virtual ~IceMunition() {}
+    };
+}
+
+#endif /* _SplitMunition_H__ */

Added: code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.cc	                        (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.cc	2015-10-06 19:37:11 UTC (rev 10627)
@@ -0,0 +1,55 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SplitMunition.h
+    @brief Implementation of the SplitMunition class.
+*/
+
+#include "SplitMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterClass(SplitMunition);
+
+    SplitMunition::SplitMunition(Context* context) : Munition(context)
+    {
+        RegisterObject(SplitMunition);
+
+        this->maxMunitionPerMagazine_ = 1;
+        this->maxMagazines_ = 100;
+        this->magazines_ = 25;
+
+        this->bUseSeparateMagazines_ = false;
+        this->bStackMunition_ = true;
+
+        this->bAllowMunitionRefilling_ = true;
+        this->bAllowMultiMunitionRemovementUnderflow_ = false;
+    }
+}

Added: code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.h	                        (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/munitions/SplitMunition.h	2015-10-06 19:37:11 UTC (rev 10627)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SplitMunition.h
+    @brief Definition of the SplitMunition class.
+*/
+
+#ifndef _SplitMunition_H__
+#define _SplitMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        SplitMunition.
+    @author
+        Fabien Vultier
+    @ingroup WeaponsMunitions
+    */
+    class _WeaponsExport SplitMunition : public Munition
+    {
+        public:
+            SplitMunition(Context* context);
+            virtual ~SplitMunition() {}
+    };
+}
+
+#endif /* _SplitMunition_H__ */

Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc	2015-10-06 19:37:11 UTC (rev 10627)
@@ -48,8 +48,9 @@
 
         this->numberOfSplits_ = 0;
         this->numberOfChilds_ = 0;
-        this->splitTime_ = 1.0;     
-        this->spread_ = 0.2;
+        this->splitTime_ = 1.0f;
+        this->spread_ = 0.2f;
+        this->damageReduction_ = 1.0f;
     }
 
     void SplitGunProjectile::setNumberOfSplits(int numberOfSplits)
@@ -95,11 +96,20 @@
 
     void SplitGunProjectile::setSpread(float spread)
     {
-        spread_ = spread;
+        this->spread_ = spread;
     }
 
     /**
     @brief
+        This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1.
+    */
+    void SplitGunProjectile::setDamageReduction(float damageReduction)
+    {
+        this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f);
+    }
+
+    /**
+    @brief
         If this function is called the projectile splits up into many child projectiles. The original projectiles does not get destroyed but it will never split up again.
     */
     void SplitGunProjectile::split()
@@ -108,8 +118,8 @@
         {
             -- numberOfSplits_;
 
-            // Reduce damage of this projectile by the number of childs plus one. This way the total amount of possible damage contained in the original projectile and its childs is unchanged after s aplit.
-            this->setDamage(this->getDamage()/(numberOfChilds_+1));
+            // Reduce damage of this projectile
+            this->setDamage(this->getDamage() * this->damageReduction_ / (this->numberOfChilds_+1));
 
             // Calculate a normalized vector (velocityOffset) that is perpendicluar to the velocity of this projectile. Since there are infinitly many perpendicular vectors a random one is chosen.
             Vector3 velocityInitial = this->getVelocity();
@@ -137,6 +147,7 @@
                 projectile->setNumberOfChilds(this->numberOfChilds_);
                 projectile->setSplitTime(this->splitTime_);
                 projectile->setSpread(this->spread_);
+                projectile->setDamageReduction(this->damageReduction_);
 
                 projectile->setShooter(this->getShooter());
                 projectile->setDamage(this->getDamage());

Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h	2015-10-06 19:37:11 UTC (rev 10627)
@@ -60,12 +60,14 @@
             virtual void setNumberOfChilds(int numberOfChilds);
             virtual void setSplitTime(float splitTime);
             virtual void setSpread(float spread);
+            virtual void setDamageReduction(float damageReduction);
 
         private:            
             int numberOfSplits_;
             int numberOfChilds_;
             float splitTime_;
             float spread_;
+            float damageReduction_; //The damage of a child projectile is reduced by this factor
             Timer splitTimer_;
 
             virtual void split();            

Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc	2015-10-06 19:37:11 UTC (rev 10627)
@@ -53,7 +53,7 @@
         // Default values
         this->reloadTime_ = 1.0f;
         this->damage_ = 0.0f;
-        this->speed_ = 750.0f;
+        this->speed_ = 1200.0f;
 
         this->setFreezeTime(3.0);
         this->setFreezeFactor(0.5);

Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc	2015-10-06 19:37:11 UTC (rev 10627)
@@ -55,10 +55,11 @@
         this->speed_ = 750.0f;
         this->numberOfSplits_ = 2;
         this->numberOfChilds_ = 3;
-        this->splitTime_ = 0.3;
-        this->spread_ = 0.1;
+        this->splitTime_ = 0.3f;
+        this->spread_ = 0.1f;
+        this->damageReduction_ = 1.0f;
 
-        this->setMunitionName("LaserMunition");
+        this->setMunitionName("SplitMunition");
         this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     }
 
@@ -78,6 +79,7 @@
         XMLPortParam(SplitGun, "numberofchilds", setNumberOfChilds, getNumberOfChilds, xmlelement, mode);
         XMLPortParam(SplitGun, "splittime", setSplitTime, getSplitTime, xmlelement, mode);
         XMLPortParam(SplitGun, "spread", setSpread, getSpread, xmlelement, mode);
+        XMLPortParam(SplitGun, "damagereduction", setDamageReduction, getDamageReduction, xmlelement, mode);
     }
 
     /**
@@ -94,11 +96,12 @@
         projectile->setPosition(this->getMuzzlePosition());
         projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
 
-        // Pass important information to the projectile: Number of splits, Number of childs, split time, spread
+        // Pass important information to the projectile: Number of splits, Number of childs, split time, spread and the damage reduction
         projectile->setNumberOfSplits(getNumberOfSplits());
         projectile->setNumberOfChilds(getNumberOfChilds());
         projectile->setSplitTime(getSplitTime());
         projectile->setSpread(getSpread());
+        projectile->setDamageReduction(getDamageReduction());
 
         projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
         projectile->setDamage(this->getDamage());

Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h	2015-10-05 13:34:47 UTC (rev 10626)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h	2015-10-06 19:37:11 UTC (rev 10627)
@@ -72,6 +72,10 @@
                 { this->spread_ = spread; }
             inline float getSpread() const
                 { return this->spread_; }
+            inline void setDamageReduction(float damageReduction)
+                { this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f); }
+            inline float getDamageReduction() const
+                { return this->damageReduction_; }
 
        private:
             float speed_; //The speed of the fired projectile.
@@ -79,6 +83,7 @@
             int numberOfChilds_; //The number of child projectiles that are created if the projectile splits
             float splitTime_; //The time between creation of the projectile and the split of the projectile
             float spread_; //Low spread means that the child projectiles are concentrated in a small area
+            float damageReduction_; //The damage of a child projectile is reduced by this factor
     };
 }
 




More information about the Orxonox-commit mailing list