headofmarimo Posted January 13, 2021 Share Posted January 13, 2021 (edited) I'm making a character mod where bosses like deerclops wont aggro the character unless it is hit (Kinda useless I know but thought itd still be neat to have). However, every time I spawn deerclops the game crashes. It says there's a nil value somewhere but I'm not sure how to fix it? Here is the warning the client log gives: =[C]:-1 in (method) FindEntities (C) <-1--1> scripts/simutil.lua:35 in () ? (Lua) <31-42> inst = 123790 - deerclops (valid:true) radius = nil fn = function - ../mods/charmod/modmain.lua:140 musttags = table: 14921210 canttags = table: 14921238 mustoneoftags = nil x = 151.81788635254 y = 0 z = -332.45700073242 [00:01:32]: [string "scripts/simutil.lua"]:35: bad argument #3 to 'FindEntities' (number expected, got nil) LUA ERROR stack traceback: =[C]:-1 in (method) FindEntities (C) <-1--1> scripts/simutil.lua:35 in () ? (Lua) <31-42> =(tail call):-1 in () (tail) <-1--1> scripts/components/combat.lua:206 in (method) TryRetarget (Lua) <199-222> scripts/components/combat.lua:196 in (field) fn (Lua) <195-197> scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> scripts/update.lua:185 in () ? (Lua) <164-243> and here is my code, which I essentially just copy-pasted from the deerclops.lua file local RETARGET_MUST_TAGS = { "_combat" } local RETARGET_CANT_TAGS = { "prey", "smallcreature", "INLIMBO", "communer" } local function DeerclopsRetarget(inst) local range = inst:GetPhysicsRadius(0) + 8 return GLOBAL.FindEntity( inst, TARGET_DIST, function(guy) return inst.components.combat:CanTarget(guy) and ( guy.components.combat:TargetIs(inst) or guy:IsNear(inst, range) ) end, RETARGET_MUST_TAGS, RETARGET_CANT_TAGS ) end AddPrefabPostInit("deerclops", function(inst) if GLOBAL.TheWorld.ismastersim then inst.components.combat:SetRetargetFunction(1, DeerclopsRetarget) end end) Edited January 13, 2021 by headofmarimo Link to comment https://forums.kleientertainment.com/forums/topic/126066-crashing-when-near-deerclops/ Share on other sites More sharing options...
Thomas_klei Posted January 14, 2021 Share Posted January 14, 2021 Gotta take a guess and say that TARGET_DISTANCE hasn't been defined unlike the other 2 Link to comment https://forums.kleientertainment.com/forums/topic/126066-crashing-when-near-deerclops/#findComment-1416460 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now