Update Status after MoraleStatus

Post Reply
DasTactic
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 127
Joined: Sat Jan 07, 2006 2:36 am
Contact:

Update Status after MoraleStatus

Post by DasTactic »

I'm changing the MoraleStatus of a couple of units by setting the attribute in the CustomiseUnits() function...

Code: Select all

FUNCTION CustomiseUnits()
{
	int i;
	int id;
	int starting_strength; // starting strength - percent of full base unit strength

	// Custom MoraleStatus
	id = GetUnitID(1,1);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 1); // Disrupted
		}
	id = GetUnitID(1,2);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 2); // Fragmented
		}
...
It is working in terms of the game calculating the battle outcomes but the banners or status don't display correctly on the opening turn. Is there another function I need to run to refresh the displayed status for the first turn? After the first turn they display correctly.
Paul59
General - King Tiger
General - King Tiger
Posts: 3859
Joined: Tue Jul 21, 2015 11:26 pm

Re: Update Status after MoraleStatus

Post by Paul59 »

das123 wrote: Sun Jun 09, 2019 7:24 pm I'm changing the MoraleStatus of a couple of units by setting the attribute in the CustomiseUnits() function...

Code: Select all

FUNCTION CustomiseUnits()
{
	int i;
	int id;
	int starting_strength; // starting strength - percent of full base unit strength

	// Custom MoraleStatus
	id = GetUnitID(1,1);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 1); // Disrupted
		}
	id = GetUnitID(1,2);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 2); // Fragmented
		}
...
It is working in terms of the game calculating the battle outcomes but the banners or status don't display correctly on the opening turn. Is there another function I need to run to refresh the displayed status for the first turn? After the first turn they display correctly.
I had this same problem with my Kynoskephai scenario, which you can download from the game. I solved it like this:

// Set Thracians Fragmented
id = GetUnitOnTile(31,31);
SetAttrib(id, "MoraleState", 2);
SetUnitStatusFlag(id);
SetAttrib(id, "DisplayMoraleState", 2);

So if you put a SetUnitStatusFlag and SetAttrib line for each unit it will force the game to display the correct banner.
Field of Glory II Scenario Designer - Age of Belisarius, Rise of Persia, Wolves at the Gate and Swifter than Eagles.

Field of Glory II Medieval Scenario Designer.

FOGII TT Mod Creator

Warhammer 40,000: Sanctus Reach Tournament Scenario Designer.
DasTactic
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 127
Joined: Sat Jan 07, 2006 2:36 am
Contact:

Re: Update Status after MoraleStatus

Post by DasTactic »

Paul59 wrote: Sun Jun 09, 2019 9:42 pm I had this same problem with my Kynoskephai scenario, which you can download from the game. I solved it like this:

// Set Thracians Fragmented
id = GetUnitOnTile(31,31);
SetAttrib(id, "MoraleState", 2);
SetUnitStatusFlag(id);
SetAttrib(id, "DisplayMoraleState", 2);

So if you put a SetUnitStatusFlag and SetAttrib line for each unit it will force the game to display the correct banner.
Brilliant. Thanks Paul59. :)
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28294
Joined: Sun Dec 04, 2005 6:25 pm

Re: Update Status after MoraleStatus

Post by rbodleyscott »

das123 wrote: Sun Jun 09, 2019 7:24 pm I'm changing the MoraleStatus of a couple of units by setting the attribute in the CustomiseUnits() function...

Code: Select all

FUNCTION CustomiseUnits()
{
	int i;
	int id;
	int starting_strength; // starting strength - percent of full base unit strength

	// Custom MoraleStatus
	id = GetUnitID(1,1);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 1); // Disrupted
		}
	id = GetUnitID(1,2);
	if (id != -1)
		{
			SetAttrib(id, "MoraleState", 2); // Fragmented
		}
...
It is working in terms of the game calculating the battle outcomes but the banners or status don't display correctly on the opening turn. Is there another function I need to run to refresh the displayed status for the first turn?
Yes. The proper way to do this is:

Code: Select all

SetAttrib(id, "MoraleState", 1); // Disrupted
UpdateDisplayMoraleState(id, 1);
This will set the "DisplayMoraleState" attribute, update the banner, and update the unit formation.
Richard Bodley Scott

Image
Post Reply

Return to “Field of Glory II: Scenario Design”