Page 1 of 1

HOW TO : Start the Scenario with Veteran or Elite Units

Posted: Mon Sep 13, 2010 6:37 pm
by Merr
This code allows ALL your Units to begin the scenario at either Veteran or Elite status.
No longer need to include the DrillSgt bonus card (if you were using the card for that design intention).

Cut and paste the code into your scenarios BSF, in the FUNCTION StartTurn(side), at very end.
Adding it at the end ensures that any units placed in turn (-1) before this code are ALL promoted.
I added comments to help understand the code if you want to ; change sides, only promote specific units, or only promote to veteran level. (default is Elite).

Hope this helps !
Enjoy!

Code: Select all

	//  Now we need to Promote all of side 0 units before game starts
	if( GetTurn() == -1 )
	{
	int id ;
	int i ;
	int x ;
	int y ;
	
		id = GetUnitID(0, i) ; // setting the id to side 0

		for ( x=GetUnitX(id) ; x < GetMapWidth() ; x++)
		{
			for ( y=GetUnitY(id) ; y < GetMapHeight() ; y++)
			{
				if(id != -1)  // use ID from Squads.csv to promote specific unit
				{
					// promote to Elite
					if( GetUnitStatus(id) < 2) // to promote to veteran use,  if( GetUnitStatus(id) < 1)
					{
						for(i=0; i<GetUnitCount(0);i++)
						{
							id = GetUnitID(0, i) ;  // again, sets id to side 0
						
							if ( ( x >= 0 ) && ( x < GetMapWidth()) && ( y >= 0 ) && ( y < GetMapHeight()) )
							{
							// Level up all units 
							CallUnitFunctionDirect(id, "GainExperience", id, -1) ;
							}
						}
					}
				}
			}
		}
	}

Posted: Mon Sep 13, 2010 7:19 pm
by adherbal
IIRC you can press 1-2-3 while hovering over a unit to set its level in the editor? Unless that's not what you wanted to achieve.

Posted: Mon Sep 13, 2010 7:30 pm
by Merr
adherbal wrote:IIRC you can press 1-2-3 while hovering over a unit to set its level in the editor? Unless that's not what you wanted to achieve.
That doesn't appear to work (for me at least).

What mode do you have to be in?

Posted: Mon Sep 13, 2010 8:19 pm
by adherbal
Unit mode. Use the numeric keys on the left side of the keyboard, not the numpad keys.

Posted: Mon Sep 13, 2010 8:27 pm
by Merr
adherbal wrote:Unit mode. Use the numeric keys on the left side of the keyboard, not the numpad keys.
Ok ... Thanks!

The trick is .... BEFORE ADDING THE UNIT ... hold the numeric key down.

Oh well .... :oops:

Perhaps the code can be used in other aspects, such as during the game on a particular turn.
Of course, there are a billion ways to code it.

I'm such a noob.

Posted: Tue Sep 14, 2010 12:27 am
by pipfromslitherine
That shouldn't be necessary - I'll double check, but you should only need to hover over the unit and press the key.

Cheers

Pip