Withdrawal + Reinforcement
Withdrawal + Reinforcement
I'd like to have a battle in two 'episodes' :
1) Hoplites and LF are caught up and attacked by the Persian cavalry vangard
2) As soon as the slower Persian Infantry enter the battlefield in front of the Hoplites (using the Scripted Method of reinforcements), the enemy cavalry vangard withdraw (by the sides), definitely leaving the map (the rationale being, they need to rest their mounts and refill their arsenal, waiting for the outcome of the Infantry battle to either protect their friendly routing army or pursue enemy routers ; this is a final phase not played, only shown on the result panel at the end of the game)
Making reinforcements seem simple. My question is about the withdrawal part : How to make units leave the battlefied at the time of the reinforcement ?
It can also be seen as a kind of a mini Campaign, made of 2 successive 'battles' (first a skirmish against Cav, then an Infantry battle) where the Greek losses of the first battle are used in the second one.
Can it be achieved ?
1) Hoplites and LF are caught up and attacked by the Persian cavalry vangard
2) As soon as the slower Persian Infantry enter the battlefield in front of the Hoplites (using the Scripted Method of reinforcements), the enemy cavalry vangard withdraw (by the sides), definitely leaving the map (the rationale being, they need to rest their mounts and refill their arsenal, waiting for the outcome of the Infantry battle to either protect their friendly routing army or pursue enemy routers ; this is a final phase not played, only shown on the result panel at the end of the game)
Making reinforcements seem simple. My question is about the withdrawal part : How to make units leave the battlefied at the time of the reinforcement ?
It can also be seen as a kind of a mini Campaign, made of 2 successive 'battles' (first a skirmish against Cav, then an Infantry battle) where the Greek losses of the first battle are used in the second one.
Can it be achieved ?
Re: Withdrawal + Reinforcement
I might have found an easy (ie script-free) solution. I made a module for this battle with 2 battles :
1) first, the skirmish against the Persian Cav, Chariots and LH with a limited number of turns (4 or 6)
2) second, the infantry battle against the Persian Infantry alone. All the Greek units are Unfixed and ‘Force Points Callback’ allow to buy up to almost all the units. To keep it simple, the player uses the total % of losses from the panel of the first battle and applies it to all his unit types for the second one during the deployment to calculate and select how many units he’ll be able to command during the second battle.
A couple of texts will explain the arrival and withdrawal of the Persian cavalry, the arrival of the Persian Infantry, how to calculate the number of units for the 2nd battle, the link between both ‘battles’, etc.
Here Fixed/Unfixed is not used for difficulty levels, but to simulate losses. I don’t know whether both can be mixed.
Hope I’m clear enough.
Need to test it, especially the fun of an initial skirmish between Hoplites and Persian Cav/Chariots.
1) first, the skirmish against the Persian Cav, Chariots and LH with a limited number of turns (4 or 6)
2) second, the infantry battle against the Persian Infantry alone. All the Greek units are Unfixed and ‘Force Points Callback’ allow to buy up to almost all the units. To keep it simple, the player uses the total % of losses from the panel of the first battle and applies it to all his unit types for the second one during the deployment to calculate and select how many units he’ll be able to command during the second battle.
A couple of texts will explain the arrival and withdrawal of the Persian cavalry, the arrival of the Persian Infantry, how to calculate the number of units for the 2nd battle, the link between both ‘battles’, etc.
Here Fixed/Unfixed is not used for difficulty levels, but to simulate losses. I don’t know whether both can be mixed.
Hope I’m clear enough.
Need to test it, especially the fun of an initial skirmish between Hoplites and Persian Cav/Chariots.
-
rbodleyscott
- Field of Glory 2

- Posts: 28385
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Withdrawal + Reinforcement
FOG2 Medieval has a script called SpecialScenarioTools.BSF in which there is a function
It is not unlikely that this could work in FOG2 Ancients if you put it in the scenario script.
But there is the issue of the rout % calculation.
Code: Select all
// Make team leave battlefield. Note that it will still count for the original strength for rout % purposes.
// This is because deleting the units would mess up references to other units in close combat arrays.
FUNCTION RemoveTeam(side, team)
{
int i;
int total;
int id;
total = GetUnitCount(side);
for (i = 0; i < total; i++)
{
id = GetUnitID(side, i);
if (id != -1)
{
if (GetUnitTeam(id) == team)
{
// v1.7.2 addition
if (IsInCloseCombat(id) == 1)
{
RemoveAllCloseCombats(id);
}
// End v1.7.2 addition
RemoveUnit(id, 1);
}
}
}
SetCurrentSelectedUnit(-1);
}But there is the issue of the rout % calculation.
Richard Bodley Scott


