Quick Questions Thread on Modding
-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Quick Questions Thread on Modding
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.
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
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
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
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
In the StartTurnMoraleUpdate() function in /Data/Battle/Scripts/StartTurn.BSFkronenblatt 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?
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


-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
OK, thanks Richard! And only units with more than 50% of starting strength may rally at all?rbodleyscott wrote: ↑Mon Jun 22, 2020 6:38 amIn the StartTurnMoraleUpdate() function in /Data/Battle/Scripts/StartTurn.BSFkronenblatt 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?
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"));
kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
Yeskronenblatt wrote: ↑Tue Jun 23, 2020 12:03 pmOK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
Richard Bodley Scott


-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
Thanks! And autobroken units never rally either, even if above 50% of starting strength?rbodleyscott wrote: ↑Tue Jun 23, 2020 12:12 pmYeskronenblatt wrote: ↑Tue Jun 23, 2020 12:03 pmOK, 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
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
Correctkronenblatt wrote: ↑Tue Jun 23, 2020 12:25 pmThanks! And autobroken units never rally either, even if above 50% of starting strength?rbodleyscott wrote: ↑Tue Jun 23, 2020 12:12 pmYeskronenblatt wrote: ↑Tue Jun 23, 2020 12:03 pmOK, thanks Richard! And only units with more than 50% of starting strength may rally at all?
Richard Bodley Scott


Re: Quick Questions Thread on Modding
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.
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.
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
Mostly in AITools.BSF. Some in CombatTools.bsf
WillUnitPursue() function in CombatTools.bsfand 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.
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


Re: Quick Questions Thread on Modding
Thank you very much. Will be very useful 

-
- Private First Class - Opel Blitz
- Posts: 2
- Joined: Thu Nov 03, 2016 11:37 am
Re: Quick Questions Thread on Modding
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?
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?
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
It is a function not a variable. GetFragmentedBaseAP() in \Data\scripts\Tools.BSFWoollymammoth wrote: ↑Fri Oct 09, 2020 8:31 pm What is "GetFragmentedBaseAP" variable and what can I set this to as default?
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.
There is no such list, because everything in the scripts (and squads files) is available for modding.Sorry, if I'm missing the obvious: where can I find a list of variables/functions 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
CScriptLike what programming language is being used?
Richard Bodley Scott


-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
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?
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
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
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.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?
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


-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
Super: thanks!rbodleyscott wrote: ↑Sat Jul 09, 2022 9:52 amAs 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.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?
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).
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
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Field of Glory 2
- Posts: 28297
- Joined: Sun Dec 04, 2005 6:25 pm
Re: Quick Questions Thread on Modding
The main directory of your mod folder.kronenblatt wrote: ↑Sat Jul 09, 2022 10:17 amSuper: thanks!rbodleyscott wrote: ↑Sat Jul 09, 2022 9:52 amAs 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.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?
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).
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.)
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


-
- General - Carrier
- Posts: 4662
- Joined: Mon Jun 03, 2019 4:17 pm
- Location: Stockholm, SWEDEN
Re: Quick Questions Thread on Modding
Oki, thanks, Richard!rbodleyscott wrote: ↑Sat Jul 09, 2022 11:46 amThe main directory of your mod folder.kronenblatt wrote: ↑Sat Jul 09, 2022 10:17 amSuper: thanks!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).
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.)
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.
kronenblatt's campaign and tournament thread hub:
https://www.slitherine.com/forum/viewtopic.php?t=108643
https://www.slitherine.com/forum/viewtopic.php?t=108643
-
- Private First Class - Opel Blitz
- Posts: 4
- Joined: Mon Jul 13, 2020 9:19 pm
Banner size/scaling
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.
-
- Site Admin
- Posts: 9876
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Banner size/scaling
There isn't anything that can be used to scale the banners. Sorry!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.
Cheers
Pip
follow me on Twitter here
-
- Private First Class - Opel Blitz
- Posts: 4
- Joined: Mon Jul 13, 2020 9:19 pm
Re: Quick Questions Thread on Modding
Thanks for the reply 
