Intermediate Scripting

32.  What does "saving waypoints" do?   

Most movement and attack commands have two options: to save or to not save waypoints.  A waypoint is a "place" in the game environment (a set of coordinates corresponding to a point on the map) to which units will proceed when ordered to move.  When you control and move formations, you see the waypoints represented by little yellow dots on the map.  "Saving" these, in scripting terms, makes waypoints persist beyond the immediate command given.  This has significant consequences for units in formation.

For single units, the game seems capable of handling unit movements with or without saving waypoints.  For formations, however, saving waypoints is crucial.  Without waypoints to guide them, units in formation seem incapable of finding their way on the map and will stay put -- as if ordered to "stand ground" but without gaining the benefit of a bonus.  With saved waypoints, units in formation will find their way to their destination.

However, there's a downside to saving waypoints for units in formation: they can be interrupted.  This is most obvious when ordering units of player Red about on the map, as he or she can take control and give them countermanding orders.  The strange thing about this is that, once those new orders are carried out (i.e. destination reached), the "old" waypoints appear again and the formation will resume its march towards the scripted destination.  Even with a repeated trigger (see below) this cannot be defeated.

Therefor, if you ever need to have Red units move without possibility of being interrupted by the player, you will need to break the formation and/or transfer the units (temporarily) to another color.  This can be achieved with with "Change unit color" from the "Operations on units" menu.

33.  How do I make the enemy units attack?    

Fighting is arguably what Cossacks: is all about, and you have plenty of ways of ordering death and destruction on the battlefield of your scenarios.  The simplest is to do nothing: if enemy units are approached, they will defend themselves unless under orders to hold fire.  This doesn't cut the mustard for most scenarios, however, so more sophisticated ways of promoting pugilism are described below  

A.   Attack enemy with units selected.

This option is good for targeted attacks against a specific group.  The upside is, your units will attack that group and only that group, and not stop until they or their target are defeated.  The downside is, your units will be blind to any other attacks and rather easily fall for any "bait" sent their way.  Use with care!

Example:

CONDITION

      Number of units of group <RedDragoons> in zone <MountainPass> is more than 10.

ACTION

      Select all units of group <BlueIntercepters> by changing previous selection.

      Selected units of player <Blue> attack group <RedDragoons>.

B.   Attack enemy in zone with group of units.

This trigger does not work; the group units "ordered" stand by idly.  For reference (in case you accidentally use it and need to troubleshoot a group of shirkers), the trigger syntax is:

 

"Units of player <name1> attack enemies in zone <name2> with group <name3>."

C.   Order selected units to go and attack saving waypoints.

"Go and attack" is one of the most versatile and reliable actions for ordering attacks in Cossacks: The Art of War.  If an enemy unit is in or near the path between a group and its target zone, it is in peril.  The advantage of using this trigger is that attacking units will respond normally to new threats -- no "falling for the bait."  The downside is that if the enemy is not encountered in their path, they will be eluded.

Example:

CONDITION

      Number of units of player <Red> in zone <TargetZone> is more than 0.

ACTION

      Select all units of group <SaxonCavalry>.

      Order selected units of player <Orange> to go and attack to zone <TargetZone> saving waypoints and place them in direction <127>.

NOTE:  This trigger will save the waypoints of the group ordered to attack.

D.   Order selected units to go and attack without saving waypoints.

Exactly the same as with the last action, only waypoints will not be saved.

NOTE:  This trigger seems immune to the adverse effects of unsaved waypoints on formations, so use it freely.

E.   Attack zone with artillery.

Another action that doesn't work.  For reference, the syntax is:

"Attack zone <name1> with <name2> player's artillery from group <name3>."

F.   Attack buildings in zone.

Yet another action that doesn't work.  Syntax:

"Attack buildings in zone <name1> with <name2> player's artillery from group <name3>."

 

34.  How do I order enemy units from one point to another?  

Go to "Unit Orders" and select one of two options: "Order selected units to go to zone saving waypoints" or "Order selected units to go to zone without saving waypoints."  Once you understand the implications of waypoints (see Question 32), it's a fairly straightforward operation.

 

Example:

CONDITION

      Number of ticks after the game beginning is more than 5000

ACTION

      Deselect units of player <Red>.

      Select all units of group <RedScouts> by changing previous selection.

      Order selected units of player <Red> to go to zone <EastFord> saving waypoints, place them in direction <223>.

You can also order units to patrol between a location and a zone.  This is an easy way to make guards that tirelessly patrol the perimeter of a fort, or never-ending barge traffic on a river.

CONDITION

      ALWAYS

ACTION

      Deselect units of player <Red>.

      Select all units of group <RoyalGuard>.

      Patrol territory with selected units of player <Red>, starting from their location to zone <PatrolPoint>.

35.  Can I order one unit to guard another?    

This feature is missing in the Cossacks: The Art of War scenario editor.  You *can* order friendly units to "attack" their comrades, which will keep them in close proximity; see the Cossacks Engineers' Toolkit (Dedicated Gun Crews) for an example.

36.  How do I determine the starting position of the player's screen?    

In "Map" there is a command called "Set screen into zone."  This action can be used any time, but is perhaps most useful at the start of the game to ensure the player "starts" with a view of his base (or another important game feature), and not wherever you left the screen when you last saved the map.

Example:

CONDITION

      ALWAYS

ACTION

      Set screen into zone <RedTown>.

NOTE:  This command does not reveal any of the map not already visible to the player.

37.  Can I make parts of the map visible through the Fog of War?    

To reveal a hidden area of the map, use the command "Open map area."  This trigger is a bit confusing, because you have to "number" a map area as you select the zone to reveal, and give a radius in terms of the field of vision of a pikeman (=1).

