Project Zomboid

Project Zomboid

166 ratings
[B41] MaintenanceFIX
2
3
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
284.459 KB
Jun 28, 2023 @ 2:06pm
Apr 13, 2024 @ 8:03pm
8 Change Notes ( view )

Subscribe to download
[B41] MaintenanceFIX

Description
This Mod is no longer needed for B42!

After investigating the maintenance skill in b42, i found that when the game calculates the maintenance mod, it no longer divides it by two, which means in all likelihood, the bug is fixed.

I have yet to confirm if the game modifies the maintenance mod when it asks for it, since I'm a novice programmer and I'm not really sure where to look. If somebody more experienced could point me in the right direction, that would be great.

Until further notice however, it will not be updating. For those still playing b41, it will still be up.

Description:

Removes 'dead' maintenance levels, by making weapons more durable at odd maintenance levels.
Also lets weapon skill contribute more to durability at levels 2, 6, and 10

How Maintenance Works:

So, as a quick recap in case you aren't aware of how maintenance works, each weapon has a chance of breaking when used. for example, a crafted spear has a 1/2 chance of breaking when used. Maintenance, alongside half the weapon skill, are directly added to the denominator of this chance. So a maintenance skill of 2, and a spear skill of 4, will both add 2 to the denominator of 1/2, making it 1/6. Now you are less likely to break your spear.

The problem:

The problem here is that when the game calculates the number to add to the weapon's break chance, it divides it in half. Then, when it needs it actively, it multiples it by 2 again. The problem, is that java effectively rounds any decimals in these calculations down, meaning that odd maintenance levels contribute the same amount as the last even maintenance level, and only weapon skills 4 and 8 actually contribute to the weapon's break chance.

Here are some examples:
Crafted Spear Break Chance: 1/2. Maintenance level(ML) 1, Spear Level (SL) 3.
ML 1 / 2 = 0.5. Rounds down to 0. 0 x 2 = 0.
SL 3 / 2 = 1.5 Rounds down to 1. 1 / 2 = 0.5. Rounds down to 0. 0 x 2 = 0.
Spear break chance = 1 / (2 + 0 + 0) = 1/2. The same as a base spear with no levels.

Crafted Spear Break Chance: 1/2. Maintenance level(ML) 3, Spear Level (SL) 6.
ML 3 / 2 = 1.5. Rounds down to 1. 1 x 2 = 2.
SL 6 / 2 = 3. 3 / 2 = 1.5. Rounds down to 1. 1 x 2 = 2.
Spear break chance = 1 / (2 + 2 + 2) = 1/6. The same as if you wielded the spear with 2 less spear levels and 1 less maintenance level.

What my mod does:

What my mod does is effectively nullifies this quirk in the coding by adding 1 to all weapon's base break chance at odd maintenance levels, and weapon levels 2, 6, and 10. It then removes them at even maintenance levels and weapon levels 4 and 8. There should be no way to tell the weapon's are modified unless you use the Show Weapon's stats mod or something similar. The mod modifies weapons when equipped, and it should work on any melee weapon, modded or otherwise.

Compatability:
Should be compatible with all weapons, including modded ones, as long as they are properly coded as melee weapons and use one of the vanilla weapon categories.

Also compatible with Maintenance Improves Repair, since that is a common question. They alter different things about the game code so there isn't any issues there.

Known Issues:
None, report any you find!

This is my first mod! let me know if there are any strange quirks or anything, thanks!

Workshop ID: 2996013868
Mod ID: MaintenanceFix
39 Comments
Redeye Dec 25, 2024 @ 10:49am 
thanks man for checking. I appreciate the work you put into this, no worries. So far it's good, just needs some additional patches.
Virplexer  [author] Dec 24, 2024 @ 12:56pm 
@Redeye after investigating, I'm pretty sure the bug this mod was patching is fixed. At least, I know it doesn't divide the maintenance mod by 2 anymore, not quite sure if it alters it when its called though. The division by 2 was causing the problem though, and without it, I'm pretty sure this mod is no longer necessary. Have a good time with B42!
Redeye Dec 22, 2024 @ 9:29pm 
they made some changes I think, seems more important now for repairs
Virplexer  [author] Dec 22, 2024 @ 9:21pm 
@Redeye I'll try to see if I can get an update out, if not tomorrow then probably past christmas. It should be unchanged for B42 but I'll need to gander at the source code to see if they updated the maintenance skill at all because there's a chance this mod will now be redundant.
Redeye Dec 22, 2024 @ 6:37pm 
B42 update please?
ImRenzo Oct 12, 2024 @ 1:27pm 
well, i'll try playing with both mods, and if any issues show up, i'll share them here. thanks for the help!
Virplexer  [author] Oct 12, 2024 @ 12:52pm 
@ImRenzo should have no compatibility issues, my mod alters weapons when you equip them, so it should work on any melee weapon modded or otherwise.
ImRenzo Oct 12, 2024 @ 11:40am 
does this mod work with Simple Overhaul: Melee Weapons (SOMW)?
Wiker Jul 3, 2024 @ 8:22pm 
Nice mod :steamthumbsup:
Gamemo May 24, 2024 @ 6:03pm 
effectively