CT ?
Posted: Thu Jan 13, 2022 3:25 pm
In a Scenario, I'd like to have the AI army take a Cohesion Test (as in Ambush (own)) when the player's units (already on the battlefield) appear in line of sight. How can I do that ?
This is a script I constructed for a future scenario that imposes a Cohesion test on all AI units in turn 13 ((GetTurn() == 24) actually means AI turn 13):Athos1660 wrote: Thu Jan 13, 2022 3:25 pm In a Scenario, I'd like to have the AI army take a Cohesion Test (as in Ambush (own)) when the player's units (already on the battlefield) appear in line of sight. How can I do that ?
Code: Select all
if (GetTurn() == 24)
{
for (i = 0; i < GetUnitCount(1); i++) // for every unit in side
{
id = GetUnitID(1, i);
if (id != -1)
{
SetAttrib(id, "MoraleTestDue", 1);
}
}
DoProximityMoraleTests(side);
}And the other point is that it has to be in the StartTurnPost() function, and hence happens at the start of the turn after the event occurs, not immediately when the event occurs.Paul59 wrote: Fri Jan 14, 2022 10:06 amThis is a script I constructed for a future scenario that imposes a Cohesion test on all AI units in turn 13 ((GetTurn() == 24) actually means AI turn 13):Athos1660 wrote: Thu Jan 13, 2022 3:25 pm In a Scenario, I'd like to have the AI army take a Cohesion Test (as in Ambush (own)) when the player's units (already on the battlefield) appear in line of sight. How can I do that ?
It goes into the FUNCTION StartTurnPost(side) section.Code: Select all
if (GetTurn() == 24) { for (i = 0; i < GetUnitCount(1); i++) // for every unit in side { id = GetUnitID(1, i); if (id != -1) { SetAttrib(id, "MoraleTestDue", 1); } } DoProximityMoraleTests(side); }
This could be adapted to trigger the Cohesion tests when a player unit enters a defined area, but like Richard, I cannot see how it can be triggered by units entering LOS.