rotators / zomboid-lib

Project Zomboid utils and helpers
https://steamcommunity.com/sharedfiles/filedetails/?id=2732594572
MIT License
4 stars 1 forks source link

Can I set the values of these? #2

Open Slaughterias opened 2 years ago

Slaughterias commented 2 years ago

Hi! I'm working on a mod using this library, I understand the functions and can make use of them. However, I'm just starting to learn lua and I'm wondering if you know if it's possible for me to change some strings in order to create functions to set other vehicle values, specifically: -EngineForce -EngineRPM / gearRatio -wheelFriction -steeringIncrement -steeringClamp

I intend to attach these function to either parts, radial menu or both.

Any input would be greatly appreciated! Thanks for making this library available.

-Edit: I thought i posted this in questions, my bad.

wipe2238 commented 2 years ago

I'm not 100% sure right now, but i think some of things you want can be changed only via VehicleScript, meaning it will affect all vehicles of given type. Plus there's a chance it will work only on newly spawned vehicles, so yeah... Only one i'm pretty confident can be changed easily is wheel friction (via VehiclePart)

I'd recommend to skim BaseVehicle and VehiclePart first to see what sits in game engine by simply checking functions names. Or go step further and decompile java code yourself :P

That said, java code around vehicles is tricky. There is some interesting stuff out there which could potentially spawn interesting mods, but it's "hidden" behind functions/classes not exposed to lua, or kept inside VehicleScript which has a high chance to make mod unplayable in multiplayer, depends what you are doing with that.

Slaughterias commented 2 years ago

I see! Yes I've been looking through it and tried to use vehicle:setenginePower = (), which successfully changes the value within the mechanics window. But as soon as you start the car and drive, it will change the value back to whatever is in the template. Makes me wonder if i'm missing something obvious I'd have to do in order to to actually update the vehicle itself.

I have noticed however that if you've got a engine quality of, say 15%, it will divide the engine power relative to that value. (Not gonna bother to do the math right now). This makes me wonder if it's possible to change the quality and use that instead, and maybe mitigate the "Chance to start". This really doesn't feel like an ideal solution though.

A third option i'm thinking of is the debug "Set script" which changes the entire vehicle, but that will also reroll the condition of the vehicle as well as color hue and attached parts, which is not an option since i've got about 15 different visual attachments on my mod at this point. But maybe there's a way to have the vehicle load another engine template, whilst keeping everything else the same.

Thank you for the reply, I'll update you if I find a way.

Slaughterias commented 2 years ago

Another thing I just thought about was the Speed Demon trait which increases maxspeed and enginepower among other things, so maybe have the update tied to the character driving as opposed to the vehicle itself?

Slaughterias commented 2 years ago

Update: I've decompiled BaseVehicle and VehicleParts in order to figure out my options. The i've found out that the core is constantly updating handling from the original template, so if you try to change any values it will instantly flip them back over to the original. I'm not sure how possible it is to work around this but I'm sure as hell gonna try, mainly through these methods:

Sorry if I'm bombarding you with information you have no interest in, I'm just leaving it here because I'd be more than happy to let you include that code in this library if I manage to work something out.