Using AI orders for a group of units

A forum to discuss custom scenarios, campaigns and modding in general.

Moderators: Slitherine Core, Panzer Corps Moderators, Panzer Corps Design

Post Reply
Molve
Master Sergeant - U-boat
Master Sergeant - U-boat
Posts: 538
Joined: Wed Jul 27, 2011 10:06 am

Using AI orders for a group of units

Post by Molve »

From a thread called Re: Scripting under 1.10 - question
viewtopic.php?f=147&t=37945
Rudankort wrote:AI zone is mandatory for the following 5 AI orders:

Move To. The unit will move to the nearest hex in AI zone, then next nearest and until the zone is exhausted. Then its behavior will reset to Default.
Random Move To. The unit will select random hex from AI zone and move there. Then its behavior will reset to Default.
Patrol. The unit will move to the nearest hex in AI zone, then next nearest etc. untis the zone is exhausted, then it will start from the first hex again etc. in a loop.
Random Patrol. On every turn the unit will choose a random hex from AI zone and move there.
Disembark. The unit will choose a random hex from AI zone and will move and then disembark there. Then its behavior will reset to Default. This behavior is similar to "Random Move To", only disembark action is added in the end.

All the other AI behaviors do not use AI zone setting.
I've tried to examine the scripts of existing scenarios but still I wonder, how do you use the "Move To" AI order to direct a bunch of units across the map.

Let's take an example: You have a British flotilla of perhaps ten units (warships and transports for an amphibious assault). I want to direct this group from one end of the map to a beach at the other end of the map, and for the transports to disembark the land units there while the naval units provide general support (and defend themselves).

Can I designate a Zone over by the landing area?
Do the zone specified in Move To have to be within immediate reach (the unit can reach it directly and move there immediately) - or will the AI find its way toward the zone using general pathing routines?
The instances of Move To I've found in existing scenarios always involve single units, and I'm worried Move To would force each naval vessel to visit each and every hex in the zone - which obviously isn't what I want. I want the group to move over to this zone over here, and I just assume I need to make this zone big enough to have one hex for each unit...
(My hopes are that I do not have to lead each and every unit by the nose, and that I have to create an individual set of zone for each unit. That would far too quickly use up all 32 zones... I hope I can direct a group of units with these AI orders)

Do units under a Move To command respond to hostile attacks? (Would the warships engage enemies or would they plow straight through ignoring enemies they would shoot at if under Attack/Defend orders?)

I have already understood that the way you "switch back" from Move To orders to general Attack/Defend behaviour (or Disembark for paratroopers) is by setting up a zone and when it gets filled by the units you want, it sets the AI orders for the units in that zone.
bebro
Slitherine
Slitherine
Posts: 4575
Joined: Sun Nov 19, 2006 12:50 pm

Re: Using AI orders for a group of units

Post by bebro »

From the experiences I made while modding:
Molve wrote: Can I designate a Zone over by the landing area?
You can certainly create a zone as landing area, so one or several hexes on land, at the coast. Probably be better to give the TPs the "disembark to" order with that zone specified. Might work with "move to" for them (not sure), but obviously not for the warships - those could get a second zone at sea close to the landing zone to provide cover.

However, the longer the distance those ships have to move, the warships will probably race ahead of the TPs due to higher speed/move. Might be mitigated somewhat by choosing clever unit placing for both sides in that scn.
Do the zone specified in Move To have to be within immediate reach (the unit can reach it directly and move there immediately) - or will the AI find its way toward the zone using general pathing routines?
Units should find their way to a zone even when it takes several turns to arrive, at least I never noticed any problem with this as long there are no obvious obstacles like impassables rivers for land units. Actually now that I think of it I'm not sure if that goes for the "disembark" order too. But you could always direct TPs to a zone at sea first, then order them to disembark from there to a nearby coastal landing zone.
The instances of Move To I've found in existing scenarios always involve single units, and I'm worried Move To would force each naval vessel to visit each and every hex in the zone - which obviously isn't what I want. I want the group to move over to this zone over here, and I just assume I need to make this zone big enough to have one hex for each unit...
(My hopes are that I do not have to lead each and every unit by the nose, and that I have to create an individual set of zone for each unit. That would far too quickly use up all 32 zones... I hope I can direct a group of units with these AI orders)
From my experience, it works quite well, and does certainly not require you to set up a single hex as specific zone for each and every unit you want to move. As you said, it's usually enough to create one zone of several hexes and direct your units to move there. A unit under "move to" order does not have to visit all hexes in the zone, just will default when it has arrived in one of those hexes. You can of course add another trigger giving units that arrived in that zone a new order.
Do units under a Move To command respond to hostile attacks? (Would the warships engage enemies or would they plow straight through ignoring enemies they would shoot at if under Attack/Defend orders?)
The AI attempts to fight its way to the target zone if needed, so will not stay passive while moving.
Molve
Master Sergeant - U-boat
Master Sergeant - U-boat
Posts: 538
Joined: Wed Jul 27, 2011 10:06 am

