Scripting questions
Moderators: Slitherine Core, Panzer Corps Design, Panzer Corps Moderators
Scripting questions
1. I`m trying to achieve the following result: when the Axis troops capture the city designated Zone 5 a bunch of units will attack towards the city-Zone 5.
Looking at the scripting in the Streets of Moscow scenario I see that one of the soviet attacks is triggered by designating a number of hexagons as zone 6 and placing the attacking soviet units there. Another hexagon is designated as Zone 5. Then the script has a trigger like this:
Number of Axis flags in Zone 5 is more than 0
and an action like this:
Set AI behaviour of Allies All units in zone 6 to Attacker (AI zone: Zone 1)
I presume that when the Axis units occupy hex Zone 5, all the Allies units that happen to be in hexagons designated as Zone 6 will start attacking. What I`m not sure of is what triggers the direction/target of the attack? I`d like the attacking units to head straight for a particular Zone and attempt to take it, not attack randomly. Also, in the example above what is the purpose of this part: (AI zone: Zone 1)
2. If I shieft-click an unit to edit it there is a field like this: AI zone: Zone 1. Could someone give me an application example making use of this field? Thank you!
Looking at the scripting in the Streets of Moscow scenario I see that one of the soviet attacks is triggered by designating a number of hexagons as zone 6 and placing the attacking soviet units there. Another hexagon is designated as Zone 5. Then the script has a trigger like this:
Number of Axis flags in Zone 5 is more than 0
and an action like this:
Set AI behaviour of Allies All units in zone 6 to Attacker (AI zone: Zone 1)
I presume that when the Axis units occupy hex Zone 5, all the Allies units that happen to be in hexagons designated as Zone 6 will start attacking. What I`m not sure of is what triggers the direction/target of the attack? I`d like the attacking units to head straight for a particular Zone and attempt to take it, not attack randomly. Also, in the example above what is the purpose of this part: (AI zone: Zone 1)
2. If I shieft-click an unit to edit it there is a field like this: AI zone: Zone 1. Could someone give me an application example making use of this field? Thank you!
Re: Scripting questions
In this case of attacker, the AI (here SOV) will move those units from zone 6 towards the nearest player held VH (not necessarily zone 5) when the assigned AI zone (here zone 1) has not been defined.Mark50 wrote:1. I`m trying to achieve the following result: when the Axis troops capture the city designated Zone 5 a bunch of units will attack towards the city-Zone 5.
Looking at the scripting in the Streets of Moscow scenario I see that one of the soviet attacks is triggered by designating a number of hexagons as zone 6 and placing the attacking soviet units there. Another hexagon is designated as Zone 5. Then the script has a trigger like this:
Number of Axis flags in Zone 5 is more than 0
and an action like this:
Set AI behaviour of Allies All units in zone 6 to Attacker (AI zone: Zone 1)
I presume that when the Axis units occupy hex Zone 5, all the Allies units that happen to be in hexagons designated as Zone 6 will start attacking. What I`m not sure of is what triggers the direction/target of the attack? I`d like the attacking units to head straight for a particular Zone and attempt to take it, not attack randomly. Also, in the example above what is the purpose of this part: (AI zone: Zone 1)
2. If I shieft-click an unit to edit it there is a field like this: AI zone: Zone 1. Could someone give me an application example making use of this field? Thank you!
If you want to move those units to a specific area, that you must zone this area, 1 for example; then in the script AI zone: Zone 1.
Re: Scripting questions
Thank you very much for your reply!
Ok, so the target of the attack is designated via the (AI zone: Zone 1) part of the script command (in the vanilla DLC example).
Ok, so the target of the attack is designated via the (AI zone: Zone 1) part of the script command (in the vanilla DLC example).
Re: Scripting questions
You're asking about the different "AI behaviors".
"Attacker" is a general order to go on the offensive as best as the AI can. Like said above, the AI might still do something you didn't expect. In some cases, it will appear to "attack randomly".
The five behaviors that use the AI zone:
viewtopic.php?f=147&t=37945&p=359277#p359277
It's important to note the AI can't see any difference between "attacking" and simply "moving". You'd use the same AI behavior in both cases.
Any of these AI behaviors will look like simple movement if there is no obstacles (=your units) in the way. If the unit can't get to its destination, I believe it tries to get there but not at any cost (i.e. the AI will consider attacking your units even if that isn't the move that brings it the closest to the destination)
Move To = Use this when the zone is a single hex. Also use this when the zone is a series of hexes stringed out in the exact way you want a unit to move. Since Move To means the unit will try to visit ALL hexes of a zone, this isn't appropriate for a general "go attack over here" - when and if the unit reaches the zone, it would obsess by touching all hexes...
Random Move To = Actually quite different than Move To in that this is an order for a SINGLE hex only. That is, the unit only moves to ONE of the zone's hexes and then resumes its default behavior. This makes Random Move To appropriate for the case when you wish a bunch of units to "attack over here" in a non-deterministic way (i.e. each unit of your team selects a random hex out of the zone). With creative zoning you can have a group "fan out" to form a loose perimeter, for instance.
Patrol = Move To but on repeat. Use for when you want a unit to be there only part of the time. Most often when you want a unit to strike when enemies come close a simple "Hold position (active)" will do. I seldom use it. It might be useful for a scenario where you want to sneak a unit through an enemy perimeter, but keep in mind that the unit on patrol won't abandon its path just because it sees you. (If the patrol is recon for other forces it could work of course).
Random Patrol = Like patrol but without the possibility to study and learn the pattern
Not sure when useful...
Disembark = Special use behavior. Use this for AI units that start out their life in a landing craft or onboard transport planes...
One very useful trick to know of is this:
Set your unit(s) to get over to zone A. Also make a script that each time units are detected in zone A, you change the AI behavior of units in zone A to some other AI behavior.
This way you can get an amphibious force to move across the map and only disembark where you want them to (Move or Random Move to Zone A; change to Disembark once they've reached Zone A), or perhaps move back and forth and only at some point deciding to go on the attack (Random Patrol with a "special" hex in the zone triggering a change to Attacking behavior - the Random Patrol means that on one playthru the unit hits that special hex right away, while in the next playthru it never makes up it's mind by always patrolling on nearby hexes only...)
This way scripts can make units mimic very uncanny and human-like behavior! (At least the first few times you play that particular scenario
)
"Attacker" is a general order to go on the offensive as best as the AI can. Like said above, the AI might still do something you didn't expect. In some cases, it will appear to "attack randomly".
The five behaviors that use the AI zone:
viewtopic.php?f=147&t=37945&p=359277#p359277
It's important to note the AI can't see any difference between "attacking" and simply "moving". You'd use the same AI behavior in both cases.
Any of these AI behaviors will look like simple movement if there is no obstacles (=your units) in the way. If the unit can't get to its destination, I believe it tries to get there but not at any cost (i.e. the AI will consider attacking your units even if that isn't the move that brings it the closest to the destination)
Move To = Use this when the zone is a single hex. Also use this when the zone is a series of hexes stringed out in the exact way you want a unit to move. Since Move To means the unit will try to visit ALL hexes of a zone, this isn't appropriate for a general "go attack over here" - when and if the unit reaches the zone, it would obsess by touching all hexes...
Random Move To = Actually quite different than Move To in that this is an order for a SINGLE hex only. That is, the unit only moves to ONE of the zone's hexes and then resumes its default behavior. This makes Random Move To appropriate for the case when you wish a bunch of units to "attack over here" in a non-deterministic way (i.e. each unit of your team selects a random hex out of the zone). With creative zoning you can have a group "fan out" to form a loose perimeter, for instance.
Patrol = Move To but on repeat. Use for when you want a unit to be there only part of the time. Most often when you want a unit to strike when enemies come close a simple "Hold position (active)" will do. I seldom use it. It might be useful for a scenario where you want to sneak a unit through an enemy perimeter, but keep in mind that the unit on patrol won't abandon its path just because it sees you. (If the patrol is recon for other forces it could work of course).
Random Patrol = Like patrol but without the possibility to study and learn the pattern
Disembark = Special use behavior. Use this for AI units that start out their life in a landing craft or onboard transport planes...
One very useful trick to know of is this:
Set your unit(s) to get over to zone A. Also make a script that each time units are detected in zone A, you change the AI behavior of units in zone A to some other AI behavior.
This way you can get an amphibious force to move across the map and only disembark where you want them to (Move or Random Move to Zone A; change to Disembark once they've reached Zone A), or perhaps move back and forth and only at some point deciding to go on the attack (Random Patrol with a "special" hex in the zone triggering a change to Attacking behavior - the Random Patrol means that on one playthru the unit hits that special hex right away, while in the next playthru it never makes up it's mind by always patrolling on nearby hexes only...)
This way scripts can make units mimic very uncanny and human-like behavior! (At least the first few times you play that particular scenario
Re: Scripting questions
@Molve thank you for taking the time to write that enlighting explanation! I now realize that Random Move To was the command I need for a certain action.
A couple of questions:
1. When you use Random Move To what happens if the hex where a unit chooses to relocate becomes occupied by another friendly unit before it arrives? Will it choose another unoccupied hex of the same Zone?
2. I was thinking to have 4 French units (for example) move to Zone 5 and from the moment they arrive counterattack if the Germans take the hex designated as Zone 6. BUT, have only these 4 units counterattack, regardless of the fact that other units (belgian units for example) may end up in the meantime occupying hexes from Zone 5. My plan was to:
a - designate as Zone 5 more hexes than the number of units to ensure that all 4 French units do end up in Zone 5 designated hexes (in case other units pass by).
b - set each of the 4 French units to "AI behaviour Random Move To" and "Zone 5" to get them to their new staging area.
c - since on arrival they switch to default behaviour and I want them to stay there unless something radical happens I will set a script to change their behaviour:
Trigger: Run at: Instantly
Action: Set AI behaviour of Allies Ground units in Zone 5 to Hold position(active) (AI zone: Zone 5)
[Question: does this guaranty that only the 4 French units will have their behaviour changed and not any other unit passing through the Zone 5?]
d - add a script that will make the units counterattack to take back the hex/Zone 6:
Trigger: Number of Axis flags in Zone 6 is equal to 1
Run at: Instantly
Action: Set AI behaviour of Allies Ground units in Zone 5 to Attacker (AI zone: Zone 6)
The problem here is that I can`t see a way to make sure only the 4 French units counterattack and not any other unit that may happen to rest in Zone 5 at the time when the Germans take Zone 6. Any suggestion?
A couple of questions:
1. When you use Random Move To what happens if the hex where a unit chooses to relocate becomes occupied by another friendly unit before it arrives? Will it choose another unoccupied hex of the same Zone?
2. I was thinking to have 4 French units (for example) move to Zone 5 and from the moment they arrive counterattack if the Germans take the hex designated as Zone 6. BUT, have only these 4 units counterattack, regardless of the fact that other units (belgian units for example) may end up in the meantime occupying hexes from Zone 5. My plan was to:
a - designate as Zone 5 more hexes than the number of units to ensure that all 4 French units do end up in Zone 5 designated hexes (in case other units pass by).
b - set each of the 4 French units to "AI behaviour Random Move To" and "Zone 5" to get them to their new staging area.
c - since on arrival they switch to default behaviour and I want them to stay there unless something radical happens I will set a script to change their behaviour:
Trigger: Run at: Instantly
Action: Set AI behaviour of Allies Ground units in Zone 5 to Hold position(active) (AI zone: Zone 5)
[Question: does this guaranty that only the 4 French units will have their behaviour changed and not any other unit passing through the Zone 5?]
d - add a script that will make the units counterattack to take back the hex/Zone 6:
Trigger: Number of Axis flags in Zone 6 is equal to 1
Run at: Instantly
Action: Set AI behaviour of Allies Ground units in Zone 5 to Attacker (AI zone: Zone 6)
The problem here is that I can`t see a way to make sure only the 4 French units counterattack and not any other unit that may happen to rest in Zone 5 at the time when the Germans take Zone 6. Any suggestion?
Re: Scripting questions
Any unit in that stops in that zone 5 will change its behavior.
You could add a time condition. Say between turn 5 and 7.
The only units that stop in zone 5 on turn 5, 6 or 7 will change their behavior.
You could add a time condition. Say between turn 5 and 7.
The only units that stop in zone 5 on turn 5, 6 or 7 will change their behavior.
Re: Scripting questions
That`s somewhat disappointing. I think we need a Group function for units (as the Zone function is for hexes) to be able to designate specific units and issue more detailed scripting actions. Otherwise, if you have two groups of units that should head to two different zones where they should afterwards receive different orders and the units from one group happen to pause on their way in the other groups`s zone their behaviour is reset and they`re stuck there. If I understand things correctly. The only thing to do is what you`ve suggested with the turns time limit for the orders on arrival to trigger, but that would require many scenario tests to set properly and even then it wouldn`t be a sure thing.
Re: Scripting questions
I think it's better you start by explaining, in plain English, what you want happening, and we'll help you from there.
Part of the skill of a scenario designer is simplifying. Meaning that oftentimes you can switch out complex behaviors and still achieve almost the same result by remarkably simple scripting. (Which is especially good, since that's the only kind of script that work well
)
So tell us your basic scenario idea first, and let's worry about specific scripting questions later.
Part of the skill of a scenario designer is simplifying. Meaning that oftentimes you can switch out complex behaviors and still achieve almost the same result by remarkably simple scripting. (Which is especially good, since that's the only kind of script that work well
So tell us your basic scenario idea first, and let's worry about specific scripting questions later.
Re: Scripting questions
If you make the Zone 5 with 4 hex fields and give the counterattack-units a Special Name you could ask for 4 Units in Zone 5 with Name ... to Change their Action to attack.
But if some other Units in Zone 5. the counterattack will never start
But if some other Units in Zone 5. the counterattack will never start
Re: Scripting questions
Could you please tell me how to set the attack for units with a specific name?fsx wrote:If you make the Zone 5 with 4 hex fields and give the counterattack-units a Special Name you could ask for 4 Units in Zone 5 with Name ... to Change their Action to attack.
Re: Scripting questions
lolMolve wrote:I think it's better you start by explaining, in plain English, what you want happening, and we'll help you from there.
Part of the skill of a scenario designer is simplifying. Meaning that oftentimes you can switch out complex behaviors and still achieve almost the same result by remarkably simple scripting. (Which is especially good, since that's the only kind of script that work well)
So tell us your basic scenario idea first, and let's worry about specific scripting questions later.
I don`t have the exact details figured out yet as I`m still researching the historical dispositions so I should probably post again when I have the final plan firmly set. Broadly speaking, I`m editing a Fall Gelb scenario with the aim that at the scenario start the French units will be in France and that in the first turn they will start implementing the Dyle plan by moving in groups representing different armies/corps/divisions to different defensive areas so to speak that are in Belgium.
For gameplay as well as historical reasons I also want some of the groups (the armoured units) to stage counterattacks after arrival in their designated zones when the Germans take targets like Dinant, Namur and Liege. The rest of the units I expect to stay put on their new Zones and wait for the Germans to arrive.
The problematic part I anticipate will be the area east of Brussels because coming from the south-west, most french units would probably pass through the southern staging Zone to get to their own Zone. I fear that they might end up on hexes they`re not supposed to and have their behaviour/action set to something they`re not supposed to have (infantry counterattacking, tanks staying put etc.).
Re: Scripting questions
Use as condition for the counterattack:Mark50 wrote:Could you please tell me how to set the attack for units with a specific name?fsx wrote:If you make the Zone 5 with 4 hex fields and give the counterattack-units a Special Name you could ask for 4 Units in Zone 5 with Name ... to Change their Action to attack.
1. if the Player captured the City AND (as second condition)
2. the AI has 4 units with <Name> in Zone 5 (sorry in the screenshot are 5 Units)
And the Action is to set the Units in Zone 5 to attack
- Attachments
-
- condition.jpg (105.65 KiB) Viewed 3177 times
Re: Scripting questions
Ah, I see what you mean now. Interesting solution. Thank you!




