Retreat To Cover ... Reverse!
Posted: Sun May 29, 2011 1:21 am
When Reverse came out I jumped all over this ...
Inside the MoraleTools, in the body of FUNCTION RetreatToCover, I made a quick change that does the following ...
When an Armored Unit retreats, and the "best" retreat tile is more than 130 degrees from the unit's facing it will "Reverse To Cover".
I didn't change anything to help determine the "best" tile ... but this works nicely.
Note ... you must add in the declaration of int mult ;
Original Code
Change To Read
Inside the MoraleTools, in the body of FUNCTION RetreatToCover, I made a quick change that does the following ...
Note ... you must add in the declaration of int mult ;
Original Code
Code: Select all
//Log("Ret", GetUnitX(me), GetUnitY(me), bestX, bestY) ;
AddVizFunctionCall("SetRoute", me, bestX, bestY, 0 ) ;
//Log ("Retreat from x1, y1 to x2, y2", GetAttrib (me, "LastX"), GetAttrib (me, "LastY"), GetUnitX(me), GetUnitY(me)) ;
Change To Read
Code: Select all
//Log("Ret", GetUnitX(me), GetUnitY(me), bestX, bestY) ;
if ( GetAttrib(me, "ArmourType") != 1 )
{
AddVizFunctionCall("SetRoute", me, bestX, bestY, 0 ) ;
}
else
{
mult = GetAngleFromTile(bestX, bestY, me) ;
if( mult > 130 )
{
AddVizFunctionCall("SetRouteReverse", me, bestX, bestY, 0 ) ;
}
else
{
AddVizFunctionCall("SetRoute", me, bestX, bestY, 0 ) ;
}
}
//Log ("Retreat from x1, y1 to x2, y2", GetAttrib (me, "LastX"), GetAttrib (me, "LastY"), GetUnitX(me), GetUnitY(me)) ;