Example:

CONDITION

      Number of units of group <Guide> in zone <Rendezvous> is more than 0.

      Number of units of group <General> in zone <Rendezvous> is more than 0.

ACTION

      Open map area 1 of radius 2 in zone <WhiteBase>.

Thus, if the above Guide shows up at his Rendezvous place and meets the player's General there, an area of twice the field of vision of a pikeman (approx. the same as a 17th century drummer) will be revealed centered on the White player's base.

NOTE:  To hide a map area again, you need to use "Close open map area."  This will not blind units, however.

Example:

CONDITION

      Number of units of group <Guide> is less than 1.

ACTION

      Close map area numbered 1.

38.  What do flags do?    

Flags are the game's "toggle" switches.  They have only 2 states: on and off (or True or False if you prefer).  Their uses are innumerable: they can be used to regulate triggers and timers, "store" information, help set up complex responses to game situations, etc.  Their use is fundamental in advanced scripting because they can be used in combination with each other (and other factors), so that activities separated in time and space on the game map can affect each other.

By default all flags are set to ON.  While it's conceptually easier to turn the flags you'll need OFF at the beginning of a scenario, this takes up space which could be used for other things.  You have the option of naming flags when toggling them.  These names persist, and it's a good idea to name your flags intelligently so you can readily refer to it in other triggers.

To get a taste of working with flags, try something like the following-two-trigger example:

- Western Approach Detected

CONDITION

      Number of units of player <Red> in zone <WestApproach> is more than 0.

ACTION

      Select all units of group <AdvanceGuard> by changing previous selection.

      Order selected units of player <Black> go and attack to zone <WestApproach> saving waypoints and place them in direction 0.

      Select all units of group <CavalryFlank> by changing previous selection.

      Order selected units of player <Black> to go to zone <FlankZone> saving waypoints, place them in direction 95.

      Turn flag <WestFlag> off.

- West Flanking Maneuver

CONDITION

      Number of units of group <AdvanceGuard> is less than 20.

      Flag <WestFlag> is off.

ACTION

      Select all units of group <CavalryFlank> by changing previous selection.

      Order selected units of player <Black> to go and attack to zone <WestApproach> saving waypoints and place them in direction 223.

This pair of triggers would make Black's AdvanceGuard attack the approaching (red) player units in the WestApproach, and send their cavalry into a flanking position.  After the AdvanceGuard has suffered a few losses, the cavalry is then sent into the fray.  The power in this example is that it leaves the CavalryFlank's options open should the AdvanceGuard be intercepted from another direction, and the Western Approach avoided entirely by the enemy.

39.  How do timers work?    

Timers, as the name implies, are ways of adding time-dependent elements into a Mission Script.  There's one action and three conditions that work with them:

A.   Set timer <name> for <number> ticks.

This is how you set timers.  You can set them for any integer, but the smallest practical timing is about 20 ticks.  You can and should name your timers while selecting which one to set, so you can keep track of what's setting what off.

B.   Timer has snapped into action

Once a timer has "rung" it has snapped into action.  This condition checks to see if a timer has gone off.

NOTE:  Once a timer has rung, it "stays rung" indefinitely!  There's no true way to "clear" this out, so if you do need to turn a timer "off" the only way to do it is to set it again for a large number of ticks.  1,000,000 is a good place to start.

C.   Timer has not snapped into action.

If you need something to happen before a timer goes off, but not dependent on how much time is left before it does, this is the condition for you.  

D.   Number of ticks before timer snaps into action.

As it says.  This can be used for a lot of things, such as "extending" a timer under certain circumstances, e.g.

CONDITION

      Number of ticks before timer <ForestTimer> snaps into action is less than 100.

      Number of units of player <Red> in zone <ForestPath> is less than 1.

ACTION

      Set timer <ForestTimer> for 1,000 ticks.

...will reset the timer for (about) another minute if Red hasn't arrived at the forest path yet.

NOTE:  If a timer has not yet been set, the number of ticks before it snaps into action is 0.  This will activate triggers that use "Number of ticks before timer snaps into action is less than <number>" unless that number is either 0 (making the condition equivalent to "Timer has snapped into action"), or there's a flag included as another condition to tell the game when it's OK to start waiting for the countdown.  See below, "How do I work with gates?" for an example.

NOTE:  Remember that a fast PC will tick/count faster than a slower PC, also dependent upon your game speed settings.
 

40.  What does "Activate Current Trigger" do?  

When a trigger has been activated (used) it is "closed" and, by default, will not be used again.  To force that trigger to open (allow it to be used again), you need to add "Activate Current Trigger" (from the "Basic" list) within it.  Otherwise, your trigger is a one-shot affair.

 

This reactivation happens almost instantaneously, which is both good and bad.  It's good in that it can make a trigger quite persistent, which is sometimes needed.  It's bad in that not only can it get out of hand if not properly regulated, but the player can exploit that slight delay between iterations -- say if his units' attack is disabled through a trigger.  In that example, especially with ranged fire, a click will fire a volley at the enemy before the repeating trigger can repress it.  Read on if you want some additional hints!

41.  How do I regulate looping triggers?     

If a trigger using Activate Current Trigger isn't properly regulated, strange things can happen: units can be created infinitely, troops will get stuck at their destination, your trigger causes the game to crash, or it just won't work.  Therefor, usually when you need a repeating trigger, you will need to set up a control mechanism to make sure it doesn't get out of hand.

One of the most effective techniques for doing this is by using flags.  If a repeating trigger turns off a flag, and that flag being on is a condition of the trigger being activated, the trigger will "close" until the flag is turned back on (with another trigger).