Page 1 of 1

How to give names to newly added units?

Posted: Mon May 26, 2025 9:00 pm
by MustangKim
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.

Re: How to give names to newly added units?

Posted: Tue May 27, 2025 7:17 am
by rbodleyscott
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.

Re: How to give names to newly added units?

Posted: Mon Jun 09, 2025 2:02 pm
by MustangKim
Thanks a lot!

I kinda just saw your reply and then never thanked you. That I am not proud of, and I apologize :oops:

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?

Re: How to give names to newly added units?

Posted: Mon Jun 09, 2025 4:57 pm
by rbodleyscott
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:

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;			
		}
Or you could add an "Undead" attribute column to the squads file, and make its value 1 for undead units, then

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;			
		}