[4202] | 1 | -- Create the trigger |
---|
| 2 | trigger = ScriptTrigger() |
---|
| 3 | trigger:setName("spaceship_flight_trigger") |
---|
| 4 | trigger:setScript("spaceship_flight.lua") |
---|
| 5 | trigger:setFunction("tick") |
---|
| 6 | trigger:setAbsCoor(2500, 0, -1695) |
---|
| 7 | trigger:setTarget("SPACE_CRAFT") |
---|
| 8 | trigger:setRadius(150) |
---|
| 9 | |
---|
| 10 | -- Add Objects |
---|
[4114] | 11 | thisscript:addObject("GameWorld", "Ambush_at_Uranus") |
---|
[4094] | 12 | thisscript:addObject("Spacecraft2D", "SPACE_CRAFT") |
---|
[4202] | 13 | thisscript:addObject("Gate", "Hypergate") |
---|
| 14 | thisscript:addObject("SpaceShip", "TerranCruizer") |
---|
| 15 | -- Global Variables |
---|
| 16 | horizontalmode = false |
---|
| 17 | gateReached = false |
---|
| 18 | terrancriuseratgate = false |
---|
[3905] | 19 | |
---|
| 20 | |
---|
[4202] | 21 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
| 22 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
| 23 | end |
---|
[3905] | 24 | |
---|
[4202] | 25 | |
---|
| 26 | function observeSpaceCraft() |
---|
| 27 | SPACE_CRAFTX = SPACE_CRAFT:getAbsCoorX() |
---|
| 28 | SPACE_CRAFTY = SPACE_CRAFT:getAbsCoorY() |
---|
| 29 | SPACE_CRAFTZ = SPACE_CRAFT:getAbsCoorZ() |
---|
| 30 | |
---|
| 31 | distance = dist(SPACE_CRAFTX,SPACE_CRAFTY,SPACE_CRAFTZ,6053.186035, -2.306574, -1704.989624) |
---|
| 32 | |
---|
| 33 | if distance < 100 then |
---|
| 34 | Hypergate:destroy() |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | end |
---|
| 38 | |
---|
[3919] | 39 | function tick(timestep) |
---|
[4202] | 40 | observeSpaceCraft() |
---|
[3919] | 41 | |
---|
[4202] | 42 | if not horizontalmode then |
---|
[4217] | 43 | Ambush_at_Uranus:setPlaymode("Horizontal") |
---|
[4147] | 44 | Ambush_at_Uranus:setSoundtrack("sound/music/00-luke_grey_-_hypermode.ogg") |
---|
[4109] | 45 | SPACE_CRAFT:setAirFriction(3.0) |
---|
[4202] | 46 | horizontalmode = true |
---|
| 47 | end |
---|
[3919] | 48 | |
---|
[4202] | 49 | if not terrancriuseratgate then |
---|
| 50 | dx = 70 * timestep |
---|
| 51 | dy = 0 * timestep |
---|
| 52 | dz = 0 * timestep |
---|
| 53 | |
---|
| 54 | TerranCruizerX = TerranCruizer:getAbsCoorX() |
---|
| 55 | TerranCruizerY = TerranCruizer:getAbsCoorY() |
---|
| 56 | TerranCruizerZ = TerranCruizer:getAbsCoorZ() |
---|
| 57 | |
---|
| 58 | distance = dist(TerranCruizerX,TerranCruizerY,TerranCruizerZ,6053.186035, -2.306574, -1704.989624) |
---|
| 59 | |
---|
| 60 | if distance < 100 then |
---|
| 61 | TerranCruizer:hide() |
---|
| 62 | dx = 5000 |
---|
| 63 | terrancriuseratgate = true |
---|
[3919] | 64 | end |
---|
[4202] | 65 | |
---|
| 66 | TerranCruizer:setAbsCoor(TerranCruizerX + dx, TerranCruizerY + dy, TerranCruizerZ + dz) |
---|
| 67 | |
---|
| 68 | end |
---|
| 69 | |
---|
| 70 | return false |
---|
| 71 | end |
---|