Page 1 of 1

Direct enemy unit movement precisely

Posted: Mon Jul 15, 2013 8:12 am
by rf900
I am trying to find a way to make a unit move directly to a specific tile. When moving teams it appears they move to a point close to the target, and using SetUnitDestination for a unit seems to do the same. Is there another way to make a unit move to a specific tile directly?

Re: Direct enemy unit movement precisely

Posted: Mon Jul 15, 2013 8:57 am
by Amaris
Well dont' know what you want but you can try:
//place this unit on the tile. Fails if the tile is occupied.
SetUnitTile(id, x, y)

or may be use:
//Set a squad to route to the designated tile. react denotes whether the move triggers reaction fire.
SetRoute(id, x, y, [react])

Re: Direct enemy unit movement precisely

Posted: Mon Jul 15, 2013 10:08 am
by rf900
I want to make a unit capture a VP directly, they seem to move around it a bit before moving into the flag. Will try that second function to see if it is any better, thanks.

Re: Direct enemy unit movement precisely

Posted: Wed Jul 24, 2013 8:16 am
by rf900
I have used SetRoute(id, x, y, [react]) on AI units and it seems to do what I am looking for. Just wondering if there are any side effects of doing it vs the MoveTeam and similar functions. Will this function move the specific unit before the rest? Can it be used to override a TeamOrder for the current turn?

Re: Direct enemy unit movement precisely

Posted: Wed Jul 24, 2013 3:04 pm
by pipfromslitherine
If a unit is moving, then the AI processing will be halted anyway, so nothing should override it.

Cheers

Pip

Re: Direct enemy unit movement precisely

Posted: Fri Jul 26, 2013 2:36 pm
by rf900
Hum, it appears SetRoute does the actual movement of the unit without taking into account if it has moves left. I was thinking on adding an attribute so that when I use this function I can know which units have moved during the turn. Or check the units APs before calling it. Any other ideas?

Re: Direct enemy unit movement precisely

Posted: Tue Aug 13, 2013 4:51 pm
by Amaris
Well try to check the moved attrib - you can see how deal with in the move.bsf file into \Battlefield Academy\Data\Battle\Scripts:

Code: Select all

			ap = GetAttrib (me, "AP") ;
			
			if ((GetDiffMode() == 2) && (GetUnitSide(me) == GetPlayerSide())) // FUN MODE
			{
				SetAttrib (me, "moved", 2) ;
			}
			else
			{
				// mark unit as moved
				if (GetAttrib (me, "SneakMode") == 0 )
				{
					SetAttrib (me, "moved", 1) ;
					// flag us to show we are not sneaking
					SetUnitIconMask(me, 32) ;
				}
				else // no movement penalty
				{
					SetAttrib (me, "moved", 2) ;
				}
			}
			// reduce AP