[Orxonox-commit 6983] r11604 - in code/branches/ProtectBoss_HS17: data/levels src/orxonox/worldentities/pawns

lrigoni at orxonox.net lrigoni at orxonox.net
Mon Nov 27 16:29:35 CET 2017


Author: lrigoni
Date: 2017-11-27 16:29:35 +0100 (Mon, 27 Nov 2017)
New Revision: 11604

Added:
   code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc
   code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.h
Modified:
   code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw
   code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/CMakeLists.txt
Log:
Changes of 27.11.2017

Modified: code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw
===================================================================
--- code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw	2017-11-27 15:15:26 UTC (rev 11603)
+++ code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw	2017-11-27 15:29:35 UTC (rev 11604)
@@ -10,6 +10,9 @@
   include("HUDTemplates3.oxo")
   include("templates/lodInformation.oxt")
   include("templates/HeavyCruiser.oxt")
+  include("HUDPickupTemplate.oxo")
+  include("templates/pickupRepresentationTemplates.oxt")
+  include("includes/pickups.oxi")
 ?>
 
 <?lua
@@ -57,11 +60,14 @@
     <Pawn
         team      = 0
         collisionType = kinematic
+        enablecollisiondamage=true
+        collisiondamage = 10
         position  = "0,0,-2500"
-        mass      = 10000
+        mass      = 100000
         health    = 1000 initialhealth=1000 maxhealth="1000"
         direction = "1,0,0"
         rotationaxis="0,0,1" rotationrate="4.5" velocity="0,0,30"
+        vulnerable=true
         name      = "CargoShip"
         radarname = "Cargo Ship" >
       <attached>
@@ -106,8 +112,44 @@
     <!-- triggers when first quest is completed -->
     <DistanceTrigger name="passedAsteroidFieldOne" beaconMode=identify position="0,0,3000" distance=1000 target="Pawn" targetname="CargoShip" />
 
+    <!-- triggers when first pirate wave is defeated -->
+    <Trigger name="firstPirateWaveKilled" mode="and">
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p1" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p2" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p3" />
+          </trigger>
+        </events>
+      </EventTrigger>
+    </Trigger>
+
     <!-- create asteroids -->
     <?lua
+      function asteroidMesh()
+        x = math.random(8)
+        if x < 7 then
+          return "ast" .. x .. ".mesh"
+        elseif x == 7 then
+          return "asteroid_ice.mesh"
+        else
+          return "asteroid_UV.mesh"
+        end
+      end
+
       for count = 1, 30, 1 do
         x = math.random(-1000, 1000)
         y = math.random(-1000, 1000)
@@ -120,10 +162,38 @@
         vy = math.random(-vmax, vmax)
         vz = math.random(-vmax, vmax)
         rr = math.random() * 10
-        print("<Pawn team=1 health=30 position=\"" .. x .. "," .. y .. "," .. z .. "\" direction=\"0,0,-1\" velocity=\"" .. vx .. "," .. vy .. "," .. vz .. "\"rotationaxis=\"" .. rx .. "," .. ry .. "," .. rz .. "\" rotationrate=" .. rr .. " collisionType=dynamic mass=1 name=asteroid radarname=Asteroid> <!--events> <visibility> <EventListener event=flying4 /> </visibility> </events--> <attached> <Model position=\"0,0,0\" mesh=\"ast" .. math.random(6) .. ".mesh\" scale3D=\"10,10,10\" /> </attached> <collisionShapes> <SphereCollisionShape position=\"0,0,0\" radius=5 /> </collisionShapes> <!--controller> <WaypointController team=1> </WaypointController> </controller--> <explosion> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_flash2\" effect2=\"orxonox/explosion_flame2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_shockwave2\" effect2=\"orxonox/explosion_sparks2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_streak2\" effect2=\"orxonox/explosion_afterglow\" /> </explosion> </Pawn>")
+        print("<Pawn team=1 health=30 position=\"" .. x .. "," .. y .. "," .. z .. "\" direction=\"0,0,-1\" velocity=\"" .. vx .. "," .. vy .. "," .. vz .. "\"rotationaxis=\"" .. rx .. "," .. ry .. "," .. rz .. "\" rotationrate=" .. rr .. " collisionType=dynamic mass=1 name=asteroid radarname=Asteroid> <attached> <Model position=\"0,0,0\" mesh=\"" .. asteroidMesh() .. "\" scale3D=\"10,10,10\" /> </attached> <collisionShapes> <SphereCollisionShape position=\"0,0,0\" radius=5 /> </collisionShapes> <controller> <WaypointController team=1> </WaypointController> </controller> <explosion> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_flash2\" effect2=\"orxonox/explosion_flame2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_shockwave2\" effect2=\"orxonox/explosion_sparks2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_streak2\" effect2=\"orxonox/explosion_afterglow\" /> </explosion> </Pawn>")
       end
