[Orxonox-commit 7523] r12129 - in code/branches/wagnis_HS18: data/levels data/levels/templates src/modules/weapons/projectiles src/modules/weapons/weaponmodes

kunzro at orxonox.net kunzro at orxonox.net
Wed Nov 28 12:53:04 CET 2018


Author: kunzro
Date: 2018-11-28 12:53:04 +0100 (Wed, 28 Nov 2018)
New Revision: 12129

Added:
   code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc
   code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.h
   code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc
   code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.h
Modified:
   code/branches/wagnis_HS18/data/levels/Wagnis.oxw
   code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt
   code/branches/wagnis_HS18/src/modules/weapons/projectiles/CMakeLists.txt
   code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/CMakeLists.txt
Log:
Cursor fixed, should be working properly now

Modified: code/branches/wagnis_HS18/data/levels/Wagnis.oxw
===================================================================
--- code/branches/wagnis_HS18/data/levels/Wagnis.oxw	2018-11-28 11:06:14 UTC (rev 12128)
+++ code/branches/wagnis_HS18/data/levels/Wagnis.oxw	2018-11-28 11:53:04 UTC (rev 12129)
@@ -53,15 +53,15 @@
 
 <WagnisGameboard position="20,20,20" connections_string="1=2+1000, 2=1, 1000=1">
 
+
   <Provinces>
   
-    <WagnisProvince ID="1" collisionType=dynamic mass=100 continent="1" position="0,<?lua print((10+7))?>,<?lua print((135-6))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+    <WagnisProvince ID="1" health=10000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((10+7))?>,<?lua print((135-6))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
       <attached>
-        <Billboard position="0,0,0" material="Examples/flare" colour="0, 0, 1" scale=1/>
         <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
       </attached>
       <collisionShapes>
-        <SphereCollisionShape   position="0,0,0" radius="1" />
+        <SphereCollisionShape   position="0,0,0" radius="2" />
       </collisionShapes>
     </WagnisProvince>
 <!--
@@ -117,6 +117,11 @@
 </WagnisGameboard>
 
 <Model position="0,0,0" mesh="Coordinates.mesh" scale="20"/>
+<MovableEntity position="0,0,0">
+    <attached>
+        <Billboard position="100,0,0" material="Examples/Flare" colour="0, 0, 1" scale=1/>
+    </attached>
+</MovableEntity>
 
 
 

Modified: code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt
===================================================================
--- code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt	2018-11-28 11:06:14 UTC (rev 12128)
+++ code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt	2018-11-28 11:53:04 UTC (rev 12129)
@@ -55,20 +55,15 @@
           <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
         </links>
         <Weapon>
-            <HsW01 mode=0 munitionpershot=1 delay=0     damage=1    material="Flares/point_lensflare" muzzleoffset="0, 0, 0" />
-            <HsW01 mode=1 munitionpershot=1 delay=0     damage=100  material="Flares/point_lensflare" muzzleoffset="0, 0, 0" />
+            <WagnisGun mode=0 munitionpershot=0 delay=0     damage=1      muzzleoffset="0, 0, 0" />
+            <WagnisGun mode=1 munitionpershot=0 delay=0     damage=1000   muzzleoffset="0, 0, 0" />
         </Weapon>
       </WeaponPack>
 </weaponpacks>
 <munition>
-      <LaserMunition initialmagazines=800 maxmagazines=800 munitionpermagazine=1000 replenishamount=2 replenishinterval=7.5/>
-      <LightningMunition initialmagazines=400 maxmagazines=400 munitionpermagazine=800 />
+      <LaserMunition initialmagazines=2 maxmagazines=4 munitionpermagazine=1 replenishamount=2 replenishinterval=7.5/>
 </munition>
 
-
-
-
-
   </SpaceShip>
 </Template>
 
@@ -75,9 +70,8 @@
 <Template name=spaceshipassffcameras defaults=0>
   <SpaceShip>
     <camerapositions>
-      <CameraPosition position="0,10, 40" drag=true mouselook=true />
-      <CameraPosition position="0,20, 80" drag=true mouselook=true />
-      <CameraPosition position="0,30,120" drag=true mouselook=true />
+      <CameraPosition position="0,0, 0" drag=true mouselook=true />
+      <CameraPosition position="0,0, 0" drag=true mouselook=true />
     </camerapositions>
   </SpaceShip>
 </Template>

Modified: code/branches/wagnis_HS18/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/projectiles/CMakeLists.txt	2018-11-28 11:06:14 UTC (rev 12128)
+++ code/branches/wagnis_HS18/src/modules/weapons/projectiles/CMakeLists.txt	2018-11-28 11:53:04 UTC (rev 12129)
@@ -13,4 +13,5 @@
   GravityBomb.cc
   GravityBombField.cc
   MineProjectile.cc
+  WagnisProjectile.cc
 )

Added: code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc	                        (rev 0)
+++ code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc	2018-11-28 11:53:04 UTC (rev 12129)
@@ -0,0 +1,90 @@
+/*
+ *   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.
+*/
+
+#include "WagnisProjectile.h"
+
+#include "core/config/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/command/Executor.h"
+
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    RegisterClass(WagnisProjectile);
+
+    WagnisProjectile::WagnisProjectile(Context* context) : MovableEntity(context), BasicProjectile()
+    {
+        RegisterObject(WagnisProjectile);
+
+        this->setConfigValues();
+
+        // Get notification about collisions
+        if (GameMode::isMaster())
+        {
+            this->setMass(0.1f);
+            this->enableCollisionCallback();
+            this->setCollisionResponse(false);
+            this->setCollisionType(CollisionType::Dynamic);
+
+            // Create a sphere collision shape and attach it to the projectile.
+            collisionShape_ = new SphereCollisionShape(this->getContext());
+            setCollisionShapeRadius(2.0f);
+            this->attachCollisionShape(collisionShape_);
+
+            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
+        }
+    }
+
+    WagnisProjectile::~WagnisProjectile()
+    {
+    }
+
+    void WagnisProjectile::setConfigValues()
+    {
+        SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive");
+    }
+
+    void WagnisProjectile::tick(float dt)
+    {
+        SUPER(WagnisProjectile, tick, dt);
+
+        if (!this->isActive())
+            return;
+
+        this->destroyCheck();
+    }
+
+    bool WagnisProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
+    {
+        return this->processCollision(otherObject, contactPoint, cs);
+    }
+
+    void WagnisProjectile::setCollisionShapeRadius(float radius)
+    {
+        if (collisionShape_ != nullptr && radius > 0)
+        {
+            collisionShape_->setRadius(radius);
+        }        
+    }
+}

Added: code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.h	                        (rev 0)
+++ code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.h	2018-11-28 11:53:04 UTC (rev 12129)
@@ -0,0 +1,68 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      simonmie
+ *
+ */
+
+/**
+    @file Projectile.h
+    @brief Definition of the Projectile class.
+*/
+
+#ifndef _WagnisProjectile__
+#define _WagnisProjectile__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "worldentities/MovableEntity.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
+
+#include "BasicProjectile.h"
+
+namespace orxonox
+{
+    class _WeaponsExport WagnisProjectile : public MovableEntity, public BasicProjectile
+    {
+        public:
+            WagnisProjectile(Context* context);
+            virtual ~WagnisProjectile();
+
+            void setConfigValues();
+
+            virtual void tick(float dt) override;
+            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) override;
+
+        protected:
+            virtual void setCollisionShapeRadius(float radius);
+            float lifetime_; //!< The time the projectile exists.
+
+        private:
+            Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
+            WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
+    };
+}
+
+#endif /* _WagnisProjectile__ */

Modified: code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/CMakeLists.txt	2018-11-28 11:06:14 UTC (rev 12128)
+++ code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/CMakeLists.txt	2018-11-28 11:53:04 UTC (rev 12129)
@@ -12,4 +12,5 @@
   SimpleRocketFire.cc
   GravityBombFire.cc
   MineGun.cc
+  WagnisGun.cc
 )

