Files with scripts for exporting battle to FoG2?

Moderator: Pocus

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Tue Jul 21, 2020 11:22 am

OK, so now I've managed to get the following working, replacing row 238 of BattleConnection.BSF (in BattleConn_Export function) from vanilla. Please see below.

What I'd like to do now is to export the ethnicside variable's value plus vanilla's choice of unit type (BattleConn_MapUnit(unitID, squad)) to a function of my own, and in that function setting the value of squad and returning that value to the BattleConn_Export function. Would be much neater and nicer to have all nitty gritty of which faction gets which unit type changed, and to what.

Anybody having an idea of how to export the ethnicside and BattleConn_MapUnit(unitID, squad) values to a new function and returning a squad value from that function? (Until then I can just work on doing the mechanics inside the BattleConn_MapUnit(unitID, squad) function.)

Code: Select all

			// MODDING
			randomunit = Dice(100);
			unitside = side;
			
			if (bSwapSides)
			{
				unitside = (unitside + 1) % 2;
			}

			ethnicside = Faction_Ethnic(gBattleDesc.factionID[unitside][0] );
			
			if ( ethnicside == 9 )
			{
				if (randomunit < 50)
				{
					squad = "Pike";
				}
				else
				{
					squad = "Citizen_Hoplites";
				}
			}
			else if ( ethnicside == 16 )
			{
				if (randomunit < 50)
				{
					squad = "Persian_Cav_Jav_Arm";
				}
				else
				{
					squad = "Cataphracts";
				}
				
			}
			else
			{
				squad = "Elephants";
			}			
			
			// VANILLA
			// BattleConn_MapUnit(unitID, squad);
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

pipfromslitherine
Site Admin
Site Admin
Posts: 9273
Joined: Wed Mar 23, 2005 10:35 pm

Re: Files with scripts for exporting battle to FoG2?

Post by pipfromslitherine » Tue Jul 21, 2020 6:46 pm

I'm not entirely sure what you want to do. You would need to have your own version of the BSF where you had inserted your code. If you want to put your new code into a function that is not an issue, you just define your new function in the same way as all the functions in the BSF file do already.

Cheers

Pip
follow me on Twitter here

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Tue Jul 21, 2020 7:37 pm

pipfromslitherine wrote:
Tue Jul 21, 2020 6:46 pm
I'm not entirely sure what you want to do. You would need to have your own version of the BSF where you had inserted your code. If you want to put your new code into a function that is not an issue, you just define your new function in the same way as all the functions in the BSF file do already.

Cheers

Pip
Well, it doesn't really seem to be that easy to call upon functions and get values returned from them... :(

I'd like to export the values of the following variables (ethnicside as integer, and squadtemp as string) to a new function (from BattleConn_Export function) and then return the value of the (potentially changed) squad string value to the BattleConn_Export function to be used when writing to the AgeodBattleData file.

In BattleConn_Export function:

Code: Select all

squad = Modded_UnitType(ethnicside, squadtemp);
Then I create a new function in the same file (contents are just an example):

Code: Select all

FUNCTION Modded_UnitType(ethnicside, char squad[STRING_AVG])
{	
	if ( ethnicside == 9 )
	{
		squad = "Pike";
	}
	else if ( ethnicside == 16 )
	{
		squad = "Cataphracts";
	}
	else
	{
		squad = "Elephants";
	}		
	return squad;
}
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

pipfromslitherine
Site Admin
Site Admin
Posts: 9273
Joined: Wed Mar 23, 2005 10:35 pm

Re: Files with scripts for exporting battle to FoG2?

Post by pipfromslitherine » Tue Jul 21, 2020 10:28 pm

All arrays are passed by reference, so simply create a char array in the calling function, copy in the input and use it as the param for the fn call, then in the function rewrite that array to your return value for the string. You can only return integer values as function results.

Cheers

Pip
follow me on Twitter here

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Tue Jul 21, 2020 10:53 pm

pipfromslitherine wrote:
Tue Jul 21, 2020 10:28 pm
All arrays are passed by reference, so simply create a char array in the calling function, copy in the input and use it as the param for the fn call, then in the function rewrite that array to your return value for the string. You can only return integer values as function results.

Cheers

Pip
Thanks, Pip! Good to know that I can only return integer values as function results.

How would it look script wise then? Something like this (since I can overwrite that array every time)?

Code: Select all

char squadtemp[STRING_AVG];

