Cossacks 1,2 and 3 Info Site - Triggers
A trigger is the main logic unit for scenario building.

Getting Familiar with Triggers In any mission, the player is supposed to accomplish certain tasks. Accomplishing these provokes responsive computer actions. A trigger is the computer's response to a player's action. For example, the player is supposed to kill the enemy general in order to win. The general's death is a condition the trigger responds to, and conferring victory upon the player is the computer's response. An event leading to the trigger is called a "trigger activation condition". The trigger's response is called a "responsive action". At the beginning of the mission, all triggers are active and will snap into action as soon as the condition is performed. Having worked once, the trigger is deactivated and will never work again. To force it to operate once again, use the "Activate current trigger" option. 

Condition A condition will be met or not, as the case may be. Here's an example of a condition: "Amount of food owned by red player is more than 1000". If the red player has more than 1000 units of food, this condition is met. A condition may be either simple as in the previous example, or complex, i.e. a combination of simple conditions. Complex conditions are considered met if every simple condition contained within them is met. If a condition is met, the scenario will perform commands from the action section and this trigger will become inactive.

Action Commands in the action block are performed consecutively, one by one. Thus, in certain cases, any changes in the array of commands may lead to undesirable consequences, frequently quite deplorable ones. To simplify non-linear plot creation, there is an "Inserted condition block" action.

Inserted Condition The action "Inserted condition block" is used to heed some secondary parameter inside the trigger (for example, mission difficulty level). This action consists of three sections, i.e. an "If" section similar to the trigger condition section, and two action sections. The "Then" section contains commands fulfilled when the "If" condition has been met. The "Else" section contains commands fulfilled when the "If" condition is not met. There are two ways of provoking different computer reactions for difficulty levels. The first is to create a separate trigger for each difficulty level. Trigger condition sections will differ only in one simple condition, the "difficulty level". Another way is to use only one trigger with its action section containing the "Inserted condition block" actions for each difficulty level. So, it's up to you which way to go.

Manipulating triggers The trigger list is presented by the TreeView element, the element displaying the tree of folders in the Windows Explorer. Commands for manipulating triggers are located either to the right of the trigger list or in the "Edit" menu. Click on "New Trigger" to add a new trigger. Every trigger is given a name that can be changed by selecting the trigger and clicking on "Change …". If necessary, you can duplicate a trigger by selecting the "Duplicate" command. Select a trigger and use the "Delete" command to delete it. The order of triggers can be changed with the help of the "Up" and "Down" commands. Each trigger consists of two sections, i.e. "Condition" and "Action". To make these sections visible, click on the plus sign to the left of trigger name.

"Condition" Section This section contains the list of simple conditions for a given trigger. Their order is of no importance. The trigger will work only if every simple condition is met. By default, this section contains the simple condition "Always". This means the trigger doesn't require a player to perform any actions and will snap into action as soon as it is activated. To add a new condition, use the "Add Condition" command. A condition will be added to the right trigger if the trigger list pointer is placed either on the name of the trigger, on the name of a section - i.e. "Condition" or "Action" - or on the name of any simple condition or action of these sections. Each condition constitutes a statement. For example, "Amount of gold possessed by red player is more than 1000". The "Add Condition" command brings up a dialogue that allows you to select a condition. In the upper part of the window there is a set of all conditions split into groups. In the lower part is a condition you can set parameters for. Changeable parameters are displayed in white and underlined. By default, every parameter is not set, but presented by a key word. For example, the key word for the amount of resources is quantity, and resource is the key word for naming a resource. As soon as you have set all parameters, the "OK" button is activated. Press this button to finally add a condition to the "Condition" section. Simple conditions can also be changed, deleted, and duplicated in the current section. In addition to that, you can change the order with commands analogous to those for the triggers.

