Scenario creation guide part 13 (Reversing a scenario)

Post Reply
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Scenario creation guide part 13 (Reversing a scenario)

Post by Paul59 »

Now that you have created a scenario, you can only play one side. However, many players like to have the option to play with either of the opposing armies in a battle. I will now show you how you can “reverse” a scenario, so that the player can fight with the original AI side.

First, open up your My Documents/My Games/FieldOfGlory2/CAMPAIGNS/YOUR SCENARIO NAME/ SCENARIOS folder. You will see one or two files: a .BAM file and (if you created one) a .BSF file.
Create a copy of both these two files into the same folder.

In my example, I have created a copy of the Kynoskephalai files:

Image

The originals are named Kynoskephalai_M, the “M” denotes that the scenario is playable as the Macedonians.

Then rename the copied files to something else, it does not matter what, just so long as it is different to the originals and is something that you will help you remember what side is playable. The Slitherine convention is to have a letter on the end of the battle name to indicate the side, so in my example I am going to call them Kynoskephalai_R, where “R” denotes Romans.

Now open the new .BAM file in a text editor (NOT a word processor). You can download "Notepad++" for free.

Near the top of the file you will see these two lines:

SIDEID0
SIDEID1

The number at the end of each line is the side number of the army. So as we are reversing this scenario we need to swap these around. In my example the lines for Kynoskephalai_M are:

SIDEID0 22
SIDEID1 32

Where 22 is the Macedonian side number, and 32 is the Romans. So for Kynoskephalai_R we have to change these to read:

SIDEID0 32
SIDEID1 22

Next we need to use the text editor’s Replace function to change all the Side0 units to Side1, and vice versa. For Notepad++ click on the binoculars icon in the Toolbar:

Image

Then click on the Replace tab:

Image

Enter _0_ in the “Find” space and _2_ in the “Replace with” space, just like I have put in the screenshot above.

Now SLOWLY repeatedly press on the “Find Next” button, until you get to the first line that says UNITTS_0_.

Then click on “Replace All”.

The reason that I recommend doing it this way, rather than just pressing “Replace All” at the start of the file, is that there is a strange chunk of code near the top of the file that starts like this:

[TEAM]
A0_0 0
D0_2_0 -1
D0_2_1 0
D0_2_2 0
D0_2_3 0
A0_1 0
D0_1_0 -1
D0_1_1 0
D0_1_2 0
D0_1_3 0

Not even RBS knows what this is for, and rather than mess things up, I think it is best to bypass it and only change the Units information. I have reversed many scenarios this way, and they all work fine.

Next enter _1_ in the “Find” space and _0_ in the “Replace with” space.

SLOWLY repeatedly press on the “Find Next” button, until you get to the first line that says UNITTS_1_.

Then click on “Replace All”.

Next we enter _2_ in the “Find” space and _1_ in the “Replace with” space.

SLOWLY repeatedly press on the “Find Next” button, until you get to the first line that says UNITTS_2_.

Then click on “Replace All”.

Next, search for the line that says UNITCOUNT_0 and change it to read to UNITCOUNT_1, and search for the line that says UNITCOUNT_1 and change it to read to UNITCOUNT_0.

Finally, highlight ALL the side0 unit information, from the UNITCOUNT_0 line to the very last UNITATTRV7 line, then cut and paste it before the UNITCOUNT_1 line. It will be a big chunk of data, probably a few hundred lines, but just click and drag to select the whole section, it should be easy. This will ensure that all the custom unit names and General info will now be allocated to the correct units.

You have now swapped the units and sides over, so close the .BAM file and save it.

If you have a .BSF file for the reversed scenario, you will have to open it up and make some changes.

a) If you have used the .BSF file for scripted AI orders, these will have to be deleted because they were written for the original AI side, but now you have changed the sides around. If you want you could add scripted orders for the new AI side, or use the Editor’s AI order button to create new orders.

b) If you have used the ReSkinArmy lines in the original scenario, and by that I mean you have taken out the comment marks to activate the function, you will need to change them to look exactly like this:

ReSkinArmy(0, 1);
ReSkinArmy(1, 1);

This reverses the process for allocating texture folders, so that the armies look the same as in the original scenario.

If in the original scenario you left the comment marks in front of the ReSkinArmy lines and made your own manual texture selections, just leave the ReSkinArmy lines as they are.

c) If you have added custom points allocations in the FORCE_POINTS_CALLBACK function, these will need to be recalculated.

d) If you have scripted reinforcements, you will have to swap over the side that they belong to. In Scenario creation guide part 9, I explained about the script that gives the information on each reinforcement unit:

id = PlaceUnit(32, 16, 0, 0, 0, "LIGHT_JAVELINS")

The first number in the brackets is the X coordinate of the entry square.
The second number is the Y coordinate of the entry square.
The third number is the direction that the unit is facing.
The fourth number is the army that the unit belongs to, this is side 0 for the player side, or side 1 for the AI side (or other player in an MP scenario).
The fifth number is AI team number that you have assigned to the unit in the editor.
The name in quotation marks is the name of the unit from the Squads.csv file.

If you are reversing the scenario, then the fourth number will have to be changed from 0 to 1 (or 1 to 0 of course!).

Basically if you put anything in the original .BSF, you will need to rethink whether it will need changing for the reversed scenario, because you have now swapped the sides over and the original function might not apply.

Now you need to open the Text9.txt file. Copy all the text paragraphs that refer to the original scenario, and paste them in at the bottom of the Text9.txt file. Then change the heading of each paragraph to the new scenario name. Using Kynoskephalai as an example, the completed file looks like this:

Image

Notice that the Kynoskephalai_M paragraphs have been copied and added at the bottom, and the headings have been changed to read Kynoskephalai_R. You might want to change some of the wording for the reversed scenario, if appropriate.

If you have used Custom Unit names and Generals in your scenario, I am afraid that they will all now be allocated to the wrong units on the map. The only way that I know how to fix this, is to open the Editor and manually delete every name and general from the map, and then reassign them. It sounds awful, but does not actually take that long. It depends on how many names you have allocated of course!

Finally, open the Campaign.txt file, see Scenario Creation Guide Part 11, and enter a new chunk of info for the new scenario. For Kynoskephalai it will look like this:

NOSKIRMISH
TYPE 0

[Kynoskephalai_M]
SIDE0 22
SIDE1 32
DATE 2803
MAPX 620
MAPY 508

[Kynoskephalai_R]
SIDE0 32
SIDE1 22
DATE 2803
MAPX 620
MAPY 508
REVERSEOF Kynoskephalai_M

You will notice that the two chunks are identical apart from the Side ids have been reversed, and I have added the line REVERSEOF Kynoskephalai_M. This line tells the game to group the two scenarios together on the same scenario selection page so that it looks like this:

Image

Notice that there are now two buttons at the bottom of the screen, one for the Macedonians and one for the Romans.

So that's it, job done!
Last edited by Paul59 on Sat Feb 24, 2018 4:31 pm, edited 3 times in total.
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.
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Re: Scenario creation guide part 13 (Reversing a scenario)

Post by Paul59 »

I've just amended the section in the first post about the ReSkinArmy lines, I had realised that in some situations you do not need to touch them.
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.
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Re: Scenario creation guide part 13 (Reversing a scenario)

Post by Paul59 »

Eureka! I have just worked out a way to easily retain the Custom Unit names and Generals when you reverse a scenario.

In the .BAM file, after each unit data chunk, there are 8 lines of unit attribute info, they look like this:

UNITATTRV0 22
UNITATTRV1 5
UNITATTRV2 0
UNITATTRV3 0
UNITATTRV4 0
UNITATTRV5 0
UNITATTRV6 0
UNITATTRV7 0

The first line gives the Custom Unit name, as recorded in the Text9.txt file, The second line gives the Custom General number, again as recorded in the Text9.txt file. I don’t know what the other lines are for, probably they are not used in the game at the moment.

When you swap the units to the different sides using your text editor’s Replace function, you end up with the Side1 units listed before the Side0 units. Then, when you load the scenario in the Editor, the game sorts the BAM file, so that Side0 is in front of Side1, but it does not move the unit attribute lines! They stay in place and end up allocated to units from the other side!

So to solve this problem all you have to do is this:

After you have finished using the Replace function and swapped the unit sides over, cut ALL the side0 unit information, from the UNITCOUNT_0 line to the very last UNITATTRV7 line, and paste it before the start of the Side1 unit info. It will be a big chunk of data, probably a few hundred lines, but just click and drag to select the whole section, it should be easy.

All the custom unit names and General info will now be allocated to the correct unit, and you have saved yourself 30 minutes of tedious work in the editor!

I'm going to be busy for the next few hours, but hopefully I can edit the guide before the end of the day.
Last edited by Paul59 on Mon Apr 09, 2018 7:20 pm, edited 1 time in total.
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.
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Re: Scenario creation guide part 13 (Reversing a scenario)

Post by Paul59 »

I was a lot busier than expected! But I have updated the first post now.
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.
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Re: Scenario creation guide part 13 (Reversing a scenario)

Post by Paul59 »

If you have scripted reinforcements in the scenario .BSF file, then you will have to change the side to which these belong.

In Scenario creation guide part 9, I explained about the script that gives the information on each reinforcement unit:

id = PlaceUnit(32, 16, 0, 0, 0, "LIGHT_JAVELINS")

The first number in the brackets is the X coordinate of the entry square.
The second number is the Y coordinate of the entry square.
The third number is the direction that the unit is facing.
The fourth number is the army that the unit belongs to, this is side 0 for the player side, or side 1 for the AI side (or other player in an MP scenario).
The fifth number is AI team number that you have assigned to the unit in the editor.
The name in quotation marks is the name of the unit from the Squads.csv file.

If you are reversing the scenario, then the fourth number will have to be changed from 0 to 1 (or 1 to 0 of course!).

I will update the first post with this info.
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.
Post Reply

Return to “Field of Glory II: Scenario Design”