+
+      for count = 1, 20, 1 do
+        x = math.random(-1000, 1000)
+        y = math.random(-1000, 1000)
+        z = 125 * count + math.random(-250, 250)
+        typenum = math.random(7)
+        type = ""
+        if typenum == 1 then
+          type = "smallmunition"
+        elseif typenum == 2 then
+          type = "mediummunition"
+        elseif typenum == 3 then
+          type = "hugemunition"
+        elseif typenum == 4 then
+          type = "smallhealth"
+        elseif typenum == 5 then
+          type = "mediumhealth"
+        elseif typenum == 6 then
+          type = "hugehealth"
+        else
+          type = "crazyhealth"
+        end
+        type = type .. "pickup"
+        --[[print("<PickupSpawner pickup=\"" .. "mediumhealth" .. "\" position=\"" .. x .. "," .. y .. "," .. z .. "\" triggerDistance=10 respawnTime=5 maxSpawnedItems=1 />")]]
+      end
     ?>
 
+    <!--PickupSpawner pickup=mediumhealthpickup position="0,0,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="1" /-->
+    <!--PickupSpawner pickup=smallshieldpickup position="-25,-25,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10" /-->
+
     <!-- start first quest -->
     <QuestEffectBeacon times=1>
       <effects>
@@ -184,17 +254,46 @@
         </events>
     </SimpleNotification>
 
-    <!-- A function to put pirates to a certain location -->
+    <SimpleNotification message="A second pirate wave is approaching!" broadcast=true >
+      <events>
+            <trigger>
+                <EventListener event="firstPirateWaveKilled" />
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+
+    <!-- A function to put pirates and asteroids to a certain location -->
     <?lua
-      function placePirate(posX, posY, posZ, trigger)
-        print("<SpaceShip mass=10 position=\"" .. posX .. "," .. posY .. "," .. posZ .. "\" name=Pirate radarname=Pirate><events><visibility><EventListener event=\"" .. trigger .. "\"/></visibility><activity><EventListener event=\"" .. trigger .. "\"/></activity></events><templates><Template link=spaceshippirate /></templates><controller><WaypointPatrolController alertnessradius=3129 team=1 active=false><waypoints><Model mesh=\"cube.mesh\" scale=0 position=\"-1300,-600,900\" /><Model mesh=\"cube.mesh\" scale=0 position=\"0,0,0\" /></waypoints><events><activity><EventListener event=attack /></activity></events></WaypointPatrolController></controller></SpaceShip>")
+      function placePirate(posX, posY, posZ, name, trigger)
+        print("<SpaceShip mass=10 health=25 initialhealth=25 maxhealth=25 shieldhealth=10 maxshieldhealth=10 initialshieldhealth=10 shieldabsorption=0.3 shieldrechargerate=1 shieldrechargewaittime=1 primaryThrust=40 auxiliaryThrust=15 rotationThrust=10 boostpower=5 boostrate=2 boostCooldownDuration = 20 position=\"" .. posX .. "," .. posY .. "," .. posZ .. "\" name=\"" .. name .. "\" radarname=Pirate><events><visibility><EventListener event=\"" .. trigger .. "\"/></visibility><activity><EventListener event=\"" .. trigger .. "\"/></activity></events><templates><Template link=spaceshippirate /></templates><controller><WaypointPatrolController alertnessradius=3129 team=1 active=false><waypoints><Model mesh=\"cube.mesh\" scale=0 position=\"-1300,-600,900\" /><Model mesh=\"cube.mesh\" scale=0 position=\"0,0,0\" /></waypoints><events><activity><EventListener event=attack /></activity></events></WaypointPatrolController></controller></SpaceShip>")
       end
+
+      function placeAsteroid(posX, posY, posZ, vx, vy, vz, trigger)
+        rx = math.random(-vmax, vmax)
+        ry = math.random(-vmax, vmax)
+        rz = math.random(-vmax, vmax)
+        rr = math.random() * 10
+        print("<Pawn team=1 health=30 position=\"" .. posX .. "," .. posY .. "," .. posZ .. "\" direction=\"0,0,-1\" velocity=\"" .. vx .. "," .. vy .. "," .. vz .. "\"rotationaxis=\"" .. rx .. "," .. ry .. "," .. rz .. "\" rotationrate=" .. rr .. " collisionType=dynamic mass=1 name=asteroid radarname=Asteroid> <events> <visibility> <EventListener event=\"" .. trigger .. "\" /> </visibility> </events> <attached> <Model position=\"0,0,0\" mesh=\"" .. asteroidMesh() .. "\" scale3D=\"10,10,10\" /> </attached> <collisionShapes> <SphereCollisionShape position=\"0,0,0\" radius=5 /> </collisionShapes> <!--controller> <WaypointController team=1> </WaypointController> </controller--> <explosion> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_flash2\" effect2=\"orxonox/explosion_flame2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_shockwave2\" effect2=\"orxonox/explosion_sparks2\" /> <ExplosionPart minspeed=0 maxspeed=0 effect1=\"orxonox/explosion_streak2\" effect2=\"orxonox/explosion_afterglow\" /> </explosion> </Pawn>")
+      end
     ?>
 
     <?lua
