Page 1 of 1
Update Status after MoraleStatus
Posted: Sun Jun 09, 2019 7:24 pm
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.
Re: Update Status after MoraleStatus
Posted: Sun Jun 09, 2019 9:42 pm
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.
Re: Update Status after MoraleStatus
Posted: Mon Jun 10, 2019 5:36 am
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.

Re: Update Status after MoraleStatus
Posted: Mon Jun 10, 2019 7:47 am
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.