Page 1 of 1

Retreat To Cover ... Reverse!

Posted: Sun May 29, 2011 1:21 am
by Merr
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 ...

:arrow: 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".
:arrow: I didn't change anything to help determine the "best" tile ... but this works nicely. 8)

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)) ;				

Posted: Sun May 29, 2011 5:58 pm
by pipfromslitherine
Nice. Something that we missed for sure. Not sure we can get it in for the next update, but we'll definitely get it added in.

Cheers

Pip

Posted: Sat Jun 04, 2011 11:54 pm
by Merr
Pip,

My thoughts on why it was missing ... You weren't in the neighborhood :)

If/when you add something, can you accidently be in the neighborhood of the AI.bsf :wink:
It could use some "reverse" logic, pun intended.

Thanks for your work!

Posted: Thu Jun 09, 2011 5:15 pm
by IainMcNeil
Just tried it - had a crash first time as I had to delcare teh mult variable but after that it seems to work :)

Posted: Tue Jun 14, 2011 10:42 pm
by Merr
iainmcneil wrote:Just tried it - had a crash first time as I had to delcare teh mult variable but after that it seems to work :)
Ian,

Thanks for trying it!

You guys definately need to delv' this more ... I noticed that the 130 degrees doesn't always work ... especially if the threat is adjacent!

For example .... If the tank is facing EAST, and an infantry unit is adjacent one tile NORTHEAST, if the tank retreats and the BestX/Y is SOUTH (90 degrees) it will retreat forward :cry: .

So, the if (in this case) needs to be mult > 85 ... Now, in my case above, the BestX/Y could have been WEST (which was an available tile), and the 130 would have worked, so you guys might need to re-write the Threat logic since it appears it selected the first available tile instead of a logical tile.

Of course, when it comes to retreating, a logical tile has many conditions and considering ALL of those would take forever to script!

Anyway, try 85 ... it solves the "adjacent" problem and it may help all around!