<?lua
  include("overlay/hudtemplates3.oxo")
  include("overlay/stats.oxo")
  include("levels/templates/spaceship_assff.oxt")
?>

<?lua
	dofile("../../media/levels/includes/CuboidSpaceStation.lua")
?>

<NotificationQueue
	name  = "notification"
	position = "1.0, 1.0"
	targets = "questsystem"
/>

<Level
 name         = "The Tale of Princess Aeryn"
 description  = "The Tale of Princess Aeryn"
>
    <Scene
        ambientlight = "0.3, 0.3, 0.3"
        skybox       = "Orxonox/skypanoramagen1"
    >
      <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" />

        <Template name=turboitem baseclass=Turbo>
          <Turbo
            playerclass=SpaceShip
            duration=15
          />
        </Template>

        <ParticleSpawner position="200,0,-500" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
          <events>
            <spawn>
              <PickupSpawner position="200,0,-500" distance=50 respawntimer=25 item=turboitem>
                <attached>
                  <Model mesh="sphere.mesh" scale=3 />
                  <Billboard material="Examples/Flare" colour="0.5, 1.0, 0.3" scale=0.5 />
                </attached>
              </PickupSpawner>
            </spawn>
          </events>
        </ParticleSpawner>

        <Template name=turboequipment baseclass=Turbo>
          <Turbo
            playerclass=SpaceShip
            duration=0
          />
        </Template>

        <ParticleSpawner position="400,0,-1000" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
          <events>
            <spawn>
              <PickupSpawner position="400,0,-1000" distance=50 respawntimer=25 item=turboequipment>
                <attached>
                  <Model mesh="sphere.mesh" scale=3 />
                  <Billboard material="Examples/Flare" colour="1.0, 0.5, 0.3" scale=0.5 />
                </attached>
              </PickupSpawner>
            </spawn>
          </events>
        </ParticleSpawner>

        <!-- Quest: -->
        <GlobalQuest id="b80c2c60-e62c-4637-80f8-5aa18dc93b34">
            <QuestDescription title="The Tale of Princess Aeryn" description="Princess Aeryn has been kidnapped by evil Mr. M and you were just a little too late to save her.\nYou have to find and save her from her captors." failMessage="You cannot fail, how did you?" completeMessage="You did it John. You're a hero. Princess Aeryn however will still not marry you." />
            <subquests>
                <GlobalQuest id="43766602-7e2f-4d24-976a-3f9de1474d5b">
                    <QuestDescription title="Find Aeryn's S.H.O.E.S." description="Oh, the kidnappers must have been in a hurry because they overlooked princess Aeryns S.H.O.E.S. (Super Heavily Organized Escape Ship) hidden in the asteroid field over there.\nFind it and look there for clues to Princess Aeryns whereabouts." completeMessage="You did it, Looking through her stuff you find an odd looking device - Could this be the receiver of Princess Aeryns locator beacon? - But it must be broken, the screen remains blank." />
                    <complete-effects>
                        <AddQuest questId="50845552-c8af-4091-947c-76bd850b224e" />
                    </complete-effects>
                </GlobalQuest>
                <GlobalQuest id="50845552-c8af-4091-947c-76bd850b224e">
                    <QuestDescription title="Repair the receiver." description="There is a space station called 'Serenity Station' near here. An engineer called Nathan Stark who shoud be able to help you lives there." completeMessage="'Yeah Nathan lives here, he'll shurely help you.'\nAnd he does, apparenty the device was just low on batteries so you're now able to locate your beloved Princess Aeryn." />
                    <hints>
                        <QuestHint id="b9b10841-b045-4797-b1d3-cfce760e1de6">
                            <QuestDescription title="The Katratzi Station" description="'We ain't buying!'\n'What do you want?'\n'No there lives no Nathan here.'\n'Fuck off.''" />
                        </QuestHint>
                        <QuestHint id="1ee785f8-b71d-4b51-b080-42cec5be8e3c">
                            <QuestDescription title="The Pegasus Station" description="'Hello friend.'\n'How can we help you?'\n'A Mr. Stark you say? Sorry no man with such a name lives here.'" />
                        </QuestHint>
                    </hints>
                    <complete-effects>
                        <AddQuest questId="97628524-b243-492c-b7b6-498f325b21d4" />
                    </complete-effects>
                </GlobalQuest>
                <GlobalQuest id="97628524-b243-492c-b7b6-498f325b21d4">
                    <QuestDescription title="Follow the dots" description="Just follow the dots, they'll lead you right to her." completeMessage="You found Princess Aeryn. Her captors give up at the shere sight ou you." />
                    <complete-effects>
                        <CompleteQuest questId="b80c2c60-e62c-4637-80f8-5aa18dc93b34" />
                    </complete-effects>
                </GlobalQuest>
            </subquests>
        </GlobalQuest>

        <!-- Create spaceship spawner: -->
        <ParticleSpawner position="0,0,100" source="Orxonox/BigExplosion1part3" lifetime=2.0 loop=0 autostart=0>
          <events>
            <spawn>
              <EventTrigger delay=1>
                <events>
                  <trigger>
                    <SpawnPoint position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
                  </trigger>
                </events>
              </EventTrigger>
            </spawn>
          </events>
          <attached>
            <QuestEffectBeacon position="0,0,0" times=1>
                <effects>
                    <AddQuest questId="b80c2c60-e62c-4637-80f8-5aa18dc93b34" />
                    <AddQuest questId="43766602-7e2f-4d24-976a-3f9de1474d5b" />
                </effects>
                <events>
                    <execute>
                        <EventListener event=questbeacon1 />
                    </execute>
                </events>
                <attached>
                    <DistanceTrigger name=questbeacon1 position="0,0,0" distance=10 target="ControllableEntity" />
                </attached>
            </QuestEffectBeacon>
          </attached>
        </ParticleSpawner>

        <!-- Create world -->

            <!-- Kidnapper flying away -->
            <MovableEntity position="200,0,0" velocity="-140,0,-140" yaw=45>
                <attached>
                    <Model position="0,0,0" scale=4 yaw=180 pitch=-90 roll=-90 mesh="pirate.mesh" />
                    <ParticleSpawner position="0,0,10" source="Orxonox/fire3" lifetime=2.0 loop=0 autostart=1 />
                    <QuestEffectBeacon position="0,0,0" times=1 active=false name=trail >
                        <effects>
                            <CompleteQuest questId="b80c2c60-e62c-4637-80f8-5aa18dc93b34" />
                        </effects>
                        <events>
                            <execute>
                                <EventListener event=questbeacon7 />
                            </execute>
                        </events>
                        <attached>
                            <DistanceTrigger name=questbeacon7 position="0,0,0" distance=10 target="ControllableEntity" />
                        </attached>
                    </QuestEffectBeacon>
                </attached>
            </MovableEntity>

            <!-- Asteroid field -->
            <StaticEntity position="-500,0,-3000">
                <attached>
                    <?lua
                        for i = 1, 200
                        do ?>
                        <MovableEntity position="<?lua print(math.random() * 2000 - 1000)?>, <?lua print(math.random() * 2000 - 1000) ?>, <?lua print(math.random() * 2000 - 1000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.abs(math.random() * 30 -10)) ?>">
                            <attached>
                                <Model scale="<?lua print(math.random() * 50) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
                            </attached>
                        </MovableEntity>
                    <?lua
                        end
                    ?>
                    <!-- S.H.O.E.S -->
                    <StaticEntity position="-300,0,0">
                        <attached>
                            <Model position="0,0,0" scale=4 yaw=180 pitch=-90 roll=-90 mesh="assff.mesh" />
                            <QuestEffectBeacon position="0,0,0" times=-1>
                                <effects>
                                    <CompleteQuest questId="43766602-7e2f-4d24-976a-3f9de1474d5b" />
                                </effects>
                                <events>
                                    <execute>
                                        <EventListener event=questbeacon2 />
                                    </execute>
                                </events>
                                <attached>
                                    <DistanceTrigger name=questbeacon2 position="0,0,0" distance=50 target="ControllableEntity" />
                                </attached>
                            </QuestEffectBeacon>
                        </attached>
                    </StaticEntity>
                </attached>
            </StaticEntity>



            <!-- Spacestations -->

            <!-- Serenity Station -->
            <StaticEntity scale=1 position="0,0,5000" yaw=30>
                <attached>
                    <?lua
                        createSpaceStationPar(65461,2,1,2,1,2,1,100)
                    ?>
                    <QuestEffectBeacon position="0,450,0" times=1>
                        <effects>
                            <CompleteQuest questId="50845552-c8af-4091-947c-76bd850b224e" />
                        </effects>
                        <events>
                            <execute>
                                <EventListener event=questbeacon3 />
                            </execute>
                        </events>
                        <attached>
                            <Billboard position="0,0,0" colour="1.0,1.0,0" material="Examples/Flare" />
                            <DistanceTrigger name=questbeacon3 position="0,0,0" distance=100 target="ControllableEntity" />
                        </attached>
                    </QuestEffectBeacon>
                </attached>
            </StaticEntity>

            <!-- Katratzi Station -->
            <StaticEntity scale=1 position="0,5000,300" yaw=60>
                <attached>
                    <?lua
                        createSpaceStationPar(9851,2,1,2,1,2,1,100)
                    ?>
                    <QuestEffectBeacon position="0,450,0" times=1>
                        <effects>
                            <AddQuestHint hintId="b9b10841-b045-4797-b1d3-cfce760e1de6" />
                        </effects>
                        <events>
                            <execute>
                                <EventListener event=questbeacon4 />
                            </execute>
                        </events>
                        <attached>
                            <Billboard position="0,0,0" colour="1.0,1.0,0" material="Examples/Flare" />
                            <DistanceTrigger name=questbeacon4 position="0,0,0" distance=100 target="ControllableEntity" />
                        </attached>
                    </QuestEffectBeacon>
                </attached>
            </StaticEntity>

            <!-- Pegasus Station -->
            <StaticEntity scale=1 position="-5000,100,1000" roll=30>
                <attached>
                    <?lua
                        createSpaceStationPar(3574,2,1,2,1,2,1,100)
                    ?>
                    <QuestEffectBeacon position="200,450,0" times=1>
                        <effects>
                            <AddQuestHint hintId="1ee785f8-b71d-4b51-b080-42cec5be8e3c" />
                        </effects>
                        <events>
                            <execute>
                                <EventListener event=questbeacon5 />
                            </execute>
                        </events>
                        <attached>
                            <Billboard position="0,0,0" colour="1.0,1.0,0" material="Examples/Flare" />
                            <DistanceTrigger name=questbeacon5 position="0,0,0" distance=100 target="ControllableEntity" />
                        </attached>
                    </QuestEffectBeacon>
                </attached>
            </StaticEntity>

            <!-- Trail -->
            <EventDispatcher>
                <targets>
                    <EventTarget name=trail />
                </targets>
                <events>
                    <visibility>
                        <QuestListener questId="50845552-c8af-4091-947c-76bd850b224e" mode="complete" />
                    </visibility>
                    <activity>
                        <QuestListener questId="50845552-c8af-4091-947c-76bd850b224e" mode="complete" />
                    </activity>
                </events>
            </EventDispatcher>

            <?lua
                for i = 1, 25
                do
            ?>
                <Billboard position="<?lua print(i*5000/25) ?>,<?lua print(450+i*(5000-450)/25) ?>,5000" colour="1.0,0,0" material="Examples/Flare" name=trail visible=false/>
            <?lua
                end
            ?>

            <!-- Hideout -->
            <StaticEntity position="5000,5000,5000" >
                <attached>
                    <Model scale="100" mesh="ast2.mesh" shadow=false />
                </attached>
            </StaticEntity>

            <StaticEntity position="5400,5400,5000" visible=false name=trail >
                <attached>
                    <Model position="0,0,0" scale=4 yaw=180 pitch=-90 roll=-90 mesh="pirate.mesh" visible=false name=trail />
                    <QuestEffectBeacon position="0,0,0" times=1 active=false name=trail >
                        <effects>
                            <CompleteQuest questId="97628524-b243-492c-b7b6-498f325b21d4" />
                        </effects>
                        <events>
                            <execute>
                                <EventListener event=questbeacon6 />
                            </execute>
                        </events>
                        <attached>
                            <DistanceTrigger name=questbeacon6 position="0,0,0" distance=100 target="ControllableEntity" />
                        </attached>
                    </QuestEffectBeacon>
                </attached>
            </StaticEntity>

    </Scene>
</Level>