Re: Withdrawal + Reinforcement
Thank you very much, Richard !
I succeeded in turning the Persian Infantry into Reinforcements with Artaphernes as their C-in-C.
But I haven't figured out yet how to use the FUNCTION RemoveTeam.
I succeeded in turning the Persian Infantry into Reinforcements with Artaphernes as their C-in-C.
But I haven't figured out yet how to use the FUNCTION RemoveTeam.
Re: Withdrawal + Reinforcement
I get it.
1) I added RemoveTeam at the end of the fragment about the Reinforcement in my scenario script :
FUNCTION StartTurn(side)
{
int id
(...)
if (GetTurn() == 3) // For testing.
{
id = PlaceUnit(36, 42, 4, 1, 6, "EASTERN_HILLMEN")
AddVizCam(GetUnitX(id), GetUnitY(id), 0)
AddVizFunctionCall("GetHeadImage", 1, "BP0Image:", 13)
ShowUIScreenToSide("BattlePop0", "Anim1", "IDS_AUTO_REINF_0", GetWorkString(13), 0)
(...)
RemoveTeam(1,4);
RemoveTeam(1,5);
2) I added the FUNCTION RemoveTeam(side, team) above at the end of the scenario script.
The mecanism/result is really nice.
1) I added RemoveTeam at the end of the fragment about the Reinforcement in my scenario script :
FUNCTION StartTurn(side)
{
int id
(...)
if (GetTurn() == 3) // For testing.
{
id = PlaceUnit(36, 42, 4, 1, 6, "EASTERN_HILLMEN")
AddVizCam(GetUnitX(id), GetUnitY(id), 0)
AddVizFunctionCall("GetHeadImage", 1, "BP0Image:", 13)
ShowUIScreenToSide("BattlePop0", "Anim1", "IDS_AUTO_REINF_0", GetWorkString(13), 0)
(...)
RemoveTeam(1,4);
RemoveTeam(1,5);
2) I added the FUNCTION RemoveTeam(side, team) above at the end of the scenario script.
The mecanism/result is really nice.
-
rbodleyscott
- Field of Glory 2

- Posts: 28385
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Withdrawal + Reinforcement
I wrote this fragment of script for my scenario script (here is only the upper part of the FUNCTION) :
The goal is to make the reinforcement imperatively happens between turn 4 and 7.
I tried it. It seems to work. However I don't know a thing about coding.
My only question : does it look logical at first sight ?
Code: Select all
FUNCTION StartTurn(side)
{
int turn;
int i;
int id
if (GetTurn() == -1)
{
SetUniversalVar("Deploym", 0);
}
if(((GetTurn() >= 7) && (Rand(1,100) <= 20) && (GetTurn() <= 11) && (GetUniversalVar("Deploym") == 0)) || (turn == 13 && (GetUniversalVar("Deploym") == 0)))
{
SetUniversalVar("Deploym", 1);
id = PlaceUnit(43, 39, 5, 1, 0, "LIGHT_JAVELINS")
I tried it. It seems to work. However I don't know a thing about coding.
My only question : does it look logical at first sight ?
-
rbodleyscott
- Field of Glory 2

- Posts: 28385
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Withdrawal + Reinforcement
Looks good at a quick glance through. If it does not work as you want, ask again.Athos1660 wrote: ↑Sat Feb 21, 2026 4:18 pm I wrote this fragment of script for my scenario script (here is only the upper part of the FUNCTION) :
The goal is to make the reinforcement imperatively happens between turn 4 and 7.Code: Select all
FUNCTION StartTurn(side) { int turn; int i; int id if (GetTurn() == -1) { SetUniversalVar("Deploym", 0); } if(((GetTurn() >= 7) && (Rand(1,100) <= 20) && (GetTurn() <= 11) && (GetUniversalVar("Deploym") == 0)) || (turn == 13 && (GetUniversalVar("Deploym") == 0))) { SetUniversalVar("Deploym", 1); id = PlaceUnit(43, 39, 5, 1, 0, "LIGHT_JAVELINS")
I tried it. It seems to work. However I don't know a thing about coding.
My only question : does it look logical at first sight ?
Richard Bodley Scott


Re: Withdrawal + Reinforcement
Thank you so much for taking the time to look at it and reply !
I keep on testing to see if unwanted results come up.
.
To fix it, I guess I could either try to add a few units of Persian Irregular Foot to the Persian infantry or reduce the cav army, but actually :
- the infantry units are already quite numerous and the overall fight is already long with the cav 'pre-battle',
- I'd rather add a few cav units to the cav battle to made it harder...
However, the rout % calculation is no big deal to me. I like the battle as it is. Some other players could too.
I'll look at what I can do for that. Anyway, the number and types of units still need to be tweaked to adjust the difficulty.
(edit)
For now, at level 3, we have :
1) During the first part of the battle (cav attack) : 8400 Greeks vs 4110 Persians
2) During the second part (infantry clash) : the same 8400 Greeks vs 9840 Persian Infantrymen,
and at the end of the battle, we have 8400 Greeks vs 4110 + 9840 = 13950 Persians :

As the Persian cavalry are not meant to massively die and rout against Hoplites (and a few LF), most of the rout % is made by the Greeks during the second part of the battle, the Infantry clash, ie against the 9840 Persian Foot, 1200 of which being LF.
I guess an 'honest' rout% would be that calculated with the numbers :
8400 (number of Greeks from the start)
9840 (number of Persians of the second part of the Battle, ie. number of reinforcement troops).
Again no big deal.
I keep on testing to see if unwanted results come up.
Once the Persian cavalry has left, the Greeks have to rout 100% of the Persian non-light infantry to get a 53% winrbodleyscott wrote: But there is the issue of the rout % calculation.
To fix it, I guess I could either try to add a few units of Persian Irregular Foot to the Persian infantry or reduce the cav army, but actually :
- the infantry units are already quite numerous and the overall fight is already long with the cav 'pre-battle',
- I'd rather add a few cav units to the cav battle to made it harder...
However, the rout % calculation is no big deal to me. I like the battle as it is. Some other players could too.
I'll look at what I can do for that. Anyway, the number and types of units still need to be tweaked to adjust the difficulty.
(edit)
For now, at level 3, we have :
1) During the first part of the battle (cav attack) : 8400 Greeks vs 4110 Persians
2) During the second part (infantry clash) : the same 8400 Greeks vs 9840 Persian Infantrymen,
and at the end of the battle, we have 8400 Greeks vs 4110 + 9840 = 13950 Persians :

As the Persian cavalry are not meant to massively die and rout against Hoplites (and a few LF), most of the rout % is made by the Greeks during the second part of the battle, the Infantry clash, ie against the 9840 Persian Foot, 1200 of which being LF.
I guess an 'honest' rout% would be that calculated with the numbers :
8400 (number of Greeks from the start)
9840 (number of Persians of the second part of the Battle, ie. number of reinforcement troops).
Again no big deal.
Re: Withdrawal + Reinforcement
I modified the bit of script (shown above) aboout the reinforcement/withdrawal of the AI army, forcing it to occur only on human player’s turn, as new bugs happened today such as the reinforcement message ou the reinforcement not showing up at all. It seems to work better :
Given the ‘issue’ of rout %, this scenario most likely won’t make it to the in-game community scenarios.
So here is a link to download & play it :
https://drive.google.com/drive/folders/ ... sp=sharing
Place EPHESUS_498BC in your Documents\My Games\FieldOfGlory2\Campaigns\
Enjoy!
Localisations : English, French
Any suggestion is welcomed.
Many thanks to Richard and Paul59.
Code: Select all
if(((GetTurn() == 6) && (Rand(1,100) <= 20)) || ((GetTurn() == 8) && (Rand(1,100) <= 20) && (GetUniversalVar("Deploym") == 0)) || ((GetTurn() == 10) && (Rand(1,100) <= 20) && (GetUniversalVar("Deploym") == 0)) || (GetTurn() == 12 && (GetUniversalVar("Deploym") == 0)))So here is a link to download & play it :
https://drive.google.com/drive/folders/ ... sp=sharing
Place EPHESUS_498BC in your Documents\My Games\FieldOfGlory2\Campaigns\
Enjoy!
Localisations : English, French
Any suggestion is welcomed.
Many thanks to Richard and Paul59.
