Index: code/branches/campaignHS15/data/levels/expeditionSector.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/expeditionSector.oxw	(revision 10920)
+++ code/branches/campaignHS15/data/levels/expeditionSector.oxw	(revision 10921)
@@ -52,5 +52,5 @@
         radSector = 12000
 
-	      cStationA = {1400, 400, -800}
+	    cStationA = {1400, 400, -800}
         cNewShip = {1000, 250, -350}
 
@@ -91,5 +91,5 @@
 
     <GlobalQuest id="quest1">
-        <QuestDescription title="Quest 1" description="We received some extraterrestial binary radio signals from Sector 5C! We'd like yout to take the portal and fly over there to check out if life can be found there as we believed to be an inhabitated region in space." failMessage="" completeMessage="" />
+        <QuestDescription title="Get the scout ship" description="We received some extraterrestial binary radio signals from Sector 5C! We'd like you to get to the outer base in sector 4A and get a scout ship to explore the sector!" failMessage="" completeMessage="" />
         <hints>
         </hints>
@@ -99,7 +99,42 @@
     </GlobalQuest>
 
+    <GlobalQuest id="quest2">
+        <QuestDescription title="Explore the sector" description="Now then, Commander, fly over there to check out if life can be found in what we believed it to be an inhabitated region in space. We have marked 5B with red lights so you can easily find it." failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+        <subquests>
+            <GlobalQuest id="quest2.1">
+                <QuestDescription title="> Get to the Field Source" description="We percieve a large magnetic field source at a certain spot in the sector. You should check it out! We have marked it with a blue light." failMessage="" completeMessage="" />
+                <hints>
+                </hints>
+                <complete-effects>
+                    <AddQuest questId="quest2.2" />
+                </complete-effects>
+            </GlobalQuest>
+            <GlobalQuest id="quest2.2">
+                <QuestDescription title="> Fight your way out" description="Oh no... this cannot be happening! We discovered an alien race, and it does not seem to be interested in peace. In fact, they seem to be planning an attack! You must get out of the hot zone. Fight if necessary!" failMessage="" completeMessage="" />
+                <hints>
+                </hints>
+                <complete-effects>
+                    <AddQuest questId="quest3" />
+                </complete-effects>
+            </GlobalQuest>
+        </subquests>
+    </GlobalQuest>
+
+    <GlobalQuest id="quest3">
+        <QuestDescription title="Get back to 4A" description="You made it out in one piece. Now report to base 4A to warn the others!" failMessage="" completeMessage="" />
+        <hints>
+        </hints>
+    </GlobalQuest>
+
     <!--EVENTS AND TRIGGERS
         Usable events and triggers:
         spawntrigger
+        dockA
+        reachedSector
+        reachedEnemyStation
+        fightEnd
+        backToA
 
         BASE-STORY-LINE:
@@ -134,26 +169,73 @@
     </EventMultiTrigger>
 
-    <!--TODO: Complete the DistanceTriggers for completing/succeeding correctly! -->
-
-    <DistanceTrigger active=false name="missionComplete" position="2000,0,0" distance=100 target="SpaceShip" stayactive=true>
+    <!-- HACK: just waited out 3sec for animation. Cannot link an event to the COMPLETION of a dock. How is this not possible?? -->
+    <EventMultiTrigger name="dockedA" activations="1" stayactive="true" delay=3>
+        <events>
+            <trigger>
+                <EventListener event="dockA" />
+            </trigger>
+        </events>
+    </EventMultiTrigger>
+
+    <DistanceTrigger name="reachedSector" position="<?lua printC(cSector) ?>" distance="<?lua print(radSector) ?>" target="SpaceShip" beaconMode="identify" targetname="newSpaceShip" stayactive=true />
+
+    <DistanceTrigger name="reachedEnemyStation" position="<?lua printC(cEnemyBaseStation1) ?>" distance="5000" target="SpaceShip" beaconMode="identify" targetname="newSpaceShip" stayactive=true />
+
+    <!-- Recursive helper function for the fightEnd event -->
+    <?lua
+    function enemyTriggerRecursor(i)
+    if i > 0 then
+    return [[
+    <EventTrigger name=killedEnemy]] .. i .. [[ activations=1 stayactive=true delay=0.1>
+        <events>
+            <trigger>
+                <EventListener event=enemy />
+            </trigger>
+        </events>
+        ]] .. enemyTriggerRecursor(i-1) .. [[
+    </EventTrigger>
+    ]]
+    else return ""
+    end
+    end
+    ?>
+    <!-- Actual Event for the enemies. -->
+    <?lua print(enemyTriggerRecursor(5)) ?>
+    <EventMultiTrigger name="fightEnd" delay=0.1 stayactive=true>
+        <events>
+            <trigger>
+                <EventListener event="killedEnemy5" />
+            </trigger>
+        </events>
+    </EventMultiTrigger>
+
+    <DistanceTrigger active=false name="closeToPatrol" position="<?lua printC(cStationA) ?>" distance="6000" target="SpaceShip" beaconMode="identify" targetname="newSpaceShip" stayactive=true >
         <events>
             <activity>
