More Modding Questions

Moderator: rbodleyscott

Mav01
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Wed Feb 26, 2025 1:24 pm

More Modding Questions

Post by Mav01 »

How do I mod the game to lessen the chances for the general to die in battle?

I want to make melees to last longer by making all units more resilient in melee and/or making the units inflict less
casualties in melee. How can I do this please?

How can I mod the game so units fragment less or lose cohesion less on first impact?

I want to make units react more to their own units breaking, by increasing the chances of damage being done to their
morale and widen the scope of the impact of breaking units to impact more units around them.

Is it possible to add the banners of allies in battle. So that units of allies don't fight under the main army banner?

If I wanted to make terrain and foliage to reflect spring or autumn in northern lands, is it possible to add them in the
game and as a choice for a terrain for a custom battle?

Thank you for any help
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Tue Mar 04, 2025 12:32 pm How do I mod the game to lessen the chances for the general to die in battle?
Alter the numbers in

FUNCTION TestForGeneralLost(me, loser, pursuit, notional_turn)

in GeneralTools.BSF
I want to make melees to last longer by making all units more resilient in melee and/or making the units inflict less casualties in melee. How can I do this please?
Reduce the value in

damage = 50; // Basic damage inflicted by a UnitSize 6 unit in terms of % of a UnitSize point. This may need tweaking to allow for multiple rounding down errors.

in

FUNCTION ModifiedCloseCombatDamage(me, enemy, EffectiveSize, POA, moraleModifier, attacking, test)

in

CloseCombatLogic.BSF

This should affect both close combat casualties and reduce morale tests.
How can I mod the game so units fragment less or lose cohesion less on first impact?
You can reduce the chance of double drops greatly by changing the 3 to a 2 in

if ((score < 3) && (reason != 0)) // Double drop if score low enough and not testing for being shot at

in

FUNCTION CohesionTest(me, enemy, reason, combatLog, shot, notional_turn, fullReason)

in

MoraleTools.BSF
I want to make units react more to their own units breaking, by increasing the chances of damage being done to their morale and widen the scope of the impact of breaking units to impact more units around them.
You could change the distance values in

SetProximityMoraleFlags(router)

in

MoraleTools.BSF to widen the scope.

To increase the chance of failing you would need to add an additional modifier in

FUNCTION CohesionTest(me, enemy, reason, combatLog, shot, notional_turn, fullReason)

if (fullReason == 6)

Is it possible to add the banners of allies in battle. So that units of allies don't fight under the main army banner?
No, otherwise we would already have done it. The engine only allows each side to have one banner.
If I wanted to make terrain and foliage to reflect spring or autumn in northern lands, is it possible to add them in the game and as a choice for a terrain for a custom battle?
It should be, but there no simple fix like the above. It would require many changes in many places.

Take a look at the stuff in the

/Data/objects

and

/Data/TILES

folders.

Also the

FUNCTION GetTerrain(type)

and you would need to add a bunch of strings and modify the UI to show your alternative map types.
Richard Bodley Scott

Image
Mav01
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Wed Feb 26, 2025 1:24 pm

Re: More Modding Questions

Post by Mav01 »

Thank you for so much for your help and taking your time to answer my questions.

I have come up with more questions to nag you with.

How do I decrease the chances of the AI using flank march or to make the flank march units appear more quickly?

How do I shorten the time cavalry pursue routed units?

Is their any way to change the AI so it does not counter flanking units by moving way more units than is necessary to counter them with and then chasing after them? It so easy to fool the AI by letting it chase after flanking units with a much bigger
force, which weakens the Ai front line. Also the AI has a habit of leaving gaps in the front line than can exploited for usually only one round, but even so it weakens the AI unit which is so unnecessary.

Thank you again
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Sat Mar 08, 2025 11:42 am How do I decrease the chances of the AI using flank march?
In

FUNCTION SequesterOffMapUnits(side)

in

MoreScenarioTools.bsf

you will find a section of code reading:

Code: Select all

          // Side 1 can send a flank march in Open Battle (if NOT overconfident), Reinforcements (Own) or (player) Flank March scenario.         
          if ((scenarioType == 0) || (scenarioType == 2) || (scenarioType == 3)) // vM1.4.0 change - for clarity and ease of searching
						{
							if ((Rand(1,100) <= 10) && (IsMultiplayer() == 0)) // Fairly small chance of flank march - may need tweaking. No chance in Multiplayer.
								{
									SequesterFlankMarch(side, SkewedRandom(10, 25, 2));
								}
						}
