Quick Questions Thread on Modding

kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Quick Questions Thread on Modding

Post by kronenblatt »

This thread aims at presenting the opportunity to ask simple questions on modding that can be answered with a "yes", "no" or a couple of sentences (not "don't know") and thus to act as a hub that modders can turn to.

Please always answer with quote in order for it to be evident which question the answer refers to.
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

20200621_142403.jpg
20200621_142403.jpg (179.35 KiB) Viewed 4499 times
In which file is the rallying of routed units scripted, and where is the part setting out the chance of a routed unit (without a general) making a cohesion test in order to rally?
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

kronenblatt wrote: Sun Jun 21, 2020 12:09 pm
In which file is the rallying of routed units scripted, and where is the part setting out the chance of a routed unit (without a general) making a cohesion test in order to rally?
In the StartTurnMoraleUpdate() function in /Data/Battle/Scripts/StartTurn.BSF

Code: Select all

	// Possibly recover morale state if not Steady and Morale State did not drop last turn. Currently is spontaneous and unrelated to generals.
	morale_state = GetAttrib(me, "MoraleState");

	if (GetAttrib(me, "TotalMen") > StartingStrength(me) / 2) // If unit is at more than 50% original strength.
		{
			if ((morale_state > 0)  && (morale_state < 4) && (IsAutobroken(me) == 0) && (GetAttrib(me, "PreviousMoraleState") >= GetAttrib(me, "MoraleState")) && (IsValidTile(GetUnitX(me), GetUnitY(me)) == 1))
				{
					if (morale_state == 3)
						{
							if ((IsBeingPursued(me) == -1) && (lastTurnShootingDamage <= (FIRST_CT_THRESHOLD) * 2)) // Twice first CT threshold because because it is the sum of 2 shots. May possibly want to add an enemy proximity test
								{
									chanceOfTestingForBolster = 20;
								}
							else
								{
									chanceOfTestingForBolster = 0;
								}
						}
					else
						{
							chanceOfTestingForBolster = 40; // Conceivably we might want non-routing troops to bolster outside the playable area - but for now they don't
						}

					// If any chance of testing, unit with general will always test
					if (chanceOfTestingForBolster > 0)
						{
							if (GetAttrib(me, "General") > -1)
								{
									chanceOfTestingForBolster = 100;
								}
						}

					if (Rand(1,100) <= chanceOfTestingForBolster)
						{
							CohesionTest(me, -1, 4, 0, 0, GetCurrentSide(), 4);
							AddVizFunctionCall("UpdateDisplayMoraleState", me, GetAttrib(me, "MoraleState"));
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

rbodleyscott wrote: Mon Jun 22, 2020 6:38 am
kronenblatt wrote: Sun Jun 21, 2020 12:09 pm
In which file is the rallying of routed units scripted, and where is the part setting out the chance of a routed unit (without a general) making a cohesion test in order to rally?
In the StartTurnMoraleUpdate() function in /Data/Battle/Scripts/StartTurn.BSF

Code: Select all

	// Possibly recover morale state if not Steady and Morale State did not drop last turn. Currently is spontaneous and unrelated to generals.
	morale_state = GetAttrib(me, "MoraleState");

	if (GetAttrib(me, "TotalMen") > StartingStrength(me) / 2) // If unit is at more than 50% original strength.
		{
			if ((morale_state > 0)  && (morale_state < 4) && (IsAutobroken(me) == 0) && (GetAttrib(me, "PreviousMoraleState") >= GetAttrib(me, "MoraleState")) && (IsValidTile(GetUnitX(me), GetUnitY(me)) == 1))
				{
					if (morale_state == 3)
						{
							if ((IsBeingPursued(me) == -1) && (lastTurnShootingDamage <= (FIRST_CT_THRESHOLD) * 2)) // Twice first CT threshold because because it is the sum of 2 shots. May possibly want to add an enemy proximity test
								{
									chanceOfTestingForBolster = 20;
								}
							else
								{
									chanceOfTestingForBolster = 0;
								}
						}
					else
						{
							chanceOfTestingForBolster = 40; // Conceivably we might want non-routing troops to bolster outside the playable area - but for now they don't
						}

					// If any chance of testing, unit with general will always test
					if (chanceOfTestingForBolster > 0)
						{
							if (GetAttrib(me, "General") > -1)
								{
									chanceOfTestingForBolster = 100;
								}
						}

					if (Rand(1,100) <= chanceOfTestingForBolster)
						{
							CohesionTest(me, -1, 4, 0, 0, GetCurrentSide(), 4);
							AddVizFunctionCall("UpdateDisplayMoraleState", me, GetAttrib(me, "MoraleState"));
OK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

kronenblatt wrote: Tue Jun 23, 2020 12:03 pmOK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
Yes
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

rbodleyscott wrote: Tue Jun 23, 2020 12:12 pm
kronenblatt wrote: Tue Jun 23, 2020 12:03 pmOK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
Yes
Thanks! And autobroken units never rally either, even if above 50% of starting strength?
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

kronenblatt wrote: Tue Jun 23, 2020 12:25 pm
rbodleyscott wrote: Tue Jun 23, 2020 12:12 pm
kronenblatt wrote: Tue Jun 23, 2020 12:03 pmOK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
Yes
Thanks! And autobroken units never rally either, even if above 50% of starting strength?
Correct
Richard Bodley Scott

Image
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Quick Questions Thread on Modding

Post by Athos1660 »

Following the format of this Quick questions Thread :
In which file is Pursuing scripted, and where is the part setting out which unit types of close combat opponents will sometimes pursue (mounted troops, warbands, raw foot, etc.) and their %age chance of doing so ?
Thx in advance.
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

Athos1660 wrote: Sat Jun 27, 2020 11:07 am Following the format of this Quick questions Thread :
In which file is Pursuing scripted
Mostly in AITools.BSF. Some in CombatTools.bsf
and where is the part setting out which unit types of close combat opponents will sometimes pursue (mounted troops, warbands, raw foot, etc.) and their %age chance of doing so ?
Thx in advance.
WillUnitPursue() function in CombatTools.bsf

Code: Select all

// Returns 1 if unit will Pursue, otherwise 0
// Type 0 = initial pursuit. Type 1 = follow on pursuit. Type 2 = Pursuit off playable area.
// Assumes that units are still in adjacent squares prior to any pursuit
// All chances tweakable
FUNCTION WillUnitPursue(me, enemy, type)
{
	int ret;
	int stopChance;
	int obstacle;

	ret = 1;

	if (type == 0)
		{
			if (IsFoot(me) == 1)
				{
					// Foot normally don't pursue mounted
					if (IsMounted(enemy) == 1)
						{
							stopChance = 90; // May need tweaking
						}
					else
						{
							if ((IsLightTroops(me) == 0) && (IsLightTroops(enemy) == 1))
								{
									stopChance = 90; // May need tweaking
								}
							else
								{
									// Lower chance of pursuing if unit did not initiate the combat.
									if (GetAttrib(me,"Attacking") == 1)
										{
											stopChance = 0; // May need tweaking.
										}
									else
										{
											stopChance = 75; // May need tweaking
										}
								}
						}

					// Infantry who are neither warbands nor raw will not pursue
					if ((GetAttrib(me, "Impact_Foot") < 20) || ((IsUnitSquadType(me, "Warriors") == 0) && (IsUnitSquadType(me, "Undrilled_Heavy_Foot") == 0)))
						{
							if (GetBaseAttrib(me, "Experience") > 60) // UI reports Raw up to and including 60.
								{
									stopChance = 100;
								}
							else
								{
									stopChance = Max(stopChance, 75);
								}
						}

					// Foot usually don't pursue across an obstacle they are defending, and are even less likely to if the enemy are mounted or lights
					if (GetAttrib(me, "Attacking") == 0)
						{
							obstacle = IsTileEdgeDefendibleObstacle(GetUnitX(me), GetUnitY(me), GetUnitX(enemy), GetUnitY(enemy));
							if (obstacle > -1)
								{
									if ((IsMounted(enemy) == 1) || (GetTerrainCoverValue(GetUnitX(me), GetUnitY(me), 3) == 3)) // never pursue if enemy is mounted, or if defending heavy fortifications.
										{
											stopChance = 100;
										}
									else
										{
											if (IsLightTroops(enemy) == 1)
												{
													stopChance = Max(stopChance, 95); // May need tweaking
												}
											else
												{
													stopChance = Max(stopChance, 85); // May need tweaking
												}
										}
								}
						}
				}

			// Troops in square do not pursue
			if (GetAttrib(me, "InSquare") == 1)
				{
					stopChance = 100;
				}

			// Battle wagons and artillery do not pursue
//      if ((IsUnitSquadType(me, "Battle_Wagons") == 1) || (IsArtillery(me) == 1))
//			if (IsArtillery(me) == 1)
      if ((IsUnitSquadType(me, "Battle_Wagons") == 1) || (IsArtillery(me) == 1)) // v1.3.0	
				{
					stopChance = 100;
				}
		}

	if (type > 0)
		{
			stopChance = 50; // May need tweaking

			// Foot won't continue to pursue mounted and will rarely continue to pursue at all
			if (IsFoot(me) == 1)
				{
					if (IsMounted(enemy) == 1)
						{
							stopChance = 100; // May need tweaking
						}
					else
						{
							stopChance = 75; // May need tweaking
						}
				}

			//  Knights tend to keep pursuing
      if (IsUnitSquadType(me, "Knights") == 1)
        {
          stopChance = 25; // May need tweaking
        }
		}

	if (Rand(1,100) <= stopChance)
		{
			ret = 0;
		}

	Log("Unit, chance of stopping pursuit, will pursue?", me, stopChance, ret);

	if (ret == 1)
		{
			if (type == 0) // Initial pursuit
				{
					if ((IsFoot(me) == 1) && (GetBaseAttrib(me, "Experience") <= 60)) // Raw foot
						{
							PrintStringLiteralX(1, 0, "\n");
							PrintStringX(1,0, "IDS_INEXPERIENCED_PURSUE1");
							PrintStringLiteralX(1,0, " ");
							PrintUnitPossession(1, 0, me, 2);
							PrintStringLiteralX(1,0, " ");
							PrintStringX(1,0, "IDS_INEXPERIENCED_PURSUE2");
							PrintStringLiteralX(1,0, ".");

							PrintStringLiteralX(2, 0, "\n");
							PrintStringX(2,0, "IDS_INEXPERIENCED_PURSUE1");
							PrintStringLiteralX(2,0, " ");
							PrintUnitPossession(2, 0, me, 2);
							PrintStringLiteralX(2,0, " ");
							PrintStringX(2,0, "IDS_INEXPERIENCED_PURSUE2");
							PrintStringLiteralX(2,0, ".");
						}
				}
		}

	return ret;
}
Richard Bodley Scott

Image
Athos1660
Major-General - Elite Tiger I
Major-General - Elite Tiger I
Posts: 2678
Joined: Wed May 29, 2019 3:23 pm

Re: Quick Questions Thread on Modding

Post by Athos1660 »

Thank you very much. Will be very useful :-)
Woollymammoth
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 2
Joined: Thu Nov 03, 2016 11:37 am

Re: Quick Questions Thread on Modding

Post by Woollymammoth »

What is "GetFragmentedBaseAP" variable and what can I set this to as default?

I tried googling it, but nothing came up.

Working on fixing the Napeleon mod.

Sorry, if I'm missing the obvious: where can I find a list of variables/functions available for modding?
I looked at the modding guide and stuff, but couldn't find it? I might be overlooking something though

Edit: ok can search through (some) game files I noticed and found the variable. Some games are completed locked in code, so that may make it easier

Still not sure how to use it, but I may be able to figure that out, any help to get started would be nice. Like what programming language is being used?
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

Woollymammoth wrote: Fri Oct 09, 2020 8:31 pm What is "GetFragmentedBaseAP" variable and what can I set this to as default?
It is a function not a variable. GetFragmentedBaseAP() in \Data\scripts\Tools.BSF

If the mod is crashing with a script error that mentions a missing GetFragmentedBaseAP variable, that is because the mod used an older version of the Tools.BSF script which did not have the GetFragmentedBaseAP() function. Copying the GetFragmentedBaseAP() function from the vanilla Tools.BSF function into the modded version should fix that particular error.
Sorry, if I'm missing the obvious: where can I find a list of variables/functions available for modding?
There is no such list, because everything in the scripts (and squads files) is available for modding.

http://archonwiki.slitherine.com/index.php/Modding

The game is more logic driven than data driven, because we wanted to bring out the nuances of the different troop types, which is difficult to do just by changing numbers.

Hence if you want to mod substantial changes to the game, you need to mod scripts and not just data.

The scripted functions are all moddable. The engine functions are not moddable, but can of course be used in modded scripts - you will find a list of them in /Documents/My Games/FieldOfGlory2/Autodocs/Battlescript.txt
Like what programming language is being used?
CScript
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

I think I recall (from somewhere else, maybe I’ve even asked before) that it’s hardcoded, but asking anyway:

Can LoS distance (currently fixed at 20) be modded, and if yes, where and how?
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

kronenblatt wrote: Sat Jul 09, 2022 9:48 am I think I recall (from somewhere else, maybe I’ve even asked before) that it’s hardcoded, but asking anyway:

Can LoS distance (currently fixed at 20) be modded, and if yes, where and how?
As far as I can recall it is only "fixed" in the sense that all units have 200 LOS in the squads file, which equates to 20 squares LOS.

You should therefore be able to mod it by modding the LOS column in the squads file. (For epic battles it may be better to do it in the scenario script by modding each unit's LOS attrib).
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

rbodleyscott wrote: Sat Jul 09, 2022 9:52 am
kronenblatt wrote: Sat Jul 09, 2022 9:48 am I think I recall (from somewhere else, maybe I’ve even asked before) that it’s hardcoded, but asking anyway:

Can LoS distance (currently fixed at 20) be modded, and if yes, where and how?
As far as I can recall it is only "fixed" in the sense that all units have 200 LOS in the squads file, which equates to 20 squares LOS.

You should therefore be able to mod it by modding the LOS column in the squads file. (For epic battles it may be better to do it in the scenario script by modding each unit's LOS attrib).
Super: thanks!

And basically then only append the base game’s Squads file to the mod, with only change being that column?

In which folder of the mod then to put the Squads file? (I’ve never modded that file before.)
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28297
Joined: Sun Dec 04, 2005 6:25 pm

Re: Quick Questions Thread on Modding

Post by rbodleyscott »

kronenblatt wrote: Sat Jul 09, 2022 10:17 am
rbodleyscott wrote: Sat Jul 09, 2022 9:52 am
kronenblatt wrote: Sat Jul 09, 2022 9:48 am I think I recall (from somewhere else, maybe I’ve even asked before) that it’s hardcoded, but asking anyway:

Can LoS distance (currently fixed at 20) be modded, and if yes, where and how?
As far as I can recall it is only "fixed" in the sense that all units have 200 LOS in the squads file, which equates to 20 squares LOS.

You should therefore be able to mod it by modding the LOS column in the squads file. (For epic battles it may be better to do it in the scenario script by modding each unit's LOS attrib).
Super: thanks!

And basically then only append the base game’s Squads file to the mod, with only change being that column?

In which folder of the mod then to put the Squads file? (I’ve never modded that file before.)
The main directory of your mod folder.

See the chart near the end of this document.

https://archonwiki.slitherine.com/index.php/Modding

Note that the game only reads the .csv version.
Richard Bodley Scott

Image
kronenblatt
General - Carrier
General - Carrier
Posts: 4662
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: Quick Questions Thread on Modding

Post by kronenblatt »

rbodleyscott wrote: Sat Jul 09, 2022 11:46 am
kronenblatt wrote: Sat Jul 09, 2022 10:17 am
rbodleyscott wrote: Sat Jul 09, 2022 9:52 am

As far as I can recall it is only "fixed" in the sense that all units have 200 LOS in the squads file, which equates to 20 squares LOS.

You should therefore be able to mod it by modding the LOS column in the squads file. (For epic battles it may be better to do it in the scenario script by modding each unit's LOS attrib).
Super: thanks!

And basically then only append the base game’s Squads file to the mod, with only change being that column?

In which folder of the mod then to put the Squads file? (I’ve never modded that file before.)
The main directory of your mod folder.

See the chart near the end of this document.

https://archonwiki.slitherine.com/index.php/Modding

Note that the game only reads the .csv version.
Oki, thanks, Richard!
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
MattoFrank
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Mon Jul 13, 2020 9:19 pm

Banner size/scaling

Post by MattoFrank »

Does anyone know which file controls the scaling for banners? I want to make them smaller but I can't find anything related to banner model scaling in the files.
pipfromslitherine
Site Admin
Site Admin
Posts: 9876
Joined: Wed Mar 23, 2005 10:35 pm

Re: Banner size/scaling

Post by pipfromslitherine »

MattoFrank wrote: Tue Aug 22, 2023 10:18 am Does anyone know which file controls the scaling for banners? I want to make them smaller but I can't find anything related to banner model scaling in the files.
There isn't anything that can be used to scale the banners. Sorry!

Cheers

Pip
follow me on Twitter here
MattoFrank
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Mon Jul 13, 2020 9:19 pm

Re: Quick Questions Thread on Modding

Post by MattoFrank »

Thanks for the reply :)
Post Reply

Return to “Field of Glory II: Modding”