Project Zomboid

Project Zomboid

More Traits
curveo 18 Jul @ 12:37pm
XP Multipliers Conflict – Error with Fitness/Strength XP when multiple traits are active
Disclaimer:
This is a quick and dirty patch I made to fix a specific issue in the More Traits mod.
I’m sharing it here in case it helps others, but I’m not the mod author.
If you want a clean, official fix, you’ll have to wait for the mod owner.
Please don’t come complaining to me – this is just a "works for now" solution.

🛠 Issue
When multiple traits that modify XP are active (e.g. GymGoer + spec* traits), gaining XP in Fitness or Strength causes:
    Errors in the console.Incorrect XP values.
  • In some cases, the game might even crash.

🔍 What I Found
The original code in the functions Specialization and GymGoer doesn’t handle multiple XP multipliers stacking properly.
Variables like skipxpadd and hardcoded if/else blocks cause conflicts.

✅ Quick Fix
I created a helper function GetXPModifier(player, perk) that calculates all XP bonuses dynamically.
I then patched Specialization and GymGoer to use this function instead of their old logic.

📜 How to Apply
    Go to your Project Zomboid Workshop mods folder.Open the MoreTraits.lua file (usually under C:\Program Files (x86)\Steam\steamapps\workshop\content\108600\1299328280\mods\More Traits\42\media\lua\client).
  • Add the following function near the top (just above AddXP):

local function GetXPModifier(player, perk) local m = 1.0 -- GymGoer bonus if player:HasTrait("gymgoer") and (perk == Perks.Fitness or perk == Perks.Strength) and player:getCurrentState() == FitnessState.instance() then local gymMod = SandboxVars.MoreTraits.GymGoerPercent or 200 m = m * ((gymMod * 0.01) - 1) * 0.1 end -- Auto-detect spec* traits local specMod = (SandboxVars.MoreTraits.SpecializationXPPercent or 75) * 0.01 for i = 0, player:getTraits():size()-1 do if player:getTraits():get(i):sub(1,4) == "spec" then m = m * specMod end end return m end

  • Replace the body of Specialization with:

function Specialization(player, perk, amount) if perk == Perks.Fitness or perk == Perks.Strength then return end local finalAmount = amount * GetXPModifier(player, perk) AddXP(player, perk, finalAmount) end

  • Replace the body of GymGoer with:

function GymGoer(player, perk, amount) if player:HasTrait("gymgoer") and (perk == Perks.Fitness or perk == Perks.Strength) and player:getCurrentState() == FitnessState.instance() then local finalAmount = amount * GetXPModifier(player, perk) AddXP(player, perk, finalAmount) end end
🎯 Results
With this patch:

No more XP errors with Fitness/Strength.

XP from multiple traits stacks correctly.

The mod remains compatible with future traits that start with spec.

💬 Final Note
This is a quick workaround, not an official fix.
If you want to revert, just restore your original MoreTraits.lua file.
Last edited by curveo; 18 Jul @ 12:48pm
< >
Showing 1-3 of 3 comments
can u upload video instruction ?
chaos 2 Aug @ 10:46am 
Thanks ! It works ! There are no more those annoying errors any more.You save my game !
Great fix thank you
< >
Showing 1-3 of 3 comments
Per page: 1530 50