;Xenocartographer: Hey, this is my fork of Axem's in-mission jump script. ;Consult his documentation immediately below for normal usage ;I've added a couple features though! ; Diaspora compatibility: Use IMJump:Diaspora instead of IMJump:To ; and the script will play nicely with Diaspora! Other mods without ; normal subspace can use this, too. ; Multiple ship support: Multiple ships can safely jump to the same ; waypoint at once! If multiple ships are in subspace at once, they'll ; all show up near each other. If you want a subspace battle, call ; To with a sufficiently large duration, then IMJump:ResetAI() 7 seconds ; later. ; Note that this won't work terribly well with large numbers of ships ; or ships bigger than ~a Chronos or Satis. PM Xenocartographer if you ; want support for bigger/more ships. ;Also, this isn't my addition, but it's not documented, so I'll. If you call ;IMJump:To with a waypoint list containing more than one waypoint, the ship's ;orientation is set to point to the second waypoint in the list. ;If this is used with my multi-ship support above, the orientation is set as ;if the second waypoint is offset the same as the ship is (that is, a wing ;jumping to the same waypoint will all be parallel to each other). ;One last thing: there's a neat trick with when-argument and script-eval-block: ; ( when-argument ; ( any-of "Alpha 1" "Alpha 2" "Alpha 3" ) ; (WHATEVER) ; ( script-eval-block ; "IMJump:To('" ; "" ; "', 'Waypoint')" ; ) ; ) ;Axem: you would call it with IMJump:To('Ship', 'Waypoint Name') ;Axem: you can add an extra number argument to change the time spent in subspace ;Axem: so like IMJump:To('Ship', 'Waypoint Name', 10) for a super long one ;Axem: using script-eval-block is probably smart here ;Axem: erases ai orders after jump ;Axem: and you need to specify jump waypoints for each ai ship ;Axem: and itll only for that specific fighter's name ;Axem: so wave wont work #Conditional Hooks $Application: FS2_Open $On Game Init: [ IMJump = {} --CONFIGURATION IMJump.Shields = false -- shields on during subspace? SET THIS TO TRUE IN AN UNSHIELDED ENVIRONMENT (eg. fsport) IMJump.TransitTime = 3 -- seconds to jump for by default (may be overriden) IMJump.Speed = 0.33 -- % of throttle IMJump.Subspace = ba.createVector(50000, 50000, 0) --probably won't ever need to touch this --END CONFIGURATION function IMJump:Init() self.Enabled = true self.Ships = {} self.SeqTimer = {0, 4, 2, 1, self.TransitTime, 2, 1} self.NextSubspaceIndex = 0 self.NextRealspaceIndex = 0 end function IMJump:To(ship, dest, transittime) local t = {} if mn.Ships[ship]:isValid() and mn.WaypointLists[dest]:isValid() then if not self.Enabled then IMJump:Init() end t.DoStage1 = IMJump.Stage1 t.DoStage2 = IMJump.Stage2 t.DoStage3 = IMJump.Stage3 t.DoStage4 = IMJump.Stage4 t.DoStage5 = IMJump.Stage5 t.DoStage6 = IMJump.Stage6 t.DoStage7 = IMJump.Stage7 t.Stage = 1 t.Sig = mn.Ships[ship]:getSignature() t.Dest = mn.WaypointLists[dest][1]:getSignature() t.AltTime = {nil, nil, nil, nil, transittime, nil, nil} t.Timer = mn.getMissionTime() + self.SeqTimer[1] end self.Ships[#self.Ships+1] = t return t end function IMJump:Diaspora(ship, dest, transittime) local entry = self:To(ship, dest, transittime) entry.Diaspora = true entry.AltTime[5] = 0 entry.AltTime[6] = 0 end function IMJump:Monitor() local ships = self.Ships local numShips = #ships if numShips > 0 then local mtime = mn.getMissionTime() for i = 1, numShips do local entry = ships[i] if entry and mtime > entry.Timer then if entry.Stage == 1 then entry:DoStage1() elseif entry.Stage == 2 then entry:DoStage2() elseif entry.Stage == 3 then entry:DoStage3() elseif entry.Stage == 4 then entry:DoStage4() elseif entry.Stage == 5 then entry:DoStage5() elseif entry.Stage == 6 then entry:DoStage6() elseif entry.Stage == 7 then entry:DoStage7() end local stage = entry.Stage if stage < 7 then stage = stage + 1 entry.Stage = stage entry.Timer = mtime + (entry.AltTime[stage] or self.SeqTimer[stage]) else entry = nil end end if not entry then table.remove(ships, i) if #ships == 0 then self.Enabled = false end end end end end function IMJump:Stage1() --Rev warmup local me = mn.getObjectFromSignature(self.Sig) local name = me.Name if me == hv.Player then mn.runSEXP("( player-use-ai )") mn.runSEXP("( hud-display-gauge 4000 !warpout! )") ad.playGameSound(50) end mn.runSEXP("( clear-goals !" .. name .. "! )") mn.runSEXP("( add-goal !" .. name .. "! ( ai-play-dead 101 ) )") mn.runSEXP("( ship-lat-maneuver !" .. name .. "! 60000 0 0 " .. IMJump.Speed * 100 .. "( true ) )") end function IMJump:Stage2() --Open warp flash local me = mn.getObjectFromSignature(self.Sig) local name = me.Name local distance = me.Physics.VelocityMax.z * IMJump.Speed * (IMJump.SeqTimer[2] + 0.5) local lvector = ba.createVector(0,0,distance) local wvector = me.Position + me.Orientation:unrotateVector(lvector) mn.runSEXP("( warp-effect " .. wvector.x .. " " .. wvector.y .. " " .. wvector.z .. " " .. me.Position.x .. " " .. me.Position.y .. " " .. me.Position.z .. " " .. me.Class.Model.Radius * 2 .. " 10 45 46 0 0 )") end function IMJump:Stage3() --Fadeout local me = mn.getObjectFromSignature(self.Sig) if me == hv.Player then mn.runSEXP("( fade-out 1000 255 255 255 )") else -- mn.runSEXP("( ship-stealthy !" .. me.Name .. "!)") -- mn.runSEXP("( friendly-stealth-invisible !" .. me.Name .. "!)") end end function IMJump:Stage4() --Go to subspace if self.Diaspora then return end local me = mn.getObjectFromSignature(self.Sig) local pos = IMJump:GetNextSubspacePosition() local ori = ba.createOrientation(0,0,0) if me == hv.Player then mn.runSEXP("( fade-in 1000 )") mn.runSEXP("( mission-set-subspace 1 )") mn.runSEXP("( hud-set-max-targeting-range 2000 )") pos.z = pos.z - 10 else me:addShipEffect("Cloak", 1) end if not IMJump.Shields then mn.runSEXP("( shields-off !" .. me.Name .. "!)" ) end me.Position = pos me.Orientation = ori end function IMJump:Stage5() --Open warp flash if self.Diaspora then return end local me = mn.getObjectFromSignature(self.Sig) local name = me.Name local distance = me.Physics.VelocityMax.z * IMJump.Speed * (IMJump.SeqTimer[5] + 1) local lvector = ba.createVector(0,0,distance) local wvector = me.Position + me.Orientation:unrotateVector(lvector) mn.runSEXP("( warp-effect " .. wvector.x .. " " .. wvector.y .. " " .. wvector.z .. " " .. me.Position.x .. " " .. me.Position.y .. " " .. me.Position.z .. " " .. me.Class.Model.Radius * 2 .. " 10 45 46 0 0 )") if me == hv.Player then mn.runSEXP("( player-use-ai )") end end function IMJump:Stage6() --Fadeout if self.Diaspora then return end local me = mn.getObjectFromSignature(self.Sig) if me == hv.Player then mn.runSEXP("( fade-out 1000 255 255 255 )") end end function IMJump:Stage7() --Go to destination local me = mn.getObjectFromSignature(self.Sig) local name = me.Name local destList = mn.getObjectFromSignature(self.Dest):getList() local pos = destList[1].Position local ori = (destList[2].Position - pos):getOrientation() local radius = me.Class.Model.Radius * 2 if me == hv.Player then mn.runSEXP("( fade-in 1000 )") mn.runSEXP("( mission-set-subspace 0 )") mn.runSEXP("( hud-set-max-targeting-range 0 )") mn.runSEXP("( player-not-use-ai )") else me:addShipEffect("Decloak", 1) -- mn.runSEXP("( ship-unstealthy !" .. me.Name .. "!)") -- mn.runSEXP("( friendly-stealth-visible !" .. me.Name .. "!)") end me.Position = pos + IMJump:GetNextRealspaceOffset() me.Orientation = ori if not IMJump.Shields then mn.runSEXP("( shields-on !" .. me.Name .. "!)" ) end local lvector = ba.createVector(0,0,-10) local wvector = pos + ori:unrotateVector(lvector) mn.runSEXP("( warp-effect " .. wvector.x .. " " .. wvector.y .. " " .. wvector.z .. " " .. pos.x .. " " .. pos.y .. " " .. pos.z .. " " .. radius .. " 4 0 70 0 0 )") mn.runSEXP("( clear-goals !" .. name .. "! )") end function IMJump:GetOffset(index) local offsetX = (index % 5) local offsetY = (math.floor(index/5) * -1) offsetX = offsetX * 75 + math.random(-25, 25) offsetY = offsetY * 75 + math.random(-25, 25) local offsetZ = math.random(-25, 25) return ba.createVector(offsetX, offsetY, offsetZ) end function IMJump:GetNextRealspaceOffset() local index = self.NextRealspaceIndex local pos = self:GetOffset(index) self.NextRealspaceIndex = index + 1 return pos end function IMJump:GetNextSubspacePosition() local index = self.NextSubspaceIndex local pos = self:GetOffset(index) + self.Subspace self.NextSubspaceIndex = index + 1 return pos end ] $State: GS_STATE_GAME_PLAY $On Gameplay Start: [ IMJump.Enabled = false IMJump.Ships = {} ] $On Frame: [ if IMJump.Enabled then IMJump:Monitor() end ] #End