BannerlordCE / CEEvents

Captivity Events Source Code
https://www.nexusmods.com/mountandblade2bannerlord/mods/1226
MIT License
4 stars 6 forks source link

BattleStateCheck never checks if Player has Won #87

Open SkipWestcott opened 1 year ago

SkipWestcott commented 1 year ago

TO REPRODUCE Enter a city and use:

//captivity.fire_event TB_catcall_duel

Turns out this is because the City battle is just using PlayerStartBattle which will always kick you out of the Town!

The way Alley battles work, they call Mission.Current.GetMissionBehavior().StartCustomFight, but the args here are Agents, not Parties. I'm going to see what I can do.

SkipWestcott commented 1 year ago

Original Bug

TO REPRODUCE Enter a city and use:

//captivity.fire_event TB_catcall_duel

This var is never set: CEPersistence.playerWon, so the Lose event will always fire.

Since the BattleStateCheck is only fired on map tick, it looks to me that it is never hitting the logic to actually check on the post-battle status.

Briefly, PlayerEncounter.Current becomes null immediately, and there is no Battle to check for WinningSide.

CESubmodule.BattleStateCheck()
...
else if (CEPersistence.battleState == CEPersistence.BattleState.AfterBattle && Game.Current.GameStateManager.ActiveState is MapState mapstate2 && !mapstate2.IsMenuState)
{
if (PlayerEncounter.Current == null)
{
HandleFinishBattle(mapstate2);
}
...

And of course you already knew:

       //TODO: move all of these to their proper listeners and out of the OnApplicationTick

I