• Since we're having an issue with spam and very few people use this website, I've closed Game-Warden to new user registrations. Any FS2, BtRL, SoL, etc questions can be directed to HLP instead.

ground attack

Hax's

New member
My old computer went the way of the dinosaur. So i decieded to try and write a script that would allow close air support. The results are rather buggy (aka you've been warned and don't kill me over this.) but if your interested . . .

ships with the affect gravity flag become ground based targets (er are supposed to be) and to activate the atmo flight model at least one surviving ship in the mission must have that flag. Was intended to also work on hills but infintry can hit speeds of 45 m/s and stuff like that.

lagg is big problem you'll probably need to turn off normal maps and all that good stuff to be able to play at reasonable frame rate.

So like i said you've been warned

#Conditional Hooks

$State: GS_STATE_GAME_PLAY

$On Frame:

[
-- notes. flight profile is hihgly dependent on damp, bounce, friction, and hitpoints.
-- ground model is dependent on damp mass, bounce and friction

--initializing orientation variables and creating grav vector

orip = 0
orib = 0
gravship = ba.createVector(0, -10, 0) --different from debris vector due to lower ship damp
gravityAffected = false

for i=1, #mn.Ships do
local ship = mn.Ships

--variables in common between flight and ground models

forSpeed = mn.Ships.Physics:getForwardSpeed()
velDesMag = mn.Ships.Physics.VelocityDesired:getMagnitude()
ratio = forSpeed / velDesMag

--ground model

if (ship.FlagAffectedByGravity == true) then

--setting ground stuff pos

--in ships table recomend bounce = 10.0 and friction = 1.0

gravityAffected = true -- determining if any ship has grav flag

if (ratio >= 0.5 ) then

velocity = mn.Ships.Physics.Velocity
velocity["y"] = -50
mn.Ships.Physics.Velocity = velocity

end

if (ratio < 0.5) then

pos = mn.Ships.Position
pos["y"] = pos["y"] + 0.1
mn.Ships.Position = pos

end

--setting ground stuff orientation

orientationblank = mn.Ships.Orientation
orientationblank["p"] = orip
orientationblank["b"] = orib
mn.Ships.Orientation = orientationblank

end --end of affected by gravity if statement

--flight grav and lift velocity additions

if (ship:isValid()) then --so that abvm doesnt freak out is ships present w/o AB
if (gravityAffected == true) then --setting flight model if there are ground objects

abvm = mn.Ships.Physics.AfterburnerVelocityMax:getMagnitude()

if (ratio > 0.95 ) then

uvec = mn.Ships:getuvec(true)

--accounting for some ships not having afterburners

if (abvm > 1 ) then
fsVm = forSpeed / abvm
end
if ( abvm < 1 ) then
vm = mn.Ships.Physics.VelocityMax:getMagnitude()
abvm = vm
fsVm = forSpeed / abvm
end

mn.Ships.Physics.Velocity = mn.Ships.Physics.Velocity+(uvec*fsVm^(1/6)*12+gravship)*7

-- setting rotational damping 1/alpha to speed and max rotational vel to peak at ~50% throttle

hpm = mn.Ships.HitpointsMax
rvd = mn.Ships.Physics.RotationalVelocityDamping
rvm = mn.Ships.Physics.RotationalVelocityMax
rvmx = rvm["x"]
rvmy = rvm["y"]
rvmz = rvm["z"]

mn.Ships.Physics.RotationalVelocityDamping = hpm*abvm/(180*(3*forSpeed+abvm))

if (fsVm > 0.25 ) then

rvmx = hpm*abvm^(2)/(30*(forSpeed+220)^(2))
rvmy = hpm*abvm^(2)/(50*(forSpeed+148)^(2))
rvmz = hpm*abvm^(2)/(30*(forSpeed+290)^(2))

end

if (fsVm <= 0.25 ) then

rvmx = hpm*(forSpeed+79)^(2)/(50*abvm^(2))
rvmy = hpm*(forSpeed+52)^(2)/(25*abvm^(2))
rvmz = hpm*(forSpeed+75)^(2)/(75*abvm^(2))

end

mn.Ships.Physics.RotationalVelocityMax = ba.createVector(rvmx, rvmy, rvmz)

end

end
end

-- debris flight model

i = 1
gravDebris = ba.createVector(0, -0.7, 0) --debris grav vector

if (gravityAffected == true ) then

for i=1, #mn.Debris do

local debris = mn.Debris

veldebris = mn.Debris.Physics.Velocity
veldebris = veldebris + gravDebris
mn.Debris.Physics.Velocity = veldebris

end

end

end


]

#End
 
Back
Top