theCrius / project-zomboid-random-zombies-full

GNU General Public License v3.0
3 stars 3 forks source link

Treat Probabilities as Weights to Spare Users (and Mod Support) Unnecessary Headache #13

Closed Burryaga closed 4 months ago

Burryaga commented 4 months ago

Prevent users from being able to enter invalid combinations of probabilities by treating them as weights that translate to portions of 100% of the total weight for a category.

Provided probabilities are normalized to a 100-point scale so that user addition mistakes no longer matter, and do not need to trigger runtime errors. For example, if a user enter 5:0:0:0, there will be 100% crawlers; if they enter 100:50:50:0, there will be 50% crawlers; if they enter 50:40:5:10, ratios will be adjusted to something like 49:39:4:8.

Code is basically the same number of lines due to functional restructuring and reduced need for error-based validation.

theCrius commented 4 months ago

Thank you @Burryaga, will push live by the end of the day now. Cheers

Burryaga commented 4 months ago

Hey, thanks for upgrading this super popular mod. I suggested this improvement to the original author a long time ago, and they didn't appreciate the value of it. Glad you did! Keep up the good work.

Just as a little FYI, I noticed when I saw your reply that there are two deleted functions that are no longer present in the live version of your mod, which led me to not realize that I even "deleted" them (I didn't actually delete them, I just edited this file by downloading the live mod, and they're not there anymore, so they are effectively deleted from GitHub by this update). You might want to make sure the other files on GitHub that used utilities.getSandboxVarValue or utilities.setSandboxVarValue are updated to match the live code.