How to change troop quality of specific units + other questions

Moderator: rbodleyscott

Post Reply
Ihatesiginingupforstuff
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 5
Joined: Wed Sep 06, 2023 2:00 pm

How to change troop quality of specific units + other questions

Post by Ihatesiginingupforstuff »

Hello everyone im new to this whole scenario design thing but ive been trying to make a scenario myself recently and ive hit snags along the way but solved them here in this very forum! i thank stockwellpete for making all those topics describing his various problems and solutions as i finally understand how to change starting morale of soldiers in the bsf file. yay,

i would now like to change the quality of some units to reflect that they are of superior quality over other units that are the same type, for instance i want yorkist billmen to be better than lancastrian billmen in a specific engagement i would like any ideas on how to do that, i would also like to know if theres any place i can find "generic" scripts for variables in the game, an example would be once again, stockwellpetes excellent northampton scenario where theres heavy rain that makes archers unable to fire but then the heavy rain stops and they can fire. that adds a whole new dynamic to the game and im itching for trying to make something like that myself.

so, are all of these scripts homemade if you will, or are they passed around somewhere.

if there isn't, where would i learn to JUST understand what scripts are doing and which function id need to place them in so i can just copy them from other more talented amazing people and use them for myself.

thank you for reading.
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28108
Joined: Sun Dec 04, 2005 6:25 pm

Re: How to change troop quality of specific units + other questions

Post by rbodleyscott »

Ihatesiginingupforstuff wrote: Fri Sep 29, 2023 6:33 pm i finally understand how to change starting morale of soldiers in the bsf file.

i would now like to change the quality of some units to reflect that they are of superior quality over other units that are the same type, for instance i want yorkist billmen to be better than lancastrian billmen in a specific engagement i would like any ideas on how to do that,
You would do this in the same way as you altered the morale, by altering the "Experience" and "Elan" attribs. (Quality is the average of these two attributes). In order to only alter some units, you would need to write code that distinguishes between the units of the same type. e.g. which side they belong to.
i would also like to know if theres any place i can find "generic" scripts for variables in the game, an example would be once again, stockwellpetes excellent northampton scenario where theres heavy rain that makes archers unable to fire but then the heavy rain stops and they can fire. that adds a whole new dynamic to the game and im itching for trying to make something like that myself.

so, are all of these scripts homemade if you will, or are they passed around somewhere.
The only place to look at most of them is in the scenario scripts they are in.

There are some "official" ones in /Data/scripts/SpecialScenarioTools.bsf
if there isn't, where would i learn to JUST understand what scripts are doing and which function id need to place them in so i can just copy them from other more talented amazing people and use them for myself.
There isn't really any easy way to do this without a basic understanding of programming in CScript. (A cut down version of C)
Richard Bodley Scott

Image
Paul59
General - King Tiger
General - King Tiger
Posts: 3815
Joined: Tue Jul 21, 2015 11:26 pm

Re: How to change troop quality of specific units + other questions

Post by Paul59 »

Ihatesiginingupforstuff wrote: Fri Sep 29, 2023 6:33 pm i would now like to change the quality of some units to reflect that they are of superior quality over other units that are the same type, for instance i want yorkist billmen to be better than lancastrian billmen in a specific engagement i would like any ideas on how to do that, i would also like to know if theres any place i can find "generic" scripts for variables in the game, an example would be once again, stockwellpetes excellent northampton scenario where theres heavy rain that makes archers unable to fire but then the heavy rain stops and they can fire. that adds a whole new dynamic to the game and im itching for trying to make something like that myself.
Hi,

Increasing the quality of certain units can be done in several different ways. Perhaps the easiest, if you are familiar with scripting, is this:

If you don't have one already create a .bsf file for your scenario. You can read this guide to tell you how for instructions on how to do that:

https://www.slitherine.com/forum/viewtopic.php?t=81190

Open the .bsf file, and towards the bottom of the file you will find a section called FUNCTION CustomiseUnits(). In this section you can add some lines of code to upgrade your units.

You can open the Standard_S.bsf file to see how I have upgraded the Scots Galwegians to Superior quality (from Average) for the official Battle of the Standard scenario in the Medieval base game.

Beneath a line of green text that says // Adjust starting unit strengths, you will see two almost identical sections of code. The first section is for altering the units of Side 0 (ie; the player side in SP games, or the side that moves first in MP games), this is denoted by the 0 in GetUnitCount(0) and GetUnitID(0).