BattleConn_MapUnit(unitID, squad);
squadtemp = squad;
Modded_UnitType(ethnicside, squadtemp);
squad = squadtemp;

FUNCTION Modded_UnitType(ethnicside, char squadtemp[STRING_AVG])
{	
	if ( ethnicside == 9 )
	{
		squadtemp = "Pike";
	}
	else if ( ethnicside == 16 )
	{
		squadtemp = "Cataphracts";
	}
	else
	{
		squadtemp = "Elephants";
	}	
}
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Wed Jul 22, 2020 7:30 am

pipfromslitherine wrote:
Tue Jul 21, 2020 10:28 pm
All arrays are passed by reference, so simply create a char array in the calling function, copy in the input and use it as the param for the fn call, then in the function rewrite that array to your return value for the string. You can only return integer values as function results.

Cheers

Pip
kronenblatt wrote:
Tue Jul 21, 2020 10:53 pm
Thanks, Pip! Good to know that I can only return integer values as function results.

How would it look script wise then? Something like this (since I can overwrite that array every time)?

Code: Select all

char squadtemp[STRING_AVG];

BattleConn_MapUnit(unitID, squad);
squadtemp = squad;
Modded_UnitType(ethnicside, squadtemp);
squad = squadtemp;

FUNCTION Modded_UnitType(ethnicside, char squadtemp[STRING_AVG])
{	
	if ( ethnicside == 9 )
	{
		squadtemp = "Pike";
	}
	else if ( ethnicside == 16 )
	{
		squadtemp = "Cataphracts";
	}
	else
	{
		squadtemp = "Elephants";
	}	
}
Morning Pip! I got this to work actually. But BEFORE I added the squadtemp IFs parts. Then I got this error message when starting it all up:
StringConditional.jpg
StringConditional.jpg (73.09 KiB) Viewed 343 times

The script that generated the error message looks as follows. How should it look?

Code: Select all

FUNCTION Modded_UnitType(ethnicside, char squadtemp[STRING_AVG])
{	
	if ( ethnicside == 9 )
	{
		if ( squadtemp == "Arm_Citizen_Hoplites" )
		{
			squadtemp = "Pike";
		}
		if ( squadtemp == "E_Greek_LH_Jav" )
		{
			squadtemp = "Arab_Camelry";
		}
	}
	else if ( ethnicside == 16 )
	{
		if ( squadtemp == "Arab_Camelry" )
		{
			squadtemp = "Elephants";
		}
		if ( squadtemp == "Hillmen" )
		{
			squadtemp = "Pike";
		}
	}
	else
	{
		squadtemp = "Cataphracts";
	}	
}
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Wed Jul 22, 2020 10:34 am

Using the StringCompare function seemed to do the trick though, when looking (sorry, should have done that in the first place) into the BATTLESCRIPT.TXT file. :)

Makes sense?

BATTLESCRIPT.TXT says return is either 1 or 0, but the FoGE vanilla scripts apply TRUE and FALSE though... What's best practice, in your view?

Code: Select all

//  IGNORES CASE. returns 1 if the two strings are the same, otherwise 0
StringCompare(string1, string2)

Code: Select all

FUNCTION Modded_UnitType(ethnicside, char squadtemp[STRING_AVG])
{	
	if ( ethnicside == 9 )
	{
		if ( StringCompare(squadtemp, "Arm_Citizen_Hoplites") == 1 )
		{
			squadtemp = "Pike";
		}
		if ( StringCompare(squadtemp, "E_Greek_LH_Jav") == 1 )
		{
			squadtemp = "Arab_Camelry";
		}
	}
	else if ( ethnicside == 16 )
	{
		if ( StringCompare(squadtemp, "Arab_Camelry") == 1 )
		{
			squadtemp = "Elephants";
		}
		if ( StringCompare(squadtemp, "Hillmen") == 1 )
		{
			squadtemp = "Pike";
		}
	}
	else
	{
		squadtemp = "Cataphracts";
	}	
}
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

pipfromslitherine
Site Admin
Site Admin
Posts: 9273
Joined: Wed Mar 23, 2005 10:35 pm

Re: Files with scripts for exporting battle to FoG2?

Post by pipfromslitherine » Wed Jul 22, 2020 2:34 pm

You can just use implicit comparisons if you like. e.g.

if( something() )
{

}

Cheers

Pip
follow me on Twitter here

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Wed Jul 22, 2020 3:09 pm

pipfromslitherine wrote:
Wed Jul 22, 2020 2:34 pm
You can just use implicit comparisons if you like. e.g.

if( something() )
{

}

Cheers

Pip
Yep, that's what I've been doing already.
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Thu Jul 23, 2020 8:55 am

So I'm working on this FoGE mod (see above), changing the unit types to which the FoGE unit types are converted into FoG2. I'm not changing conversion factors (1->2, 2->1, etc), but I am looking at (a) making the conversion much more faction (or at least ethnic group) specific, all using the FoG2 army lists to a much larger extent, and (b) adding some type of randomness to get a (still FoG2 army list consistent) variety in armies when battling it out in FoG2 (so that sometimes a certain type of FoGE unit type gets translated into one FoG2 unit type and sometimes to another, maybe 2-3 random outcomes).

Of course, this needs to be made manually and I could use some input. Right now there seems to be a number of unit types most often applied in FoG2. Which of these would be the most urgent to work with and find alternatives to?

Warband (Close Order): 47 translations from FoGE (i.e., FoGE translates into Warband (Close Order) for 47 of its 700 units in UNITS.xls)
Warband (Loose Order): 32
Noble Cavalry: 30
Irregular Foot: 22
Light Javelin Horse: 19
Light Javelinmen: 16


I'm looking at applying the 15 different ethnicity groups of FoGE and link the most relevant and generic ones to unit types from FoG2 army lists. Which would be the ones to focus upon first?

(1. Multinational)
2. Caledonian
3. Caucasian
4. Celtic
5. Dalmatic
6. Desertic
7. Egyptian
8. Germanic
9. Hellenic
10. Hispanic
11. Indian
12. Iranian
13. Italic
14. Nomadic
15. Nubian
16. Semitic
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

kronenblatt
Major - 8.8 cm FlaK 36
Major - 8.8 cm FlaK 36
Posts: 951
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Files with scripts for exporting battle to FoG2?

Post by kronenblatt » Sat Jul 25, 2020 11:01 pm

The structure I'm aiming at is as follows:

A. Each of the fifteen distinct ethnic groups in FoGE will get a FoG2 army determined for it.
B. For each of these fifteen distinct ethnic groups and its FoG2 units that vanilla FoGE suggests (in UNITS.csv/xls), one or more FoG2 units will then be identified (each with a probability attached to it), based upon the FoG2 army list for that ethnic group. The probability for each such unit will be based on its maximum number that can be chosen in the vanilla deployment phase of FoG2 (relative to maximum number of the other possible FoG2 units).
C. Once it's time for a FoGE battle to be exported to and take place in FoG2, the armies to fight it out will be determined from A and B above, i.e., for each unit that vanilla FoGE proposes, another unit will actually be used, based on the possible alternative unit(s) and their respective probabilities. Example: vanilla FoGE suggests a Warband (Close Order) for the Germanic ethnicity group, which will be replaced by a Warband (Close Order) with 60% probability, Warband (Loose Order) with 30% probability, Superior Warband (Close Order) with 5% probability, and Superior Warband (Loose Order) with 5% probability. Or what vanilla FoGE suggests as Javelinmen will be replaced by Javelinmen, Light Archers, or Slingers (depending on whether they exist in the FoG2 army list selected to that ethnicity group).

The proposed FoG2 army lists to the FoGE ethnic groups are as follows. Alternative suggestions and ideas are welcome:

FoGE Ethnic Group FoG2 Army List
Caledonian: Caledonian 50-225 AD
Caucasian: Armenian 331 BC - 252 AD
Celtic: Gallic 300-101 BC
Dalmatic: Illyrian 680 BC - 25 AD
Desertic: Arab 312 BC - 299 AD
Egyptian: Egyptian 405-343 BC
Germanic: Germanic Foot Tribes 105 BC - 259 AD
Hellenic: Greek 280-228 BC
Hispanic: Spanish (Iberian) 300-10 BC
Indian: Indian 500 BC - 319 AD
Iranian: Achaemenid Persian 419-329 BC
Italic: Etruscan 330-280 BC
Nomadic: Saka 300 BC - 50 AD
Nubian: Kushite Egyptian 727-656 BC
Semitic: Jewish 163-111 BC
Arranging the The Year of Many Emperors (TYME), Dividing the Spoils (DiSp), and The West is No More (TWiNM) tournaments for Field of Glory II!

Post Reply

Return to “MOD”