Index: code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw
===================================================================
--- code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw	(revision 11638)
+++ code/branches/ProtectBoss_HS17/data/levels/ProtectBoss.oxw	(revision 11639)
@@ -2,7 +2,8 @@
  name = "ProtectBoss"
  description = "Protect a disabled cargo ship!"
- tags = "test"
+ tags = "test, mission"
  screenshot = "emptylevel.png"
 />
+
 
 <?lua
@@ -13,5 +14,4 @@
   include("HUDPickupTemplate.oxo")
   include("templates/pickupRepresentationTemplates.oxt")
-  include("includes/pickups.oxi")
 ?>
 
@@ -45,4 +45,8 @@
     skybox       = "Orxonox/Starbox"
   >
+
+    <?lua
+      include("includes/pickups.oxi")
+    ?>
 
     <WorldAmbientSound source="Earth.ogg" looping="true" playOnLoad="true" /> <!-- AlphaCentauri.ogg, Mars.ogg-->
@@ -65,5 +69,5 @@
         position  = "0,0,-2500"
         mass      = 100000
-        health    = 1000 initialhealth=1000 maxhealth="1000"
+        health    = 100 initialhealth=100 maxhealth="100"
         direction = "1,0,0"
         rotationaxis="0,0,1" rotationrate="4.5" velocity="0,0,30"
@@ -114,6 +118,12 @@
 
     <!-- triggers when first pirate wave is defeated -->
+
     <Trigger name="firstPirateWaveKilled" mode="and">
-      <EventTrigger activations="1" stayactive="true" >
+      <?lua
+        for n = 1, 3, 1 do
+          print("<EventTrigger activations=1 stayactive=true><events><trigger><EventListener event=p" .. n .. "/></trigger></events></EventTrigger>")
+        end
+      ?>
+      <!--EventTrigger activations="1" stayactive="true" >
         <events>
           <trigger>
@@ -135,8 +145,146 @@
           </trigger>
         </events>
-      </EventTrigger>
+      </EventTrigger-->
     </Trigger>
 
-    <!-- create asteroids -->
+    <!-- triggers when second pirate wave is defeated -->
+    <Trigger name="secondPirateWaveKilled" mode="and">
+      <?lua
+        for n = 1, 6, 1 do
+          print("<EventTrigger activations=1 stayactive=true><events><trigger><EventListener event=p1" .. n .. "/></trigger></events></EventTrigger>")
+        end
+      ?>
+      <!--EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p11" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p12" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p13" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p14" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p15" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p16" />
+          </trigger>
+        </events>
+      </EventTrigger-->
+    </Trigger>
+
+    <!-- triggers some time after the second pirate wave was defeated -->
+    <Trigger name="thirdPirateWaveStarting" delay=15>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="secondPirateWaveKilled" />
+          </trigger>
+        </events>
+      </EventTrigger>
+    </Trigger>
+
+    <!-- triggers when third pirate wave is defeated -->
+    <Trigger name="thirdPirateWaveKilled" mode="and" delay=5>
+      <?lua
+        for n = 1, 7, 1 do
+          print("<EventTrigger activations=1 stayactive=true><events><trigger><EventListener event=p2" .. n .. "/></trigger></events></EventTrigger>")
+        end
+      ?>
+      <!--EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p21" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p22" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p23" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p24" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p25" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p26" />
+          </trigger>
+        </events>
+      </EventTrigger>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="p27" />
+          </trigger>
+        </events>
+      </EventTrigger-->
+    </Trigger>
+
+    <Trigger name="succeedMission" delay=7>
+      <EventTrigger activations="1" stayactive="true" >
+        <events>
+          <trigger>
+             <EventListener event="thirdPirateWaveKilled" />
+          </trigger>
+        </events>
+      </EventTrigger>
+    </Trigger>
+
+      <EventTrigger activations="1" stayactive="true" name="failMission" delay=0.1>
+        <events>
+          <trigger>
+             <EventListener event="CargoShip" />
+          </trigger>
+        </events>
+      </EventTrigger>
+
+    <!-- create asteroids and pickups -->
     <?lua
       function asteroidMesh()
@@ -163,12 +311,12 @@
         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> <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>")
+        print("<ShootableObstacle team=1 enablecollisiondamage=true collisiondamage=10 health=100 maxhealth=100 initialhealth=100 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> </ShootableObstacle>")
       end
 
-      for count = 1, 20, 1 do
+      for count = 1, 50, 1 do
         x = math.random(-1000, 1000)
         y = math.random(-1000, 1000)
         z = 125 * count + math.random(-250, 250)
-        typenum = math.random(7)
+        typenum = math.random(11)
         type = ""
         if typenum == 1 then
