-
-
Notifications
You must be signed in to change notification settings - Fork 484
Add get/setVehicleWheelScale #1641
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
These functions, related to issue #719, expose the wheel scale size attribute of the CVehicle class to clientside Lua scripts.
Mad props to you, @AlexTMjugador — the PR is really high quality and very descriptive! Thank you |
This keyword guarantees that these methods override the virtual methods in the CVehicle class, as intended.
I dont think this is a very good idea, maybe someone can find out why setVehicleComponentScale doesnt work with wheels and otherwise the server owner can still remodel his vehicle wheels, this is not a good fix for the missing vehicle wheel collision issue. |
I agree with your point, @Einheit-101. This PR, alone, feels like a kinda bad fix for that issue. However, in combination with #1644, it may be better. What do you think? |
setVehicleComponentScale was designed to only modify the wheel geometry. The reason why it doesn't affect the collision is that there's no code to modify the collision. We shouldn't touch setVehicleComponentScale because it takes 3 parameters for scale, and that's absurd. We're dealing with wheels here, it should only take 1 parameter, but it's too late to fix the function. |
* Add get/setVehicleModelFrontWheelSize and get/setVehicleModelRearWheelSize These functions, related to issue #719, allow setting the front and rear wheel size of a vehicle model that GTA: SA reads from the vehicle.ide file. Moreover, in combination with #1641, all the wheels can then be visually scaled per vehicle. * Streamline API of new functions The new API takes into account suggestions made by StrixG, LosFaul, qaisjp and others. Thanks! * Fix returning std::variant with std::unordered_map in new function parser This fix is needed for the previous commit to compile. According to @sbx320, the original author of the function parser, it seems correct. * Replace newly introduced NULL by nullptr * Remove optional arguments from getVehicleModelWheelSize * Revert 0765cd3 and fix setVehicleModelFrontWheelSize instead I changed the wrong function because of a mistake.
@AlexTMjugador Please add the below wiki pages: https://wiki.multitheftauto.com/wiki/getVehicleWheelScale |
Added, thanks for the reminder! |
These functions, related to issue #719, simply expose the wheel scale size attribute of the
CVehicle
class to clientside Lua scripts.Considerations
Why?
As explained in the related issue above, custom vehicle models may have a different wheel size than the default model they replace. This wouldn't be an issue if GTA: SA somehow calculated ride height, wheel hitbox and possibly other data from the information contained in the model, but it doesn't. Singleplayer vehicle modifications handle differing wheel sizes by modifying the
WheelScale_Front
andWheelScale_Rear
fields indata/vehicles.ide
, which tell GTA the size of the front and rear wheel components so that it can calculate things properly, but script developers can't change those.On the other hand, most replacement vehicle models with differing wheel sizes that I've seen are not too far off from the sizes of the default models. I believe that the most visible effect of this discrepancy is that vehicle mods look "sunken" into the ground in MTA: SA, while in singleplayer they don't. The
setVehicleWheelScale
function that this PR adds, while it doesn't affect how GTA: SA calculates the mentioned physical parameters for the model, allows to draw all the wheels of a vehicle taller or shorter, so that these small differences can be compensated and the custom model will look better. It may also add the possibility of enhancing car tunning scripts.Why not?
Admittedly, these functions expose relatively unflexible functionality to scripts. Ideally, we should let scripts set the
WheelScale_Front
andWheelScale_Rear
values independently, or even improve upon that and let them change the size of each wheel somehow, updating the physical parameters of the model too. However, I've heard that doing that is fairly complex, I don't really have the skills to successfully do a deep dive in GTA: SA internals, and maybe these functions are "good enough".Isn't this PR already covered by
setVehicleComponentScale
?It's not! For example, consider this runcode command:
Intuitively, running that while in a car should make the wheels 2x bigger, but it doesn't.
Why not fix
setVehicleComponentScale
instead?That would be a good idea, but I don't know why
setVehicleComponentScale
doesn't work with wheels. I guess it may have something to do with theCVehicle
attribute that this PR exposes, or other GTA stuff.Added functions
Returns a decimal number that represents the scale multiplier in the vertical and horizontal axes that is applied for all the wheels of the vehicle. By default, 1.
Sets the wheel scale multiplier for all the wheels of the vehicle. A value of 1 draws the wheels with the default scale. A value of 0 is allowed, and it makes wheels disappear.
Screenshots