HOW TO : Start the Scenario with Veteran or Elite Units
Posted: Mon Sep 13, 2010 6:37 pm
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!
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) ;
}
}
}
}
}
}
}