Index: code/branches/campaignHS15/data/levels/Campaign1.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/Campaign1.oxw	(revision 10680)
+++ code/branches/campaignHS15/data/levels/Campaign1.oxw	(revision 10683)
@@ -25,4 +25,5 @@
         <Template link="lodtemplate_default" />
     </templates>
+
     <?lua include("includes/notifications.oxi") ?>
 
@@ -32,4 +33,6 @@
     >
 
+    <SpawnPoint name="PlayerSpawn" team=1 position="0,-50,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 />
+
     <WorldAmbientSound source="Earth.ogg" looping="true" playOnLoad="true" />
 
@@ -43,115 +46,136 @@
             <QuestHint id="quest1hint1" />
         </hints>
-        <subquests>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest2">
-        <QuestDescription title="Prepare to fight the Wave" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-            <GlobalQuest id="quest2.1">
-                <QuestDescription title="Get a better Spaceship" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-            <GlobalQuest id="quest2.2">
-                <QuestDescription title="Get some Pickups" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-            <GlobalQuest id="quest2.3">
-                <QuestDescription title="Meet your Unit" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest3">
-        <QuestDescription title="Fight the first Wave" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest4">
-        <QuestDescription title="Prepare for the next Wave" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-            <GlobalQuest id="quest4.1">
-                <QuestDescription title="Get to the Defense Station" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-            <GlobalQuest id="quest4.2">
-                <QuestDescription title="Find the turret" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest5">
-        <QuestDescription title="Fight the Hord!" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest6">
-        <QuestDescription title="Get back to the Transporter" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-            <GlobalQuest id="quest6.1">
-                <QuestDescription title="Collect the local Pickups" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-            <GlobalQuest id="quest6.2">
-                <QuestDescription title="Use Portal to the Transporter" description="" failMessage="" completeMessage="" />
-            </GlobalQuest>
-        </subquests>
-    </GlobalQuest>
-
-    <GlobalQuest id="quest7">
-        <QuestDescription title="Fight the final Wave" description="" failMessage="" completeMessage="" />
-        <hints>
-        </hints>
-        <subquests>
-        </subquests>
-    </GlobalQuest>
-
-    <!--EVENTS-->
-
-    <EventMultiTrigger name=spawntrigger>
-        <events>
-            <trigger>
-                <SpawnPoint team=1 position="0,-50,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 />
-            </trigger>
-        </events>
-    </EventMultiTrigger>
-
-    <QuestEffectBeacon times=1>
-        <effects>
-            <AddQuest questId="quest1" />
+        <complete-effects>
             <AddQuest questId="quest2" />
             <AddQuest questId="quest2.1" />
             <AddQuest questId="quest2.2" />
             <AddQuest questId="quest2.3" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest2">
+        <QuestDescription title="Prepare to fight the Wave" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <subquests>
+            <GlobalQuest id="quest2.1">
+                <QuestDescription title="Get a better Spaceship" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+            <GlobalQuest id="quest2.2">
+                <QuestDescription title="Get some Pickups" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+            <GlobalQuest id="quest2.3">
+                <QuestDescription title="Meet your Unit" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+        </subquests>
+        <complete-effects>
             <AddQuest questId="quest3" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest3">
+        <QuestDescription title="Fight the first Wave" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <complete-effects>
             <AddQuest questId="quest4" />
             <AddQuest questId="quest4.1" />
             <AddQuest questId="quest4.2" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest4">
+        <QuestDescription title="Prepare for the next Wave" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <subquests>
+            <GlobalQuest id="quest4.1">
+                <QuestDescription title="Get to the Defense Station" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+            <GlobalQuest id="quest4.2">
+                <QuestDescription title="Find the turret" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+        </subquests>
+        <complete-effects>
             <AddQuest questId="quest5" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest5">
+        <QuestDescription title="Fight the Hord!" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <complete-effects>
             <AddQuest questId="quest6" />
             <AddQuest questId="quest6.1" />
             <AddQuest questId="quest6.2" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest6">
+        <QuestDescription title="Get back to the Transporter" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <subquests>
+            <GlobalQuest id="quest6.1">
+                <QuestDescription title="Collect the local Pickups" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+            <GlobalQuest id="quest6.2">
+                <QuestDescription title="Use Portal to the Transporter" description="" failMessage="" completeMessage="" />
+            </GlobalQuest>
+        </subquests>
+        <complete-effects>
             <AddQuest questId="quest7" />