-      placePirate(0, 0, 5500, "passedAsteroidFieldOne")
-      placePirate(0, 0, 6500, "passedAsteroidFieldOne")
-      placePirate(0, 0, 7500, "passedAsteroidFieldOne")
+    placeAsteroid(0, 0, -1000, 0, 0, 0, "spawntrigger")
+    placeAsteroid(0, 0, -1100, 0, 0, 0, "spawntrigger")
+    placeAsteroid(0, 0, -1200, 0, 0, 0, "spawntrigger")
+    placeAsteroid(0, 0, -1300, 0, 0, 0, "spawntrigger")
+    placeAsteroid(0, 0, -1400, 0, 0, 0, "spawntrigger")
+    placeAsteroid(0, 0, -1500, 0, 0, 0, "spawntrigger")
+      placePirate(0, 0, 5500, "p1", "spawntrigger")
+      placePirate(0, 0, 6500, "p2", "spawntrigger")
+      placePirate(0, 0, 7500, "p3", "spawntrigger")
+      placePirate(0, 0, 5500, "p11", "firstPirateWaveKilled")
+      placePirate(0, 0, 5600, "p12", "firstPirateWaveKilled")
+      placePirate(0, 0, 5700, "p13", "firstPirateWaveKilled")
+      placePirate(0, 0, 5800, "p14", "firstPirateWaveKilled")
+      placePirate(0, 0, 5900, "p15", "firstPirateWaveKilled")
+      placePirate(0, 0, 6000, "p16", "firstPirateWaveKilled")
     ?>
 
   </Scene>

Modified: code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/CMakeLists.txt
===================================================================
--- code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/CMakeLists.txt	2017-11-27 15:15:26 UTC (rev 11603)
+++ code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/CMakeLists.txt	2017-11-27 15:29:35 UTC (rev 11604)
@@ -6,4 +6,5 @@
   ModularSpaceShip.cc
   TeamBaseMatchBase.cc
   Destroyer.cc
+  ShootableObstacle.cc
 )

Added: code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc
===================================================================
--- code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc	                        (rev 0)
+++ code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc	2017-11-27 15:29:35 UTC (rev 11604)
@@ -0,0 +1,59 @@
+/*
+ *   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:
+ *      Leon Rigoni
+ *
+ */
+
+namespace orxonox
+{
+    RegisterClass(ShootableObstacle);
+
+    ShootableObstacle::ShootableObstacle(Context* context) : Pawn(context)
+    {
+        RegisterObject(ShootableObstacle);
+    }
+
+    bool ShootableObstacle::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+    {
+        if (GameMode::isMaster() && enableCollisionDamage_)
+        {
+            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
+            if (victim)
+            {
+                float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
+                victim->hit(nullptr, contactPoint, ownCollisionShape, damage);
+            }
+        }
+
+        return false;
+    }
+
+    void ShootableObstacle::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(ShootableObstacle, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ShootableObstacle, "enablecollisiondamage", setEnableCollisionDamage, getEnableCollisionDamage, xmlelement, mode).defaultValues(false);
+        XMLPortParam(ShootableObstacle, "collisiondamage", setCollisionDamage, getCollisionDamage, xmlelement, mode).defaultValues(1);
+    }
+
+}
\ No newline at end of file

Added: code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.h
===================================================================
--- code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.h	                        (rev 0)
+++ code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.h	2017-11-27 15:29:35 UTC (rev 11604)
@@ -0,0 +1,66 @@
+/*
+ *   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:
+ *      Leon Rigoni
+ *
+ */
+#ifndef _ShootableObstacle_H__
+#define _ShootableObstacle_H__
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox // tolua_export
+{
+    /**
+    @brief
+        This class encapsulates a pawn (so an object with health) with the addition, that it damages other objects when it hits them.
+    */
+
+    class _OrxonoxExport ShootableObstacle
+        : public Pawn
+    {
+	    public:
+	    	ShootableObstacle(Context* context);
+	        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+	        virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) override;
+
+	        inline void setCollisionDamage(float c)
+	                { this->collisionDamage_ = c; }
+
+	        inline float getCollisionDamage()
+	            { return this->collisionDamage_; }
+
+	        inline void setEnableCollisionDamage(bool c)
+	        {
+	            this->enableCollisionDamage_ = c;
+	            this->enableCollisionCallback();
+	        }
+
+	        inline bool getEnableCollisionDamage()
+	            { return this->enableCollisionDamage_; }
+
+	    private:
+	    	float collisionDamage_;
+	        bool enableCollisionDamage_;
+    };
+}
+
+#endif
\ No newline at end of file



More information about the Orxonox-commit mailing list