Scripting F.A.Q.

55.  Can I make different things happen according to the difficulty level the player selects?    

Yes indeed!  The Basic condition "Difficulty Level" is what you need to use.  This can be used to regulate any number of things, from start conditions to battlefield actions and responses, giving a scenario a greater scope for replayability.

Note that, for setting up start conditions, in many cases this is an additive process: X is done for an Easy game; XY is done for a normal game; XYZ is done for a hard game; WXYZ is done for a very hard game.  While one cannot create a condition if the difficulty level "is greater than easy," one CAN instruct the game to do something if the difficulty level is NOT a particular level.  This can help the player save a little space.

Example:

Trigger: EasySetup

CONDITION:

      Difficulty level of player <red> equals to easy.

ACTION:

      Carry out upgrade Conduct a fencing drill (cold steel weapons' attack +1) for units of group <RedArmy>.

      Carry out upgrade Research granular gunpowder (firing power +15%) for units of group <RedArmy>.

      Carry out upgrade Forge new types of broadswords and sabres (cavalry attack +5) for units of group <RedArmy>.

 

Trigger: NormalSetup

CONDITION:

      Difficulty level of player <red> does not equal to easy.

ACTION:

      Carry out upgrade Conduct a physical training (morale, defence +2) for units of group <BlueArmy>.

      Carry out upgrade Conduct a physical training (morale, defence +2) for units of group <BlueArmy>.

      Carry out upgrade Conduct a riding drill (morale, defence +3) for units of group <BlueArmy>.

      Carry out upgrade Conduct a riding drill (morale, defence +1) for units of group <BlueArmy>.

      Carry out upgrade Conduct a riding drill (morale, defence +1) for units of group <BlueArmy>.

 

Trigger: HardSetup

CONDITION:

      Difficulty level of player <red> equals to hard.

ACTION:

      Carry out upgrade Research granular gunpowder (firing power +15%) for units of group <BlueArmy>.

      Carry out upgrade Forge new types of broadswords and sabres (cavalry attack +5) for units of group <BlueArmy>.

Trigger: VeryHardSetup

CONDITION:

      Difficulty level of player <red> equals to very hard.

ACTION:

      Carry out upgrade Research granular gunpowder (firing power +15%) for units of group <BlueArmy>.

      Carry out upgrade Forge new types of broadswords and sabres (cavalry attack +5) for units of group <BlueArmy>.

      Carry out upgrade Design wheel lock (handguns' rate of fire +35%) for units of group <BlueArmy>.

Here, Red is given an advantage if he's selected an easy game; for normal, hard, and very hard games, blue is given a series of advantages.  The defense upgrades are carried out not just for normal difficulty, but for hard and very hard as well.  Thus, using the condition "Difficulty ... does not equal to easy" saves you writing an additional 10 commands, since they don't have to be repeated!

NOTE:  This example could also be considered a form of "response chain," as the game goes down the list and executes commands from the simplest to most complex.

 

56.  How do I select different start options (Peace Time, No Peasant Capture, etc.)?    

There's regrettably no way to actually script these starting conditions.  Some of them can be included in a scenario by creating a random map with the appropriate parameters, and then using that random map as a template on which to build your own map and scenario.  Peace Time is known to work in this fashion, although you *must* do all your work in pause to avoid peace time expiring (it counts down otherwise, even in the Editor). The Balloon options do NOT work with this method, however.

Given the number of start options available, no systematic effort has been made to test each and every possibility.  If you have a scenario you wish to build based on nonstandard start options, you should attempt building a small scenario from a random map with just enough functionality to see if the options will work or not, and test it. 

 

 

57.  Why can't I attack the enemy?    

If after selecting a military unit and passing the cursor over an "enemy" the cursor does not change to a sword, the most likely cause is you forgot to "Change relations between players," or failed to place the combatants' colors on separate lines when setting the game up.  Check or add the trigger that should regulate this.

Another possible cause is that you've created a map with a set peace time, which hasn't yet run out.  Open the map up in the Map Editor, wait for peace to expire, and then save the map; this should clear the peace time.

If you can order units to attack but they don't move, then the most likely culprit is a trigger that selects that group and orders them to move without saving waypoints.  This should only happen with formations, however.  Check any trigger that selects player's units (especially if they include Activate Current Trigger) and make sure that before the selection is made, "Deselect units of player <red>" is performed.

58.  My trigger only happens once.  Why won't it work again?    

You probably forgot to insert "Activate Current Trigger" into it.  Do that, and the trigger should repeat as directed.  If it still does not repeat, then there must be something in the conditions set which changes once the trigger is carried out, so check your conditions carefully.

59.  My repeating trigger goes crazy once it kicks in.  How do I stop it?    

If a repeating trigger doesn't have a proper regulating mechanism, the results can be bizarre, amusing, and disastrous.  See  Question 41, "How do I Regulate Looping Triggers?" for suggestions on how to keep things under control.

60.  One of my triggers just doesn't work at all.  How do I fix it?    

There are two broad causes for triggers not working: one, because part of it is dependent on an action or condition that doesn't work (you've found a bug); two, because the condition/action logic used is faulty (operator error).  If the trigger is relatively simple and it doesn't work, that's likely the symptom of a bug, while with complex triggers it's easy to make a mistake that throws the whole thing off.

The best way to troubleshoot nonfunctional complex triggers is to "take them apart" and test them in a separate scenario.  Rebuild the trigger slowly and playtest after each change.  If something stops working after a point, then you've probably found your error.  Coming up with alternate strategies for problems is a challenging affair -- even the pros can be stumped by a simple mistake! 

61.  My triggers are changing all on their own.  I can't even save the game without everything going haywire.  Help!    

This is bad news indeed, fellow script writer... because it probably means that, somewhere, you used the "Duplicate" function in writing your scenario.  The only fix is to start over, from scratch.  Sorry!

62.  A formation I've ordered to march into a zone just stands there.  What's wrong?    

Most likely, you neglected to tell the formation to march "saving waypoints."  Check the trigger that orders them to move and change it if necessary.  Unfortunately, though, Cossacks seems to be a bit erratic in interpreting this function, so you may need to either break the formation or order it to "Go and Attack" instead.

63.  The enemy artillery rolls toward the player and attacks with grape shot.  I want them to use round shot.  How do I do this?      

Artillery, when ordered to "Go and attack in zone," don't behave quite the way one would expect.  The best solution is to order them to attack a specific group.  When ordered to attack this way, they will use round shot.  Selecting units in a zone and saving them to a Dynamic Group is an excellent way of solving this problem.

Example:

CONDITION

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

ACTION

      Deselect units of player <Red>.

      Select units of player <Red> in zone <ArtilleryZone>.

      Save selected units of player <Red> to Dynamic Group <RedTargets_Dyn> by adding to existing units.

      Deselect units of player <Blue>.

      Select units of group <BlueGuns>.

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

      Activate current trigger.

 

 

 

64.  The grenadiers (or archers) won't attack a building with grenades (or arrows).  Can't it be done?    

"Attack zone with artillery" and "Attack buildings in zone" do not work.  The same strategy in the previous example works splendidly for ordering grenadiers and archers to attack specific structures, however.

65.  The grenadiers always attack with bayonets and won't shoot!  How can this be fixed?     Back to top

Grenadiers and 18th c. muskets in formation tend to get trigger-shy when told to "Go and attack in zone."  The best fix is to order them to attack a group.  The strategy above, for attacking with artillery, can be used as an example for attacking with bayonet-happy troops.

66.  My dragoons have forgotten how to shoot!  How can I get them to fire on the player?    

A similar problem as with grenadiers can crop up for dragoons in formation.  Unfortunately, only breaking the formation seems to make them open fire before arriving at their destination.  

67.  My scenario loads fine until the Fog of War starts to lift... then it crashes to desktop.  What's wrong with it?     

This is usually caused by having too many command lines in your script.  Simplify and cut down until it works.

68.  I get a Mission Script Error when I try to run my scenario.  What's that mean?    

It means you used a condition or action which is buggy.  See questions 11 and 12 for a list of common bugs and their symptoms.  If you find something that isn't there, please let us know so we can include it in subsequent versions of this FAQ.
 
 

Appendix I:  Comprehensive Bug List         

Conditions (see Question 11):

- Upgrade is already accomplished.

- Number of units of a certain type in zone by player.

- Number of units of a certain type by player

- Number of deceased units of a certain type by player.

- Number of killings done by group units.

 

 

Actions (see Question 12):

- Attack enemy in zone with group units.

- Attack zone with artillery.

- Attack buildings in zone.

- Disable upgrade.

- Launching AI for certain countries.

- Building peasants for most countries.

 

Prussia is labeled as Germany (see Question 22).

 

Lengthy scenarios can cause crashes to desktop upon loading (see Question 13).

 

Large numbers of units can cause irregularities and crashes (not detailed in FAQ).

 

Cavalry formations may be buggy (see Question 15).

 

"Duplicate" causes instability in the Scenario Editor (see Question 16).

 

Messages can cause instability in the Scenario Editor (see Question 16).

 

AI does not cope well with having lots of units at the beginning of a game (see Question 22).

 

Units cannot be ordered to "guard" other units (see Question 35).

 

Artillery attacks with grapeshot when ordered to "Go and Attack" (see Question 63)

 

Dragoons do not fire until a destination is reached (see Question 66).
 

 
Credits: Cossacks Tech Depot (offline)