Direct enemy unit movement precisely

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Direct enemy unit movement precisely

Post by rf900 » Mon Jul 15, 2013 8:12 am

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?

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: Direct enemy unit movement precisely

Post by Amaris » Mon Jul 15, 2013 8:57 am

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])
“Take care, my friend; watch your six, and do one more roll… just for me.”

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Direct enemy unit movement precisely

Post by rf900 » Mon Jul 15, 2013 10:08 am

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.

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Direct enemy unit movement precisely

Post by rf900 » Wed Jul 24, 2013 8:16 am

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?

pipfromslitherine
Site Admin
Site Admin
Posts: 8975
Joined: Wed Mar 23, 2005 10:35 pm

Re: Direct enemy unit movement precisely

Post by pipfromslitherine » Wed Jul 24, 2013 3:04 pm

If a unit is moving, then the AI processing will be halted anyway, so nothing should override it.

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Direct enemy unit movement precisely

Post by rf900 » Fri Jul 26, 2013 2:36 pm

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?

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: Direct enemy unit movement precisely

Post by Amaris » Tue Aug 13, 2013 4:51 pm

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 
“Take care, my friend; watch your six, and do one more roll… just for me.”

Post Reply

Return to “Battle Academy : Modders Corner ”