One day I got tired of the endless spy and priest spams of the AI. Turns out using the faction_capabilities didn't work as it simply decreased the agent_limit of the individual buildings until at a certain number of buildings in the faction no recruitment at all was possible.
Which meant it had to be via the script. After some testing and some help here now the finished result for spies and assassins:
Code:
;=== Faction Limits for agents ===
declare_counter spy_counter
declare_counter assassin_counter
monitor_event PreFactionTurnStart TrueCondition ; resetting counters for the coming faction
set_event_counter spy_limit 0
set_counter spy_counter 0
set_event_counter assassin_limit 0
set_counter assassin_counter 0
end_monitor
monitor_event CharacterTurnStart TrueCondition
and AgentType = spy
inc_counter spy_counter 1
if I_CompareCounter spy_counter = 2 ; corresponding to desired max number
set_event_counter spy_limit 1
end_if
end_monitor
monitor_event CharacterTurnStart TrueCondition
and AgentType = assassin
inc_counter assassin_counter 1
if I_CompareCounter assassin_counter = 2 ; corresponding to desired max number
set_event_counter assassin_limit 1
end_if
end_monitor
EDB entry for each agent's entry
Code:
capability
{
agent spy 0 requires factions { all, } and not event_counter spy_limit 1
agent_limit spy 1 ; limit per building - still needs to be set to restrict at lower levels of building count
agent assassin 0 requires factions { all, } and not event_counter assassin_limit 1
agent_limit assassin 1 ; limit per building - still needs to be set to restrict at lower levels of building count
}
Recruiting will be disabled\enabled in the round after the number of agents has reached or fallen below the desired maximum number respectively.