Skip to content

XP actions still NPE every tick when per-skill XP multipliers are used #277

Description

@MakeAsplashKira

Follow-up to the previous XP report — still reproduces in 2.4.0 on PZ 42.20.4, Single Player.

The trigger

Sandbox option MultiplierConfig.GlobalToggle set to off (per-skill XP multipliers instead of
one global one). Its default is true, which is why this doesn't show up with default settings.

What happens

Any action wrapped by ExpActions.WrapUpdate throws on every update() tick — 500–1000 errors per
action:

Lua((MOD:The Only Cure)).action(ExpActions.lua:87)
    Lua((MOD:The Only Cure)).IterateTOCXp(ExpActions.lua:29)
    Lua((MOD:The Only Cure)).AddTOCXp(ExpActions.lua:86)
    Lua((MOD:The Only Cure)).update(ExpActions.lua:123)
java.lang.NullPointerException: Cannot invoke "zombie.SandboxOptions$SandboxOption.asConfigOption()" because the return value of "zombie.SandboxOptions.getOptionByName(String)" is null
    at zombie.characters.IsoGameCharacter$XP.AddXP(IsoGameCharacter.java:14269)

Why

With the global toggle off, AddXP looks up a per-skill multiplier by name:

xp *= Float.parseFloat(SandboxOptions.instance
    .getOptionByName("MultiplierConfig." + perk.getType())   // perk.toString() == perk id
    .asConfigOption().getValueAsString());

MultiplierConfig.* options exist only for the 36 vanilla skills. Side_L, Side_R and
ProstFamiliarity have none, so the lookup returns null.

This can't be fixed on the Lua side: addXp has a single 3-arg overload, and AddXPNoMultiplier
just calls back into the same code path. The option has to exist.

Fix

Add to 42/media/sandbox-options.txt (vanilla values are 0.0 / 1000.0 / 1.0):

option MultiplierConfig.Side_L
{
    type = double,
    min = 0.0,
    max = 1000.0,
    default = 1.0,
    page = MultiplierConfig,
    translation = TOC_MultiplierSide_L,
}

same for Side_R and ProstFamiliarity, plus the Sandbox_TOC_Multiplier* translation keys.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions