-
-
Notifications
You must be signed in to change notification settings - Fork 474
Add override argument to setAnalogControlState #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
What happens if you call getAnalogControlState after a call to this? |
for example: in the next frame and player input still 0.9 |
But what if there is no controller plugged in? Getter returns 0 when no controller is plugged in and the W key is pressed, and rawValue=true |
the same except that player input would be 1 |
So this is a bugfix / enchantment? |
well i kind of both basicly ensuring backwards compatibility |
But getAnalogControlState says:
|
thanks for your reply, i didn't check getAnalogControlState properly |
i checked release and this is doesn't seem to be case for every control |
we both have missunderstood the meaning of controller in this case |
after clearing up a lot confusion i had a few times my self i checked and tested everything carefully again: |
btw. if someone asks why the value is only forced for one frame: |
renamed frameForced to override |
has someone suggestions what could be changed? |
static void RemoveSetAnalogControlState(const char* szName); | ||
|
||
static void ProcessSetAnalogControlState(CControllerState& cs, bool bOnFoot); | ||
static void ProcessControl(short& usControlValue, unsigned int uiIndex, bool bResetCmp); | ||
static void ProcessControl(short& usControlValue, unsigned int uiIndex); //, bool bPositive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what this comment is supposed to mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overlooked it while cleaning up :x
i also made some small refactors while working on the stuff and removed some redundant code
The code looks good. |
I think |
|
As of my understanding 'override' (aka 'frameForced') means that its forced for a frame, right? |
yes, which i personally believe is more practical first of all i believe the main usage would be frame based anyway second if you have for example a race map with a script but if it's only forced for a frame |
I think the name should clearly state that it's effective for one frame only, and the verb part can be "override", "force" or whatever as long as this lifetime part is included in the name. So my suggestions would be something like |
i would keep out "controller" from the name, since many people will automaticly associate it with gamepads since it affects the next called game position update, i would suggest: |
Agreed. Controller was just for an example of maybe-overly-verbose name here, but it is definitely a bad choice. "Input device" or maybe also "hardware" (although one can argue that it is not always hardware as they can be emulated) are probably the only generic enough names to cover it precisely. But anyway your latest suggestions sound reasonable too 😉 |
called it now: forceOverrideNextFrame |
This PR adds a frameForced argument to setAnalogControlState
this allows me to solve my issues i had here: #567
Fixes #567
old behavior (override = false)
- player input will not be overwitten if it's unequals to 0
- otherwise it will use the last set value after player input went 0 every following frame
behavior with (override = true)
- will overwrite the player input even if it's not 0, but only for the next frame
example edge case:
todo the way setAnalogControlState works
you can in case of a script were you want to invert player controlls only get the player value
with getAnalogControlState if you use set the raw value to true
this is because the opposite control value is always set to 0 except for accelerate and brake
some code examples:
Allows to perfectly switch left right steering of the player
can be usefull for fun race maps with item pickup scripts :)
Allows to make traction control for custom handlings with very aggressive acceleration
for example: take bullet and use this code with runcode
srun setVehicleHandling(me.vehicle, "engineAcceleration", 50) setVehicleHandling(me.vehicle, "maxVelocity", 400)
then try to drive with and with out traction controll script
there is also a lot more use stuff where this can be usefull
but the most important is: