I am trying to track down how to fix a problem with some code I'm using to interrupt enemy abilities. Sorry if this is a little long.
Here is the code I am using to cast an interrupt and determine if it's needed
If a setting is true, and the spell a monster is using is found, it casts blunt arrow. However, on some enemies and abilities it seems to be having some problems. I sat with a Wind Sprite attacking me with Aero in my interrupt list and it worked just as it should. It casted Blunt Arrow to interrupt Aero, and did other abilities if it wasn't or if UseInterrupt was false.
Then I went into Stone Vigil Hard mode, and every enemy ability there would cause the routine to stop until the enemy finished using their ability.
I tried out this code in the console to see if I could find what was happening
On the Wind Sprite, it returns nothing if the sprite isn't casting, and Aero when the sprite is casting Aero. On the enemies in Stone Vigil Hard, it would usually log nothing if they weren't casting, but when they were casting, I got this
Is my code wrong? Is SpellCastInfo.Name broken? How can I make this work consistently?
Here is the code I am using to cast an interrupt and determine if it's needed
Code:
Spell.Cast("Blunt Arrow", r => settings.UseInterrupt && settings.Interrupt.Contains(((BattleCharacter)Core.Player.CurrentTarget).SpellCastInfo.Name))
Then I went into Stone Vigil Hard mode, and every enemy ability there would cause the routine to stop until the enemy finished using their ability.
I tried out this code in the console to see if I could find what was happening
Code:
Log(((BattleCharacter)Core.Player.CurrentTarget).SpellCastInfo.Name);
On the Wind Sprite, it returns nothing if the sprite isn't casting, and Aero when the sprite is casting Aero. On the enemies in Stone Vigil Hard, it would usually log nothing if they weren't casting, but when they were casting, I got this
Code:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Driver.Run() in c:\Users\redacted\Desktop\RebornBuddy\Plugins\RebornConsole\Temp\151f0zh1.0.cs:line 36
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at HighVoltz.CodeDriver.CompileAndRun(String input) in c:\Users\redacted\Desktop\RebornBuddy\Plugins\RebornConsole\RebornConsole.cs:line 452
Is my code wrong? Is SpellCastInfo.Name broken? How can I make this work consistently?