Index: code/branches/levelMichael/data/levels/Spacefight.oxw
===================================================================
--- code/branches/levelMichael/data/levels/Spacefight.oxw	(revision 9769)
+++ code/branches/levelMichael/data/levels/Spacefight.oxw	(revision 9778)
@@ -60,11 +60,13 @@
  <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
 
-<!-- QUESTS & SPAWNTRIGGER -->
-
-<!-- Spawntrigger -->
+<!-- SPAWNTRIGGER -->
+
+<!-- Spawntrigger -->    
+	<SpawnPoint team=0 position="0,0,0" lookat="100,0,0" spawnclass=SpaceShip pawndesign=spaceshipswallow />
+	
 	<EventMultiTrigger name=spawntrigger>
 	  <events>
 	    <trigger>
-	      <SpawnPoint team=0 position="0,0,0" lookat="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipcollateralDamage >
+	      <SpawnPoint team=0 position="0,0,0" lookat="100,0,0" spawnclass=SpaceShip pawndesign=spaceshipswallow >
 	        <EventTrigger invert=true>
 		  <events>
@@ -77,5 +79,8 @@
 	    </trigger>
 	  </events>
-	</EventMultiTrigger>
+	</EventMultiTrigger>	
+
+	<!-- Second Spawntrigger -->
+	<DistanceTrigger name=spawntrigger2 position="0,0,0" target="SpaceShip" distance=10 stayActive="true" delay=0 />
 
 	<!-- Drone pickup -->
@@ -152,18 +157,9 @@
 				Prepare to fight against a strong enmey!"
 			completeMessage="Well done! Now the element of surprise will be ours!" />
-		<complete-effects>
-			<AddQuest questId="spacefight.flying3" />
-		</complete-effects>
 	</LocalQuest>
 
-	<LocalQuest id="spacefight.flying3" >
-		<QuestDescription
-			title="Prepared for the big fight?"
-			description=""
-			failMessage="You've lost all your ships!"
-			completeMessage="" />
-	</LocalQuest>
-
-	<LocalQuest id="spacefight.mainfight" >
+<!-- 2 different possibilitys -->
+	<!-- Spion is destroyed -->
+	<LocalQuest id="spacefight.mainfight(min)" >
 		<QuestDescription
 			title="The big fight!"
@@ -178,4 +174,19 @@
 	</LocalQuest>
 
+	<!-- Spion isn't destroyed -->
+	<LocalQuest id="spacefight.mainfight(max)" >
+		<QuestDescription
+			title="The big fight!"
+			description="Now the time is come!
+				You've done all you can to prepare you for this spacebattle.
+				Unfortunately the spion has alert the mainship. So the soldiers will also be prepared for you.
+				But you can manage it.
+				Good luck!"
+			failMessage="You've lost all your ships!"
+			completeMessage="YEEEHAAA!
+				You managed it! For that you will get the golden medal of the united space armies." />
+	</LocalQuest>
+<!-- -->
+
 	<LocalQuest id="spacefight.rescue" >
 		<QuestDescription
@@ -232,9 +243,20 @@
 			<CompleteQuest questId="spacefight.guard1" />
 		</effects>
-		<attached>
-			<BlinkingBillboard position="13500, 2500, 10500" color="1,1,0" frequency=0.6 amplitude=10 material="Examples/Flare" />
-		</attached>
 	</QuestEffectBeacon>
 
+	<BlinkingBillboard position="13500, 2500, 10500" color="1,1,1" frequency=0.6 amplitude=10 material="Examples/Flare" >
+          <events>
+            <visibility>
+              <EventTrigger>
+                <events>
+                  <trigger>
+                    <EventListener event=spawntrigger2 /> <!-- "guard1trigger4" -->
+                  </trigger>
+                </events>
+	      </EventTrigger>
+            </visibility>
+          </events>
+	</BlinkingBillboard>
+	
 	<!-- Drone (optional) -->
 	<QuestEffectBeacon times=0>
@@ -250,4 +272,18 @@
 	
 	<!-- Guard 2 -->
+
+	<!-- zum testen! -->
+	<QuestEffectBeacon times=0>
+		<effects>
+			<AddQuest questId="spacefight.flying2" />
+		</effects>
+		<events>
+			<execute>
+				<EventListener event=spawntrigger2 />
+			</execute>
+		</events>
+	</QuestEffectBeacon>
+	<!-- -->
+
 	<QuestEffectBeacon times=0>
 		<effects>
