I've had a bug report sent to me that seems to indicate that if something attacks a 'PlanarEntity' and immediately removes itself for any reason, the game will crash.
[string "scripts/components/planarentity.lua"]:21: attempt to perform arithmetic on local 'z1' (a nil value) LUA ERROR stack traceback: scripts/components/planarentity.lua:21 in (method) OnResistNonPlanarAttack (Lua) <13-32>
function PlanarEntity:OnResistNonPlanarAttack(attacker) local fx = SpawnPrefab("planar_resist_fx") local radius = self.inst:GetPhysicsRadius(0) + .2 + math.random() * .5 local x, y, z = self.inst.Transform:GetWorldPosition() local theta if attacker ~= nil then local x1, y1, z1 = attacker.Transform:GetWorldPosition() if x ~= x1 or z ~= z1 then -- |||| x1 AND OR z1 ARE BEING RETURNED AS NIL theta = math.atan2(z - z1, x1 - x) + math.random() * 2 - 1 end end if theta == nil then theta = math.random() * TWOPI end fx.Transform:SetPosition( x + radius * math.cos(theta), math.random(), z - radius * math.sin(theta) ) end
Whats odd about this is that you would think doing a nil check for the attacker would prevent this, but, y'know, #JustCodingThings
Steps to Reproduce
Specifically happens with a mod related feature, however, if any entity was attacked and removed within a frame or so, the same thing could happen.
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 account
Already have an account? Sign in here.Sign In Now