You can reduce the chance of an AI flank march by changing the 10 in

Code: Select all

(Rand(1,100) <= 10)
to a lower number.
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Sat Mar 08, 2025 11:42 am How do I .... or to make the flank march units appear more quickly?
In

FUNCTION CheckForSkirmishFlankMarch(side)

in

MoreScenarioTools.BSF

there is a section of code:

Code: Select all

					deadline = GetUniversalVar("ScenarioDeadline") / 2;
					min = (deadline / 4); // May need tweaking
					max = (deadline / 3); // May need tweaking
You can change the time at which flank marches start testing to appear by altering the formulae for min, and the longstop for arrival by altering the formula for max.
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Sat Mar 08, 2025 11:42 am How do I shorten the time cavalry pursue routed units?
In

FUNCTION WillUnitPursue(me, enemy, type)

in

CombatTools.bsf

you will find

Code: Select all

	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
            stopChance = 40; // May need tweaking // v1.7.4 change
        }
		}
To reduce the chance of cavalry continuing to pursue after the first turn of pursuit, increase the value in

Code: Select all

stopChance = 50;
to a higher value. (This is the chance of the unit stopping pursuit each turn).

For knights, increase the value in

Code: Select all

stopChance = 40;
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Sat Mar 08, 2025 11:42 am Is their any way to change the AI so it does not counter flanking units by moving way more units than is necessary to counter them with and then chasing after them? It so easy to fool the AI by letting it chase after flanking units with a much bigger force, which weakens the Ai front line.
If you discover a way to do this, please let me know.
Also the AI has a habit of leaving gaps in the front line than can exploited for usually only one round, but even so it weakens the AI unit which is so unnecessary.
Likewise.
Richard Bodley Scott

Image
Mav01
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Wed Feb 26, 2025 1:24 pm

Re: More Modding Questions

Post by Mav01 »

Well if bigger brains like you and others can't work it out, then I have no chance.

Is it possible to change daylight in a custom battle, So the daylight changes from dusk to dawn as the battle progresses?

Here is a cheeky question.
Are the team going to create a future field of glory II game set in the flintlock musket era?

Thank you for your help
Mav01
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Wed Feb 26, 2025 1:24 pm

Re: More Modding Questions

Post by Mav01 »

How do I increase armour protection against ranged weapons?
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Tue Mar 11, 2025 1:17 pm Is it possible to change daylight in a custom battle, So the daylight changes from dusk to dawn as the battle progresses?
Yes, but you would need lighting files for each stage, then all you have to do in your scenario script is specify on which turns the lighting files switch.

Using

SetLightingFile(lightFile);

e.g.

SetLightingFile("default_night");
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Mav01 wrote: Sat Mar 15, 2025 2:54 pm How do I increase armour protection against ranged weapons?
You would need to mod

FUNCTION GetShootingWeaponModifier(me, target, distance, volley, test, print)

in

CombatTools.BSF

Unfortunately, each weapon type has its own armour code - because some weapons are better against armour than others. So you would need to alter the code for each weapon type whose effect against armour you want to alter, and the code is fairly complicated.

Look for the sections of code starting

Code: Select all

effective_armour = bodyArmour;
Richard Bodley Scott

Image
Mav01
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Wed Feb 26, 2025 1:24 pm

Re: More Modding Questions

Post by Mav01 »

Thank you so much Richard, you have constantly been helpful. The game is so great to be so moddable.
kronenblatt
General - Carrier
General - Carrier
Posts: 4621
Joined: Mon Jun 03, 2019 4:17 pm
Location: Stockholm, SWEDEN

Re: More Modding Questions

Post by kronenblatt »

rbodleyscott wrote: Mon Mar 17, 2025 6:58 am
Mav01 wrote: Tue Mar 11, 2025 1:17 pm Is it possible to change daylight in a custom battle, So the daylight changes from dusk to dawn as the battle progresses?
Yes, but you would need lighting files for each stage, then all you have to do in your scenario script is specify on which turns the lighting files switch.

Using

SetLightingFile(lightFile);

e.g.

SetLightingFile("default_night");
Interesting! Which file and which script would be the proper one to mod for this?
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: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

kronenblatt wrote: Wed Apr 09, 2025 4:22 pm
rbodleyscott wrote: Mon Mar 17, 2025 6:58 am
Mav01 wrote: Tue Mar 11, 2025 1:17 pm Is it possible to change daylight in a custom battle, So the daylight changes from dusk to dawn as the battle progresses?
Yes, but you would need lighting files for each stage, then all you have to do in your scenario script is specify on which turns the lighting files switch.