Re: Using AI orders for a group of units

Post by Molve »

bebro wrote:From the experiences I made while modding:
Thank you.

So "best practices" for an AI amphibious assault would, in your opinion, to
A) create a zone in the water just offshore the target land area (Zone A)
B) create a second zone consisting of the landing beaches (Zone B)
C) Assign the Move To command for units out at sea to move to Zone A
D) Have a script or two that assigns the "Disembark at Zone B" to transports arriving in Zone A, and perhaps "Defend" to warships arriving in Zone A.
E) Have another script that assigns "Attack" (or "Defend") to the newly disembarked land units arriving in Zone B

However:
bebro wrote:A unit under "move to" order does not have to visit all hexes in the zone, just will default when it has arrived in one of those hexes.
Does this not contradict what Rudancort specified? He said:
Rudankort wrote:AI zone is mandatory for the following 5 AI orders:

Move To. The unit will move to the nearest hex in AI zone, then next nearest and until the zone is exhausted. Then its behavior will reset to Default.
That would suggest that unless I use a script to change AI orders (per step D above) the transports would race towards the zone, only to then putter about visiting each and every hex of that zone before reverting to default. Such a zone could easily be ten hexes, and this would cause a 10 turn delay before the AI would even consider disembarking?

(Let me recommend you to check the "Mobile Radar Unit" AI coding of the Alam Halfa scenario of Afrika Corps, if you have it. It utilizes Move To to direct the unit's movement in exact detail, including the technique of zoning its "final destination" hex in order to change its AI orders if and when that final hex is reached)

This technicality notwithstanding, again thank you for your reply!
bebro
Slitherine
Slitherine
Posts: 4575
Joined: Sun Nov 19, 2006 12:50 pm

Re: Using AI orders for a group of units

Post by bebro »

Molve wrote:
bebro wrote:From the experiences I made while modding:
Thank you.

So "best practices" for an AI amphibious assault would, in your opinion, to
A) create a zone in the water just offshore the target land area (Zone A)
B) create a second zone consisting of the landing beaches (Zone B)
C) Assign the Move To command for units out at sea to move to Zone A
D) Have a script or two that assigns the "Disembark at Zone B" to transports arriving in Zone A, and perhaps "Defend" to warships arriving in Zone A.
E) Have another script that assigns "Attack" (or "Defend") to the newly disembarked land units arriving in Zone B
Yes, this would work IMO, though I'd try first if a shorter method works:
Like, create the landing zone A, give TP units the order to disembark to A. Only when I notice the AI has trouble following this I'd do the "move to" (A), then "dismembark to" (B) sequence you propose. But in general, the method you outlined should be fine, and seems the overall safer way.
bebro wrote:A unit under "move to" order does not have to visit all hexes in the zone, just will default when it has arrived in one of those hexes.
Does this not contradict what Rudancort specified? He said:
Rudankort wrote:AI zone is mandatory for the following 5 AI orders:

Move To. The unit will move to the nearest hex in AI zone, then next nearest and until the zone is exhausted. Then its behavior will reset to Default.
That would suggest that unless I use a script to change AI orders (per step D above) the transports would race towards the zone, only to then putter about visiting each and every hex of that zone before reverting to default. Such a zone could easily be ten hexes, and this would cause a 10 turn delay before the AI would even consider disembarking?
I always thought the "move to nearest, then next nearest"-part etc. is for cases in which the nearest hex in the target zone is already occupied - then the unit coming in would try the next hex. But I can't answer that definately, so maybe I'm just wrong on this. When in doubt, just create another trigger to give units arriving in Zone X a new order immediately.
(Let me recommend you to check the "Mobile Radar Unit" AI coding of the Alam Halfa scenario of Afrika Corps, if you have it. It utilizes Move To to direct the unit's movement in exact detail, including the technique of zoning its "final destination" hex in order to change its AI orders if and when that final hex is reached)

This technicality notwithstanding, again thank you for your reply!
No prob :) (haven't checked the AC issue so far, I own it, but it's not installed currently).
Post Reply

Return to “Panzer Corps : Scenario Design”