+        </complete-effects>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest7">
+        <QuestDescription title="Fight the final Wave" description="" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <subquests>
+        </subquests>
+    </GlobalQuest>
+
+    <!--EVENTS AND TRIGGERS
+        Usable events and triggers:
+        _spawntrigger
+        _reachedA
+        _wave<1|2|3>
+    -->
+
+    <EventMultiTrigger name="spawntrigger">
+        <events>
+            <trigger>
+                <EventListener event="PlayerSpawn" />
+            </trigger>
+        </events>
+    </EventMultiTrigger>
+
+    <QuestEffectBeacon times=1>
+        <effects>
+            <AddQuest questId="quest1" />
         </effects>
         <events>
             <execute>
-                <EventListener event=spawntrigger />
+                <EventListener event="spawntrigger" />
             </execute>
         </events>
     </QuestEffectBeacon>
 
+    <DistanceTrigger name="reachedA" position="2494,-1667,0" distance=200 target="SpaceShip" beaconMode="exclude" targetname="NPC" stayactive=true />
+
+    <EventMultiTrigger name="wave1">
+        <events>
+            <trigger>
+                <EventListener event="reachedA" />
+            </trigger>
+        </events>
+    </EventMultiTrigger>
+
     <!--STRUCTURE -->
 
     <!-- A, Coordinates are approx. (cos(29pi/16), sin(29pi/16), 0)*3000 -->
-    <StaticEntity position="2494,-1667,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
+    <StaticEntity name="statA" position="2494,-1667,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01>
         <attached>
             <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
@@ -163,5 +187,5 @@
 
     <!-- B, Coordinates are approx. (-cos(29pi/16), sin(29pi/16), 0)*3000 -->
-    <StaticEntity position="-2494,-1667,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
+    <StaticEntity name="statB" position="-2494,-1667,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01>
         <attached>
             <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
@@ -172,33 +196,68 @@
     </StaticEntity>
 
+    <!-- C -->
+    <StaticEntity name="statC" position="0,-1400,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01>
+        <attached>
+            <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,0" halfExtents="10,10,10" />
+        </collisionShapes>
+    </StaticEntity>
+
     <!--ELEMENTS -->
 
-    <!-- Enemies -->
+    <!-- Enemies. Outer loop defines waves, inner loop defines enemies in every wave. -->
     <?lua
-    max = 5
-    for i = 1, max, 1
+    waves = 5
+    for k = 1, waves, 1
+    do
+    ?>
+    <?lua
+    enemies = 5
+    for i = 1, enemies, 1
     do
     x = math.cos(math.pi/8*(i+1))*1500
     y = math.sin(math.pi/8*(i+1))*1500
     ?>
-    <SpaceShip position="<?lua print(x)?>,<?lua print(y)?>,<?lua print(math.pow(-1,i)*250) ?>" lookat="0,0,0" team=2>
+    <SpaceShip visible=false active=false name="attackers<?lua print(k)?>" radarname="Attacker" position="<?lua print(x)?>,<?lua print(y)?>,<?lua print(math.pow(-1,i)*250) ?>" lookat="0,0,0" team=2>
         <templates>
             <Template link="spaceshippirate" />
         </templates>
+        <events>
+            <visibility>
+                <EventListener event="wave<?lua print(k)?>" />
+            </visibility>
+            <activity>
+                <EventListener event="wave<?lua print(k)?>" />
+            </activity>
+        </events>
+        <attached>
+            <DistanceTriggerBeacon name="NPC" />
+        </attached>
         <controller>
-            <WaypointPatrolController alertnessradius=50 team=1>
+            <WaypointPatrolController name="attackController" alertnessradius=50 team=1 active=false>
                 <waypoints>
                     <Attacher target="transporter" deletewithparent=false />
                 </waypoints>
+                <events>
+                    <activity>
+                        <EventListener event="wave<?lua print(k)?>" />
+                    </activity>
+                </events>
             </WaypointPatrolController>
         </controller>
     </SpaceShip>
     <?lua end ?>
+    <?lua end ?>
 
     <!-- Transporter, starting Point is near A, end Point near B, the circle parameters for the waypoints are: Center = (0, -887, 0), r = 2613 -->
-    <SpaceShip position="2450, -1667, 0" lookat="-2494, -1667, 0" team=1 name="transporter">
+    <SpaceShip position="2450, -1667, 0" lookat="-2494, -1667, 0" team=1 name="transporter" radarname="Shuttle">
         <templates>
             <Template link="spaceshipTransporter" />
         </templates>
+        <attached>
+            <DistanceTriggerBeacon name="NPC" />
+        </attached>
         <controller>
             <WaypointController accuracy=10>
