OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CAS_Daniel on 24 Oct 2005, 01:15:17

Title: C130 Rolling Deployment
Post by: CAS_Daniel on 24 Oct 2005, 01:15:17
Is it possible to force a C130 to land in a flat open space (not runway) and keep a steady, slow speed (around 10mph) before taking off again? Would it also be possible to have units dropped off or created as they passed?

(http://www.diggerz.org/~adaa/130dust.jpg)

Thanks, Dan.  :)
Title: Re:C130 Rolling Deployment
Post by: penguinman on 24 Oct 2005, 05:38:06
you can use flyin height 1 to make them do that but they will crash if theres a tree or hill,

you could probably drop a tank or somthing, but infantry would die.
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 24 Oct 2005, 13:08:24
Thanks, I'll try it out.  :)

Ok, that worked, but is there a way of forcing a plane to slow down without using setvelocity which looks bad?
Title: Re:C130 Rolling Deployment
Post by: Homefry31464 on 24 Oct 2005, 16:44:23
No.  A slow setvelocity look is about the only way.  A slow setpos loop would work as well I suppose... but I don't know if you'd achieve the desired effect that way.  Either way getting planes to land on anything not defined as a runway would be tough.
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 24 Oct 2005, 19:04:25
Hmm, thats a shame, I thought there might be a less dramatic version like the way flyInHeight works. I'm, gonna keep trying some different ideas, any suggestions are very welcome.

Just one other quick question, how do I force Hawk's C130 to deploy it's gear? Cheers, Dan.  :)
Title: Re:C130 Rolling Deployment
Post by: Dane on 25 Oct 2005, 11:09:50
[nameOfPlane] exec "\HWK_c130\script\geardown.sqs"
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 25 Oct 2005, 19:01:59
Thanks.  :)
Title: Re:C130 Rolling Deployment
Post by: Pilot on 25 Oct 2005, 19:33:30
Setvelocity should work fine, just do something like this:

_plane=_this select 0

#Loop
~.1
_vel = getvelocity _plane
?planeDone: exit
?_vel<=100: goto "Loop"
_plane setvelocity (_vel*.9)
~.9
goto "Loop"

Simply set planeDone=true when you want the script to stop.

The script will slow the plane down gradually, it won't immediately set it to a certain velocity.  Play around with the .9 value to get what you want, you may also want to adjust the delays a bit.

Not tested, so I don't know if it works.

-Pilot

EDIT:
You can also change the speed (100 in the script) to whatever speed you want
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 25 Oct 2005, 20:45:04
Ah, thanks a lot Pilot! That's exactly what I meant, I'm gonna try this out now.  :D
Title: Re:C130 Rolling Deployment
Post by: Trapper on 25 Oct 2005, 22:35:47
Hm. There is no getvelocity command and setvelocity works with an [x,y,z] array to define the direction of the created velocity.

_plane=_this select 0

#Loop
~.1
_vel = (speed _plane)*1000/3600
?planeDone: exit
?_vel<=100: goto "Loop"
_plane setvelocity [(_vel*.9),0,0]
~.9
goto "Loop"


Replaced getvelocity with speed. Speed is km/h, velocity m/s...

In this example the plane has to fly from W to E. To make the heading unimportant you will have to include getdir and trigometry calculations for perfect setvelocity values.
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 25 Oct 2005, 23:17:35
EDIT: Do you guys know how I can fix this error?

'herc|#|=_select 0': Error Reserved variable in expression

At the moment, the C130 just stops in mid air and falls to the floor not so smoothly, no matter what else I tweak.  ???
Title: Re:C130 Rolling Deployment
Post by: Pilot on 26 Oct 2005, 01:48:30
Quote
There is no getvelocity command
*slaps head*

And on top of that setvelocity is an array format...now I really feel dumb...

However, there is a velocity command.  Try this:
_plane=_this select 0

#Loop
~.1
?planeDone: exit
?speed _plane<=10: goto "Loop"
_plane setvelocity [(velocity _plane select 0)*.9,(velocity _plane select 1)*.9,(velocity _plane select 2)*.9]
~.9
goto "Loop"

Call the script in the init field of the plane like this:
[this] exec "script.sqs"

