-- Create the trigger trigger = ScriptTrigger() trigger:setName("spaceship_flight_trigger") trigger:setScript("spaceship_flight.lua") trigger:setFunction("tick") trigger:setAbsCoor(2500, 0, -1695) trigger:setTarget("SPACE_CRAFT") trigger:setRadius(150) -- Add Objects thisscript:addObject("GameWorld", "Ambush_at_Uranus") thisscript:addObject("Spacecraft2D", "SPACE_CRAFT") thisscript:addObject("Gate", "Hypergate") thisscript:addObject("SpaceShip", "TerranCruizer") -- Global Variables horizontalmode = false gateReached = false terrancriuseratgate = false function dist( x1,x2,x3, y1,y2,y3 ) return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) end function observeSpaceCraft() SPACE_CRAFTX = SPACE_CRAFT:getAbsCoorX() SPACE_CRAFTY = SPACE_CRAFT:getAbsCoorY() SPACE_CRAFTZ = SPACE_CRAFT:getAbsCoorZ() distance = dist(SPACE_CRAFTX,SPACE_CRAFTY,SPACE_CRAFTZ,6053.186035, -2.306574, -1704.989624) if distance < 100 then Hypergate:destroy() end end function tick(timestep) observeSpaceCraft() if not horizontalmode then Ambush_at_Uranus:setPlaymode("Horizontal") Ambush_at_Uranus:setSoundtrack("sound/music/00-luke_grey_-_hypermode.ogg") SPACE_CRAFT:setAirFriction(3.0) horizontalmode = true end if not terrancriuseratgate then dx = 70 * timestep dy = 0 * timestep dz = 0 * timestep TerranCruizerX = TerranCruizer:getAbsCoorX() TerranCruizerY = TerranCruizer:getAbsCoorY() TerranCruizerZ = TerranCruizer:getAbsCoorZ() distance = dist(TerranCruizerX,TerranCruizerY,TerranCruizerZ,6053.186035, -2.306574, -1704.989624) if distance < 100 then TerranCruizer:hide() dx = 5000 terrancriuseratgate = true end TerranCruizer:setAbsCoor(TerranCruizerX + dx, TerranCruizerY + dy, TerranCruizerZ + dz) end return false end