Simple Scripting

17.  What should my first trigger look like?    

"Trigger 0" (which of course can be renamed by you!) is very important as it usually sets the scene/conditions that the game will be played under: alliances, starting resources, as well as toggling any flags which need to be used later in the game.  This "startup" trigger is often one of the longest in a game -- indeed it can be the only trigger besides ones to set defeat/victory.  More detailed descriptions of how to do these follow.

18.  How do I make the players enemies?

The default of all missions is that all players (colors) are allied.  This can make for a fairly boring game, so you will probably want to break the alliances (or establish new ones) early on in your script.  To do this, select "Change relations between players" from the "Players" action menu. In the Relations dialogue box, drag any colors that are to be friends onto the same line.  Even though the default setting is "all friends," when the dialogue opens it's set up as "all enemies" -- so unless you have plans to the contrary, you can usually simply click "OK" after bringing up this dialogue box.

Example:

CONDITION

      ALWAYS

ACTION

      Change relations between players.  [Details can only be seen by clicking on the action and editing it.]

NOTE:  When setting up your map, it's a good idea to use Peace Mode, especially if the players begin with an alliance that is broken during the course of the game.  Click on the white dove in the Map Editor control palette.  "Peace Mode" will be indicated to the left of the mini-map.

19.  Can I make a color neutral?    

No, neutral players are not possible with the Scenario Editor.  It is possible to establish more complicated alliances using the "Szenario Tool," which is actually just a library of C++ programming functions used by the Cossacks game engine.  This "tool" is not for novices and requires a C++ compiler.  If you're interested, there is a small tutorial available (insert link)

20.  Can the player be a color other than red?    

The short answer to this question is "no."  There is no provision for choosing a different color in playing a Single Mission, and selecting a color other than Red when playing a "designed map" produces unsatisfactory results.  Essentially, any selection made by the script will override YOUR selection; to command your troops you will need to hit "pause" otherwise they won't remain selected long enough for you to give orders.  Red, however, is immune to these adverse effects; scripted selection and ordering is largely transparent to the player.

However, you CAN use other colors as friendly units, which are not directly controlled by the player.  Some possibilities are for deserters (changing color of certain units from Red to another color); allies commanded by triggers; local villagers that go about their business without interfering with you; etc.  Unit color can be changed within the game, giving control to (or taking it away from) Red at will.

NOTE:  Brown is a special color .Mutinied units automatically change to brown in game if you run out of gold.  If Brown is set in alliance with Red, then they won't attack you (and will defend against other enemy units), but they cannot be controlled by the player.  However, Brown is "AI-disabled:" their national AI cannot be launched, and Brown peasants can only build a few limited structures.  (Try using Brown peasants in the Map Editor to see what's available to them.)  Therefor, Brown should only be used for non-building players, deserters, retreating units, etc. -- they cannot be used as an independent eighth player.

21.  How do I set resource levels?

There are two ways to do this: within the Map Editor, and via triggers in the Scenario Editor.

The Map Editor is great for setting up equal resources for all players (which can be modified via scripts).  Select the "Set Starting Parameters" tool from the control palette.  A dialogue opens up, the main feature of which is six text entry boxes for each of the resources used in Cossacks.  For Fixed Force maps it's a good idea to be exorbitant and give everyone huge amounts of everything.  This can be achieved by setting numbers and selecting "All" from the player list.  Don't worry about the other parameters, as those will be taken care of in your scripting.

In the Scenario Editor, you can also set each resource via a number of "Resources" actions:

A.   Set player <name> <quantity> of <resource>.

 

This can be used in a startup trigger to alter the default settings for a game, e.g. if you want to give Red only a limited amount of gold while other players have been given more.  Something like:

CONDITION

      ALWAYS

ACTION

      Set player <Red> 2500 of gold.

...will give the player that much gold to start with. You can also add or subtract to the resources a player has within a game, say to reflect trades between the player and a "non-player character."

Example:

CONDITION

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

ACTION

      Take from player <Red> 1000 of gold.

      Add to player <Red> 5000 of food.

