How to change morale level for suppression/white flag?

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

How to change morale level for suppression/white flag?

Post 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) ;
			}				
			
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

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

Post 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
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

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

Post 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) ;
	}
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
pk867
Sr. Colonel - Battleship
Sr. Colonel - Battleship
Posts: 1602
Joined: Fri May 08, 2009 3:18 pm

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

Post by pk867 »

Hi,
So is it '0' or '-1' ? If zero, then should it be <1 ?
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

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

Post 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 )
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Granfali
Slitherine
Slitherine
Posts: 1642
Joined: Mon Aug 09, 2010 9:19 am

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

Post by Granfali »

Good work GL88 ;)
Richcat
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 219
Joined: Sun Nov 07, 2010 10:09 pm

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

Post 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 ) ;
Cheers
Richcat
Post Reply

Return to “Battle Academy : Modders Corner ”