Using

SetLightingFile(lightFile);

e.g.

SetLightingFile("default_night");
Interesting! Which file and which script would be the proper one to mod for this?
The lighting files are text files in /Data/Lighting

I have no idea how they work.

(Ignore the CLUT files, that system does not work.)

If you want to change the lighting in an editor-created scenario you need to use SetLightingFile("filename") in the scenario script, probably in the StartTurn() function.
Richard Bodley Scott

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

Re: More Modding Questions

Post by kronenblatt »

rbodleyscott wrote: Wed Apr 09, 2025 5:06 pm If you want to change the lighting in an editor-created scenario you need to use SetLightingFile("filename") in the scenario script, probably in the StartTurn() function.
StartTurn() in Core.BSF? Because I'm not sure what you mean by "scenario script"? Would this be implementable in a Custom Battles campaign, for example? And if yes, 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: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

kronenblatt wrote: Wed Apr 09, 2025 5:20 pm
rbodleyscott wrote: Wed Apr 09, 2025 5:06 pm If you want to change the lighting in an editor-created scenario you need to use SetLightingFile("filename") in the scenario script, probably in the StartTurn() function.
StartTurn() in Core.BSF? Because I'm not sure what you mean by "scenario script"? Would this be implementable in a Custom Battles campaign, for example? And if yes, how?
I meant in the secnario script - which is how the "epic battles" work. Each one has a scenario script.

As for doing it for Custom Battles, that would be different as there are no scenario scripts. What exactly are you trying to achieve?
Richard Bodley Scott

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

Re: More Modding Questions

Post by kronenblatt »

rbodleyscott wrote: Thu Apr 10, 2025 6:32 am
kronenblatt wrote: Wed Apr 09, 2025 5:20 pm
rbodleyscott wrote: Wed Apr 09, 2025 5:06 pm If you want to change the lighting in an editor-created scenario you need to use SetLightingFile("filename") in the scenario script, probably in the StartTurn() function.
StartTurn() in Core.BSF? Because I'm not sure what you mean by "scenario script"? Would this be implementable in a Custom Battles campaign, for example? And if yes, how?
I meant in the secnario script - which is how the "epic battles" work. Each one has a scenario script.

As for doing it for Custom Battles, that would be different as there are no scenario scripts. What exactly are you trying to achieve?
The light of each Custom Battle to change from dawn to dusk and ultimately night, as turns pass. Along the lines of what you wrote above: ”specify on which turns the lighting files switch.”
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: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

[Unedited version removed]
Richard Bodley Scott

Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: More Modding Questions

Post by rbodleyscott »

Core.bsf cannot be safely modded. The engine will ignore any version in a mod folder.

You should be able to put the code in StartTurn.BSF in \Data\Battle\Scripts

Try putting the code immediately after

Code: Select all

			// Reset Undo variables to current unit position (Do this last so starting AP is correct)
			ResetUndoPosition(me);
before

Code: Select all

  }
}
e.g.

Code: Select all

			// Reset Undo variables to current unit position (Do this last so starting AP is correct)
			ResetUndoPosition(me);
			
			if ((GetTurn() >= -1) && (GetTurn() < 4))
				{
					SetLightingFile("NorthernEurope_Dawn");
				}
				
			if ((GetTurn() >= 4) && (GetTurn() < 44))
				{
					SetLightingFile("NorthernEurope_DayLight");
				}
				
			if (GetTurn() >= 44)
				{
					SetLightingFile("NorthernEurope_Sunset");
				}								
		}
}
Or something like that. Night will automatically be set at the end of the battle by the existing code.

I am not entirely sure how that will interact with the default code, which sets daylight to daylight at the start of the battle and night at the end.

But it may well work. But sSeems a lot of work for minor cosmetic benefit.
Richard Bodley Scott

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

Re: More Modding Questions

Post by kronenblatt »

rbodleyscott wrote: Thu Apr 10, 2025 9:28 am ...
Seems a lot of work for minor cosmetic benefit.
...
Hey, never thought you were afraid of work... :lol:

Thanks for suggested syntax, I'll give it or something similar a try and post here what works and not, for the benefit of other modders.
kronenblatt's campaign and tournament thread hub:

https://www.slitherine.com/forum/viewtopic.php?t=108643
Post Reply

Return to “Field of Glory II: Medieval - Modding”