feat(extra-natives/five): GET_VEHICLE_GEAR_RATIO and SET_VEHICLE_GEAR_RATIO
Goal of this PR
These new natives will allow developers to create scripts to create custom gear ratios for vehicles.
How is this PR achieving the goal
I added the memory editing stuff to VehicleExtraNatives.cpp to allow me to create the 2 new natives.
The natives
float GetVehicleGearRatio(Vehicle vehicle, int gear); void SetVehicleGearRatio(Vehicle vehicle, int gear, float ratio);
This PR applies to the following area(s)
FiveM, Vehicle, Lua, JS, C#
Successfully tested on
Game builds: 3095,2944,2802,2699,2612,2545,2372,2189,2060,1604
Platforms: Windows, Linux
Checklist
- [x] Code compiles and has been tested successfully.
- [x] Code explains itself well and/or is documented.
- [x] My commit message explains what the changes do and what they are for.
- [x] No extra compilation warnings are added by these changes.
Hey Ricky,
Thank you for the PR, seems like you got it working, good job! Some prechecks: your commit titles don't follow our format, see https://github.com/citizenfx/fivem/actions/runs/8118915693/job/22194013573?pr=2409#step:4:83 could you resolve these?
When you are at it can you also squash the commits? Guide: https://docs.fivem.net/docs/contributing/git/squash-guide/
Hey Ricky,
Thank you for the PR, seems like you got it working, good job! Some prechecks: your commit titles don't follow our format, see https://github.com/citizenfx/fivem/actions/runs/8118915693/job/22194013573?pr=2409#step:4:83 could you resolve these?
When you are at it can you also squash the commits? Guide: https://docs.fivem.net/docs/contributing/git/squash-guide/
should be all good now just need to let the thing run
Should we handle or document MODIFY_VEHICLE_TOP_SPEED, SET_VEHICLE_MOD, REMOVE_VEHICLE_MOD (VMT_GEARBOX) potentially recalculating this gear ratio array and overwriting changes made by SET_VEHICLE_GEAR_RATIO? Additionally b3095 introduced 0x337EF33DA3DDB990 which also repopulates the array while allowing different constants, e.g., 0.9 vs. 0.8 and 1.1 vs 1.03 in its calculations (native is tentatively named _SET_TRANSMISSION_REDUCED_GEAR_RATIO).
Should we handle or document MODIFY_VEHICLE_TOP_SPEED, SET_VEHICLE_MOD, REMOVE_VEHICLE_MOD (VMT_GEARBOX) potentially recalculating this gear ratio array and overwriting changes made by
SET_VEHICLE_GEAR_RATIO? Additionally b3095 introduced0x337EF33DA3DDB990which also repopulates the array while allowing different constants, e.g.,0.9 vs. 0.8and1.1 vs 1.03in its calculations (native is tentatively named_SET_TRANSMISSION_REDUCED_GEAR_RATIO).
possibly might want to add to the corresponding decals that they might interfere with each other
is there anything else i need to change about this?
@Disquse there you go all done lmk if you notice anything else that needs changing
any updates for changes needed?
i assume this is ready to merge then?
Tested this code in-game, works great. Thanks for your contribution, this is a nice feature to have. Apologies for the very slow review process, I was busy with a lot of other stuff. I'm attaching a debug script I made to test this feature, just in case anyone is interested in testing it out before there are any proper resources: https://pastebin.com/yDYj0sqA