@@ -268,5 +304,5 @@
 		<events>
 			<execute>
-				<EventListener event="flying3" /> <!-- eigentlich "guard2trigger4", aber funkt. nicht! -->
+				<EventListener event="guard2" /> <!-- eigentlich "guard2trigger4", aber funkt. nicht! -->
 			</execute>		
 		</events>
@@ -274,9 +310,48 @@
 
 	<!-- Escape -->
+	<SimpleNotification message="A spion is startet to the mainship!"  broadcast="true">
+		<events>
+			<trigger>
+				<EventListener event="guard2trigger1" />
+			</trigger>
+		</events>
+	</SimpleNotification>
+
+	<QuestEffectBeacon times=0>
+		<effects>
+			<AddQuest questId="spacefight.escape" />
+		</effects>
+		<events>
+			<execute>
+				<EventListener event="guard2trigger1" />
+			</execute>
+		</events>
+	</QuestEffectBeacon>
+
+	<QuestEffectBeacon times=0>
+		<effects>
+			<CompleteQuest questId="spacefight.escape" />
+			<CompleteQuest questId="spacefight.mainfight(max)" />
+		</effects>
+		<events>
+			<execute>
+				<EventListener event="escaped" />
+			</execute>
+		</events>
+	</QuestEffectBeacon>
+
+	<QuestEffectBeacon>
+		<effects>
+			<CompleteQuest questId="spacefight.escape" />
+			<AddQuest questId="spacefight.mainfight(min)" />
+		</effects>
+		<events>
+			<execute>
+				<EventListener event="notEscaped" />
+			</execute>
+		</events>
+	</QuestEffectBeacon>
 
 <!-- ---------------------------------------------------------------------- -->
-	<!-- Second Spawntrigger -->
-	<DistanceTrigger name=spawntrigger2 position="0,0,0" target="SpaceShip" distance=10 stayActive="true" delay=0 />
-
 	<!--Helper-Trigger for first guard -->
 	<DistanceTrigger name="flying1" position="4000,0,0" target="SpaceShip" distance=2000 stayActive="true" delay=0 />
@@ -319,5 +394,5 @@
 			</trigger>
 		</events>
-	</SimpleNotification>
+	</SimpleNotification>	
 
 <!-- ----------------------------------------------------- -->
@@ -388,6 +463,6 @@
     </EventTrigger>
 
+
 <!-- for guard 2 -->
-
     <SimpleNotification message="first"  broadcast="true">
         <events>
@@ -414,8 +489,8 @@
     </SimpleNotification>
 
-    <SimpleNotification message="all shot! Fly to the blinking light"  broadcast="true">
+    <SimpleNotification message="all shot! Catch the spion!"  broadcast="true">
         <events>
             <trigger>
-                <EventListener event="guard2trigger4" />
+                <EventListener event="guard2" />
             </trigger>
         </events>
@@ -452,4 +527,42 @@
     </EventTrigger>
 
+	<EventTrigger name="guard2" stayactive="true" delay=0.1 >
+		<events>
+			<trigger>
+				<EventListener event="guard2trigger4" />
+			</trigger>
+		</events>
+	</EventTrigger>
+
+<!-- For Escape -->
+	<!-- If the spion is escaped -->
+	<Trigger name="escaped" mode="xor" stayActive="true" >
+		<DistanceTrigger position="-7000,-10000,42000" target="SpaceShip" distance=100 stayActive="true" delay=0 />
+		<EventTrigger activations="1" >
+			<events>
+				<trigger>
+					<EventListener event="spion" />
+				</trigger>
+			</events>
+		</EventTrigger>
+	</Trigger>
+
+	<!-- If the spion is destroyed -->
+	<Trigger name="notEscaped" mode="xor" stayActive="true" >
+		<DistanceTrigger position="-7000,-10000,42000" target="SpaceShip" distance=100 stayActive="true" delay=0 />
+		
+		<!-- If the spion is escaped -->
+		<Trigger name="escaped" mode="xor" stayActive="true" >
+			<DistanceTrigger position="-7000,-10000,42000" target="SpaceShip" distance=100 stayActive="true" delay=0 />
+			<EventTrigger activations="1" >
+				<events>
+					<trigger>
+						<EventListener event="spion" />
+					</trigger>
+				</events>
+			</EventTrigger>
+		</Trigger>
+	</Trigger>		
+	
 <!-- ----------------------------------------------------- -->
 
