Wngui / CS2WarcraftMod

GNU General Public License v3.0
17 stars 4 forks source link

Zombies (bots) invoking errors #6

Closed Jettucis closed 1 month ago

Jettucis commented 2 months ago

Hello, this boi keeps coming up when played with bots.

01:53:53 [EROR] (cssharp:Core) Error invoking callback 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 WarcraftPlugin.EventSystem.PlayerHurtHandler(EventPlayerHurt event, GameEventInfo _) in /home/runner/work/CS2WarcraftMod/CS2WarcraftMod/WarcraftPlugin/EventSystem.cs:line 110 at InvokeStub_GameEventHandler1.Invoke(Object, Span1) at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- End of inner exception stack trace --- at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Delegate.DynamicInvokeImpl(Object[] args) at CounterStrikeSharp.API.Core.FunctionReference.<CreateWrappedCallback>b__18_0(fxScriptContext* context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/FunctionReference.cs:line 100

If console doesn't lie, then it's about this line var owner = new CCSPlayerPawn(attacker.OwnerEntity.Value.Handle); The logic in there probably checks if the Bot is not used by player right? Since Bots are Zombies already it does execute every time OnPlayerHurt event no? I guess some safe-checks for the value can be added + a bit different logic to determine how it's detected that Bot is used by player.

Haven't tested it myself yet, but maybe attacker.ControllingBot instead of checking PlayerName?

I will test myself and will keep you updated if that would work.

Wngui commented 2 months ago

Thanks for the report, I'll take a look as well

Wngui commented 2 months ago

Unfortunately the issue runs a little deeper, the Respawn sig has broken recently

This means all the logic which bootstraps the zombie is never executed, causing these errors. There's not much we can do, other than wait for a new release of CounterStrikeSharp

This broken sig will also affect Necromancers splintered soul ability, and the Paladins Divine Resurrection

Wngui commented 2 months ago

Seems like a new release has dropped, try updating to the latest CounterStrikeSharp version, also update multiaddonmanager if you have that setup

Jettucis commented 2 months ago

As I mentioned before var owner = new CCSPlayerPawn(attacker.OwnerEntity.Value.Handle); is at fault and since it executes every time bot gets "hurt"

The logic in there probably checks if the Bot is not used by player right? Since Bots are Zombies already it does execute every time OnPlayerHurt event no?

and since if the bot is not controlled by Player, attacker.OwnerEntity will be null either way so you can't use .Value on null which is why the error is raised.

Do I just download files and do dotnet build will that work? (not really great with setting up building of plugins). I could test it out myself with the attacker.ControllingBot instead of checking the playername string because the current implementation will execute on all bot playerhurts since bot has Zombie in it's name.

Wngui commented 2 months ago

Aha, I think I'm starting to see the problem. You're saying all the bots on your server have the Zombie prefix, even ones not spawned by the Necromancer? Is your bot_difficulty 5? Try setting it lower to avoid this.

As for the code you mentioned, it's purpose is to check if the bot is a summoned zombie, then apply damage coming from the summoner, instead of the zombie itself, to ensure you get the kill.

I'll update the condition, but ideally you shouldn't have zombie bots running around without a master ;)

Jettucis commented 2 months ago

I see, I misunderstood the logic then. Yes, I am testing out the game mode and only way to test it is with bots and yes all bots have Zombie prefix.

Wngui commented 1 month ago

Should be fixed with the latest release