Project Zomboid

Project Zomboid

[B42/B41] Bandits NPC (v2)
Bug GetCapabilities of non-table null + Possible Fix
I killed a random civilian in testing that spawned (during Day 0). I was using week one, the required Bandits NPC mod, and had Dynamic Body Shape mod enabled (I was doing some compatibility testing).

I Believe that this is an issue with Bandits NPC mod, so I'll make a discussion there too.

I came across this issue after disabling god mod and invisibility on the cheat menu

This is the stack trace:


attempted index: GetCapabilities of non-table: null

--------------------
STACK TRACE
--------------------

function: Can - file: Bandit.lua line # 329 | MOD: Bandits
function: ManageCombat - file: BanditUpdate.lua line # 785 | MOD: Bandits function: GenerateTask-file: BanditUpdate.lua line # 1266 | MOD: Bandits function: OnBanditUpdate - file: BanditUpdate.lua line # 1427 | MOD: Bandits


java.lang.RuntimeException: attempted index: GetCapabilities of non-table: null at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1667)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:479)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:173)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1963)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1790) Lags | Initialized, CanWalk, CanCrawl UnderVehicle }}}
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protected CallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:81)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:315)
at zombie.characters.IsoZombie.updateInternal(IsoZombie.java:3689)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:102) at zombie.characters.IsoZombie.update(IsoZombie.java:3557)
at zombie.Moving ObjectUpdateScheduler UpdateBucket.update(Moving ObjectUpdateScheduler UpdateBucket.java:71)
at zombie.Moving ObjectUpdateScheduler.update(Moving ObjectUpdateScheduler.java:155)
at zombie.iso.IsoCell.ProcessObjects(IsoCell.java:3058)
at zombie.GameProfiler.invokeAndMeasure(GameProfiler.java:195)
at zombie.iso.IsoCell.updateInternal(IsoCell.java:5942)
ceFlags | Initialized, CanWalk, CanCrawlUnderVehicle }}} OD: Bandits
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:102) at zombie.iso.IsoCell.update(IsoCell.java:5884)
at zombie.iso.IsoWorld.updateWorld (IsoWorld.java:3955)
at zombie.iso.IsoWorld.updateInternal(IsoWorld.java:4055)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:102) at zombie.iso.IsoWorld.update(IsoWorld.java:3979)
at zombie.gamestates.IngameState.updateInternal(IngameState.java:1799) dits
at zombie.gameStates.IngameState.update(IngameState.java:1492)
at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:101)
at zombie.GameWindow.logic(GameWindow.java:377)
CrawlUnderVehicle ]]]
Initialized, CanWalk, CanCrawl UnderVehicle ]]]
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:76) at zombie.GameWindow.frameStep(GameWindow.java:909)
at zombie.GameWindow.run_ez(GameWindow.java:802)
at zombie.GameWindow.mainThread(GameWindow.java:600)
at java.base/java.lang.Thread.run(Unknown Source)

--------------------
STACK TRACE
--------------------
function: Can - file: Bandit.lua line # 329 | MOD: Bandits
function: ManageCombat-file: BanditUpdate.lua line # 785 | MOD: Bandits 98 { Initialized, CanWalk, CanCrawl UnderVehicle ]]]
function: GenerateTask-file: BanditUpdate.lua line # 1266 | MOD: Bandits Bandits function: On BanditUpdate - file: BanditUpdate.lua line # 1427 | MOD: Bandits
Watch Window


Brain had outfit Farmer, and Program "Bandit" instead of a table with name,which seems weird.

the simplest patch solution I see to this issue would be to change the function Bandit.Can(zombie, capability) in shared/Bandit.lua:326 a little bit, from

function Bandit.Can(zombie, capability)
local brain = BanditBrain.Get(zombie)
if brain then
local capabilities = ZombiePrograms[brain.program.name].GetCapabilities()
if capabilities then
if capabilities[capability] then return true end
end
end
return false
end

To

function Bandit.Can(zombie, capability)
local brain = BanditBrain.Get(zombie)
if not brain then
return false
end
local program = brain.program
local capabilities
if type(program) == "table" then
capabilities = ZombiePrograms[brain.program.name].GetCapabilities()
elseif type(program) == "string" then
capabilities = ZombiePrograms[brain.program].GetCapabilities()
else
return false
end

if capabilities then
if capabilities[capability] then return true end
end

return false
end

This would check wether Brain is a single string or a table, and act accordingly. The best solution would be to find out Why brain returned a string instead of a table, but as a patch I believe this would suffice.

I do not believe that this is a compatiblity issue necesarilly, but I point out every mod im currently using.
< >
Showing 1-3 of 3 comments
Fed-cap 12 Feb @ 5:40am 
This was on Build 42
Fed-cap 12 Feb @ 5:55am 
Checking further, the issue seems to stem from Bandits NPC. it seems that in client/BanditUpdate.lua:98 and client/BanditUpdate.lua:117 there is a slight error: program is set to bandit

local syncData = { id = fBrain.id, hostile = true, program = "Bandit" }

Instead of a table like

local new_program = {name = "Bandit", stage = "Prepare"}
local syncData = { id = fBrain.id, hostile = true, program = new_program }

This lines are related to witnesses when you kill a random NPC (which is exactly what I did). I guess that this is what caused program to not have a table, but a string.
Slayer  [developer] 12 Feb @ 9:08am 
fixed! update the mod. thanks again fro finding this
< >
Showing 1-3 of 3 comments
Per page: 1530 50