@@ -549,5 +662,5 @@
   <events>
     <visibility>
-      <EventListener event="guard1trigger4" />
+      <EventListener event="flying2" /> <!-- "guard1trigger4" -->
     </visibility>
   </events>
@@ -569,5 +682,5 @@
       <events>
         <activity>
-          <EventListener event="guard1trigger4" />
+          <EventListener event="flying2" /> <!-- "guard1trigger4" -->
         </activity>
       </events>
@@ -579,5 +692,5 @@
   <events>
     <visibility>
-      <EventListener event="guard1trigger4" />
+      <EventListener event="flying2" /> <!-- "guard1trigger4" -->
     </visibility>
   </events>
@@ -599,5 +712,5 @@
       <events>
         <activity>
-          <EventListener event="guard1trigger4" />
+          <EventListener event="flying2" /> <!-- "guard1trigger4" -->
         </activity>
       </events>
@@ -609,5 +722,5 @@
   <events>
     <visibility>
-      <EventListener event="guard1trigger4" />
+      <EventListener event="flying2" /> <!-- "guard1trigger4" -->
     </visibility>
   </events>
@@ -629,5 +742,5 @@
       <events>
         <activity>
-          <EventListener event="guard1trigger4" />
+          <EventListener event="flying2" /> <!-- "guard1trigger4" -->
         </activity>
       </events>
@@ -639,5 +752,5 @@
   <events>
     <visibility>
-      <EventListener event="guard1trigger4" />
+      <EventListener event="flying2" /> <!-- "guard1trigger4" -->
     </visibility>
   </events>
@@ -659,5 +772,5 @@
       <events>
         <activity>
-          <EventListener event="guard1trigger4" />
+          <EventListener event="flying2" /> <!-- "guard1trigger4" -->
         </activity>
       </events>
@@ -666,4 +779,29 @@
 </SpaceShip>
 
+<!-- Escape-Ship -->
+<SpaceShip position="17000,4000,22000" lookat="-12000, -22000, 25000" name="spion" visible="true" radarname="Spion" >
+  <events>
+    <visibility>
+      <EventListener event="flying2" /> <!-- "guard1trigger4" -->
+    </visibility>
+  </events>
+  <templates>
+    <Template link=spaceshippirate />
+  </templates>
+  <controller>
+    <WaypointController team=1>
+      <waypoints>
+        <Model mesh="cube.mesh" scale=1000 position="-7000,-10000,42000" />
+        <Model mesh="cube.mesh" scale=1000 position="-12000, -22000, 25000" />
+      </waypoints>
+      <events>
+	<activity>
+	  <EventListener event="guard2trigger1" />
+	</activity>
+      </events>
+    </WaypointController>
+  </controller>
+</SpaceShip>
+
 
 <!-- ----------------------------------------------------- -->
@@ -671,13 +809,12 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
 
-    <SpawnPoint team=0 position="0,0,0" lookat="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipswallow />
-    
+
 <!-- ASTEROIDS & ASTEROID-FIELDS -->
 
-<!-- Asteroids -->
-
-      <Model position="9800, -5000, 5700" yaw="90" pitch="-90" roll="0" scale="300" mesh="asteroid_ice.mesh" />
-
-<!-- triple large belt around the planet  -->
+	<!-- Asteroids -->
+
+	<Model position="9800, -5000, 5700" yaw="90" pitch="-90" roll="0" scale="300" mesh="asteroid_ice.mesh" />
+
+	<!-- triple large belt around the planet  -->
 	<?lua
 		dofile("includes/asteroidField.lua")
@@ -695,76 +832,92 @@
 	?>
 
-<!-- other asteroid fileds -->
-
-	<!-- left before guard 1 -->	
-	<?lua
-		dofile("includes/asteroidField.lua")
-		asteroidField(-5000, -5000, -20000, 20, 50, 10000, 200, 0)
-	?>
-
-	<!-- left behind guard 1 -->
-	<?lua
-		dofile("includes/asteroidField.lua")
-		asteroidField(20000, -10000, -12000, 30, 100, 10000, 200, 0)
-	?>
-
-	<!-- between guard 2 & mainship -->
-	<!-- Core -->	
-	<?lua
-		dofile("includes/asteroidField.lua")
-		asteroidField(-5000, -10000, 30000, 10, 700, 8000, 80, 0)
-	?>
+	<!-- other asteroid fileds -->
+
+		<!-- left before guard 1 -->	
+		<?lua
+			dofile("includes/asteroidField.lua")
+			asteroidField(-5000, -5000, -20000, 20, 50, 10000, 200, 0)
+		?>
+
+		<!-- left behind guard 1 -->
+		<?lua
+			dofile("includes/asteroidField.lua")
+			asteroidField(20000, -10000, -12000, 30, 100, 10000, 200, 0)
+		?>
+
+		<!-- between guard 2 & mainship -->
+			<!-- Core -->	
+			<?lua
+				dofile("includes/asteroidField.lua")
+				asteroidField(-5000, -10000, 30000, 10, 700, 8000, 80, 0)
+			?>
 	