-                <EventListener event="missionCompletePrereq" />
+                <EventListener event="reachedEnemyStation" />
             </activity>
         </events>
     </DistanceTrigger>
 
+    <DistanceTrigger active=false name="backToA" position="<?lua printC(cStationA) ?>" distance="600" target="SpaceShip" beaconMode="identify" targetname="newSpaceShip" stayactive=true >
+        <events>
+            <activity>
+                <EventListener event="fightEnd" />
+            </activity>
+        </events>
+    </DistanceTrigger>
+
     <Script code="Mission endMission true" onLoad="false">
         <events>
             <trigger>
-                <EventListener event="missionComplete" />
+                <EventListener event="backToA" />
             </trigger>
         </events>
     </Script>
 
-    <DistanceTrigger active=false name="missionFailed" position="2000,0,0" distance=100 target="SpaceShip" stayactive=true>
+    <DistanceTrigger invert=true active=false name="hasDied" position="<?lua printC(cSector) ?>" distance="100000" target="SpaceShip" beaconMode="identify" targetname="newSpaceShip" stayactive=true >
         <events>
             <activity>
-                <EventListener event="missionFailedPrereq" />
+                <EventListener event="reachedSector" />
             </activity>
         </events>
@@ -163,5 +245,5 @@
         <events>
             <trigger>
-                <EventListener event="failMission" />
+                <EventListener event="hasDied" />
             </trigger>
         </events>
@@ -181,4 +263,50 @@
     </QuestEffectBeacon>
 
+    <QuestEffectBeacon times=1>
+        <effects>
+            <CompleteQuest questId="quest1" />
+        </effects>
+        <events>
+            <execute>
+                <EventListener event="dockedA" />
+            </execute>
+        </events>
+    </QuestEffectBeacon>
+
+    <QuestEffectBeacon times=1>
+        <effects>
+            <AddQuest questId="quest2.1" />
+        </effects>
+        <events>
+            <execute>
+                <EventListener event="reachedSector" />
+            </execute>
+        </events>
+    </QuestEffectBeacon>
+
+    <QuestEffectBeacon times=1>
+        <effects>
+            <CompleteQuest questId="quest2.1" />
+            <AddQuest questId="quest2.2" />
+        </effects>
+        <events>
+            <execute>
+                <EventListener event="reachedEnemyStation" />
+            </execute>
+        </events>
+    </QuestEffectBeacon>
+
+    <QuestEffectBeacon times=1>
+        <effects>
+            <CompleteQuest questId="quest2.2" />
+            <CompleteQuest questId="quest2" />
+        </effects>
+        <events>
+            <execute>
+                <EventListener event="fightEnd" />
+            </execute>
+        </events>
+    </QuestEffectBeacon>
+
     <!--NOTIFICATIONS -->
 
@@ -197,11 +325,123 @@
     </SimpleNotification>
 
-    <SimpleNotification broadcast="true" message="Please check your quests!">
-        <events>
-            <trigger>
-                <EventTrigger stayactive="true" delay=7 >
+    <SimpleNotification broadcast="true" message="We've picked up strange radio Signals from Sector 5B!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=8 >
                    <events>
                       <trigger>
                          <EventListener event="spawntrigger" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="Please dock to the outer base and get into the scout ship!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=12 >
