Page 1 of 1

How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 8:37 am
by GottaLove88s
Does anyone know where the code is that affects the suppression level of units?

Granfali has updated MoraleTools.BSF to reduce suppression morale from 50 to 0 (making for tougher infantry for our GJS campaign).
The problem is the white flag that usually shows up over suppressed units still shows at 50, not 0.

This looks like the code that shows the white flag, but all the 50s have already been switched to 0s.
Could the white flag be anywhere else?

Thanks!
GL88

Code: Select all

		
			// if morale low suppress unit
			if ( (before >= 0) && (morale < 0 ) && ( destroyed == 0 ) ) 
			{				
				AddVizFunctionCall ("SetUnitIconMask", me, 8) ;
				// if unit is visible show suppression
				// play "pinned down"
				PlayVoice (FXRand(162,164), me, 3 ) ;
				
				AddVizUnitText(me, "IDS_UNIT_SUPPRESSED", "ffffff") ;				

				// vehciles retreat one tile as they cant really take cover
				if ( GetAttrib(me, "Blocking") != 0 )
				{
					Log ("MoraleUpdate armour suppressed retreat"); 
					RetreatToCover (me, 0, 1, 1) ;
				}

					// suppressed units lose action points immediately
				ap = GetBaseAttrib(me, "AP") / 4 ;
				ap = GetAttrib(me, "AP") - ap ;

				if ( ap < 0 )
				{
					ap = 0 ;
				}
				
				SetAttrib(me, "AP", ap) ;
			}				
			

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 2:56 pm
by pipfromslitherine
I think the logic would be in DATA/BATTLE/SCRIPTS/STARTTURN.BSF, I'm guessing around line 90 is the code you are interested in.

Cheers

Pip

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 3:11 pm
by GottaLove88s
Got it, thanks Pip!

We'll copy StartTurn.BSF into our GJS campaign Data\Battle\Scripts folder
and edit the < 50 below to < 0. That should solve it...

You're a genius. :-)

Code: Select all

// if morale is low set AP and icons
	if ( GetAttrib (me, "Morale") < 50 )
	{
		// only inf have reduced movement
		if (GetAttrib (me, "IsVehicle") == 0 )
		{
			ap = GetBaseAttrib(me, "AP") ;
			ap /= 2 ;
			SetAttrib(me, "AP", ap) ;
		}
		SetUnitIconMask(me, 8) ;
	}

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 4:01 pm
by pk867
Hi,
So is it '0' or '-1' ? If zero, then should it be <1 ?

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 4:16 pm
by GottaLove88s
Right now, anything below 50 is suppressed, so the original BA code is...

if ( GetAttrib (me, "Morale") < 50 )

We've modified this to anything below 0 is suppressed in GJS, so we'll alter to...

if ( GetAttrib (me, "Morale") < 0 )

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 8:34 pm
by Granfali
Good work GL88 ;)

Re: How to change morale level for suppression/white flag?

Posted: Wed Oct 17, 2012 9:17 pm
by Richcat
Hi Guys
This may or may not be of help, and you seem to have worked it out already - but I thought I would post it out of interest.
I realise this is not to do with the white flag, but found a few snippets & scripts by Merr and J2D, that may be of interest with your Morale settings.
viewtopic.php?f=104&t=19767
As you can see, when a unit for side(1) has it's morale drop below 50 it will reset it back to 50 (the unit will never be suppressed)
But, since it quickly dropped below 50 you will still see the text "suppressed" along with the voice, however, you'll note that the unit isn't really suppressed.
Now, you can change the code to read 0 instead ... this will prevent the unit from surrendering (ie, dropping below 0).

Code: Select all

FUNCTION Tick(side)
{
int id ;
int i ;

   if( GetTurn() >= -1 )
   {   
      for(i=0; i<GetUnitCount(1); i++)
      {   
         id = GetUnitID(1, i) ;

         if ( GetAttrib (id, "morale") < 50 )
         {
            SetAttrib (id, "morale", 50) ;
         }         
      }
   }
}
Further down the thread.
Instead of never suppressed >50 I'd rather have a never surrender >0

So the tick would be

if ( GetAttrib (id, "morale") < 0 )
{
SetAttrib (id, "morale", 0) ;

Or a number higher than 0 but lower than 50.

I found this in Assault script

// prevent a unit who wins an assault from getting suppressed
if ( GetAttrib(me, "Morale") < 51 )
{
SetAttrib (me, "Morale", 51 ) ;