SpellManager.CanCast() (and almost every single Lua call) is very often throwing errors like this in a loop when called within Behavior Tree, quickly filling megabytes of logs: Code: [3:11:33 PM:464] System.NullReferenceException: Object reference not set to an instance of an object. at Apsalar.ApsalarRoutine.<CreateMovement>b__11(Objec t ret) in c:\Users\woodrow\Documents\papa\CustomClasses\Apsa lar\Apsalar.Combat.cs:line 93 at TreeSharp.Decorator.CanRun(Object context) at TreeSharp.Decorator.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.Decorator.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.Decorator.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.Decorator.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.Decorator.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at TreeSharp.PrioritySelector.#h.#nF.MoveNext() at (Object ) at TreeSharp.Composite.Tick(Object context) at Styx.Logic.BehaviorTree.TreeRoot.Tick() [3:11:33 PM:464] Cleared POI - Reason Exception in Root.Tick() [3:11:33 PM:464] Cleared POI At least in my CC it's doing that. Any ideas?
if I'm not wrong this is your line that is giving the error CreateCast("Sprint", ret => !Settings.DisableMovementAndTargeting && Me.CurrentTarget.Distance > 8 && (!SpellManager.CanCast("Shadowstep") || Settings.DisableMovementAndTargeting)), Am I right? Couse if that is the case I see a major issue in your code, and is not in the can cast the problem You cannot call Me.CurrentTarget.Distance if you do not have before checked for Me.CurrentTarget!=null and Me.CurrentTarget.IsValid That because if you do anytime you have no target the CC will give that error try to change your line to CreateCast("Sprint", ret => !Settings.DisableMovementAndTargeting && Me.CurrentTarget!=null && Me.CurrentTarget.IsValid && Me.CurrentTarget.Distance > 8 && (!SpellManager.CanCast("Shadowstep") || Settings.DisableMovementAndTargeting)), And see if this FIX your problem OFC has to be done for every line where you have a Me.CurrentTarget.(whatever) call..
well what is before and after line 93? if its only happening once an enemy is dead, then its nothing to worry about, but if its spamming it, then theres something else thats returning null thats not suppose to be, and no, chances are its not getting it from Spellmanager.CanCast().
It's looping errors whenever i try to get Lua return values and in CreateCast(): Code: private Composite CreateCast(string spellName, CanRunDecoratorDelegate extraRun) { return new Decorator(extraRun, new Decorator( ret => SpellManager.HasSpell(spellName) && SpellManager.CanCast(spellName) && Me.CurrentTarget.InLineOfSight && SpellManager.Cast(spellName), new ActionLog("Casted " + spellName + "."))); }
Either have a Me.CurrentTarget != null check at top or before every Me.CurrentTarget property/field/method you use Code: private Composite CreateCast(string spellName, CanRunDecoratorDelegate extraRun) { return new Decorator(extraRun, new Decorator( ret => SpellManager.HasSpell(spellName) && SpellManager.CanCast(spellName) && Me.CurrentTarget != null && Me.CurrentTarget.InLineOfSight && SpellManager.Cast(spellName), new ActionLog("Casted " + spellName + "."))); }
again couse you are using Me.CurrentTarget.InLineOfSight without checking for the existance of Me.CurrentTarget..