Page 1 of 1

Changing base morale using a .BSF?

Posted: Sat Nov 24, 2012 4:57 pm
by GottaLove88s
Guys,

I'm trying to set up a campaign where the Germans will suffer a morale penalty in some games.

Is there a way to change the base morale of units from within a Scenario.BSF?

For example, how could I reduce the base morale of all volksgrenadiers on the map, from 75 to 50? Can it be done?

The other way is to change squads.csv, but then I would end up with one squads.csv for games where the Germans are not penalised, and another squads.csv for the games where the Germans are penalised... I can't figure out how to have more than one squads.csv for different scenarios in the same campaign???

Thanks for any ideas at all... :D

Re: Changing base morale using a .BSF?

Posted: Mon Nov 26, 2012 11:42 am
by Amaris
Easy :

In your scenario.BSF put the following code into the FUNCTION PreBattleSetup():

Code: Select all

FUNCTION PreBattleSetup()
{
...
int side;
int count;
int id;

	for(side=0; side<=1; side++)
	{
		for(count=0; count<GetUnitCount(side); count++)
		{
			id = GetUnitID(side, count) ;
			if ((GetUnitDead(id) == 0) && (IsUnitType(id, "volksgrenadier") == 1))
			{
					SetAttrib(id, "Morale", 50);
			}		
		}
	}
}

Re: Changing base morale using a .BSF?

Posted: Mon Nov 26, 2012 12:44 pm
by GottaLove88s
Thanks for your help Amaris.

If I understand, this runs two loops, one for each side, working through all of the units for one side, then the other side.
And I could put different unit types in at the if (IsUnitType(id, "volksgrenadier")==1)) stage.
NICE. :-)

Looking at the code, will this set the current morale to eg. 50?
Or will this set the base morale to 50?
I want to set the base morale.

Un grand merci (comme d'hab! ;-))

Re: Changing base morale using a .BSF?

Posted: Mon Nov 26, 2012 12:54 pm
by Amaris
Yeah you can have multiple test like if (IsUnitType(id, "volksgrenadier")==1)) ; changing the type of unit.

The SetAttrib() function attrib a new values on the unit into parameters. So it will set the current morale to 50.
A check anyway by a test.I'm at work now, and I can not test. :P