In Progress Lords and garrisons belonging to player's clan need horses to upgrade troops, but no logic tells them to buy horses

Users who are viewing this thread

Version number
e1.5.6
Branch
Beta
Modded/unmodded
No, I didn't use any mods.

bm01

Sergeant
I noticed what I describe in the title as I was making a mod to force the AI to buy and consume horses to upgrade troops.

PartyUpgrader.UpgradeReadyTroops() is called after battles and during daily ticks, and is where troop upgrades happen. There are two conditional checks that allows AI to upgrade their troops without the required items by bypassing some parts of the code, which is as far as I know an intended AI cheat. However, the code isn't bypassed when that AI belongs to the player clan (see red boxes, ignore the blue one for now):

lk2YLJc.png


In this first screenshot, if the party's inventory contains the required items, the upgrade target is added to a list of potential / possible upgrades. But it fails most of the time since there's currently no adequate logic telling lords to buy horses and warhorses. It also fails for garrisoned troops in castles since their inventories are always empty (even if lords were asked to buy horses, there's currently no logic telling them to refill castle inventories anyway).

gAHTEge.png


In this second screenshot, the required items is removed from the inventory after the upgrade happened.

As a result, garrisons and parties belonging to the player's clan end up with way less mounted units than other lords, because they need horses but aren't told to buy any. Even the player's clan should benefit from that AI cheat in my opinion, at least until a logic telling lords to buy horses for the purpose of upgrading troops is added.


Another somewhat related issue: PartyTroopUpgradeModel.CanPartyUpgradeTroopToTarget() (see the blue box in the very first screenshot) will call PartyTroopUpgradeModel.DoesPartyHaveRequiredItems() regardless of the party's clan. This happen if the checked unit is a bandit:

OWCqU4X.png


89iP7Lc.png


The consequence is that if the upgrade of the current bandit unit is as mounted unit, then AI lords (even those that don't belong to the player's clan) will be required to have horses (or warhorses) in their inventories. This is inconsistent with the way other upgrades happen.

Not only that, but if they do have the required item in their inventory and are able to upgrade it, the horse still won't be consumed for AI lords that don't belong to the player's clan (see second screenshot). While that last part is fine given the AI cheat, it basically means it's only working partially here.


Lastly, while there actually is a logic telling lords to buy horses in PartiesBuyHorseCampaignBehavior.OnSettlementEntered(), it's only done in extremely small quantities and not for troop upgrade purposes.

In fact, if the the sum of the value of all the horses in the inventory is superior to 10% of the lord's gold, horses in excess are sold back. That method also tell the lord to sell everything that isn't a horse or food. (Not shown in the screenshot.)

However, there's a check at the top of the method that can prevent all of this from happening:

FJfZZw9.png


While I never noticed it happening, I would guess that if for some reason a party ends up with more horses than troops (or whatever "NumberOfregularMembers" returns), that party would end up unable to sell non-horse / non-food items, and unable to sell horses in excess.
 
Last edited:
Back
Top Bottom