Home   Help Search Login Register  

Author Topic: VTOL using the keyboard  (Read 712 times)

0 Members and 3 Guests are viewing this topic.

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
VTOL using the keyboard
« on: 07 May 2003, 17:09:45 »
I've also posted this at the BIS forums:
http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3eb91d9d34a6ffff&act=ST&f=7&t=30070&st=


I've finally gotten VTOL to work with the keyboard.

I dug up Prospero's Prosphere scripts, heavily modified them, and wrote some scripts to interface with his to take the useful variables from his scripts for my nefarious VTOL purposes.

Here's how it works:
In your options menu, where you bind the keys on the keyboard, you can use whatever keys you have bound to certain commands to use VTOL in a plane.

The keys are:

MoveUp - vertical thrust up (default Q)
MoveDown - vertical thrust down (default Z)
Turn Left - rotate left (default X)
Turn Right - rotate right (default C)
Move Back - STOL turbo brake/reverse thrust (default S)
Forward Fast - STOL turbo forward (default SHIFT+W or E)

A programmable joystick or controller pad might also work if you can program in those specific keys.

Once you go over a certain speed (depending upon the type of aircraft), VTOL disengages.
You cannot activate it while over that max speed (which is set by a variable).
Once you are back under the max VTOL speed you can reactivate it and use the STOL reverse thrust for a fast stop and landing.

The Physics right now are VERY rudimentary. I just wanted to get this working and then let others tweak the physics to their own liking.  There are many other things that can be done in the VTOL script alone and I'm sure that someone
can write a much better method for forward and reverse thrust, rotation, etc.  In fact, that's what I'm hoping is that someone a bit better with trigonometry, etc. can make more realistic handling.  The sample mission has 3 jets and a cessna in it so you can see what I'm trying to accomplish here.

Requirements to get VTOL working in a mission:

UPGRADE TO VERSION 1.91
I use the new scripting command typeOF in one of the scripts.  It isn't 100% necessary, but it makes life easier.  Without it, 1.85 and up should work.  You really should update to 1.91 though.  Your mother would be proud.

1. Player Trigger
Have a trigger for each player like so:
Condition: Alive W1 (or whatever the name of the unit is)
Trigger: Repeatedly
OnActivation: [W1] exec "karr-VTOL-Player.sqs"

So if you have 12 units, whether AI or players that you want to be able to use VTOL, then create a trigger for them.  There are some global vars used in the vtol scripts, so in SP or with your own AI, you might see some interesting stuff if you get them all to activate vtol at once.  Of course it might be funny too.  It may not even work with AI properly at all.  I haven't tested it for AI, so I don't know for sure.

2. Copy all Scripts
Copy all of the scripts into your mission folder.  If you already have init.sqs, simply add the lines from the included init.sqs into your own mission's init.sqs.  Specifically these lines:
Quote
VTOL = TRUE
VTOLS = []
[] exec "PSinit.sqs"

All of the core scripts are prefixed with either PS or karr-vtol

3. Prosphere Triggers
Prosphere requires 3 triggers to be placed in the mission ON LAND NOT WATER.  You can simply copy the ones from the sample mission and place them over land.  These triggers must be named PS1, PS2, and PS3.

4. Adjustments
If you familiarize yourself with the Vtol scripts, you'll see that I filter out all vehicles except planes.  You can make it even more specific, i.e. only an AV8 Harrier or something.  I also created some local arrays named _jets and _planes.  _jets can use vtol up to 175 kph, planes are limited to 150.  This can be adjusted however you please with karr_maxvtolspeed global variable.

This can be found in the karr-vtol-Actions.sqs script.

In the PS.sqs script there are also many more variables that can be tinkered with to fine-tune physics.  Most of the VTOL physics are in the karr-vtol.sqs script.  I do rely upon the self-centering spring for the C-axis (rotational axis) to spring back fairly fast, but it's still a bit slow, so rotation is a bit rough at the moment.

