It can certainly depend on things disappearing, but that does not mean that this error is enevitable, because we can avoid such a crash by changing the code.
In the error message you posted I find two interesting parts:
- The location: It says it depends on the code in the method
DefenseStep
. - The kind of cause:
NullReferenceException
means this can be avoided by replacing the default member access (coded with a dot.
) by the safe member access, coded with?.
(you will likely find many of those already in the script code).
This month, I introduced code analysis which alerts you of these kinds of problems (including exact location in the code) before even starting the bot: