Hard Light Productions Forums
FreeSpace Releases => Scripting Releases => Topic started 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!
#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:
-
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.
-
Normally, jump seats are seats for other members of the crew such as co-pilots, so I'm not sure.
-
I think ejection seat fits best and yes, we'd need a special model for the pilot.
-
really?? I'll get to see a pilot eject?? :cool: :cool:
-
So, did someone try it? :nervous:
-
two question: the file goes to data folder or in the vp folder? and what is the command for ejection?
-
The file goes into a file in data/tables/jumpSeat-sct.tbm and the ejection occurs automatically for all ships.
-
yeah...thanks dude, it works!... :yes:
there is no way to eject you anytime you want? you need to be destroyed before?
-
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.
-
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
-
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.)
-
Ejecting from capships?
LOL.
-
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.
-
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:
-
I PMed you a pilot model, I hope it's good enough.
-
What does this pilot model look like?
-
A modern fighter pilot on a seat, basically. I was unable to find an FS one.
-
Is it textured?
-
Yes.