Skip to content

How do I set a hero limit for the AI?

User Avatar
#3
Auto-translated
bonycaspita
How can I set a hero limit for the AI, so that it can't hire more than 3 heroes? Thanks in advance for the answer!
Generally, there's no way to do that. Because even if you ban hiring after 3 heroes, one will still remain in the tavern, and the AI will hire him anyway. On the other hand, if you need to prohibit all heroes except certain ones, you can use AllowPlayerTavernRace(player, race, 0/1 (prohibit/allow)) 8 times for each race, and then use AllowPlayerTavernHero(player, script name of the hero, 0/1 (prohibit/allow)) to allow the AI to hire specific heroes. For example, I used this to create a player character who could only hire Andrias and Lorenzo (as in the last mission in the campaign for Freya). To ensure that heroes are always with the player, you can link them using MakeHeroReturnToTavernAfterDeath(script name of the hero, 0/1 (prohibit/allow)). It's unlikely that you'll be able to force random heroes into a hero limit (and campaign heroes in general), because you probably won't be able to create a script that will delete the least useful extra heroes, for example, only those hired after the ban is activated. Although, I might be wrong about this)

Statistics

Welcome our newest member: artem

Users Online 1 users 1491 guests