Scripts / Flight Revisited

Author
Message
Wrinkle Raisin
8
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 31st Aug 2015 20:12
Below is [another] flight script. It has some issues and some help would be appreciated.
The input keystrokes seem to be registered more than once per press. I have used a KeyPressed variable,
but I still get extra keystrokes.

Any other suggestion for optimization are also welcome.


Description:

The player can move an entity up, down, forward or backward and turn it left and right.
To see which keys are used how, see the function loadScancodeMap.

To use:
Set the entity properties for "Static Mode = No", "Always Active? = Yes"
and this script for "AI System => Main". Name this script and/or the init and main functions accordingly!


Features and Phenomena:

The player can "ride" the entity (TransportToIfUsed is called for this).
Unfortunately, the player cannot look up nor down so shooting while riding is an issue.
The player can "exit" the entity using the key defined (L to Land). The landing
can take a while for high values of y. One can go so high that the map is no longer visible.
Water landings are to be avoided due to drowning.
Physics must be off, and therefore the entity will plow through terrain, buildings and other entities.

The player was pulled through the buildings tested with; however, the player is pulled *over* terrain
and is not pulled under ground. The entity goes through the hill; the player goes over it.
An entity can be "flown" into water; the player will drown if riding along.

For simulating flight, a momentum variable is turned on, and the entity will continue moving
in the chosen direction, even when no keys are pressed. The player can disable this effect.

The player can fly the entity outside of the map boundaries. If the player is riding along and
leaves the entity while outside the map boundaries, then the player will drown in invisible water.

The Panel displays the initial speed before use, and it displays the current speed setting when hovering.
In other words, it shows "speed" when stationary. This could use some work...

The toggles donT work correctly. :-( It seems that the scan code is passed in more than once for each key pressed.
This applies to speed up and down too. The speed will increase/decrease more than the increment set.

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st Sep 2015 12:52 Edited at: 1st Sep 2015 12:53
the repeated keypress is because you have set the keypress back to 0 without any check
you should check GetScancode() == 0 before you set KeyPressed = 0 and/or KeyInput = 0 (not sure why you have 2)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Wrinkle Raisin
8
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 2nd Sep 2015 07:31
Thanks for the tip smallg. And thanks for taking the time to look into it. That was my first script. I viewed a lot of your scripting on this board while learning Lua. You are a big help.
PM

Login to post a reply

Server time is: 2024-05-07 00:55:07
Your offset time is: 2024-05-07 00:55:07