This trigger would simulate a trade of 1000 gold for 5000 food, brought on by the player's General unit group entering the merchant's zone.  (You can learn how to add messages and questions to such triggers later in the FAQ.)

22.  How do I give control of a color to the AI?      

The "Computer Player" action list has the command you need:  "Give control to computer player."  The action is long but don't be daunted!  Here's a quick breakdown of the parts you have to set.

A.   Launch <intelligence> for player <name>.

This presents you a list of nations to choose from.  Be sure the units of the color you pick match the country you select!  Note that Prussia is mislabeled as Germany.  

B.   Difficulty level: <difficulty>.

Self-explanatory.

C.   Terrain type: <relief>.

This actually tells the AI whether you're playing on a map with water, and how much if so.  Essentially it controls whether or not the computer player will bother building a shipyard.  If you don't want the computer building one, select "land."

D.   Resources: <funds>.

Gives the AI an idea of what level of funding it starts out with.  If you have pre-placed units for that nation in addition to the starting peasants, you should probably tell the computer it has less to work with than it really does.  The AI is designed to build from the ground up and has a hard time adjusting to an "advanced start."

E.   Minerals: <resources>.

This tells the AI whether it should be aggressive in its search for ore deposits or if it shouldn't worry about resources.  If you want to create an AI that squanders what it has, try placing only a handful of resources and telling it there's plenty.

Example:

CONDITION

      ALWAYS

ACTION

      Launch <Germany> AI for player <Turquoise>.  Difficulty: <hard>.  Terrain type: <Mediterranean>.  Resources: <normal>.  Minerals: <lean>.

NOTE:  You don't have to launch an AI if you don't want to.  In fact, in many scenarios (esp. fixed force style) it's best not to.  With a bit of time and thought you can script decent reactions into the mission itself.  If you've placed units on the map for the computer player, don't be surprised if they run off and go places you don't expect; the AI often has unique ideas on what to do.  Of course, if all you're after is a random-map style game based on your specific scenery, there's no other trigger that will duplicate that experience.

23.  What does "Don't use selected units by computer player" do?    

This action can be used to reserve a group of units for scripted use, so they don't run off and do their own thing while waiting for their trigger to be activated. 

Example:

CONDITION

      ALWAYS

ACTION

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

      Don't use selected units by player <Blue>.

(For more information on selecting units, see Question 28.)

 

 

24.  What are mission objectives and how can I set them?    

Mission objectives are a special type of flag (see below) which can be used to help guide a player through your mission.  Technically speaking, they have no bearing on the outcome or course of the game -- they simply appear in the Mission Objectives window (brought up with F1).  There are no conditions that check if an objective is met.

To set and show an objective, use the "Show Objective" action.  Clicking on the objective will allow you to select one and rename it.  Objectives CAN include spaces in their names.  However, keep in mind that you have only 12 objectives to use!

Example:

CONDITION

      ALWAYS

ACTION

      Show objective "March your troops to the village in the west."

NOTE:  Objectives are included in the .txt file created for each mission and can be edited outside of the Scenario Editor.

25.  How do player objectives be reflected as met?    

An objective is shown as met by changing the message to strikethrough text.  "Reflect objective as met" is the action that toggles this.  Again, since mission objectives aren't checked or marked as completed through any game process other than these actions, you can show objectives as met, and then unstrike them later if you wish!

Example:

CONDITION

      Number of units of player <Red> in zone <Village> is more than 10.

ACTION

      Reflect objective "March your troops to the village in the west." as met.

NOTE:  You can also hide objectives using that action, if you wish.  This will cause an objective to "disappear."  Objectives neither shown nor reflected as met are automatically hidden.  Hiding objectives can be useful mainly if their being met becomes impossible, e.g. if a unit the player is to bring to a specific zone is killed.

Example:

CONDITION

      Number of units in group <Merchant> is less than 1.

ACTION

      Hide objective "Escort Lorenzo da Capua to the town of Abruzzo."

26.  How do I define victory conditions?  

Victory (and defeat) conditions are set via "Endgame" actions.  The actual conditions are left up to you.  One common trigger is "Number of Units > Player has already been vanquished," which checks if there are any units of the color selected remaining.

Example:

CONDITION

      Player <Red> has already been vanquished.

ACTION

      Victory.

27.  How do I define conditions for defeat?    

Defeat conditions are defined the same as Victory conditions.  Some possibilities include your forces being reduced below a certain number (from a fixed start), or that your Town Hall is captured.

Example:

CONDITION

      Number of units of player <Red> in group <RedHall> is less than 1.

ACTION

      Defeat

28.  How do I select what units to control?

 Unit selection isn't always the most intuitive process in Cossacks: The Art of War.  Some triggers allow you to directly control a group of units (e.g. "Carry out upgrade"), but most require you first to make a selection, then give an order (or series of orders).  There are a lot of options in the "Select Units" menu, so we'll cover them one by one.

Each select action has a bit at the end which reads "...by changing/adding to previous selection."  This is important, especially when you wish to give the same order to several groups of units at once.  Changing the selection clears out whatever has been selected previously (but see below on deselecting).  Adding to the selection does just that: it temporarily groups the units together for receiving orders.

A.   Select all units of group.

 

Obvious at first glance.  The trick to note, however, is that this selects units of any color within a group.  Groups can be comprised of different colors, so it sometimes happens that you have (say) both Red and Blue units selected through this command.  Most operations, however, force you to select a color within an existing selection... so, for example, you can't order both Blue and Red units to attack their Orange enemy at once.  Something like this will take separate commands.

B.   Select player's group units.

This command will pick out only one color unit within a group.  Using this option is usually unnecessary, since most commands will operate on only one color anyway.

C.   Select player's units in zone.

This is a very versatile selection tool, because it facilitates dynamic orders based on what units are where on the map.  You'll see it used in plenty of examples later on.

D.   Select player's units of a certain type in zone.

This command will, say, select only the 17th century Netherlands riders of player <Orange> in a zone, ignoring the pikes, muskets, etc.

E.   Select units of a certain type by player.

This selects all of one particular type of unit, which can then (for example) be placed into a Dynamic Group (see below).  This is quite useful in certain situations, e.g. if you wish to exclude battleships from shoals defined by zones.

29.  Why should I use deselect player units?    

While "changing previous selection" usually clears out whatever's been previously selected, it cannot be relied upon to do its job.  Therefor it is always a good idea to deselect units before making a new selection, unless you have a specific goal in mind.  This is particularly important when dealing with units of player Red, as without taking this precaution, sometimes the units the player's selected (to issue commands, or whatnot) will be included in the next selection!

30.  Can I make peasants gather food, chop wood, or quarry stone?

Yes indeed!  There's a whole menu devoted to "Resource Procurement," which has actions to order peasants to do their gruntwork.  As long as there are enough resources close by, peasants will automatically collect food etc. when given this command.

Example:

CONDITION

      ALWAYS

ACTION

      Order peasants of group <Villagers> to gather food in place of their location.

31.  Can I make peasants enter a mine?    

Not really; there's no command that allows you to do this.  You can, however, script a mine to be built on a deposit which 5 peasants will automatically enter.  Place a zone directly on top of an ore deposit in the Map Editor with a few peasants in a group called "Miners" and try something like the following:

CONDITION

      ALWAYS

ACTION

      Create <Mine> unit for player <Red> in zone <MineZone> and assign to dynamic group <Mine_Dyn>.

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

      Repair/build up buildings of group <Mine_Dyn> with selected peasants of player <Red>.

The mine will be built and peasants will enter it as normal.  Unfortunately upgrading these (or any) mines in scenarios is impossible, and even if it were there would be no way to get more workers into them.

NOTE:  In each country are three "Mine" units, listed without differentiation.  The first is for gold; the second, iron; and the third, coal.  Strangely enough, Cossacks: The Art of War isn't picky about what kind of mine you order placed on a deposit.  If you order an iron mine constructed on a gold vein, your workers will happily do so!  They'll still be pulling gold out of it, however, even if the graphic shown is for a different resource.