The second section is for Side 1 (ie; the AI side in SP games, or the side that moves second in MP games), this is denoted by the 1 in GetUnitCount(1) and GetUnitID(1).

So for the Standard I have added the following lines:

Code: Select all

                                // Upgrade Galwegians
				GetUnitTypeString(GetUnitTypeIndex(id)); 
                                if (StringCompare(GetWorkString(), "Galwegians") == 1)
					{
						SetAttrib(id, "Experience", 200);
						SetAttrib(id, "Elan", 200);
					}									

This tells the game to upgrade all Galwegians units in Side 0 to 200 Experience and 200 Elan.

A units quality is the average of it's Experience and Elan values, so the Galwegians in this case will have quality 200 which is the normal value for Superior units. Average quality is normally 100. If you wanted them to be only slightly better than Average, you could give them Experience and Elan values of 125 or 150, or any value you wanted between 101 and 159.

So to upgrade any unit you just need to add those lines of code in the correct place in the FUNCTION CustomiseUnits(), change the unitname to the unit you want to change and the numerical values that you want for Experience and Elan.

You can find the precise unitnames in column A of the Squads.csv file. You must use the exact unitname as shown in the Squads.csv file, not the displayed name that you see in the game. So for instance the unitname for the 14th century style Men-at-Arms is actually Men_at_arms.

If you cannot work with scripts, let me know, and I will describe another method.

cheers

Paul
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.
Ihatesiginingupforstuff
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 5
Joined: Wed Sep 06, 2023 2:00 pm

Re: How to change troop quality of specific units + other questions

Post by Ihatesiginingupforstuff »

Paul59 wrote: Tue Oct 03, 2023 10:23 am

Code: Select all

                                // Upgrade Galwegians
				GetUnitTypeString(GetUnitTypeIndex(id)); 
                                if (StringCompare(GetWorkString(), "Galwegians") == 1)
					{
						SetAttrib(id, "Experience", 200);
						SetAttrib(id, "Elan", 200);
					}									

This tells the game to upgrade all Galwegians units in Side 0 to 200 Experience and 200 Elan.

thank you so much for providing me some much needed help, i also thank you for your scenario editor tutorials for i didnt even know they existed until i stumbled upon them on this forum!

i did this and it seemed to work

Code: Select all

// Adjust starting unit strengths
	for (i = 0; i < GetUnitCount(0); i++)
	{
		id = GetUnitID(0,i);
		if (id != -1)
			{
				// Upgrade yorkist billmen
				GetUnitTypeString(GetUnitTypeIndex(id)); 
                if (StringCompare(GetWorkString(), "Billmen") == 1)
					{
						SetAttrib(id, "Experience", 200);
						SetAttrib(id, "Elan", 200);
					}
					
				// Upgrade yorkist billmen/longbowmen
				GetUnitTypeString(GetUnitTypeIndex(id)); 
                if (StringCompare(GetWorkString(), "Bill_Longbow") == 1)
					{
						SetAttrib(id, "Experience", 200);
						SetAttrib(id, "Elan", 200);
					}
i also figured out if i only wanted to upgrade specific units i could so something like this, which also worked
(thank you rbodleyscott)

Code: Select all

for (i = 0; i < GetUnitCount(1); i++)
	{
		id = GetUnitID(1,i);
		if (id != -1)
			{
			     //upgrade specific billmen 
				 id = GetUnitOnTile(25,27);
				 SetAttrib(id, "Experience", 200);
				 SetAttrib(id, "Elan", 200);
in conclusion you guys are awesome and have a good day
Paul59
General - King Tiger
General - King Tiger
Posts: 3815
Joined: Tue Jul 21, 2015 11:26 pm

Re: How to change troop quality of specific units + other questions

Post by Paul59 »

Ihatesiginingupforstuff wrote: Tue Oct 03, 2023 6:56 pm
i also figured out if i only wanted to upgrade specific units i could so something like this, which also worked
(thank you rbodleyscott)

Code: Select all

for (i = 0; i < GetUnitCount(1); i++)
	{
		id = GetUnitID(1,i);
		if (id != -1)
			{
			     //upgrade specific billmen 
				 id = GetUnitOnTile(25,27);
				 SetAttrib(id, "Experience", 200);
				 SetAttrib(id, "Elan", 200);
in conclusion you guys are awesome and have a good day
Yes, that's one of the other methods that I alluded to. The problem with that method is that if you move the unit's position in the Editor you have to remember to put new coordinates in the script.
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.
Post Reply

Return to “Field of Glory II: Medieval - Scenario Design”