+                   <events>
+                      <trigger>
+                         <EventListener event="spawntrigger" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="We have marked the sector in red Lights. Enter it!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=0 >
+                   <events>
+                      <trigger>
+                         <EventListener event="dockedA" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="Huh? Something's emanating a strong field... We marked it in blue.">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=0 >
+                   <events>
+                      <trigger>
+                         <EventListener event="reachedSector" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="Woah! What the hell? We made alien contact!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=0 >
+                   <events>
+                      <trigger>
+                         <EventListener event="reachedEnemyStation" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="It looks like they are getting ready to attack someone...">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=4 >
+                   <events>
+                      <trigger>
+                         <EventListener event="reachedEnemyStation" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="It must be us! Commander, get back to the base and report!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=8 >
+                   <events>
+                      <trigger>
+                         <EventListener event="reachedEnemyStation" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="Oh no! A patrol! When did it get here?!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=0 >
+                   <events>
+                      <trigger>
+                         <EventListener event="closeToPatrol" />
+                      </trigger>
+                   </events>
+                </EventTrigger>
+            </trigger>
+        </events>
+    </SimpleNotification>
+
+    <SimpleNotification broadcast="true" message="Phew, that was close. Now get back here!">
+        <events>
+            <trigger>
+                <EventTrigger stayactive="true" delay=0 >
+                   <events>
+                      <trigger>
+                         <EventListener event="fightEnd" />
                       </trigger>
                    </events>
@@ -244,5 +484,5 @@
             <Template link="station" />
         </templates>
-	<attached>
+        <attached>
             <DockingTarget name="dockTargetA" />
             <Dock position="0,0,0" active=true>
@@ -258,9 +498,23 @@
                     </execute>
                 </events>
-	    </Dock>
-	</attached>
+                <attached>
+                    <DistanceTrigger position="0,0,0" distance="200" target="SpaceShip" beaconMode="exclude" targetname="NPC" name="dockA" />
+                    <Billboard position="0,0,0" amplitude=1 material="Flares/lensflare" colour="1,0,0.05" />
+                </attached>
+            </Dock>
+        </attached>
     </Pawn>
 
     <!-- EnemyStation -->
+
+    <!-- Marking Billboard -->
+    <Billboard visible=false position="<?lua printC(cEnemyBaseStation1) ?>" amplitude=30 scale=2 material="Flares/lensflare" colour="0,0,1">
+        <events>
+           <visibility>
+              <EventListener event="reachedSector" />
+          </visibility>
+        </events>
+    </Billboard>
+
 
     <Pawn name="statB" team=1 radarname="EnemyBase" position="<?lua printC(cEnemyBaseStation1) ?>" direction="<?lua printC(cSpawn) ?>" yaw=45 pitch=-5 roll=-25 initialhealth=10000 maxhealth=10000 >
@@ -268,4 +522,12 @@
             <Template link="station" />
         </templates>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+            <activity>
+                <EventListener event="reachedEnemyStation" />
+            </activity>
+        </events>
     </Pawn>
 
@@ -275,7 +537,7 @@
             team                = "0"
             position            = "<?lua printC(cNewShip) ?>"
-            lookat              = "0, 0, 0"
-            health              = "400"
-            initialhealth       = "400"
+            lookat              = "<?lua printC(cSector) ?>"
+            health              = "1500"
+            initialhealth       = "1500"
             maxhealth           = "1500"
             shieldhealth        = "80"
@@ -301,5 +563,11 @@
     cBillNow = addC(cSector,rBillboard)
     ?>
-    <Billboard position="<?lua printC(cBillNow) ?>"  scale=10 material="Flares/lensflare" colour="1,0.2,0.2"/>
+    <Billboard position="<?lua printC(cBillNow) ?>"  scale=10 material="Flares/lensflare" colour="1,0.2,0.2" visible=false>
+        <events>
+            <visibility>
+                <EventListener event="dockedA" />
+            </visibility>
+        </events>
+    </Billboard>
     <?lua end ?>
 
@@ -337,5 +605,5 @@
         enablecollisiondamage=true
 	      visible=true
-	      active=true
+	      active=ture
       >
       <attached>
@@ -402,6 +670,6 @@
         collisiondamage=2
         enablecollisiondamage=true
-	      visible=true
-	      active=true
+	      visible=false
+	      active=false
       >
       <attached>
@@ -425,18 +693,36 @@
       z = -4400+j*100
     ?>
-    <SpaceShip visible=true active=false name="Enemies" radarname="Attacker" position="-11000,<?lua print(z)?>,<?lua print(x)?>" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemyStalled" radarname="Attacker" position="-11000,<?lua print(z)?>,<?lua print(x)?>" lookat="0,0,0" team=1>
         <templates>
             <Template link="spaceshippirate" />
         </templates>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+        </events>
     </SpaceShip>
     <?lua end ?>
     <?lua end ?>
 
