Page 1 of 1

CT ?

Posted: Thu Jan 13, 2022 3:25 pm
by Athos1660
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 ?

Re: CT ?

Posted: Thu Jan 13, 2022 10:12 pm
by Athos1660
What about CT triggered by friendly broken units appearing in line of sight ?

Re: CT ?

Posted: Fri Jan 14, 2022 8:35 am
by rbodleyscott
To make that happen immediately the event occurs, I can't think of a way to do it in a scenario script, so it would require some modding of other scripts.

Re: CT ?

Posted: Fri Jan 14, 2022 10:06 am
by Paul59
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 ?
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):

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);		
	    }
It goes into the FUNCTION StartTurnPost(side) section.

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.

Re: CT ?

Posted: Fri Jan 14, 2022 10:12 am
by rbodleyscott
Paul59 wrote: Fri Jan 14, 2022 10:06 am
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 ?
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):

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);		
	    }
It goes into the FUNCTION StartTurnPost(side) section.

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.
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.

Re: CT ?

Posted: Sat Jan 15, 2022 2:03 am
by Athos1660
Thank you, Richard and Paul, for your help.