OK, that's it (before this becomes a novel).

Thanks to Prosperus for his Prosphere Controller Lite â„¢ technology.  It was and still is a biznitch to decipher, but it makes vtol work!

Here's the link to the sample mission source:

http://www.aggression.org/karr/karrvtoltest.zip

I hope you enjoy!
« Last Edit: 07 May 2003, 17:20:54 by KaRRiLLioN »

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:VTOL using the keyboard
« Reply #1 on: 07 May 2003, 17:23:04 »
Heeey, karry'm8, stunning!  :o :D :thumbsup: no more chopper derived addons  8)

*i'm sure 'Collin_kinK' will love this one too*  :-*  ;D


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:VTOL using the keyboard
« Reply #2 on: 07 May 2003, 17:24:11 »
Sounds great!   Why not post this as a script snippet in the Ed Depot.
Plenty of reviewed ArmA missions for you to play

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:VTOL using the keyboard
« Reply #3 on: 07 May 2003, 18:12:00 »
I may, although it's a bit more than a snippet since it requires some triggers and such.  I'm going to be altering it some more to see if I can substitute gamelogics or something else for those triggers so that they can be created dynamically.  That would make it easier for an addon maker to integrate it, i.e. the Harrier.

I also found a small bug in it.  If you are using VTOL and you perish in a ball of horrific flames, for example, then vtol ceases to work for the rest of the mission.  There must be a variable getting shutdown in there somewhere so I need to find that.

I also want to work on getting the actions to properly disappear when the aircraft is unoccupied.  I had thought that I had that working, but apparently it doesn't always work perfectly.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:VTOL using the keyboard
« Reply #4 on: 07 May 2003, 18:38:01 »
The Ed Depot doesn't have a problem with a snippet that need triggers or gamelogics and stuff, just as long as you give clear instructions as to how to make it work.

If it's still a beta you can post it on the scripts beta testing board and hopefully somebody will help with the debugging.
Plenty of reviewed ArmA missions for you to play

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:VTOL using the keyboard
« Reply #5 on: 07 May 2003, 21:34:09 »
I've integrated the script into my RTS-3 missions and a few CTF's to see how the general OFP gaming public uses it.  So far they've beta tested it fairly well, but the main thing I'm trying to tweak is the physics element of it.  I'll try to get a newer version up soon and maybe a mathematics genius will have some ideas to make the handling a bit more realistic.

Offline KaRRiLLioN

  • Members
  • *
  • Grits -n- Peanut Butter are a wonderful thing
    • OFP RTS-3 Real Time War
Re:VTOL using the keyboard
« Reply #6 on: 08 May 2003, 07:03:14 »
I just uploaded a new version of the VTOL sample mission source.

Now VTOL stays active during flight at all times unless you manually turn it off.  It doesn't activate unless you're going slower than the max vtol activation speed, currently 175 for jets and 150 for planes.

I think I got rid of the bug where vtol stopped working when you died while using STOL turbo.

Now I'm trying to figure out how to get lateral thrust (side to side) working right.  For some reason my calculations make the plane go in a sort of circle.  If anyone has suggestions of how to fix it I'd be appreciative.

Here's the code in question:

Quote
#Lateral Thrust
?_x > 0 AND _xThrust < 10 : _factor = _x*.8; _xThrust = (_factor*(cos getDir _vcl))+(velocity _vcl select 0); _xOn=TRUE
?_x < 0 AND _xThrust > -10 : _factor = _x*.8; _xThrust = (_factor*(cos getDir _vcl))+(velocity _vcl select 0); _xOn=TRUE

?_xON AND _x == 0 : _xThrust = 0; _yThrust = 0; _xOn=FALSE

Basically I want the player to be able to thrust just a bit from side to side but not go very fast while doing it.  It's strange but at some angles, it'll go really fast, and others not move much at all.

The max value of _x is 1 btw.

Thanks!