Added: code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc	                        (rev 0)
+++ code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc	2018-11-28 11:53:04 UTC (rev 12129)
@@ -0,0 +1,116 @@
+/*
+ *   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.
+
+
+ *   The WagnisGun, WagnisProjectile and WagnisCursor was made to be used as a "cursor", by fireing invisible projectiles at an object.
+ *   You can then monitor the Objects HP in order to know which one has been hit (=clicked). And yes, it isn't a very beautiful solution.
+*/
+
+#include "WagnisGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/WagnisProjectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+    RegisterClass(WagnisGun);
+
+    WagnisGun::WagnisGun(Context* context) : WeaponMode(context)
+    {
+        RegisterObject(WagnisGun);
+
+        this->reloadTime_ = 0.1f;
+        this->damage_ = 0.0f; //default 15
+        this->speed_ = 1000.0f;
+        this->delay_ = 0.0f;
+        this->setMunitionName("LaserMunition");
+
+
+
+        this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&WagnisGun::shot, this)));
+        this->delayTimer_.stopTimer();
+        hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
+    }
+
+    WagnisGun::~WagnisGun()
+    {
+    }
+
+    void WagnisGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(WagnisGun, XMLPort, xmlelement, mode);
+
+        XMLPortParam(WagnisGun, "delay", setDelay, getDelay, xmlelement, mode);
+        XMLPortParam(WagnisGun, "material", setMaterial, getMaterial, xmlelement, mode);
+        XMLPortParam(WagnisGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
+        XMLPortParam(WagnisGun, "sound", setSound, getSound, xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Set the firing delay.
+    @param delay
+        The firing delay in seconds.
+    */
+    void WagnisGun::setDelay(float delay)
+    {
+        this->delay_ = delay;
+        this->delayTimer_.setInterval(this->delay_);
+    }
+
+    void WagnisGun::fire()
+    {
+        this->delayTimer_.startTimer();
+    }
+
+    /**
+    @brief
+        Fires the weapon. Creates a projectile and fires it.
+    */
+    void WagnisGun::shot()
+    {
+        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+        // Create the projectile.
+        WagnisProjectile* projectile = new WagnisProjectile(this->getContext());
+
+        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+        projectile->setOrientation(this->getMuzzleOrientation());
+        projectile->setPosition(this->getMuzzlePosition());
+        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+        projectile->setDamage(this->getDamage());
+        projectile->setShieldDamage(this->getShieldDamage());
+        projectile->setHealthDamage(this->getHealthDamage());
+    }
+}

Added: code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.h	                        (rev 0)
+++ code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.h	2018-11-28 11:53:04 UTC (rev 12129)
@@ -0,0 +1,93 @@
+#ifndef _WagnisGun__
+#define _WagnisGun__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        Shoots laser beams.
+    @author
+        Hagen Seifert
+    @ingroup WeaponsWeaponModes
+    */
+    class _WeaponsExport WagnisGun : public WeaponMode
+    {
+        public:
+            WagnisGun(Context* context);
+            virtual ~WagnisGun();
+
+            virtual void fire() override;
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+        protected:
+            /**
+            @brief Set the mesh.
+            @param mesh The mesh name.
+            */
+            void setMesh(const std::string& mesh)
+                { this->mesh_ = mesh; }
+
+            /**
+            @brief Get the mesh.
+            @return Returns the mesh name.
+            */
+            const std::string& getMesh() const
+                { return this->mesh_; }
+
+            /**
+            @brief Set the sound.
+            @param sound The Sound name.
+            */
+            void setSound(const std::string& sound)
+                { this->sound_ = sound; }
+
+            /**
+            @brief Get the sound.
+            @return Returns the sound name.
+            */
+            const std::string& getSound() const
+                { return this->sound_; }
+
+            /**
+            @brief Set the material.
+            @param material The material name.
+            */
+            void setMaterial(const std::string& material)
+                { this->material_ = material; }
+            /**
+            @brief Get the material.
+            @return Returns the material name.
+            */
+            const std::string& getMaterial() const
+                { return this->material_; }
+
+            void setDelay(float delay);
+            /**
+            @brief Get the firing delay.
+            @return Returns the firing delay in seconds.
+            */
+            float getDelay() const
+                { return this->delay_; }
+
+            virtual void shot();
+            void muzzleflash();
+
+            std::string material_; //!< The material.
+            std::string mesh_; //!< The mesh.
+            std::string sound_; //!< The sound.
+
+
+
+            float speed_; //!< The speed of the fired projectile.
+            float delay_; //!< The firing delay.
+            Timer delayTimer_; //!< A timer to delay the firing.
+    };
+}
+
+#endif /* _WagnisGun__ */



More information about the Orxonox-commit mailing list