Scenario creation guide part 4 (AI Teams and Orders)
Scenario creation guide part 4 (AI Teams and Orders)
Ok, now let’s organize the two armies into teams, and give the AI teams some basic orders.
Experienced Pike and Shot scenario designers need to be aware that FoG2 is slightly different in this respect, because in P&S there was usually no need to organize the player side army into teams. In FoG2 you need to do this because it will allow the player to move his/her teams using the Move Whole Command feature.
So, click on the “Open Custom AI Data Dialog” button:
The “Scenario AI Data” sub screen pops up:
The first field is for “AI Team”. Each armies units can be allocated to a team, there are a maximum of 8 teams (numbered 0 to 7). All units are allocated to team 0 as a default, but we will nearly always want to change that to allow more complex AI orders.
So looking at this particular scenario, we want to allocate the left flank cavalry to a team, and order them to advance against the opposing Macedonian cavalry. First thing we do is change the “AI Team” value to the team number that we want to allocate. So click on the right arrow to make the value Team 1, and then click on each unit on the map that you want in that team. The label on each unit changes when you have successfully allocated it, from FIXED:TEAM 0 to FIXED:TEAM 1.
We then need to set the “Aggression” value. This is a numerical code that defines the team’s behavior. If you click on the “?” button at the top left of the “Scenario AI Data” it brings up a scroll that explains what the Aggression values mean:
The values can be added together to give more complex orders. For instance if we want the team to attack only enemy cavalry we would add 16 (seek and destroy) + 256 (ignore foot, unless close) + 2048 (ignore artillery) to get a total of 2320. So lets add 2320 into the “Aggression” value field using the arrow keys. You can hold down the SHIFT key while clicking to advance by 10 to make things quicker.
We can define a target point for that team to advance towards using the “Target AI Point” field. The default value is None, but for this particular team I have changed it to Target AI point 1 by clicking on the arrow:
Then click on the “Cycle AI Point to use” button, so that it shows the same value as the Target AI point number that we have chosen, in this case 1.
Then click on the button on the opposite side of the sub screen called “Set the place of the current AI point on the map”.
This allows you to click on the map in the square that you want to set the Target AI Point. An inverted yellow pyramid will appear on the map when you mouse over it, to indicate that you are in Target AI Point placement mode. Just click wherever you want the Target AI Point to be set. In this case, I have set it some way beyond the Macedonian cavalry. Once clicked, it is always displayed on the map while the “Scenario AI Data” sub screen is up.
You repeat this process for all the other teams that you need. When you have finished just click the “Close” button on the “Scenario AI Data” sub screen.
Player side units are allocated to teams in exactly the same way, you just need to keep the CTRL button pressed while clicking on the units. Of course you do not need to set Aggression values and Target AI Points for the player’s units so just ignore those values that are on the sub screen, they only apply to the AI side teams. Remember, you need to allocate the players units to teams to allow the “Move Whole Command” function to work during play.
Tips:
The AI seems to move it's units in Team order, so just bear this in mind when numbering your teams. If you have teams lined up behind each other on the battlefield, you will normally want the team at the front to move first, otherwise the units behind will move first and get in the way of the units that were in front. So have the team in front numbered lower than the teams behind. In my Elephant Victory scenario I deliberately did the opposite of this. In that battle the Galatian Chariots were deployed behind the infantry. At the start of the battle, the infantry opened ranks and let the chariots through to make their attack. So I left gaps between the Galatian infantry, and numbered the Chariot team lower than the infantry teams, so that they moved first. I also used a script to delay the infantry advance, but that's something I will show you how to do another day!
Experienced Pike and Shot scenario designers need to be aware that FoG2 is slightly different in this respect, because in P&S there was usually no need to organize the player side army into teams. In FoG2 you need to do this because it will allow the player to move his/her teams using the Move Whole Command feature.
So, click on the “Open Custom AI Data Dialog” button:
The “Scenario AI Data” sub screen pops up:
The first field is for “AI Team”. Each armies units can be allocated to a team, there are a maximum of 8 teams (numbered 0 to 7). All units are allocated to team 0 as a default, but we will nearly always want to change that to allow more complex AI orders.
So looking at this particular scenario, we want to allocate the left flank cavalry to a team, and order them to advance against the opposing Macedonian cavalry. First thing we do is change the “AI Team” value to the team number that we want to allocate. So click on the right arrow to make the value Team 1, and then click on each unit on the map that you want in that team. The label on each unit changes when you have successfully allocated it, from FIXED:TEAM 0 to FIXED:TEAM 1.
We then need to set the “Aggression” value. This is a numerical code that defines the team’s behavior. If you click on the “?” button at the top left of the “Scenario AI Data” it brings up a scroll that explains what the Aggression values mean:
The values can be added together to give more complex orders. For instance if we want the team to attack only enemy cavalry we would add 16 (seek and destroy) + 256 (ignore foot, unless close) + 2048 (ignore artillery) to get a total of 2320. So lets add 2320 into the “Aggression” value field using the arrow keys. You can hold down the SHIFT key while clicking to advance by 10 to make things quicker.
We can define a target point for that team to advance towards using the “Target AI Point” field. The default value is None, but for this particular team I have changed it to Target AI point 1 by clicking on the arrow:
Then click on the “Cycle AI Point to use” button, so that it shows the same value as the Target AI point number that we have chosen, in this case 1.
Then click on the button on the opposite side of the sub screen called “Set the place of the current AI point on the map”.
This allows you to click on the map in the square that you want to set the Target AI Point. An inverted yellow pyramid will appear on the map when you mouse over it, to indicate that you are in Target AI Point placement mode. Just click wherever you want the Target AI Point to be set. In this case, I have set it some way beyond the Macedonian cavalry. Once clicked, it is always displayed on the map while the “Scenario AI Data” sub screen is up.
You repeat this process for all the other teams that you need. When you have finished just click the “Close” button on the “Scenario AI Data” sub screen.
Player side units are allocated to teams in exactly the same way, you just need to keep the CTRL button pressed while clicking on the units. Of course you do not need to set Aggression values and Target AI Points for the player’s units so just ignore those values that are on the sub screen, they only apply to the AI side teams. Remember, you need to allocate the players units to teams to allow the “Move Whole Command” function to work during play.
Tips:
The AI seems to move it's units in Team order, so just bear this in mind when numbering your teams. If you have teams lined up behind each other on the battlefield, you will normally want the team at the front to move first, otherwise the units behind will move first and get in the way of the units that were in front. So have the team in front numbered lower than the teams behind. In my Elephant Victory scenario I deliberately did the opposite of this. In that battle the Galatian Chariots were deployed behind the infantry. At the start of the battle, the infantry opened ranks and let the chariots through to make their attack. So I left gaps between the Galatian infantry, and numbered the Chariot team lower than the infantry teams, so that they moved first. I also used a script to delay the infantry advance, but that's something I will show you how to do another day!
Field of Glory II Scenario Designer - Age of Belisarius, Rise of Persia, Wolves at the Gate and Swifter than Eagles.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
Thanks again for this guide. You forgot to add the section on adding Generals and Generals' names but for anybody interested, that's section 25.15 of the manual, page 114.
Re: Scenario creation guide part 4 (AI Teams and Orders)
No, I have'nt forgotten, that will be a separate part. In fact, I think it might be the next one. I will also do a section (or sections) on all the things you can do outside of the editor to make the scenario better.vakarr wrote:Thanks again for this guide. You forgot to add the section on adding Generals and Generals' names but for anybody interested, that's section 25.15 of the manual, page 114.
Field of Glory II Scenario Designer - Age of Belisarius, Rise of Persia, Wolves at the Gate and Swifter than Eagles.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
Re: Scenario creation guide part 4 (AI Teams and Orders)
Hi Paul59.
Thanks for these useful guides.
Do you know what the number at the 4th row is for? Is it the number of turns the team is to follow the value set for Agression?
As you can have only 8 teams per side (0-7). Do you maybe know why 24 AI points (0-23) are allowed when each team can only use 1 AI point? Or does scripting allow for more than 1 AI point to be used by a team?
Thanks for these useful guides.
Do you know what the number at the 4th row is for? Is it the number of turns the team is to follow the value set for Agression?
As you can have only 8 teams per side (0-7). Do you maybe know why 24 AI points (0-23) are allowed when each team can only use 1 AI point? Or does scripting allow for more than 1 AI point to be used by a team?
Re: Scenario creation guide part 4 (AI Teams and Orders)
As far as I know the 4th row variable serves no purpose.Pi-R wrote:Hi Paul59.
Thanks for these useful guides.
Do you know what the number at the 4th row is for? Is it the number of turns the team is to follow the value set for Agression?
As you can have only 8 teams per side (0-7). Do you maybe know why 24 AI points (0-23) are allowed when each team can only use 1 AI point? Or does scripting allow for more than 1 AI point to be used by a team?
I don't know why there are 24 possible AI points, perhaps RBS can answer that one.
Field of Glory II Scenario Designer - Age of Belisarius, Rise of Persia, Wolves at the Gate and Swifter than Eagles.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
Field of Glory II Medieval Scenario Designer.
FOGII TT Mod Creator
Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
Because you can script teams to go for the another one after reaching the first one. This is something we have not used in the game, because we have written the scenario AI in a different way, but it does exist in the engine.Paul59 wrote:As far as I know the 4th row variable serves no purpose.Pi-R wrote:Hi Paul59.
Thanks for these useful guides.
Do you know what the number at the 4th row is for? Is it the number of turns the team is to follow the value set for Agression?
As you can have only 8 teams per side (0-7). Do you maybe know why 24 AI points (0-23) are allowed when each team can only use 1 AI point? Or does scripting allow for more than 1 AI point to be used by a team?
I don't know why there are 24 possible AI points, perhaps RBS can answer that one.
Richard Bodley Scott
Re: Scenario creation guide part 4 (AI Teams and Orders)
Having a thick day again but can't get AI to follow orders. What I want the chariots to do is to chase the archers away and gallop to their target point way up north. Instead, they charge the archers and get destroyed. Not a single chariot cares about clear orders. What's wrong?
Regards,
Henry
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
I am not sure what you mean by "clear" orders.urkki63 wrote:What I want the chariots to do is to chase the archers away and gallop to their target point way up north. Instead, they charge the archers and get destroyed. Not a single chariot cares about clear orders. What's wrong?
The aggression code you have given them is 10 = 8 + 2.
8 orders is - ignore all enemy unless close - engage them as per other orders if close
So if their route to their objective goes through the enemy they will charge them.
It you want to increase their chance of ignoring light troops, you could try 8 + 2 + 128 = 138
What I don't understand is why they are getting destroyed by light archers in close combat - or is it by shooting?
Richard Bodley Scott
Re: Scenario creation guide part 4 (AI Teams and Orders)
Go to target point 1 and kill.I am not sure what you mean by "clear" orders.
I thought I gave them 16=search and destroy.The aggression code you have given them is 10 = 8 + 2.
So if their route to their objective goes through the enemy they will charge the
It doesn't. They could easily go to their target point if they wanted to without a fight. Instead, they charge and get annihilated by a bunch of levy psiloi..
I tried that - 2nd field from the top - but this time the chariots just sit there doing nothing. Not a step towards the target point.It you want to increase their chance of ignoring light troops, you could try 8 + 2 + 128 = 138
With their slings and bows alone. I don't understand it either. I took away their light spears to make them weaker and all of a sudden these **** psiloi are pretty much the fiercest fighting men in the Middle East. They're really on something now. They beat up the heavy chariots every single time. And why are the chariots ignoring their target point?What I don't understand is why they are getting destroyed by light archers in close combat - or is it by shooting?
What's the 4th field from the top in the AI dialog? I don't think Paul mentions it at all.
Cheers!
Henry
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
Ah yes, you did. I was looking at the wrong line in the dialog box.urkki63 wrote:I thought I gave them 16=search and destroy.The aggression code you have given them is 10 = 8 + 2.
Well "Seek and Destroy" means "Seek and Destroy", which is what they are doing. And they will do so even if they also have an objective point.So if their route to their objective goes through the enemy they will charge the
It doesn't. They could easily go to their target point if they wanted to without a fight. Instead, they charge and get annihilated by a bunch of levy psiloi..
Which suggests that the target point isn't working.I tried that - 2nd field from the top - but this time the chariots just sit there doing nothing. Not a step towards the target point.It you want to increase their chance of ignoring light troops, you could try 8 + 2 + 128 = 138
What is the X,Y location of Target Point 1? The dialog box says they are to head to Target Point 1, but the Target Point button is current set to Target Point 0. Which suggests that maybe you set Target Point 0 and not Target Point 1. Have you in fact set Target Point 1?
If you get the target point working, then 16 + 128 = 140 for "Aggression" may possibly do what you want.
You will have to send me your squads file so I can see why they have turned into super troops. It is probably best if you send me the latest version of the whole thing.With their slings and bows alone. I don't understand it either. I took away their light spears to make them weaker and all of a sudden these **** psiloi are pretty much the fiercest fighting men in the Middle East. They're really on something now. They beat up the heavy chariots every single time. And why are the chariots ignoring their target point?What I don't understand is why they are getting destroyed by light archers in close combat - or is it by shooting?
If I recall correctly it can be used to pass data that scripts could use. Ignore it.What's the 4th field from the top in the AI dialog? I don't think Paul mentions it at all.
Richard Bodley Scott
Re: Scenario creation guide part 4 (AI Teams and Orders)
It was 0.. So problem solved, thanks.Which suggests that maybe you set Target Point 0 and not Target Point 1. Have you in fact set Target Point 1?
As for the super troops, I think I know what happened. Their light spears confiscated, the psiloi started to refuse close combat which is the right thing to do faced with heavy chariots. Their pals can now come to rescue with their rocks and sticks. 4 units of super psiloi can easily destroy a unit of 100 chariots with the most primitive weapons imaginable.
So I gave them back their spears to see what happens and, lo and behold, while they still evaded a lot, they started to accept more close combat which is not smart at all. Their buddies can no longer help them because a) they can't charge that troop type and b) no shooting because of the melee. 1 on 1 with a chariot, the psiloi will always lose.
If my theory is correct, taking away weapons can actually upgrade certain units quite a bit (providing effective skirmishing tactics are used).
I must say I rather liked my super psiloi. Tearing apart hundreds of heavy war chariots with slings and sticks is, indeed, very therapeutic. I highly recommend it!
Cheers,
Henry
Re: Scenario creation guide part 4 (AI Teams and Orders)
Is it possible to make the AI advance the infantry one tile instead of the usual two? I'm trying to model the Spartan characteristic slow advance.
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
You can do so using a scenario script but there is no way of doing it with just the Editor.
Richard Bodley Scott
Re: Scenario creation guide part 4 (AI Teams and Orders)
That is great news, thank you.
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
There is a script function:
AI_SimpleTeamAdvanceOrders(team, enemy_team, MaxAP, ignoreLights)
which tells the team to advance towards the specified enemy team, keeping move distances down to MaxAP until the enemy are within 6 squares, after which they will move at normal speed. If ignoreLights is set to 1, they will ignore enemy light troops for the purpose of calculating the distance from the enemy.
You can see an example of how to use this in \CAMPAIGNS\2RiseOfRome\SCENARIOS\Trebia_R.BSF
To keep movement down to 1 square, MaxAP should be 6. (But this will prevent diagonal movement by heavy foot in rough terrain).
AI_SimpleTeamAdvanceOrders(team, enemy_team, MaxAP, ignoreLights)
which tells the team to advance towards the specified enemy team, keeping move distances down to MaxAP until the enemy are within 6 squares, after which they will move at normal speed. If ignoreLights is set to 1, they will ignore enemy light troops for the purpose of calculating the distance from the enemy.
You can see an example of how to use this in \CAMPAIGNS\2RiseOfRome\SCENARIOS\Trebia_R.BSF
To keep movement down to 1 square, MaxAP should be 6. (But this will prevent diagonal movement by heavy foot in rough terrain).
Richard Bodley Scott
Re: Scenario creation guide part 4 (AI Teams and Orders)
Ah, I did not see this last post until now, it is very useful, thank you!rbodleyscott wrote: ↑Thu Jan 10, 2019 8:55 am There is a script function:
AI_SimpleTeamAdvanceOrders(team, enemy_team, MaxAP, ignoreLights)
which tells the team to advance towards the specified enemy team, keeping move distances down to MaxAP until the enemy are within 6 squares, after which they will move at normal speed. If ignoreLights is set to 1, they will ignore enemy light troops for the purpose of calculating the distance from the enemy.
You can see an example of how to use this in \CAMPAIGNS\2RiseOfRome\SCENARIOS\Trebia_R.BSF
To keep movement down to 1 square, MaxAP should be 6. (But this will prevent diagonal movement by heavy foot in rough terrain).
Re: Scenario creation guide part 4 (AI Teams and Orders)
I got a small problem with AI_SimpleTeamAdvanceOrders. In my scenario there's a light infantry unit in a team of heavies, and while the heavies only move one square as intended, the light infantry moves three.
Other teams, made 100% of heavies, work great.
I've added the aggression flag 2 in TeamAI ("Move at speed of slowest unit in team"), and now the light unit is moving only 2 squares per turn (but still one too many).
How can I make this unit move just one square?
This is my current code (adapted from AI_SimpleTeamAdvanceOrders) in scenario.BSF:
Change it to
SetTeamMaxAP(1, 5, 6, 0);
The last parameter tells it to exclude light troops from the AP restriction if it is set.
Other teams, made 100% of heavies, work great.
I've added the aggression flag 2 in TeamAI ("Move at speed of slowest unit in team"), and now the light unit is moving only 2 squares per turn (but still one too many).
How can I make this unit move just one square?
This is my current code (adapted from AI_SimpleTeamAdvanceOrders) in scenario.BSF:
Code: Select all
distance = AI_GetClosestDistanceToClosestEnemyUnit(1, 5, 1);
if (distance > 2)
{
MoveTeamCoord(1, 5, GetTeamX(1, 5) - 1, GetTeamY(1, 5), 146);
SetTeamMaxAP(1, 5, 6, 1);
}
SetTeamMaxAP(1, 5, 6, 0);
The last parameter tells it to exclude light troops from the AP restriction if it is set.
-
- Field of Glory 2
- Posts: 28053
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Scenario creation guide part 4 (AI Teams and Orders)
Ooops, sorry, I edited your post instead of quoting it, by mistake.
Richard Bodley Scott