#Custom creature AI update exception that i can't seem to figure from what it's causing it (Fisobs)

1 messages · Page 1 of 1 (latest)

vale wave
#

It appears to be from vannila code, but the logs don't show like line number so its very unclear to me, ping me if u got smth to say to fix this

abstract mica
#

Base game errors in such fundamental functions are very commonly something being passed into as null that's not intended to be, e.g. a room not being baked properly or an invalid attribute being assigned.

vale wave
#

let me see if i can overwrite that method to print out what is wrong

#

@abstract mica like this?

abstract mica
vale wave
abstract mica
#

can't actually open the codebase myself rn

vale wave
#

hmm

#

maybe its the forbiddenNode that is null? or smth else here i can't figure out? maybe the coord?

abstract mica
#

figuring this out is what logging is for

#

forbiddenNode being null wouldn't matter though because there's a null check here

vale wave
#

yeah it must be coord

#

let me run the game

#

hm, idk if this is bad or not, btw i spawned my creature in a arena for testing @abstract mica

abstract mica
vale wave
#

maybe 'this.realizedRoom.aimap'?

abstract mica
#

i'd really just log pretty much everywhere where a . is used

#

it's a temporary log, you can afford to make it spammy

vale wave
#

yeah

#

rn its kinda like shooting in the dark

#

oh well

#

oh it might be

#

the aimap

vale wave
#

ah ofc u had to go offline now grr

#

:P

abstract mica
# vale wave oh it might be

might be or is certainly null, and is it null specifically in the context where that code would be reached?

vale wave
#

and it seems like it is

#

since else the game would freeze and log stuff in the console

abstract mica
#

for example, aimap being null won't matter if InThisRealizedRoom() returns false, since the code path that requires aimap never gets reached

abstract mica
# vale wave

this doesn't make sure that aimap being null even matters

#

the thing you want to know is what causes the null reference exception, and for that the two conditions are being null and having an attribute referenced
this can only establish that it's null and not that the code that references the attribute is reached

abstract mica
#

more logging leditoroverload

#

if InThisRealizedRoom() returns true in the function, it will return true in the log

#

if it returns false in the function, it will return false in the log

vale wave
abstract mica
#

as I said, you can just spam the log just fine, and you can log as many values as you want at a given time

#

you can just obtain all information about what everything used in the function is to theoretically trace what path the code takes

#

the low effort solution I typically had is just e.g. Logger.LogMessage($"{self.forbiddenNode} {coord} {self.forbiddenNode?.value} {self.InThisRealizedRoom(coord)} {self.realizedRoom} <other potential info>"); expanded to cover everything that can matter, whether it's targets of nullref or what determines the path the code takes

#

then use that to trace what path the code takes and find the first instance of a null that lies in a path the code actually takes, which is the cause of the null reference exception
and then repeat logging with assignments with code related to that variable to find what causes it to take on an unexpected value

vale wave
#

hmm, wait is the sprite creating stuff broken? and its casuing my AI issue? idk man

#

i think it was this i didn't have a null check, let me see if it will run fine again now

vale wave
#

okay it now works

#

and everything is magiclly fixed