Page 2 of 2

Re: More Modding Questions

Posted: Sat Apr 12, 2025 9:42 am
by kronenblatt
It worked fine. I did as follows.

In StartTurn.BSF file (under DATA\BATTLE\SCRIPTS\), I added a function:

Code: Select all

FUNCTION CustomStartBattleLighting()
{
	int turn;
	turn = GetTurn();
	if (turn < 6)
	{
		SetLightingFile("NorthernEurope_Dawn");
	}
	else if (turn < 10)
	{
		SetLightingFile("NorthernEurope_EarlyMorning");
	}
	else if (turn < 14)
	{
		SetLightingFile("NorthernEurope_MidMorning");
	}
	else if (turn < 40)
	{
		SetLightingFile("NorthernEurope_DayDull");
	}	
	else
	{
		SetLightingFile("NorthernEurope_Sunset");
	}
}
And also referred to it at the beginning of StartTurn() function, adding CustomStartBattleLighting(); :

Code: Select all

	if (GetWinner() == -1) // If game not already ended
		{
			// MODDED
			CustomStartBattleLighting();
Finally, to get the dawn light also when setting up the army, I also added a similar function in MoreScenarioTools.BSF file (under DATA\SCRIPTS\), just to try it out:

Code: Select all

FUNCTION ModdedRegionalDayLight()
{
	SetLightingFile("NorthernEurope_Dawn");
}
And called upon it at the beginning of the SetRegionalDaylight() function in the same file:

Code: Select all

FUNCTION SetRegionalDaylight()
{
	int deadline;
	
	// MODDED TO ADJUST DAY LIGHT
	ModdedRegionalDayLight();
	return;
Of course, more lighting files can be created and called upon, creating a more gradual sunrise and sunset. (There are as mentioned above more lighting files, such as EarlyMorning, MidMorning, and so on.)

I tried it out in Snugglebunnies' Middle Earth Mod and it looked particularly cool in the battles involving the evil side, e.g., Angmar, Orcs, Mordor. :twisted:

Re: More Modding Questions

Posted: Sat Apr 12, 2025 10:07 am
by kronenblatt
NorthernEurope_Dawn
Image

NorthernEurope_EarlyMorning
Image

NorthernEurope_MidMorning
Image

Re: More Modding Questions

Posted: Sat Apr 12, 2025 2:57 pm
by rbodleyscott
Nice

Re: More Modding Questions

Posted: Fri May 16, 2025 12:35 pm
by toska
Hello!

How can I force the machine to adopt a defensive stance in defensive battles (AI defends)?

Re: More Modding Questions

Posted: Sun May 18, 2025 4:27 pm
by rbodleyscott
toska wrote: Fri May 16, 2025 12:35 pm Hello!

How can I force the machine to adopt a defensive stance in defensive battles (AI defends)?
I presume you mean in one where they are not defending field forticifations.

In that case they will tend to advance if they feel they have sufficient advtantage in infantry.

To stop them doing so would require modifications in AI_Masterplan() in AITools.BSf

There is a line that reads:

if ((OverconfidentAI() == 1) || (((ownArmyCavalry == 0) || (GetTurn() > 1) || (IsFortifiedSide(0) == 1)) && (((comparator > enemyPoints) && (credibleFrontalThreat == 1)) || (distance < 7) || ((ownArmyCavalry == 1) && ((GetTurn() > 1) || ((IsFortifiedSide(0) == 1)))) || (GetTeamActivationStage(1, 7) == 1) || (scenario == 8 )))) // vM1.4.0 change

You could try changing this to

if ((OverconfidentAI() == 1) || (((ownArmyCavalry == 0) || (GetTurn() > 1) || (IsFortifiedSide(0) == 1)) && (((comparator > enemyPoints) && (credibleFrontalThreat == 1) && (scenario!=9)) || (distance < 7) || ((ownArmyCavalry == 1) && ((GetTurn() > 1) || ((IsFortifiedSide(0) == 1)))) || (GetTeamActivationStage(1, 7) == 1) || (scenario == 8 )))) // vM1.4.0 change

No promises

Re: More Modding Questions

Posted: Tue May 20, 2025 10:21 pm
by toska
It works! This should be in the base game so that battles where the AI ​​defends make sense.

Re: More Modding Questions

Posted: Tue May 19, 2026 1:53 pm
by Mav01
How do I change the auto break so that the a unit can take more casualties without auto breaking?
Also how do I get rid of the auto break altogether?
Thank you for any help.

Re: More Modding Questions

Posted: Thu May 21, 2026 11:00 am
by rbodleyscott
Mav01 wrote: Tue May 19, 2026 1:53 pm How do I change the auto break so that the a unit can take more casualties without auto breaking?
Also how do I get rid of the auto break altogether?
Thank you for any help.
The relevant function is IsAutobroken() in MoraleTools.BSF

// Determines whether a unit is autobroken due to losses. Returns 1 if autobroken, 0 if not. Autobreak point is <50% strength if Quality = 100, and is adjusted by 10% per 100 quality either side of 100

Code: Select all

FUNCTION IsAutobroken(me)
{
	int ret;
	int surviving;
	int quality_bonus;
	int autobreak_point;

	ret = 0;

	surviving = GetAttrib(me, "TotalMen") * 1000;
	surviving /= StartingStrength(me);

	quality_bonus = GetQuality(me);
	quality_bonus -= 100;

	autobreak_point = 500 - quality_bonus;

	if (surviving < autobreak_point)
		{
			ret = 1;
		}

	return ret;
}
If you want to allow more men to be lost before autobreak, change the 500 in

Code: Select all

autobreak_point = 500 - quality_bonus;
to a lower figure.

If you want to prevent autobreak altogether, just change the function to

Code: Select all

[code]FUNCTION IsAutobroken(me)
{
return 0;
}