I want to share a few techniques that I have learned in my own mission designs, which can provide a lot more potential for the scenario editor than people might think. For now I want to keep the guide short, but eventually I might add more details to it. I will try to add basic introductions for beginners, but I recommend that you have read the scenario editor manual and worked with it a bit.
What can you expect from this guide? It explains how to organize more intelligent mass attacks, create artillery barrages, spawn units and simulate trenches, define subclasses or unions of object types, how to use variables, etc.
• Unit and Class Variables
Basic Introduction: Variables can occur in up to three subtypes:
Type 1: a variable for the current status
Type 2: the maximum possible value for that variable (the "total" value)
Type 3: the difference between the current and the default maximum variable (indicated with a "+" behind the variable name)
E.g. hitpoints have all three subtypes, i.e. if a unit has currently 300 hitpoints (type 1) with 400 base hitpoints (type 3) and 101 additional hitpoints from his enhancements (type 2), then you will see in the unit window 300/400 and a +101 above those numbers. Other variables like the attack value have only type 1 and 3, which makes sense. For the amount of resources only type 1 makes sense, etc.
It is also important to know that type 1 only applies to a specific unit (also called unit variable), while types 2 and 3 are class variables that apply to all units of that type.
The variables can be set using the effects for unit or class properties.
Advanced Techniques:
• Unit Variables: Some variables like hitpoints change the game directly, but other variables that have no meaning in the game (like unit variables 1-3 or the flight time variable for non-flying units) can be also useful. We will see examples for that further below, but you can already see that variables can be used to set additional unit properties that can be distinguished by trigger effects. E.g. you can apply an effect only on units with "unit variable 2" = 7) or you can use an effect to eliminate all machine guns with a certain variable value, while the other machine guns are not affected. Before you can define such an effect you need to define the specific object in the object tab and add a value for the corresponding unit property (like hitpoints or attack value).
• Class Variables: Of course this does not only work for unit variables, but also for class variables. However, the trigger effects only allow to set class variables of type 2 (i.e. the ones with a "+" ). Besides the game-relevant variables (like e.g. Hitpoints+), you can also use non-game-relevant variables like Leadership+ (or whatever it is called in your language; my scenario editor is in German btw.).
• Resources: Normal units can even have resource variables (like food or iron), in which case their resource amount will be shown in their unit window, which can be handy to visualize an additional unit parameter to the player (e.g. you could use iron as a unit counter for the remaining ammunition of a unit, although it can be tricky to simulate limited ammo properly).
Also note that once a hostile unit with resources dies you can farm its resource, if you like to simulate looting or cannibalizing a unit, but you cannot loot your own units and their corpses will remain visible until all their resources are completely gone. It is also worth mentioning that the resources of a unit are capped at 15, when they are killed, unless they are killed by citizens (quite similar to hunting animals).
• Effects On Existing Objects
Trigger effects for units usually apply on existing ones (while non-existing objects require the spawn effect).
Basic Introduction: Objects can be either selected on the map or they may be specified by the following properties:
- the unit type (e.g. machine gun)
- the unit or class variable
- its vicinity in relation to another object or an area
- its current status (like being idle or attacking)
- whether it is visible to a player
- whether it is selected by a human player (even hostile units can be selected)
These properties allow you to distinguish between certain kind of units when applying effects on them.
Furthermore, the min setting of an object determines how many units with the object properties are required for that effect, while the max setting defines how many units are affected, if available. The game will always try to affect as many units as possible, but if the amount of available unit is more than the max value, than the game will randomly pick parts of them.
Advanced Techniques:
• Targeting: You can use an object-task effect to make an object attack another object. Let's say there are 30 targets available, but the max value for that target object is 2. Then the attacking units will try to concentrate their fire only on 2 units at once instead of attacking all of them. For the attacking object you can also add the property that they must be idle at that moment in order to prevent attacking units switching their targets.
It is also worth mentioning that instead of a normal object-task you can use a move-attack to make sure the attacking object is attacking all obstacles between itself and its target.
• Further notes on targeting: Of course this can be also used for the units of a human player in order to make commanding units easier. E.g. whenever the player sends a specific message in the chat you can trigger an effect which changes a variable of the units selected by the player in order to define which units should belong to the attacking object. Once the player sends a second chat message, another effect may trigger, which lets the attacking object move towards the hostile target that is currently selected by the player. The attackers may not only attack that targets, but also all hostiles of a certain type that are in its vicinity. There are a lot of possibilities that you could think of. A good trigger design can make the AI much better.
• Other effect types: There are also effects to lock or release units. This is useful e.g. when you lock a unit to prevent it from attacking. One second before it may attack a specific target you can release it again. In this way you can also control, how often a unit attacks and count how much ammo it has spent, if you want to simulate limited ammo for very powerful units like beefed up artilleries.
Besides locking objects, you may also eliminate or simply remove them, which is quite self-explaining and simple.
• Spawning Objects
This topic has quite a lot of useful applications. A spawn effect always requires a certain object type, but we will see that it handles objects a bit differently than other kind of effects.
Basic Introduction: The simplest way is to define an object of a certain type (like e.g. a tank or a machine gun). This object also needs a certain specification, where to spawn. You can either choose this location to be a random point in an area or in the vicinity of an existing object. If you have set a specification for the unit property (like. e.g. its hitpoints), then the spawned unit will have this property as well. Note however, that this only works for unit variables, while class variables will be ignored when spawning.
You can also set the value min and max for an object. Then the amount of the spawned objects will be a random value between the minimum and maximum value.
Advanced Techniques:
• Area Targeting: I have already mentioned how to use effects for attacking targets. You can combine this with spawned targets in order to simulate randomized area bombing or artillery barrages. Usually you want those targets to be invisible in the scenario. You cannot use invisible flags for this purpose, since they cannot be used as proper targets. In order to make targets invisible, you can simply define objects with their graphical size reduced to 0%. Personally I use vermin as targets, since they do not have any visibility range either. Or you can assign those targets to an AI player that acts like a dummy.
• City Creation: You can create randomly created cities in certain areas. Just use effects that spawn several kind of buildings and houses there and repeat the trigger a few times until the place is filled with them. If you want a space within that area that is free from buildings (e.g. for roads), then simply place invisible flags there. Units can walk over those flags, but buildings cannot be placed there.
It is quite interesting to see how a city is randomly created.
• Trenches: You can simulate trench building units by spawning barbed wires around them while they move across the front. You should set the max amount of wires to a limited number to avoid that the unit is surrounded by them. You can also define that the trench building unit must not be in the vicinity of too many wires in order to avoid that a repeating trigger spawns too many of them.
Similarly you can spawn machine guns around the wires that are respawned after a while if there are not enough machine guns near the wires, while avoiding that there are too many of them spawning over time. It may sound a bit confusing at first, but once you have some experience with the triggers, you should be able to do that.
• Defining Object Sets
You might have defined objects by selecting them on the map or by using certain properties, but what if you want a subset of that object? Let's say you want only the idle units within an object of selected units. Or you might want to combine the units within two objects in order to make organizing your triggers easier.
Advanced Techniques:
• Defining Subsets: The simplest method is defining an object that uses another custom object in the list that you can find on the right side of the screen. Then you add more specifications to that new object. However, it seems like this does not work very well for spawn effects. For other effects this should still work without problems.
• Defining unions of sets: Let's say you have "Object_A" and "Object_B" of player 1. Then you set an appropriate variable for both objects to a certain value. Afterwards you can define the union of both objects as the set of all units of player 1 with that specified variable value.
If you want to define unions of unit classes, then you should use class variables instead.
E.g. you can define an object of all mortars and machine guns, instead of using two different objects separately.
• Set Complement: By using subtypes or variables you can also define units that belong to an object but are not contained in another object. E.g. this allows you to define machine gun units that have more than 10 hitpoints but less than 300 hitpoints.
• Naming Conventions For Triggers
This is a rather technical topic, but when the complexity of your scenario grows over time, it can be quite difficult finding and sorting all the triggers, effects, objects, areas, etc. So I want to make a few suggestions how a good naming convention should look like.
First of all you should bear in mind that triggers can be sorted alphanumerically in the mission editor. This can help immensely to organize your triggers and such. Otherwise you would have to move triggers manually, which can be very hard when you have a lot of them.
Next you should use shortcuts and good naming conventions for them. E.g. instead of Player 1 you could use P1. Think of all the properties that will distinguish your triggers and then create a consistent naming convention based on it. E.g. "T4:A:P2AttackerP1Victims" may refer to a trigger in the 4-th phase of a scenario, where the units of player 2 attack units of player 1. Or "On:T5:Victory" may refer to an effect that activates a trigger that checks victory conditions in the 5-th phase of the scenario.
• Trigger Performance
Do not use too many triggers that run at the same time, if your scenario is becoming very complex. If you have a few hundred triggers running simultaneously it can cause lags. It may become even worse if you use looped triggers instead of effects that activate existing triggers only after a few seconds.
I have not tested myself how many triggers can be used at the same time without big performance hits, but it may help a lot, if you design your mission carefully and avoid unnecessary or less important triggers. It should not be a problem using a lot of inactive triggers, but recurring triggers can be very bad. You may also consider activating triggers only during certain phases in your scenario. Of course you do not have to worry about this for less complex scenarios.
• Further Topics
I might add more content for this guide in the future, but I think it should not be too hard figuring out the other triggers yourself.
If you have found any mistakes or confusing explanations, then just notify me. Thanks for reading!
What can you expect from this guide? It explains how to organize more intelligent mass attacks, create artillery barrages, spawn units and simulate trenches, define subclasses or unions of object types, how to use variables, etc.
E.g. hitpoints have all three subtypes, i.e. if a unit has currently 300 hitpoints (type 1) with 400 base hitpoints (type 3) and 101 additional hitpoints from his enhancements (type 2), then you will see in the unit window 300/400 and a +101 above those numbers. Other variables like the attack value have only type 1 and 3, which makes sense. For the amount of resources only type 1 makes sense, etc.
It is also important to know that type 1 only applies to a specific unit (also called unit variable), while types 2 and 3 are class variables that apply to all units of that type.
The variables can be set using the effects for unit or class properties.
• Unit Variables: Some variables like hitpoints change the game directly, but other variables that have no meaning in the game (like unit variables 1-3 or the flight time variable for non-flying units) can be also useful. We will see examples for that further below, but you can already see that variables can be used to set additional unit properties that can be distinguished by trigger effects. E.g. you can apply an effect only on units with "unit variable 2" = 7) or you can use an effect to eliminate all machine guns with a certain variable value, while the other machine guns are not affected. Before you can define such an effect you need to define the specific object in the object tab and add a value for the corresponding unit property (like hitpoints or attack value).
• Class Variables: Of course this does not only work for unit variables, but also for class variables. However, the trigger effects only allow to set class variables of type 2 (i.e. the ones with a "+" ). Besides the game-relevant variables (like e.g. Hitpoints+), you can also use non-game-relevant variables like Leadership+ (or whatever it is called in your language; my scenario editor is in German btw.).
• Resources: Normal units can even have resource variables (like food or iron), in which case their resource amount will be shown in their unit window, which can be handy to visualize an additional unit parameter to the player (e.g. you could use iron as a unit counter for the remaining ammunition of a unit, although it can be tricky to simulate limited ammo properly).
Also note that once a hostile unit with resources dies you can farm its resource, if you like to simulate looting or cannibalizing a unit, but you cannot loot your own units and their corpses will remain visible until all their resources are completely gone. It is also worth mentioning that the resources of a unit are capped at 15, when they are killed, unless they are killed by citizens (quite similar to hunting animals).
Trigger effects for units usually apply on existing ones (while non-existing objects require the spawn effect).
- the unit type (e.g. machine gun)
- the unit or class variable
- its vicinity in relation to another object or an area
- its current status (like being idle or attacking)
- whether it is visible to a player
- whether it is selected by a human player (even hostile units can be selected)
These properties allow you to distinguish between certain kind of units when applying effects on them.
Furthermore, the min setting of an object determines how many units with the object properties are required for that effect, while the max setting defines how many units are affected, if available. The game will always try to affect as many units as possible, but if the amount of available unit is more than the max value, than the game will randomly pick parts of them.
• Targeting: You can use an object-task effect to make an object attack another object. Let's say there are 30 targets available, but the max value for that target object is 2. Then the attacking units will try to concentrate their fire only on 2 units at once instead of attacking all of them. For the attacking object you can also add the property that they must be idle at that moment in order to prevent attacking units switching their targets.
It is also worth mentioning that instead of a normal object-task you can use a move-attack to make sure the attacking object is attacking all obstacles between itself and its target.
• Further notes on targeting: Of course this can be also used for the units of a human player in order to make commanding units easier. E.g. whenever the player sends a specific message in the chat you can trigger an effect which changes a variable of the units selected by the player in order to define which units should belong to the attacking object. Once the player sends a second chat message, another effect may trigger, which lets the attacking object move towards the hostile target that is currently selected by the player. The attackers may not only attack that targets, but also all hostiles of a certain type that are in its vicinity. There are a lot of possibilities that you could think of. A good trigger design can make the AI much better.
• Other effect types: There are also effects to lock or release units. This is useful e.g. when you lock a unit to prevent it from attacking. One second before it may attack a specific target you can release it again. In this way you can also control, how often a unit attacks and count how much ammo it has spent, if you want to simulate limited ammo for very powerful units like beefed up artilleries.
Besides locking objects, you may also eliminate or simply remove them, which is quite self-explaining and simple.
This topic has quite a lot of useful applications. A spawn effect always requires a certain object type, but we will see that it handles objects a bit differently than other kind of effects.
You can also set the value min and max for an object. Then the amount of the spawned objects will be a random value between the minimum and maximum value.
• Area Targeting: I have already mentioned how to use effects for attacking targets. You can combine this with spawned targets in order to simulate randomized area bombing or artillery barrages. Usually you want those targets to be invisible in the scenario. You cannot use invisible flags for this purpose, since they cannot be used as proper targets. In order to make targets invisible, you can simply define objects with their graphical size reduced to 0%. Personally I use vermin as targets, since they do not have any visibility range either. Or you can assign those targets to an AI player that acts like a dummy.
• City Creation: You can create randomly created cities in certain areas. Just use effects that spawn several kind of buildings and houses there and repeat the trigger a few times until the place is filled with them. If you want a space within that area that is free from buildings (e.g. for roads), then simply place invisible flags there. Units can walk over those flags, but buildings cannot be placed there.
It is quite interesting to see how a city is randomly created.
• Trenches: You can simulate trench building units by spawning barbed wires around them while they move across the front. You should set the max amount of wires to a limited number to avoid that the unit is surrounded by them. You can also define that the trench building unit must not be in the vicinity of too many wires in order to avoid that a repeating trigger spawns too many of them.
Similarly you can spawn machine guns around the wires that are respawned after a while if there are not enough machine guns near the wires, while avoiding that there are too many of them spawning over time. It may sound a bit confusing at first, but once you have some experience with the triggers, you should be able to do that.
You might have defined objects by selecting them on the map or by using certain properties, but what if you want a subset of that object? Let's say you want only the idle units within an object of selected units. Or you might want to combine the units within two objects in order to make organizing your triggers easier.
• Defining Subsets: The simplest method is defining an object that uses another custom object in the list that you can find on the right side of the screen. Then you add more specifications to that new object. However, it seems like this does not work very well for spawn effects. For other effects this should still work without problems.
• Defining unions of sets: Let's say you have "Object_A" and "Object_B" of player 1. Then you set an appropriate variable for both objects to a certain value. Afterwards you can define the union of both objects as the set of all units of player 1 with that specified variable value.
If you want to define unions of unit classes, then you should use class variables instead.
E.g. you can define an object of all mortars and machine guns, instead of using two different objects separately.
• Set Complement: By using subtypes or variables you can also define units that belong to an object but are not contained in another object. E.g. this allows you to define machine gun units that have more than 10 hitpoints but less than 300 hitpoints.
This is a rather technical topic, but when the complexity of your scenario grows over time, it can be quite difficult finding and sorting all the triggers, effects, objects, areas, etc. So I want to make a few suggestions how a good naming convention should look like.
First of all you should bear in mind that triggers can be sorted alphanumerically in the mission editor. This can help immensely to organize your triggers and such. Otherwise you would have to move triggers manually, which can be very hard when you have a lot of them.
Next you should use shortcuts and good naming conventions for them. E.g. instead of Player 1 you could use P1. Think of all the properties that will distinguish your triggers and then create a consistent naming convention based on it. E.g. "T4:A:P2AttackerP1Victims" may refer to a trigger in the 4-th phase of a scenario, where the units of player 2 attack units of player 1. Or "On:T5:Victory" may refer to an effect that activates a trigger that checks victory conditions in the 5-th phase of the scenario.
Do not use too many triggers that run at the same time, if your scenario is becoming very complex. If you have a few hundred triggers running simultaneously it can cause lags. It may become even worse if you use looped triggers instead of effects that activate existing triggers only after a few seconds.
I have not tested myself how many triggers can be used at the same time without big performance hits, but it may help a lot, if you design your mission carefully and avoid unnecessary or less important triggers. It should not be a problem using a lot of inactive triggers, but recurring triggers can be very bad. You may also consider activating triggers only during certain phases in your scenario. Of course you do not have to worry about this for less complex scenarios.
I might add more content for this guide in the future, but I think it should not be too hard figuring out the other triggers yourself.
If you have found any mistakes or confusing explanations, then just notify me. Thanks for reading!