Trapper's script might work too, but it seemed a bit over-complicated to me...I don't mean any offense, Trapper :-[

Once again, this isn't tested ::)

-Pilot

EDIT:
Btw, do not change the _plane=_this select 0 part.  When you call the script like I showed you, the plane's id is automatically entered into the script, there is no need to actually put the plane's name in the script.

...I hope that's understandable... ::)
Title: Re:C130 Rolling Deployment
Post by: Trapper on 26 Oct 2005, 08:29:58
*slaps head*

And on top of that setvelocity is an array format...now I really feel dumb...

However, there is a velocity command.
Now I know exactly how you felt.  ;)
Yes, velocity is much better for the script.
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 26 Oct 2005, 15:20:59
That works perfectly Pilot, thanks!  ;D

Ok, it works well if I pilot the plane and put the gear down, but the AI don't do that, and the "Gear Down" script doesn't override the "Gear Up" script that initialises with the plane.

What to I type to make the AI use the "Gear Down" action in the action menu?
Title: Re:C130 Rolling Deployment
Post by: Pilot on 26 Oct 2005, 16:00:30
Maybe try waiting about 10 seconds before you put the gear down?  I don't really know, though...the AI might automatically put the gear back up again.

The only other alternative I know would be to have a looped script that constantly puts the gear down.  If the delay is just right, the gear won't go back up.  Something like this:
_plane = _this select 0

#Loop
?planeDone: exit
[_plane] exec "\HWK_c130\script\geardown.sqs"
~.2
goto "Loop"

Quote
Now I know exactly how you felt.  ;)
Lol, what a terrible feeling, huh? :P

-Pilot
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 26 Oct 2005, 16:14:50
The AI doesn't put the gear up automatically, but I really just need the right syntax that makes the AI do the "Gear Down" action menu option, as this over rides the gear up animations.
Title: Re:C130 Rolling Deployment
Post by: Pilot on 26 Oct 2005, 17:14:12
Ok, it's been a while since I have done any editing, so I am a bit unsure of some things ;)

For a list of actions, look here (http://www.ofpec.com/editors/resource_view.php?id=862)

The proper sysntax is:
PlaneName action ["Land gear"]

Although I'm not too sure if that works with AI controlled aircraft.  Give it a try and let me know.

-Pilot
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 26 Oct 2005, 18:13:45
Hmm, couldn't find the right action name, but i've solved that problem another way now. Either that, or the AI has trouble with it like you said.

Thanks anyway, I always needed to know the right syntax for that.  ;)

EDIT:
The plane keeps exploding whenever it comes into land, no matter what its speed or descent rate. I've found the problem too, it's the landing gear.

When I get the plane to put it's own gear down using the geardown.sqs script, it explodes upon contact with the ground. If I manually select Gear Down, it always survives the landing.

Any ideas?  :-\
Title: Re:C130 Rolling Deployment
Post by: Pilot on 28 Oct 2005, 01:59:51
EDIT:
When you say manually, does that mean when you are the pilot?
Title: Re:C130 Rolling Deployment
Post by: CAS_Daniel on 29 Oct 2005, 17:15:27
Yeah.  :)
Title: Re:C130 Rolling Deployment
Post by: Pilot on 29 Oct 2005, 23:57:14
Ok, the AI is automatically putting the gear up.  What you are going to have to do is play the gear down animation every second or so.  I posted an example of what you could do, here it is:
Code: [Select]
_plane = _this select 0

#Loop
?planeDone: exit
[_plane] exec "\HWK_c130\script\geardown.sqs"
~1
goto "Loop"
Simply call the script like this:
[NameOfPlane] exec "NameOfScript.sqs"

The script automatically lowers the gear every second.  If the gear is already down, then it does nothing.  Try it and tell me what you think.

-Pilot
Title: Re:C130 Rolling Deployment
Post by: Tyger on 15 Nov 2005, 01:23:21
another trick, although it looks kind of bad if you are using it when you can see the pilot, is to temporarily kill the pilot. Then you activate the gear down, and use the setVelocity script of Pilot's.

to kill the pilot:

if your plane is named myPlane then
Code: [Select]
myPlaned setDammage 1
NOTE: The 'd' on the end is not a typo.  ;)
any 'd' added onto the end of a pre-crewed (i.e. you didn't manually add the crew) vehicle is the driver of that vehicle, 'g' is gunner and 'c' (IIRC) is commander. I dont think there's one for cargo :P