I think the Economy script disbands mercenary units also for AI when it goes into debt:
ai_ec_id = 0 for the human if I am not mistaken.monitor_event PreFactionTurnStart I_CompareCounter ai_ec_id > 0 and Treasury < -5000
log --- economy script --- AI treasury less than -5000
if I_CompareCounter ai_ec_id = 1
add_money slave 2147483647
add_money slave 2147483647
add_money slave -2147483647
add_money slave -5000
end_if
if I_CompareCounter ai_ec_id = 2
destroy_units venice, mercenary_unit
wait 0.1
set_counter freeze_venice 0
add_money venice 2147483647
add_money venice 2147483647
add_money venice -2147483647
add_money venice -5000
set_event_counter freeze_recr_pool 1
end_if
Interestingly the same thing happens when AI goes above 100k:
(In parenthesis I wonder what would happen if we remove it , that would also allow the wait 0.1 to be removed and speed up turn time maybe, but thats another discussion)monitor_event PreFactionTurnStart I_CompareCounter ai_ec_id > 0 and Treasury > 100000
log --- economy script --- AI treasury above 100000
if I_CompareCounter ai_ec_id = 2
destroy_units venice, mercenary_unit
wait 0.1
set_counter freeze_venice 0
add_money venice 2147483647
add_money venice 2147483647
add_money venice -2147483647
add_money venice 100000
end_if