
Originally Posted by
CavalryCmdr
Brilliant workaround, that just leaves script length, but that shouldn't cause much trouble with modern machines. Definitely interested in seeing how that works out.
Ok, so I've composed a draft, it's really not so big script.
First we have to see when AI faction is at war with player. We check player's stance with every faction, here's an example for spain (one need to clone it for all factions in the game)
Code:
declare_counter faction_wars
declare_counter spain_war
monitor_event PreFactionTurnStart not IsFactionAIControlled
and not DiplomaticStanceFromFaction spain = AtWar
and I_CompareCounter spain_war = 1
set_counter spain_war 0
inc_counter faction_wars -1
end_monitor
monitor_event PreFactionTurnStart not IsFactionAIControlled
and DiplomaticStanceFromFaction spain = AtWar
and I_CompareCounter spain_war = 0
set_counter spain_war 1
inc_counter faction_wars 1
end_monitor
monitor_event PreFactionTurnStart FactionType spain
and IsFactionAIControlled
and I_CompareCounter spain_war = 1
set_event_counter at_war_with_player 1
end_monitor
monitor_event FactionTurnEnd FactionType spain
and IsFactionAIControlled
and I_EventCounter at_war_with_player = 1
set_event_counter at_war_with_player 0
end_monitor
If we're at war with spain then during spain turn we set event_counter which marks war with player to 1. We need it for EDB.
Second part is about matching player's recruitment activity
Code:
monitor_event UnitTrained FactionIsLocal
and ! TrainedUnitClass heavy
and ! TrainedUnitClass light
and ! TrainedUnitClass spearmen
and TrainedUnitCategory cavalry
inc_counter hired_missile_cav 1
inc_counter hired_ranged 1
end_monitor
monitor_event UnitTrained FactionIsLocal
and ! TrainedUnitClass heavy
and ! TrainedUnitClass light
and ! TrainedUnitClass spearmen
and TrainedUnitCategory infantry
inc_counter hired_ranged 1
end_monitor
monitor_event UnitTrained FactionIsLocal
and TrainedUnitClass missile
and TrainedUnitCategory siege
inc_counter hired_ranged 1
end_monitor
monitor_event UnitTrained FactionIsLocal
and ! TrainedUnitClass missile
and ! TrainedUnitClass spearmen
and ! TrainedUnitClass skirmish
and TrainedUnitCategory infantry
inc_counter hired_melee 1
end_monitor
monitor_event UnitTrained FactionIsLocal
and TrainedUnitClass spearmen
and TrainedUnitCategory infantry
inc_counter hired_spearmen 1
end_monitor
monitor_event UnitTrained FactionIsLocal
and ! TrainedUnitClass missile
and ! TrainedUnitClass skirmish
and TrainedUnitCategory cavalry
inc_counter hired_cavalry 1
end_monitor
monitor_event FactionTurnEnd FactionType slave
inc_counter recruitment_monitor 1
if I_CompareCounter recruitment_monitor < 25
if I_CompareCounter hired_cavalry > 10
set_event_counter hired_cavalry 1
end_if
if I_CompareCounter hired_melee > 20
set_event_counter hired_melee 1
end_if
if I_CompareCounter hired_missile_cav > 10
set_event_counter hired_missile_cav 1
end_if
if I_CompareCounter hired_ranged > 15
set_event_counter hired_ranged 1
end_if
if I_CompareCounter hired_spearmen > 20
set_event_counter hired_spearmen 1
end_if
end_if
if I_CompareCounter recruitment_monitor = 25
set_counter recruitment_monitor 0
set_event_counter hired_cavalry 0
set_event_counter hired_melee 0
set_event_counter hired_missile_cav 0
set_event_counter hired_ranged 0
set_event_counter hired_spearmen 0
if I_CompareCounter hired_cavalry > 20
set_counter hired_cavalry 5
end_if
if I_CompareCounter hired_cavalry < 21
set_counter hired_cavalry 0
end_if
if I_CompareCounter hired_melee > 25
set_counter hired_cavalry 5
end_if
if I_CompareCounter hired_melee < 26
set_counter hired_cavalry 0
end_if
if I_CompareCounter hired_missile_cav > 10
set_counter hired_cavalry 5
end_if
if I_CompareCounter hired_missile_cav < 11
set_counter hired_cavalry 0
end_if
if I_CompareCounter hired_ranged > 25
set_counter hired_cavalry 5
end_if
if I_CompareCounter hired_ranged < 26
set_counter hired_cavalry 0
end_if
if I_CompareCounter hired_spearmen > 15
set_counter hired_cavalry 5
end_if
if I_CompareCounter hired_spearmen < 16
set_counter hired_cavalry 0
end_if
end_if
end_monitor
I see if player hires melee/ranged/spearmen/cavalry/missile cavalry (quantities I set for first time, need proper testing), and if player has enough units of missile (more than 15) then I set event_counter that says to AI that player has many missile units (set_event_counter hired_ranged 1). This event counter in combination with at_war_with_player 1 set for negative recruit pool for melee infantry/spearmen and with additional speed recruit pool for light cavalry/missile cavalry will give effect that AI will correct it's reruitment policy according to player's one.