Home   Help Search Login Register  

Author Topic: Speed/script questions  (Read 570 times)

0 Members and 1 Guest are viewing this topic.

Offline SEAL84

  • Members
  • *
  • Always lurking
Speed/script questions
« on: 25 Apr 2004, 23:01:48 »
Hey gang.

I'm messing around with the new C-47 addon and I've found that the AI always flies too fast and stretches out the line of parachutes, which makes it hard to drop guys anywhere.  So, I figured I'd write a little script that forces the plane to fly slower.

Here's question one:  I've forced the plane down to the speed I want with a looped "setvelocity" command.  I don't know how to make the command account for the direction the plane is travelling in.

If I add velocity to X, for example, the velocity will force the plane North, regardless of its heading.  So if I'm on a heading of 90 degrees, the plane will slide to the left.  

So how do I script it so that only the plane's forward velocity is affected?  


Question two: this one is a lot simpler, but I can't figure it out.  I have this line

Code: [Select]
if (speed c47 > 120) then (goto "speed")
which obviously holds the speed to where I want it.  This part works.  Now, I want to break this loop with something like this:

Code: [Select]
if (not (guy1 in c47)) then (goto "exit")
obviously this will end the script when all the paratroopers (in this case only one) are out of the plane.  Hopefully the plane should speed up and go on its merry way at this point.

Problem is that my code doesn't work.  Can someone show me the right syntax/right way to do that?

Thx in advance. :)

EDIT:  I just realized that my if/then lines probably won't work anyway.  So, how then do I do this properly  ???
« Last Edit: 25 Apr 2004, 23:03:39 by SEAL84 »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:Speed/script questions
« Reply #1 on: 25 Apr 2004, 23:57:00 »
afaik the setvelocity command works with XYZ coordinates...i guess this causes your plane heading north, as a single number would be interpreted as North-South axis...try it out.....when you change the value from X to -X..will it head South?

So i guess you would need the getdir command first and then calculate the proper X Y setvelocity values for it.

If i were better in math i would look for a way, but this overhelms my knowledge by far (and maybe even my english ;D)

:edit:
did you tried to setspeedmode to LIMITED?

:edit edit:

Code: [Select]
?!(guy1 in c47): goto "exit"

try this for your second prob
« Last Edit: 26 Apr 2004, 00:05:00 by myke13021 »

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Speed/script questions
« Reply #2 on: 26 Apr 2004, 00:10:07 »
I just happen to be writing a function called SetSpd.sqf.  It is called like so:

_vel = [_obj,_spd] call SetSpd

The variable _vel is the velocity required to set the object at the speed you desire while maintaining the current direction and angle of climb/dive.  So in a script the next line would be:

_obj setVelocity _vel

As soon as I finish it (in about 30 minutes) I will send it to you via the personal message boards.

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:Speed/script questions
« Reply #3 on: 26 Apr 2004, 00:19:06 »
@myke13021:  Yep, the setvelocity command works strictly along the coordinate axes.  So -Y would push the plane backwards if it was heading north.  The heading of the plane doesn't change, though, so it's possible to get a plane moving backwards at very high speeds :-\

And yes, I tried "limited"...I rode along as the co-pilot to see what the AI pilot would do, and he still flew along at about 210 km/h, which is just too fast for an OFP paradrop (even though it's not all that fast ???)

I'll give your code suggestion a shot though.

@raptorsaurus:  Thanks!  I'll test it out as soon as I get it.
« Last Edit: 26 Apr 2004, 00:20:01 by SEAL84 »

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:Speed/script questions
« Reply #4 on: 26 Apr 2004, 05:57:16 »
Raptorsaurus awed me with his OFP wizardry...

Problem solved. ;D