Honestly even after learning programming for some time over the years, I still to this day have no idea what Germanicu5 was trying to do with his scripts. To my understanding, the main movers in the scripts would be the GTA attack plans or defend plans; nothing else really matters as much as that. There are maybe 4 or 5 places the GTA attack and defend plans were used in the whole 30'000 line script (maybe I exaggerate but I remember a ton of lines). I think his goal was to have the whole army react based on what individual units were facing, but I don't think it's viable given such extreme limitations with the number of GTA attack plans and defend.
Check this code and modify it in your config ai battle. Maybe you will be able to achieve the results you want this way. Also, some files are not save game compatible, maybe config ai battle and battle config are unmodifiable during saves.
Code:
<attack-settlement>
<detachment>
<engine-collection>
<!-- when stealing an engine, prioritise being out of combat over distance -->
<prioritise-out-of-combat>1</prioritise-out-of-combat>
</engine-collection>
<commit>
<!-- commit sufficient forces to outnumber the enemy by this ratio -->
<strength-ratio>1.6</strength-ratio>
</commit>
<perimeter-attack>
<termination-criteria>
<enemy-in-perimeter>0.25</enemy-in-perimeter>
</termination-criteria>
</perimeter-attack>
<max-plaza-assault-groups>5</max-plaza-assault-groups>
<units-per-plaza-assault-group>4</units-per-plaza-assault-group>
<artillery-times>
<!-- successful assaults performed for at least 1 minute -->
<minimum>1.0</minimum>
<!-- don't prolong the bombardment longer than 6 minutes if we have no targets left -->
<maximum>6.0</maximum>
<!-- stall test is a moving average that checks if any artillery is active (moving/firing/reloading) each tick -->
<stall-test>
<!-- minimum number of ticks to collect before detecting a stall -->
<minimum-samples>900</minimum-samples>
<!-- track at most this number of samples -->
<maximum-samples>1200</maximum-samples>
<!-- if the artillery has be inactive for at least 75% of its time -->
<limit>0.5</limit>
</stall-test>
</artillery-times>
</detachment>
<tactics>
<assault-gate>
<inside-position-dist>25</inside-position-dist>
<formation>ai_settlement_assault_gate</formation>
</assault-gate>
<reform>
<offset>30</offset>
<formation>ai_settlement_attack_reform</formation>
<percentage-formed>10</percentage-formed>
<advance-timer>1.0</advance-timer>
<siege-equipment-advance-timer>6.0</siege-equipment-advance-timer>
</reform>
<capture-plaza>
<reform-dist>120</reform-dist>
</capture-plaza>
</tactics>
</attack-settlement>