Hard Light Productions Forums

FreeSpace Releases => Scripting Releases => Topic started by: m!m on January 25, 2011, 11:50:39 am

Title: Jump seat script
Post by: m!m on January 25, 2011, 11:50:39 am
This script is outdated!
Get the newest version here (http://www.hard-light.net/forums/index.php?topic=78309.0)!


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) [Select]
#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

I hope you enjoy it! :nod:
Title: Re: Jump seat script
Post by: General Battuta on January 25, 2011, 11:53:54 am
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.
Title: Re: Jump seat script
Post by: Flipside on January 25, 2011, 11:57:53 am
Normally, jump seats are seats for other members of the crew such as co-pilots, so I'm not sure.
Title: Re: Jump seat script
Post by: m!m on January 25, 2011, 12:05:06 pm
I think ejection seat fits best and yes, we'd need a special model for the pilot.
Title: Re: Jump seat script
Post by: Rodo on January 25, 2011, 12:25:54 pm
really?? I'll get to see a pilot eject??  :cool: :cool:
Title: Re: Jump seat script
Post by: m!m on January 27, 2011, 07:05:34 am
So, did someone try it? :nervous:
Title: Re: Jump seat script
Post by: torc on January 27, 2011, 08:31:06 am
two question: the file goes to data folder or in the vp folder?  and what is the command for ejection?
Title: Re: Jump seat script
Post by: m!m on January 27, 2011, 08:33:24 am
The file goes into a file in data/tables/jumpSeat-sct.tbm and the ejection occurs automatically for all ships.
Title: Re: Jump seat script
Post by: torc on January 27, 2011, 08:47:10 am
yeah...thanks dude, it works!...  :yes:
there is no way to eject you anytime you want? you need to be destroyed before?
Title: Re: Jump seat script
Post by: Mobius on June 01, 2011, 09:25:00 am
How it's possible to determine the chance that a given pilot will eject? Does it happen by default, or is it possible to set the probability that a pilot will eject, perhaps depending on AI levels?

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

More like makeshift seats for "unexpected" passengers, but the term if flexible enough to mean a lot of things.
Title: Re: Jump seat script
Post by: m!m on June 01, 2011, 10:34:03 am
How it's possible to determine the chance that a given pilot will eject? Does it happen by default, or is it possible to set the probability that a pilot will eject, perhaps depending on AI levels?

Currently it happens every time a ship explodes even for capships
Title: Re: Jump seat script
Post by: mjn.mixael on June 01, 2011, 10:48:39 am
How it's possible to determine the chance that a given pilot will eject? Does it happen by default, or is it possible to set the probability that a pilot will eject, perhaps depending on AI levels?

Currently it happens every time a ship explodes even for capships

 :lol: I just envisioned the guy at the helm hitting eject in the middle of the bridge...

I was going to rip a pilot straight out of our cockpit model along with his chair.. but he seems to be missing feet.. so nvm. (I thought it would be a quick and dirty task, but I was wrong.)
Title: Re: Jump seat script
Post by: Droid803 on June 02, 2011, 04:31:00 pm
Ejecting from capships?
LOL.
Title: Re: Jump seat script
Post by: Dragon on June 05, 2011, 05:29:15 am
Could you try to make the ejected pilot launch from the coordinates of model's eye point?
BTW, There's an ejected pilot model in debris of UEF Kentauroi (he doesn't have a seat attached though). Also, pilot in the main model of Kent has feet.
Title: Re: Jump seat script
Post by: m!m on September 01, 2011, 04:12:00 am
Just wanted to ask if someone has a better model for a ejection seat as I'm currently working on an improved version of this script (it's ~95% done) and it would be great to have a model that has the right size as a reference. :nod:
Title: Re: Jump seat script
Post by: Dragon on September 16, 2011, 10:03:42 am
I PMed you a pilot model, I hope it's good enough.
Title: Re: Jump seat script
Post by: Mobius on September 16, 2011, 11:16:16 am
What does this pilot model look like?
Title: Re: Jump seat script
Post by: Dragon on September 16, 2011, 02:20:22 pm
A modern fighter pilot on a seat, basically. I was unable to find an FS one.
Title: Re: Jump seat script
Post by: Mobius on September 16, 2011, 02:39:23 pm
Is it textured?
Title: Re: Jump seat script
Post by: Dragon on September 16, 2011, 03:31:16 pm
Yes.