Resolved [stable 1.5.8] AI lords in army not donating troops to garrison after taking castle as ruler

Users who are viewing this thread

Version number
1.5.8
Branch
Main
Modded/unmodded
Yes, but I removed mods.
Dump identifier (optional)
n/a
Summary: only happens if the player is a ruler and leading an army and successfully takes fort -- to clarify fellow lords/ladies simply do not donate troops and leave the castle empty. I first discovered this issue with mods but was able to reproduce on a clean save.
How to Reproduce: assemble army as ruler -- take castle -- should notice empty garrison even after visiting it over and over
Have you used cheats and if so which: n/a
Scene Name (if related):
Media (Screenshots & Video):
Computer Specs:
OS:win 10
GPU:1070ti
GPU Driver Version:
CPU:r5 3600
RAM: trident z neo 16gb 3600mhz
Motherboard: b450 tomahawk
Storage Device (HDD/SSD): 1tb crucial p1
 
Do you have a save file of session that you experienced this issue? With your save file, we can reproduce the issue much easier and faster. For more information regarding how to send us your save files, you can check this thread out. You can find your save file here:
C:\Users\username\Documents\Mount and Blade II Bannerlord\Game Saves

You can send your save files to us via upload.taleworlds.com site. Please write your username and this threads URL into the description box so that we can find it easier. Thanks for reporting and sorry for any inconvenience!
 
Do you have a save file of session that you experienced this issue? With your save file, we can reproduce the issue much easier and faster. For more information regarding how to send us your save files, you can check this thread out. You can find your save file here:
C:\Users\username\Documents\Mount and Blade II Bannerlord\Game Saves

You can send your save files to us via upload.taleworlds.com site. Please write your username and this threads URL into the description box so that we can find it easier. Thanks for reporting and sorry for any inconvenience!
I am having this exact issue as well. When Lords do fill the garrisons its only between 1 and 30 troops for towns and often just 1 for castles. After waiting, only if the clan that is awarded the fief is in the Army do they start putting troops into the settlement / castle garrison. Otherwise they hold onto their troops and recruit like didn't just take it. This results in Castles / Settlements coming under siege from small parties and being taken back immediately and the enemy lords almost always put at least 100 soldiers in Settlements and at least 30 troops in Castles.

I will upload my most recent save game to the above and reference this thread. It's easily reproduced by simply commanding an Army, taking a settlement or Castle and waiting. The Lords will not donate many troops to the garrison. Castles may get 1 - 3 soldiers and Settlements may get up to 30 but no more. Even for rich settlements that are taken.
 
I have already located the code that causes this bug. In the DefaultSettlementGarrisonModel there is a procedure called FindNumberOfTroopsToLeaveToGarrison. This procedure will always return zero if the player is the ruler of a faction who’s NPC army captured a settlement.

When a settlement is captured it is given to the king temporarily. In this case the king is the player. The following line of code prevents NPC armies leaving a garrison if you are king:
if ((settlement.OwnerClan.Leader != Hero.MainHero || (mobileParty.LeaderHero != null && mobileParty.LeaderHero.Clan == Clan.PlayerClan)) && num < num2)

As you can see, since the settlement is now own by the king (the player), this if statement can never be entered. settlement.OwnerClan.Leader will always be the player (Hero.MainHero) so this can never result in any donations of troops by NPC armies that capture a settlement for your kingdom.

You should change the if statement to look like this:
if ((settlement.OwnerClan.Leader != Hero.MainHero || (mobileParty.LeaderHero != null && mobileParty.LeaderHero.Clan == Clan.PlayerClan) || settlement.Town.IsOwnerUnassigned == true) && num < num2)

This will allow NPC lords and armies to donate troops to the garrison of a newly captured settlement until the settlement has been awarded to someone in a fief election. The settlement.Town.IsOwnerUnassigned flag is set to false after the fief has been awarded to someone in an election.

This is really the best solution to this problem, based on how the code is currently written.
 
I've been informed that this bug is fixed and the fix will be sent to the game with future patches. Thanks for reporting and sorry for any inconvenience!
I am playing 1.1.5
on for Mod compability and have this issue. Can i change the Lines of code myself? if yes how?
 
Back
Top Bottom