Hi, I've been trying to make new factions and units.
But then I ran into a problem. I just can't simply figure out how to give the units "names".
For example, all the units that I add in the "SQUADS" file, are shown as errors in the editor.
I'm sure if I dig more into it I can find it, but I just simply don't know enough how this forum works.
Any help would be very much appreciated, thank you in advance.
How to give names to newly added units?
Moderator: rbodleyscott
-
MustangKim
- Private First Class - Opel Blitz

- Posts: 2
- Joined: Thu Sep 21, 2023 10:15 am
-
rbodleyscott
- Field of Glory 2

- Posts: 28323
- Joined: Sun Dec 04, 2005 6:25 pm
Re: How to give names to newly added units?
What is the error message?
All units have to have name and info strings attached to them in order to display correctly.
These are indexed by the value in the ID column - column B - in the Squads file. Each unit has to have its own unique index.
So, for example, Kardakes_Hoplites have the index 618 in the Squads file.
Their strings are:
IDS_UNITNAME618, "Kardakes Hoplites",
IDS_UNITINFO618, "Kardakes equipped as hoplites",
and are found in Text15.txt
You need to have a Text1.txt (although it could be any number) file in your mod folder. Note that these are unicode files, not normal text files, so the only easy way to create them is to copy an existing file then edit it. Normal text files will not work.
Then you add indexed strings for each of your new units.
All units have to have name and info strings attached to them in order to display correctly.
These are indexed by the value in the ID column - column B - in the Squads file. Each unit has to have its own unique index.
So, for example, Kardakes_Hoplites have the index 618 in the Squads file.
Their strings are:
IDS_UNITNAME618, "Kardakes Hoplites",
IDS_UNITINFO618, "Kardakes equipped as hoplites",
and are found in Text15.txt
You need to have a Text1.txt (although it could be any number) file in your mod folder. Note that these are unicode files, not normal text files, so the only easy way to create them is to copy an existing file then edit it. Normal text files will not work.
Then you add indexed strings for each of your new units.
Richard Bodley Scott


-
MustangKim
- Private First Class - Opel Blitz

- Posts: 2
- Joined: Thu Sep 21, 2023 10:15 am
Re: How to give names to newly added units?
Thanks a lot!
I kinda just saw your reply and then never thanked you. That I am not proud of, and I apologize
Do you happen to know how to make a certain unit "unbreakable"?
I'm working on a fantasy mod, and I want to make an "undead" unit. I thought, that by giving a unit sufficient elan(like 300 elan) I could make an unit unbreakable. However, this has made the unit way too powerful.
Is there any option/solution to this problem?
I kinda just saw your reply and then never thanked you. That I am not proud of, and I apologize
Do you happen to know how to make a certain unit "unbreakable"?
I'm working on a fantasy mod, and I want to make an "undead" unit. I thought, that by giving a unit sufficient elan(like 300 elan) I could make an unit unbreakable. However, this has made the unit way too powerful.
Is there any option/solution to this problem?
-
rbodleyscott
- Field of Glory 2

- Posts: 28323
- Joined: Sun Dec 04, 2005 6:25 pm
Re: How to give names to newly added units?
Check out jomni's FOGZ mod which is downloadable in game.
The zombie units never test morale - see what he has done in MoraleUpdate() in MoraleTools.bsf
You need to put in some code to make your indomitable units never test morale, but disperse if all killed.
You would probably need to put code specifying the specifi units rather than the whole army as he did.
Perhaps something like:
Or you could add an "Undead" attribute column to the squads file, and make its value 1 for undead units, then
The zombie units never test morale - see what he has done in MoraleUpdate() in MoraleTools.bsf
You need to put in some code to make your indomitable units never test morale, but disperse if all killed.
You would probably need to put code specifying the specifi units rather than the whole army as he did.
Perhaps something like:
Code: Select all
GetUnitTypeString(GetUnitTypeIndex(me));
if (StringCompare(GetWorkString(0), "unittypenameofindomitableunit") == 1)
{
// Destruction (dispersal) if below 0% strength
if (GetAttrib(me, "TotalMen") <= 0)
{
DisperseRouters(me);
SetAttrib(me, "MoraleState", 5);
UpdateDisplayMoraleState(me, 5);
}
return;
}Code: Select all
if (GetAttrib(me, "Undead") == 1)
{
// Destruction (dispersal) if below 0% strength
if (GetAttrib(me, "TotalMen") <= 0)
{
DisperseRouters(me);
SetAttrib(me, "MoraleState", 5);
UpdateDisplayMoraleState(me, 5);
}
return;
}Richard Bodley Scott