-	<!-- Peripherie -->
-	<?lua
-		dofile("includes/asteroidField.lua")
-		asteroidField(-5000, -10000, 30000, 10, 50, 10000, 100, 0)
-	?>
-
-	<?lua
-      		dofile("includes/asteroidField.lua")
-		asteroidBelt(-10000, -12500, 0, 0, 0, 30, 30, 500, 0, 7850, 150, 0)
-    	?>
+			<!-- Peripherie -->
+			<?lua
+				dofile("includes/asteroidField.lua")
+				asteroidField(-5000, -10000, 30000, 10, 50, 10000, 100, 0)
+			?>
+
+			<?lua
+		      		dofile("includes/asteroidField.lua")
+				asteroidBelt(-10000, -12500, 0, 0, 0, 30, 30, 500, 0, 7850, 150, 0)
+		    	?>
 
 <!-- PLANETS -->
 
-  <Planet 	position="2000,-250,9000" 
-		scale=5000 
-		pitch=1 
-		mesh="iceplanet.mesh" 
-		atmosphere="atmosphere1" 
-		rotationaxis="1,1,0" 
-		rotationrate="0.5" 
-		atmospheresize=224.0f 
-		imagesize=1024.0f />
+  	<Planet 	position="2000,-250,9000" 
+			scale=5000 
+			pitch=1 
+			mesh="iceplanet.mesh" 
+			atmosphere="atmosphere1" 
+			rotationaxis="1,1,0" 
+			rotationrate="0.5" 
+			atmospheresize=224.0f 
+			imagesize=1024.0f />
+
+	<BlinkingBillboard position="-7000,-10000,42000" color="1,1,1" frequency=0.6 amplitude=100 material="Examples/Flare" >
+          <events>
+            <visibility>
+              <EventTrigger>
+                <events>
+                  <trigger>
+                    <EventListener event="spion" />
+                  </trigger>
+                </events>
+	      </EventTrigger>
+            </visibility>
+          </events>
+	</BlinkingBillboard>
 
 
 <!-- ----------------Rotating SpaceStation--------------- -->
 
-<StaticEntity position="9000,0,0" yaw=112 pitch=67>
-  <attached>
-    <?lua
-      createSpaceStationPar(0,2,1,2,1,4,1,50)
-    ?>
-  </attached>
-</StaticEntity>
-
-<StaticEntity position="18000,5000,21000" yaw=12 pitch=75>
-  <attached>
-    <?lua
-      createSpaceStationPar(0,2,1,2,1,4,1,50)
-    ?>
-  </attached>
-</StaticEntity>
+	<!-- first guard -->
+	<StaticEntity position="9000,0,0" yaw=112 pitch=67>
+		<attached>
+			<?lua
+				createSpaceStationPar(0,2,1,2,1,4,1,50)
+			?>
+		</attached>
+	</StaticEntity>
+
+	<!-- second guard -->
+	<StaticEntity position="18000,5000,21000" yaw=12 pitch=75>
+		<attached>
+			<?lua
+				createSpaceStationPar(0,2,1,2,1,4,1,50)
+			?>
+		</attached>
+	</StaticEntity>
 
 <!-- ------------------------- Mainship ------------------ -->
 
-<StaticEntity position="-12000, -22000, 25000" yaw=112 pitch=67>
-	<attached>
-		<?lua
-			createSpaceStationPar(0,2,1,2,1,4,1,50)
-		?>
-	</attached>
-</StaticEntity>
+	<StaticEntity position="-12000, -22000, 25000" yaw=112 pitch=67>
+		<attached>
+			<?lua
+				createSpaceStationPar(0,2,1,2,1,4,1,50)
+			?>
+		</attached>
+	</StaticEntity>
 
 