"Action" Section This section contains the list of the computer's retaliatory actions. If the trigger snaps into work and the "Action" section is empty, no computer response will be generated. A simple action can be added using the "Add Action" command. When working with actions, you act in the same way as with conditions. But the order of the retaliatory actions may now affect the response. Actions are performed one by one, starting at the top. An example of an incorrect trigger location: The "Attack enemy with selected units" command implies that units have already been selected. Therefore, the "Select Units" action must be performed beforehand.

"Inserted condition block" Action This action, like any other, includes the name of the action. It differs in that it has three more sections. The "If" section is similar to the "Condition" trigger section. Two other sections - "Then" and "Else" - contain actions. To add a condition to the "If" section, set the cursor on a name or on one of this section's conditions and use the "Add Condition" command. Actions are added into the section where the cursor is. As for the rest, these sections are totally analogous to the "Condition" and "Action" sections.

Description of Parameters for Conditions and Actions Click on this to change the value of either a condition, or an action parameter. This brings up a dialogue window asking you to select the value of this parameter. This section contains a description of all parameters possible and uses dialogue windows to set them. Mostly, the value of a parameter is an element of some list. Sometimes the name of the element can be changed with the help of the "Rename …" button. To acquire a text field consisting of several paragraphs, press "Ctrl+Enter".


Flags and Timers Flag can be either on or off. A flag's status is defined by the mission maker. By default, all flags are on! Timers are used if an action is to be performed with a time delay. First, set the timer using the "Set Timer" action. Before the time you have set elapses or if the timer has not been set, it is considered "not rung". When the time elapses, the program considers the timer to have "rung". Time is specified in inner conventional Cossacks engine ticks. On more powerful machines, the timer will ring sooner than on slower computers! There are 256 flags and timers available for users. A dialogue window for flag and timer selection lists all changeable names.



Time This parameter defines the time in Cossacks. Each timer tick is proportional to animation ticks or FPS. Under slow play mode, a timer tick corresponds to one frame. For example, if your computer has FPS=25, that means the Cossacks engine will display 25 frames and 25 inner ticks will elapse. At fast speed, every animation frame is equal to two inner ticks.

Groups and Zones These are the most frequently used parameters when writing missions. Zone and group creation can only be performed in the map editor if you have previously activated "Scroll Lock" on your keyboard! A group can include both units and buildings. Grouped units and buildings are framed yellow. In the upper middle part of the framework, the name of the group is displayed. A zone is a map area limited by a yellow circle of a certain radius. In the centre of the zone is a sign stating the zone's name. Units of a certain group may trespass a map area belonging to some zone. If so, at this very moment a trigger will be activated and a responsive computer action will be performed. To create a group, select units and buildings to be included in the group and, using the "Create Mission Group" tool or pressing "Ctrl+Enter", enter a group name and press "OK". It is impossible to add new units to a group with one command. To do this, you need to delete an old group and create a new one bearing the same name, but with new units this time. To delete a group, place mouse cursor inside the yellow frame. Its colour should change to white. Press the "Delete" key. Using the "Create new group of units" action, you can generate dynamic groups of units while running the scenario. Dynamic and editor-created groups may contain units belonging to different players! One unit may belong to different groups! To place a new zone you need to press "Ctrl+Enter" or use the "Create Mission Zone" tool located in the tool panel. Note that none of the buildings or units must be selected at this moment. Once this operation has been completed, enter a zone name into the text field and press the "OK" button. On the tip of the mouse pointer a sign will appear stating the zone name. Select an area on the map to specify the zone's centre and press the left mouse button. By default, the zone radius is set to zero. To change the radius, take the mouse pointer to the bottom of the zone name sign and press the left mouse button. Without releasing the button, move the pointer away from the zone's centre. By releasing the button, you will set the zone radius. In order to change the radius later on, you should place the mouse cursor on the zone's circumference. To change a zone's location, grab the name sign at the bottom and move the zone. You can delete a zone by pressing the "Delete" key while moving the zone. Be careful when deleting groups and zones. In the map editor there is no undo command! If there are some units selected and you have met the conditions for deleting some zone and group at the same time, then pressing the "Delete" key for the first time will delete the group, and pressing it again will delete the zone. Pressing it once more will delete the units selected. Dialogue windows of group and zone settings present lists of names which are not to be changed. The group list also includes dynamic groups, with names which can be changed.