-    <SpaceShip visible=true active=true name="Enemies" radarname="Attacker" position="-2700,-800,-800" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemy" radarname="Guard" position="-2700,-800,-800" lookat="0,0,0" team=1>
       <templates>
         <Template link=spaceshippirate />
       </templates>
+      <events>
+          <visibility>
+              <EventListener event="reachedEnemyStation" />
+          </visibility>
+          <activity>
+              <EventListener event="reachedEnemyStation" />
+          </activity>
+      </events>
       <controller>
-        <WaypointPatrolController accuracy=40 alertnessradius=100 team=1>
+        <WaypointPatrolController active=false accuracy=40 alertnessradius=2000 team=1>
+            <events>
+                <activity>
+                    <EventListener event="reachedEnemyStation" />
+                </activity>
+            </events>
           <waypoints>
             <StaticEntity position="-3400,-1200,-200" />
@@ -450,10 +736,23 @@
     </SpaceShip>
 
-    <SpaceShip visible=true active=true name="Enemies" radarname="Attacker" position="-3400,-1200,-200" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemy" radarname="Guard" position="-3400,-1200,-200" lookat="0,0,0" team=1>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+            <activity>
+                <EventListener event="reachedEnemyStation" />
+            </activity>
+        </events>
       <templates>
         <Template link=spaceshippirate />
       </templates>
       <controller>
-        <WaypointPatrolController accuracy=40 alertnessradius=100 team=1>
+        <WaypointPatrolController active=false accuracy=40 alertnessradius=2000 team=1>
+            <events>
+                <activity>
+                    <EventListener event="reachedEnemyStation" />
+                </activity>
+            </events>
           <waypoints>
             <StaticEntity position="-1600,-1000,-200" />
@@ -467,10 +766,23 @@
     </SpaceShip>
 
-    <SpaceShip visible=true active=true name="Enemies" radarname="Attacker" position="-1600,-1000,-200" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemy" radarname="Guard" position="-1600,-1000,-200" lookat="0,0,0" team=1>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+            <activity>
+                <EventListener event="reachedEnemyStation" />
+            </activity>
+        </events>
       <templates>
         <Template link=spaceshippirate />
       </templates>
       <controller>
-        <WaypointPatrolController accuracy=40 alertnessradius=100 team=1>
+        <WaypointPatrolController active=false accuracy=40 alertnessradius=2000 team=1>
+            <events>
+                <activity>
+                    <EventListener event="reachedEnemyStation" />
+                </activity>
+            </events>
           <waypoints>
             <StaticEntity position="-1700,-1400,-940" />
@@ -484,10 +796,23 @@
     </SpaceShip>
 
-    <SpaceShip visible=true active=true name="Enemies" radarname="Attacker" position="-1700,-1400,-940" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemy" radarname="Guard" position="-1700,-1400,-940" lookat="0,0,0" team=1>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+            <activity>
+                <EventListener event="reachedEnemyStation" />
+            </activity>
+        </events>
       <templates>
         <Template link=spaceshippirate />
       </templates>
       <controller>
-        <WaypointPatrolController accuracy=40 alertnessradius=100 team=1>
+        <WaypointPatrolController active=false accuracy=40 alertnessradius=2000 team=1>
+            <events>
+                <activity>
+                    <EventListener event="reachedEnemyStation" />
+                </activity>
+            </events>
           <waypoints>
             <StaticEntity position="-2100,-1200,-1250" />
@@ -501,10 +826,23 @@
     </SpaceShip>
 
-    <SpaceShip visible=true active=true name="Enemies" radarname="Attacker" position="-2100,-1200,-1250" lookat="0,0,0" team=1>
+    <SpaceShip visible=false active=false name="enemy" radarname="Guard" position="-2100,-1200,-1250" lookat="0,0,0" team=1>
+        <events>
+            <visibility>
+                <EventListener event="reachedEnemyStation" />
+            </visibility>
+            <activity>
+                <EventListener event="reachedEnemyStation" />
+            </activity>
+        </events>
       <templates>
         <Template link=spaceshippirate />
       </templates>
       <controller>
-        <WaypointPatrolController accuracy=40 alertnessradius=100 team=1>
+        <WaypointPatrolController active=false accuracy=40 alertnessradius=2000 team=1>
+            <events>
+                <activity>
+                    <EventListener event="reachedEnemyStation" />
+                </activity>
+            </events>
           <waypoints>
             <StaticEntity position="-2700,-800,-800" />
@@ -518,5 +856,4 @@
     </SpaceShip>
 
-
     </Scene>
 </Level>
