FreeSpace Releases > Scripting Releases

Jump seat script

(1/4) > >>

m!m:
This script is outdated!
Get the newest version here!

Original post:
Here's another neat script that tries to imitate jump seats for fighters. Currently it will create jump seats for every script but I'll change that...
The script uses a ship class of BP by default and it needs the mediavps for the trail effect.
Just paste this into a script table and there you go!

--- Code: (jumpSeat-sct.tbm) ---#Conditional Hooks

$Application: FS2_Open
$On Game Init:
[
function indexOf(t,val)
    for k,v in ipairs(t) do
        if v == val then
return k
end
    end
return nil
end

function getShipclass(class)
local ship = tb.ShipClasses[class]
if (ship:isValid()) then
return ship
else
return nil
end
end

nulVector = ba.createVector(0, 0, 0)

jumpSeatClass = getShipclass("Spacesuit")

shipClassForwDecel = nil
shipClassSlideDecel = nil

jumpSeats = nil
jumpedShips = nil
]

$On Ship Collision:
[
if (jumpSeats ~= nil) then
if (indexOf(jumpSeats, hv.Ship) ~= nil) then
if (hv.Ship.Parent:isValid() and hv.Ship.Parent ~= hv.Object) then
if (shipClassForwDecel ~= nil and shipClassSlideDecel ~= nil) then
jmp.Physics.ForwardDecelerationTime = shipClassForwDecel
jmp.Physics.SlideDecelerationTime = shipClassSlideDecel
else
jmp.Physics.ForwardDecelerationTime = 1
jmp.Physics.SlideDecelerationTime = 1
end

table.remove(jumpSeats, indexOf(jumpSeats, hv.Ship))
end
end
end
]

$State: GS_STATE_GAME_PLAY
$On Frame:
[
for i=1, #mn.Ships do
local ship = mn.Ships[i]
if (ship:isValid()) then

if (ship:hasShipExploded() == 2) then
if (not indexOf(jumpedShips, ship.Name)) then
local pos = ship.Position
local orient = ship.Orientation:unrotateVector(ba.createVector(0, 1, 0)):getOrientation()

local name = "Jump Seat (" .. ship.Name .. ")"
if (name:len() < 32) then -- avoiding to run over that 32 Byte limit for ship names...
local jmpSeat = mn.createShip(name, jumpSeatClass, ship.Orientation, pos)

jmpSeat.Parent = ship

jmpSeat.Team = ship.Team
jmpSeat.Physics.Velocity = (ship:getuvec(true) * 80) + ship.Physics.Velocity

if (shipClassForwDecel == nil or shipClassSlideDecel == nil) then
shipClassForwDecel = jmpSeat.Physics.ForwardDecelerationTime
shipClassSlideDecel = jmpSeat.Physics.SlideDecelerationTime
end

jmpSeat.Physics.ForwardDecelerationTime = 40
jmpSeat.Physics.SlideDecelerationTime = 40

jmpSeat:clearOrders()
jmpSeat:giveOrder(ORDER_PLAY_DEAD)

table.insert(jumpSeats, jmpSeat)
table.insert(jumpedShips, ship.Name) -- Thank you for keeping names unique FS :-)
end
end
end
end
end

if (jumpSeats ~= nil) then
local done = false
local index = 1
while (not done) do
for i = index, #jumpSeats do
local jmp = jumpSeats[i]
if (jmp ~= nil and jmp:isValid()) then
ts.createParticle(jmp.Position, nulVector, particleLifeTime, jmp.Class.Model.Radius / 2, PARTICLE_BITMAP, -1, false, particleTexture)

if (jmp.Physics.Velocity:getMagnitude() < 10) then

if (shipClassForwDecel ~= nil and shipClassSlideDecel ~= nil) then
jmp.Physics.ForwardDecelerationTime = shipClassForwDecel
jmp.Physics.SlideDecelerationTime = shipClassSlideDecel
else
jmp.Physics.ForwardDecelerationTime = 1
jmp.Physics.SlideDecelerationTime = 1
end

table.remove(jumpSeats, i)
index = i
break
end
end
end

done = true
end
end

]

$Application: FS2_Open
$On Mission Start:
[
particleTexture = gr.loadTexture("capflash", true)
if (particleTexture ~= nil and particleTexture:isValid()) then
particleLifeTime = particleTexture:getFramesLeft() / particleTexture:getFPS()
end

jumpSeats = {}
jumpedShips = {}
]

$Application: FS2_Open
$On Mission End:
[
if (particleTexture ~= nil) then
particleTexture:unload()
particleTexture = nil
end

jumpSeats = nil
jumpedShips = nil
]

#End
--- End code ---

I hope you enjoy it! :nod:

General Battuta:
By jump seats I assume you mean ejection seats?

This is awesome. The spacesuit model is unfortunately far too large for the job - we should get a better, smaller, pilot-sized model.

Flipside:
Normally, jump seats are seats for other members of the crew such as co-pilots, so I'm not sure.

m!m:
I think ejection seat fits best and yes, we'd need a special model for the pilot.

Rodo:
really?? I'll get to see a pilot eject??  :cool: :cool:

Navigation

[0] Message Index

[#] Next page

Go to full version