@@ -184,14 +332,19 @@
         elseif typenum == 6 then
           type = "hugehealth"
+        elseif typenum == 7 then
+          type = "crazyhealth"
+        elseif typenum == 8 then
+          type = "smallshield"
+        elseif typenum == 9 then
+          type = "mediumshield"
+        elseif typenum == 10 then
+          type = "hugeshield"
         else
-          type = "crazyhealth"
+          type = "drone"
         end
         type = type .. "pickup"
-        --[[print("<PickupSpawner pickup=\"" .. "mediumhealth" .. "\" position=\"" .. x .. "," .. y .. "," .. z .. "\" triggerDistance=10 respawnTime=5 maxSpawnedItems=1 />")]]
+        print("<PickupSpawner pickup=\"" .. type .. "\" 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 -->
@@ -247,5 +400,5 @@
     </SimpleNotification>
 
-    <SimpleNotification message="The cargo ship got destroyed!" broadcast=true >
+    <SimpleNotification message="The cargo ship got destroyed! Game over!" broadcast=true >
       <events>
             <trigger>
@@ -263,36 +416,68 @@
     </SimpleNotification>
 
-
-    <!-- A function to put pirates and asteroids to a certain location -->
+    <SimpleNotification message="The third and last pirate wave is preparing for attack! They will arrive soon!" broadcast=true >
+      <events>
+            <trigger>
+                <EventListener event="secondPirateWaveKilled" />
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification message="The pirates are attacking!" broadcast=true >
+      <events>
+            <trigger>
+                <EventListener event="thirdPirateWaveStarting" />
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification message="You defeated the pirates! The cargo ship is exiting the asteroid field. You made it!" broadcast=true >
+      <events>
+            <trigger>
+                <EventListener event="thirdPirateWaveKilled" />
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <Script code="Mission endMission true" onLoad="false">
+        <events>
+            <trigger>
+                <EventListener event="succeedMission" />
+            </trigger>
+        </events>
+    </Script>
+
+    <Script code="Mission endMission false" onLoad="false">
+        <events>
+            <trigger>
+                <EventListener event="CargoShip" />
+            </trigger>
+        </events>
+    </Script>
+
+    <!-- A function to put pirates to a certain location -->
     <?lua
       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
-    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, 3000, "p1", "passedAsteroidFieldOne")
+      placePirate(50, 0, 3500, "p2", "passedAsteroidFieldOne")
+      placePirate(0, 50, 4000, "p3", "passedAsteroidFieldOne")
       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(50, 0, 5600, "p12", "firstPirateWaveKilled")
+      placePirate(-50, 0, 5700, "p13", "firstPirateWaveKilled")
+      placePirate(0, 50, 5800, "p14", "firstPirateWaveKilled")
+      placePirate(0, -50, 5900, "p15", "firstPirateWaveKilled")
       placePirate(0, 0, 6000, "p16", "firstPirateWaveKilled")
+      placePirate(0, 0, 7000, "p21", "thirdPirateWaveStarting")
+      placePirate(50, 0, 7100, "p22", "thirdPirateWaveStarting")
+      placePirate(-50, 0, 7200, "p23", "thirdPirateWaveStarting")
+      placePirate(0, 50, 7300, "p24", "thirdPirateWaveStarting")
+      placePirate(0, -50, 7400, "p25", "thirdPirateWaveStarting")
+      placePirate(50, 50, 7500, "p26", "thirdPirateWaveStarting")
+      placePirate(-50, -50, 7600, "p27", "thirdPirateWaveStarting")
     ?>
 
Index: code/branches/ProtectBoss_HS17/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/ProtectBoss_HS17/src/orxonox/controllers/DroneController.cc	(revision 11638)
+++ code/branches/ProtectBoss_HS17/src/orxonox/controllers/DroneController.cc	(revision 11639)
@@ -49,4 +49,5 @@
         RegisterObject(DroneController);
 
+        this->setTeam(0);
         this->owner_ = nullptr;
         this->drone_ = nullptr;
@@ -164,4 +165,5 @@
             }
         }
+        
         SUPER(AIController, tick, dt);
     }
Index: code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc
===================================================================
--- code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc	(revision 11638)
+++ code/branches/ProtectBoss_HS17/src/orxonox/worldentities/pawns/ShootableObstacle.cc	(revision 11639)
@@ -25,4 +25,7 @@
  */
 
+#include "ShootableObstacle.h"
+#include "core/XMLPort.h"
+
 namespace orxonox
 {
@@ -32,4 +35,5 @@
     {
         RegisterObject(ShootableObstacle);
+        this->enableCollisionCallback();
     }
 
