KaRRiLLioN 0 Posted May 6, 2003 I've finally gotten VTOL to work with the keyboard. Basically 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. 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: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE"> VTOL = TRUE VTOLS = [] [] exec "PSinit.sqs" <span id='postcolor'> 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! Share this post Link to post Share on other sites
RED 0 Posted May 6, 2003 Good work KaRRiLLioN. Are you going to add this into the RTS3? RED Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 7, 2003 Yep, I'm adding it for version 5F. I'll be testing it on my server for a few days maybe and tweaking it. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 7, 2003 I just realized I'd put in the URL incorrectly. The sample mission source should be downloadable now. Share this post Link to post Share on other sites
The Sharpshooter 0 Posted May 7, 2003 WOW ! The Hotkeys work great ! Good Job ! I have 1 problem tough, when I engage the turbo the plane falls from VTOL and I always end up on the floor Share this post Link to post Share on other sites
silent_64 0 Posted May 7, 2003 Does the script work in multiplayer too? BOTH on client and server side (The harriers VTOL only works on server side) Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 7, 2003 @silent_64: Yes, this setup works on a dedicated server. The VTOL is client-side, but the position of objects is broadcast automatically to all clients on a server. The Addaction portion is handled by a trigger that checks for when a player respawns. It execs the VTOL-Player script which will then wait until a player gets into a vehicle. If the Vehicle is a Jet/plane (right now it checks for CountType "Plane") then the Initialize VTOL action comes up. Clicking that then execs a client-side script which adds the action "VTOL ON". After init VTOL is clicked everything is client side. I'm working on a more elegant way to add the action. With the current method, you don't have to do anything to individual vehicles because a player trigger does it. Other ways that I've done it is to put a variable in a vehicle respawn script that checks each time a plane is spawned and then sends out a temporary global var, publicvars it and then that action is available to all clients. You probably didn't want to know that much. @The Sharpshooter: The STOL Turbo disengages your vertical thrust. I plan on changing that so the vertical thrust doesn't disengage though. I'm still tweaking several physics issues, and there's also some bug that occurs during multiplayer where if you die while using VTOL (maybe in turbo mode, but I'm not sure) and a variable doesn't reset correctly and you can't use VTOL for the rest of the game. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 8, 2003 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: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="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 <span id='postcolor'> 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! Share this post Link to post Share on other sites
waffendennis 0 Posted May 8, 2003 WOW nice job man amazing now the harrier from Col. klink can be used more user friendly great job you did. Share this post Link to post Share on other sites
Prospero 1 Posted May 12, 2003 Been away. But I'm glad somebody finally used that script;) Took me bloody ages to write it. EDIT: From memory, and I could be wrong because it's been so long, deleting PSda, PSdb and PSdc will mean that the B-axis won't work. These pieces of code are used to set up 3 reference points (using the Drop command) which can then be used to determine the attitude of the (invisible) camera object which is tracked in order to get keypresses (which is how ProSphere works). EDIT: The triggers which are placed by the code called by these pieces of code are used to determine the absolute height of the reference points. EDIT: A while back, I heard you can createvehicle an "emptydetector" to create triggers without mucking around in the mission editor. I tried it, and it didn't work. Mine is not to reason why, but if it does work, then I'd use it. Prospero Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 12, 2003 Heh, I'm surprised no one has used the scripts before to do this. You are right about the B-Axis not working, but the scripts using the drop command were crashing my dedicated server for some reason. They'd work fine when testing on my machine, but when I tried testing on several dedicated servers, it would crash them all. I rem'd out the script exec lines in the PSInit.sqs and then restored them one at a time until the server started crashing again to track it. Lately I've also removed the stuff regarding the widget. I'm assuming that PSw.sqs controlled that. I tested creating server-side logics at Getpos Player instead of using the triggers, and that seemed to work just fine. Most of my missions still use the triggers, but for an addon, the dynamic creation of the logics would probably work well. I also have turbo for cars working now with a turbo jump thrown in for good measure. Occasionally I have seen some strange stuff where the A-axis would get a value of -1 and the script would get stuck there. Dunno why, but I now have it so the PS scripts all shut down and restart whenever a person is not using vtol or turbo, etc. I also have a very rudimentary form of jumping working, but it's almost not worth the effort since the soldiers look really funny without a jump animation. You have to setpos the soldier about .001 or so off the ground and then do a setvelocity on them, otherwise the setvelocity doesn't seem to work right on them. Say, you wouldn't happen to know the best calculation to make a jet do straight lateral thrusts would you? I'm trying to make vtol have a side-to-side thrust but the jet will do strange things depending upon the angle it's facing. The calculations I'm using are a couple of posts up from this one. Thanks! Share this post Link to post Share on other sites
uiox 0 Posted May 12, 2003 Prospero + Karrillon = amazing guys It's a chef d'oeuvre. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 12, 2003 Prospero built the engine, I just put in the engine belts so it would engage the transmission. Anyone have any ideas about the best calculations to make the jet/plane thrust from side to side? I've been messing with different angle calculations, but the darned thing either goes in odd loops or doesnt move at all. For example at 0 degrees, it thrusts pretty fast left and right. at 45 degrees it barely thrusts, but kind of moves forward and back. At 90 degrees it thrusts ok from side to side, etc. It just is kind of whacked. here's what I'm experimenting with now: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE"> ?_x > 0 AND _xThrust < +10 AND _yThrust < +10 AND Speed _vcl < +20 AND Speed _vcl > - 20 : _factor = _x*.1; _dir = GetDir _vcl; _xThrust = (_factor*(cos _dir))+(velocity _vcl select 0); _yThrust = (_factor*(sin _dir))+(velocity _vcl select 1); _xOn=TRUE ?_x < 0 AND _xThrust > -10 AND _yThrust > -10 AND Speed _vcl < +20 AND Speed _vcl > - 20 : _factor = _x*.1; _dir = GetDir _vcl; _xThrust = (_factor*(cos _dir))+(velocity _vcl select 0); _yThrust = (_factor*(sin _dir))+(velocity _vcl select 1); _xOn=TRUE ;;hint Format["XThrust: %1\nYThrust: %2\nZThrust: %3",_xthrust,_ythrust,_zthrust] ?_xON AND _x == 0 : _xThrust = 0; _yThrust = 0; _xOn=FALSE <span id='postcolor'> Surely someone out there can see the horrendous miscalculation I'm making and give me a correct answer. Ironically, I had a 100% average in Trigonometry in college and now can't remember much of it anymore...sigh. Share this post Link to post Share on other sites
cbfasi 4 Posted May 16, 2003 That was certainly interesting.. I just combined this script with ColKlink's Harrier and its shows great promise.. All we need is the ability to turn the harrier at slow speed as in change heading... Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted May 17, 2003 It already can rotate. Just use the Turn Left and Turn Right keys, which are X and C by default I think. Also, I'm still working on lateral thrust. Share this post Link to post Share on other sites
bn880 5 Posted May 17, 2003 Yes I tried this VTOL stuff a few days ago in a mission, it's very good. Does what it's suppost to without a hassle. Share this post Link to post Share on other sites
Prospero 1 Posted May 17, 2003 For those wanting to get a little more involved in flight-model scripting, I posted some info in a thread in this forum a while back. The message subject line to search for is: "Calculating air resistance, Needed for an arty script" (Type "Calculating AND air AND resistance" in the search box and you should find it). Note that until compiling scripts becomes an option (and indeed, a few other things), it remains a curiosity rather than a practical proposition. Roll on OFP2 perhaps. Prospero Share this post Link to post Share on other sites