Skip to content
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

Fix #552 Impossible to stop helicopter rotor if it has a driver #3621

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Jul 31, 2024

Fixed #552

This PR add two new functions

bool setVehicleRotorState(vehicle, bool state [, bool stopRotor = true ])
bool getVehicleRotorState(vehicle)

This function works in a similar way to setVehicleEngineState.

By specifying state to false, the rotor will not be processed, i.e. it will not change its speed and the helicopter/plane cannot be controlled.

The stopRotor parameter specifies whether the rotor is to be stopped (SetHeliRotorSpeed ​​to 0). If we specify false, the rotor will not change its speed, but will not be stopped, it will rotate at the same speed all the time.

Of course, instead of adding new functions, we could use setVehicleEngineState, but for backward compatibility reasons it is better not to do this and simply add these two new functions to avoid possible problems with older scripts.

This function also allows to achieve the effect that the rotor rotates even without a driver.

Client/game_sa/CVehicleSA.cpp Outdated Show resolved Hide resolved
Client/game_sa/CVehicleSA.cpp Outdated Show resolved Hide resolved
Client/game_sa/CVehicleSA.cpp Outdated Show resolved Hide resolved
Client/game_sa/CVehicleSA.h Outdated Show resolved Hide resolved
Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp Outdated Show resolved Hide resolved
Client/game_sa/CVehicleSA.cpp Show resolved Hide resolved
Client/game_sa/CVehicleSA.cpp Outdated Show resolved Hide resolved
@salwador
Copy link

salwador commented Aug 1, 2024

Will it work with planes, or only helicopters?

@FileEX
Copy link
Contributor Author

FileEX commented Aug 2, 2024

Will it work with planes, or only helicopters?

This PR only applies to helicopters. Does the same bug apply to planes?

@salwador
Copy link

salwador commented Aug 2, 2024

Does the same bug apply to planes?

Yep, same. At the moment, rotor can be stopped only in preRender.

Im ask because PR #2548 add combined method for set/get heli/plane rotor speed.
It would be good if the rotor-state methods was universal.

@TheNormalnij
Copy link
Member

Of course, instead of adding new functions, we could use setVehicleEngineState, but for backward compatibility reasons it is better not to do this and simply add these two new functions to avoid possible problems with older scripts.

What may be broken?

@FileEX
Copy link
Contributor Author

FileEX commented Aug 9, 2024

Of course, instead of adding new functions, we could use setVehicleEngineState, but for backward compatibility reasons it is better not to do this and simply add these two new functions to avoid possible problems with older scripts.

What may be broken?

As far as I know, the MTA team strongly attaches importance to backward compatibility.

In this case, various scripts using setVehicleEngineState could cause the helicopter's rotor to stop, and while this is perfectly desirable behavior for us, it may be undesirable for others. So I personally think it's safer and better to just add these simple functions

@FileEX
Copy link
Contributor Author

FileEX commented Aug 9, 2024

Does the same bug apply to planes?

Yep, same. At the moment, rotor can be stopped only in preRender.

Im ask because PR #2548 add combined method for set/get heli/plane rotor speed. It would be good if the rotor-state methods was universal.

I took this into account and introduced setVehicleRotorState & getVehicleRotorState which is for both helicopters and planes

@tederis tederis added the bugfix Solution to a bug of any kind label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solution to a bug of any kind
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to stop helicopter rotor if it has a driver
6 participants