Dynamic Groups The scenario editor saves dynamic groups automatically. By default, it contains no units. There are 64 dynamic groups available for users. While playing a mission, i.e. while a scenario is being played, the units comprised in these groups may change. For example, newly selected units can be added to existing units of a dynamic group with the "Save player's selected units to dynamic group" action. With the help of the "Create new group of units" action, you can have new units show up immediately on the map during the scenario performance. Standard names of dynamic groups, i.e. "GroupXX" - where XX is a number between 0 and 63 - can be changed in the dialogue window for dynamic group selection only. The dialogue window for group selection contains group names and groups created in the map editor and their names cannot be changed. You can't rename groups in this window.

Players Before the game starts, every player is assigned one of the eight possible colours. The maximum number of players is therefore eight. In single player missions, a player will always be red! The other colours are available for computer rivals. Apart from the colour, each player is given a name. Before starting any mission, the player sets a name for himself. The computer players require a name to be assigned to them. By default, player names coincide with their colours. But they can be changed if you like. If there is no unit or building of some colour, then the name of this player is not displayed in the information window.

Objectives While playing the mission, pressing the "F1" key opens the "Mission Objectives" window, where the current objectives are shown.

An objective is a certain text describing the assignment given to a player, or any other information (for example defeat conditions). The objectives can be displayed as not accomplished, or accomplished (the same text, but crossed out or hidden).

Messages You can pass information to a player by means of the "Display Message" action. This action will open a dialogue window with text and a picture inside, while running the scenario. This will halt the game, so that it won't continue until the player hits the "OK" button. To put a question, you also need to set a message parameter in one of the conditions: "Affirmative answer to question" or "Negative answer to question".

Difficulty The level of difficulty is set by the player before the mission starts. For computer players, the level of difficulty is set when launching the artificial intelligence. The parameter range includes easy, normal, hard and very hard options.

Relations Relations between players can be either friendly or hostile. Units of friendly players do not attack each other. Such players form an alliance. The dialogue window contains 8 rectangles of different colours symbolizing players. If all the rectangles are placed vertically, then all the players are enemies. To form an alliance of two players, you need to mouse-grab one of the rectangles and drag it onto the same horizontal line with the other. Players on the same horizontal line will become friends. You can make all the players enemies by selecting the "All Enemies" button, and friends with the "All Friends" option.

Resources There are 6 resources in Cossacks: wood, gold, stone, food, coal and iron. 

Unit Types Unit type parameters include parameters for both units and buildings. All units are split in groups. Every nation has its own set of units and buildings. In the Originals group there are units belonging to the nations. In the Mercenaries group are all mercenary units.

Upgrades The list contains all the upgrades, divided into groups according to nations and units they affect and places they are carried out in. 

Formations This parameter sets positional relationship of units. To the left there is a list with names of formations. To the right is a schematic drawing. Yellow crosses denote basic units, while commanders are shown with red ones (e.g. the officer and drummer).

Quantity Numerical value.

Relation Relation is used in conditions which require quantitative parameters. For example, "Number of units in group Group0 is 0".

Radius Used in the "Open map area" action, this defines the size of the radius for the zone to lift the fog of war in. The value of 1 will reveal an area covering one pikeman's range of view.

Direction This parameter sets the direction units will look into. The value of this parameter should be a numerical one, ranging from 0 to 255. 0 means that units will be turned to the right. Increasing the value will turn units clockwise. For instance, if you set 127, your units will face to the left.

Number Identifies the number of the map area in actions "Open map area" and "Turn open map area off".

Changing/Adding Applied when you want several groups selected at the same time. Firstly, you need to select one group and then select another one. The first action changes the previous selection, while the second adds the new group to your previous selection.