fivem icon indicating copy to clipboard operation
fivem copied to clipboard

feat(extra-natives/five): GET_VEHICLE_GEAR_RATIO and SET_VEHICLE_GEAR_RATIO

Open RickyB505 opened this issue 1 year ago • 8 comments

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.

RickyB505 avatar Mar 02 '24 00:03 RickyB505

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/

thorium-cfx avatar Mar 05 '24 09:03 thorium-cfx

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

RickyB505 avatar Mar 05 '24 18:03 RickyB505

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).

gottfriedleibniz avatar Mar 06 '24 13:03 gottfriedleibniz

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).

possibly might want to add to the corresponding decals that they might interfere with each other

RickyB505 avatar Mar 06 '24 21:03 RickyB505

is there anything else i need to change about this?

RickyB505 avatar Mar 12 '24 11:03 RickyB505

@Disquse there you go all done lmk if you notice anything else that needs changing

RickyB505 avatar Mar 12 '24 23:03 RickyB505

any updates for changes needed?

RickyB505 avatar Mar 18 '24 06:03 RickyB505

i assume this is ready to merge then?

RickyB505 avatar Apr 19 '24 02:04 RickyB505

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

Disquse avatar May 27 '24 13:05 Disquse