Instructions for using Editor/Factory Defense
Contents
- 1 Creating the mission
- 2 Take-off objective
- 3 Creating a route waypoint
- 4 Creating enemy bombers
- 5 Creating enemy fighters
- 6 Logical unification of enemy airplanes
- 7 Putting the enemy airplanes to sleep
- 8 Creating targets for the Stalingrad factory bomb run
- 9 Creating anti-air batteries
- 10 Waking up the enemy airplanes
- 11 Factory defense objective
- 12 Checking whether all the bombers have been killed
- 13 Checking the open factory defense objective
- 14 Checking whether the enemy airplanes have reached the factory
- 15 Assigning a bombing objective to the enemy bombers
Creating the mission
Open the editor and open the level ‘stalingrad’ as the project. After this, open the ‘Mission Editor’ tab on the toolbar, find the ‘New mission...’ button and click it. Now you must open the mission properties window. To do this, click the ‘Properties and Trigger/MissionObj Info’ button. After you click it, two windows will open: ‘Properties’ and ‘Trigger / Mission Obj. Info’. In the ‘Properties’ window, click the ‘Mission Settings’ section to open it. In this section, find the ‘stars’ section and open it as well. You’ll see the date and time settings for the start of the mission. Enter 9 in the ‘month’ field, 15 in the ‘day’ field, 12 in the ‘time’ field and 1942 in the ‘year’ field. This will make the mission start on September 15, 1942 at 12 a.m.
Close the ‘stars’ section and open the ‘mission’ section located below. If you can’t see this section, scroll the ‘Properties’ window down or up using your mouse wheel. In the ‘mission’ section, you’ll need to fill in several fields:
- In the ‘name’ field, enter a name for the mission in English
- In the ‘level’ field, choose the level the mission will use. For this mission, choose ‘stalingrad’
- In the ‘type’ field, you must indicate the mission’s type. This tutorial touches only on the ‘singleMission’ type, so select that one
- The ‘restoreType’ field defines what happens to the player after his airplane is destroyed. The value of ‘attempts’ allows the airplane to make several more attempts to complete the mission after being destroyed, until the attempts run out and the mission fails. The value of ‘tacticalControl’ allows the player to switch to the next airplane in the wing if his current airplane is destroyed as long as there is at least one airplane still active in the player’s wing
- In the ‘campaign’ field, you must choose which military campaign this mission belongs to. Since the battle for Stalingrad took place on the Eastern Front, choose ‘eastern’
- The ‘environment’ field defines the type of sky and the lighting intensity. We recommend setting this variable based on the ‘time’ field which was set previously. Since we entered 12 into that field, we should enter ‘day’ in ‘environment’
- The ‘weather’ field is responsible for weather conditions on the mission. Select the value ‘hazy
Close the ‘mission’ and ‘Mission Settings’ sections and go to the ‘Triggers / Mission Obj. Navigation’ section located underneath. This will be your main section of this window, and from now on, for simplicity, this section will be called the ‘trigger list’.
The section consists of a window with two currently empty lists: ‘Triggers’ and ‘Mission objectives’. Underneath the window are several buttons:
- ‘Trigger’ creates a new trigger
- ‘Mission Obj’ creates a new mission objective
- ‘Copy’ and ‘Paste’ are used to copy an item from the list with all the conditions inside and put it somewhere new
- ‘Del’ is used to delete an item from the list
- ‘Up’ and ‘Down’ allow you to move a list item downwards or upwards in the list tree.
Click the ‘Trigger’ button. A new item has appeared in the Triggers tree called ‘Trigger_01’. In the next window, titled ‘Trigger / Mission Obj. Info’, change its name in the ‘Name’ field to ‘mission_start’. Lower down in the same window, you can see the ‘Elements’ field, in which there are three currently empty trees: ‘Events’, which influences how this trigger works; ‘Conditions’, which influences which condition is required to activate the trigger; and ‘Actions’, which influences what exactly should happen when the trigger’s execution condition is met. In cases when the trigger condition is not met, the trigger can be called again according to what is written in its ‘Events’ tree. After the trigger is fulfilled, it stops being called. As of now, our trigger has a ‘periodicEvent’ event with a ‘time’ value set to 1. This means that the trigger will try to execute every second. Let’s select this event and press the ‘Delete’ button at the bottom of the ‘Elements’ window. After deleting the event, we have an absolutely empty trigger, but we need this trigger specifically to execute at the start of the mission. To do this, we need to add a new Event by clicking the corresponding button. Click the ‘Event’ button and, in the resulting window, select ‘initMission’.
Creating the player
Creating the player means creating his airplane and further instructions to the game about what airplane the player will be flying. A mission without both these conditions fulfilled cannot be launched.
First, let’s create the player’s airplane. To do this, click the ‘Create unit’ button on the Mission Editor toolbar, first selecting ‘armada’ in the field to the right of the button. Place the player’s airplane anywhere on the map, then select it and click ‘Show / hide object props. panel’. After clicking this button, the Object Properties window will open. We’ll need to change several parameters in it:
- in the ‘name’ field, enter ‘player’. The game later recognize the player’s airplane by this name.
- in the ‘class’ field, select ‘yak-1b’. We’ve giving the player a Yak-1B to control.
- in the ‘weapon’ field, choose ‘Yak1b_default’.
Lower down in this window is the ‘Properties’ section, where we’ll also need to fill in several fields:
- Set the ‘army’ field to 1. As a rule, player airplanes and units belong to army 1, while enemy airplanes and units belong to army 2.
- Set the ‘count’ field to 4. This will mean that the player has 4 airplanes under his control, including the player’s airplane. In other words, the player himself and 3 support airplanes will be present on the battlefield.
- Press the ‘+ numInWing’ button located right underneath the ‘count’ field and, in the resulting window, enter the value as 2. This will mean that the airplanes under the player’s control are divided into pairs.
Now we need to go to the Properties window, which opens after you click on the ‘Properties and Trigger/MissionObj Info’ button located on the Mission Editor’s toolbar. We’re interested in the section titled player_teamA. In the wing field, press the <none> button and, in the resulting window, select ‘player’. This tells the game who to consider the player. Now you can save the mission by clicking the Save mission button, and launch it by clicking the Run mission button. When saving the mission, it is preferable for the mission’s file name to correspond to its title entered in the name field. After the mission is launched, you’ll see yourself flying a Yak-1B fighter, and three more of the same will be flying behind you.
Creating the airfield
Let’s make things more difficult by making the player take off from the airfield. To do this, we need to create the airfield itself. To create the airfield, go to the ‘Landscape’ tab on the toolbar and click the ‘Select object by name’ button. In the resulting window, enter ‘air’, choose ‘stalingrad_airfield_2_009’ from the list that appears, click the OK button to close the window, then press the Z key. The editor’s camera will move to show the selected airfield. Now return to the Mission Editor tab on the toolbar and click the ‘Create box zone’ button. Using this, create a rectangular zone with a size roughly corresponding to the size of the airfield. After creating the zone, open the ‘Object Properties’ window by pressing the ‘Show / hide object props panel’ button. In the parameters window, change the ‘name’ parameter to ‘airfield_area’. After its creation, ‘airfield_area’ will most likely be placed at an angle to the airfield and will have to be turned. To do this, select the newly created zone and press the Z key to make the camera move to the object. Now press the ‘Rotate’ button to go into rotate mode and start turning it around the green arc to make the zone turn in the direction of the airfield. After you’re done rotating the object, press the ‘Move’ button. Move the object so that it sits where it should on the airfield. If the object turns out too large or too small, you can change its size. To do this, press the ‘Scale’ button and change the object’s size on one of its axes. The airfield’s logical area has been created. Now we need to indicate the start and end of the airfield. To do this, use ‘Create sphere zone’ to create two zones. Place one at the start of the airfield and one at the end. Both zones must be within ‘airfield_area’. Press the ‘Show / hide object props panel’ button and, in the ‘Object Properties’ window, rename the first zone to ‘airfield_start’, and the second to ‘airfield_end’. Now we need to create some points for the player’s airplane and allies to appear at. Using the same ‘Create sphere zone’ button, create four zones located inside ‘airfield_area’, between ‘airfield_start’ and ‘airfield_end’ and closer to ‘airfield_start’. Change the names of the new zones to ‘spawn01’ – ‘spawn04’.
Making the player’s airplane appear on the airfield
The airfield is done. Now we need to make is to that the player starts the game not in the air, but on the airfield.
To do this, select the ‘mission_start’ trigger and press the ‘Action’ button to add a new action. Choose ‘addAirfield’ from the list. This action has several parameters that must be edited:
- Set the ‘runwayStart’ field to ‘airfield_start’.
- Set the ‘runwayEnd’ field to ‘airfield_end’.
- The ‘runawayWidth’ field sets the width of the airfield. The recommended setting is 10 meters.
- In the ‘army’ field, choose which army this airfield will belong to. Since the player will appear on it, who belongs to army 1, we’ll choose 1 here as well.
- By clicking the ‘+ spawnPoint’ button, we need to add the previously created zones with the names ‘spawn01’–’spawn04’.
- The ‘+ visibleOnHud’ button is used to enable or disable the checkbox that is responsible for displaying the airfield on the radar.
There’s just one finishing touch remaining before the player’s airplanes can appear on the airfield. Let’s add another action, choosing ‘spawnOnAirfield’ from the list. This action also requires several parameters to be configured:
- In the ‘runwayName’ field, set the starting point of the airfield to ‘airfield_start’.
- The ‘+ objects’ button allows us to indicate who exactly should be placed on this airfield. In the resulting window, select ‘player’.
Now save the mission and launch it to test it out.
Take-off objective
Now that the player is on the airfield, it would be logical to give him the first objective: to take off. To do this, press the ‘Mission Obj’ button in the trigger list, and in the resulting window, select ‘abstractMissionObjective’. A new mission objective will be created called ‘MissionObj_01’. Only three things in its properties interest us:
- The ‘name’ field, in which you have to indicate the objective’s name. Enter ‘take_off’.
- The ‘Enabled’ field with a checkbox enabled, which means that when the trigger is called, the objective will be automatically assigned. Since the trigger is called at the start of the mission, and we want the player to receive the objective immediately, we’ll leave this ticked.
- The ‘isPrimary’ field has its checkbox enabled, which means that this objective will be the main one. Unchecking this checkbox would cause the task to be considered an additional objective. Leave it checked.
Now, in the folder where you saved the mission, you need to create a text file with the same name as the mission file, but with the extension ‘csv’. For example, in this example the mission is saved in the file ‘sample01_stalingrad.blk’. That means you must create the file ‘sample01_stalingrad.csv’. Open the created file and save it with UTF-8 encoding. Now add a line to the file: "take_off";"Take off";"Взлетите". The line consists of three parts:
- "take_off" is the line’s identifier. It must correspond to the name you gave the mission objective.
- "Take off" is the objective text in English. You can leave the quotation marks empty here if you don’t want to include the English text for some reason.
- "Взлетите" is the objective text in Russian.
All three parts are within quotation marks and separated by the ; character. Save the file once more and close it. Save the mission and launch it. Now, as soon as the player starts the mission, the new “Take off” objective should be assigned.
Checking for completion of the take-off objective
If you checked the mission, then you probably noticed that after taking off, the take-off objective stayed in the journal and its status didn’t change. To fix these issues, we’ll need to create a new trigger and call it ‘check_for_takeoff’. Since the trigger has to begin the check right after the start of the mission, we’ll leave ‘Enabled’ checked. The trigger’s check interval of 1 second also suits us, so we’ll leave ‘Events’ unchanged as well. But we need to add a check for whether the player has taken off or not. To do this, add a new condition to the newly created trigger, selecting ‘unitWhenStatus’ from the list and configuring it like so:
- In the ‘object’ field, select ‘player’.
- In the ‘object_type’ field, select ‘isInAir’.
- Leave the ‘check_objects’ field set to ‘any’. This allows the check to complete even if just one airplane has taken off. Considering that the player takes off first and the other airplanes in his wing wait their turn, this is the correct decision.
Now we’ll add a new action to the trigger which will change the objective’s status to ‘complete’. To do this, select ‘moSetObjectiveStatus’ from the ‘actions’ list with the parameters:
- In the ‘target’ field, select ‘take_off’.
- In the ‘status’ field, select 2, which means the objective was completed successfully.
Save and check whether the objective is completed after the airplane takes off.
Creating a route waypoint
The player has taken off, and now it’s time to provide a waypoint. To do this, select ‘Create point zone’ from the Mission Editor toolbar, find the factory near Stalingrad on the map and place a zone directly above the factory at a height of 2,000 meters. Rename the zone to ‘factory_point’. Now we need to somehow show this point to the player so that he knows where to fly to. Showing it on the ground wouldn’t be right, since we’ve already given the player the objective of taking off. But after the player is in the air and has completed the first objective, it will be time to provide a new mission goal. So let’s go to the ‘check_for_takeoff’ trigger and add a new action to it, selecting ‘missionMarkAsWaypoint’ for the list, and setting it up like so:
- In the ‘target’ field, indicate the zone to be marked for the player – the ‘factory_point’ zone.
- Leave the ‘visible’ field enabled to make sure the player sees a visual representation of the waypoint.
- The ‘primary’ field indicates that this waypoint is the same waypoint the player must fly to in order to meet the current objective.
Objective to reach the waypoint
We’ve shown the player the waypoint he must reach. Now it’s time to assign an objective to be displayed in the journal. To do this, open up our csv file and add a line to it: "reach_first_waypoint";"Reach the checkpoint";"Проследуйте к отмеченной зоне". Save the file and add the new Mission Objective to our mission. Do this just like the first time, but change the name to ‘reach_first_waypoint’ and uncheck the box next to the ‘Enabled’ field, since we don’t want the objective to be displayed as soon as the mission begins. When you’ve done all this, go to the ‘check_for_takeoff’ trigger. As you can see, in this trigger we’ve already changed the status of one objective. Accordingly, if we immediately assign a new objective, the messages on the screen will lie on top of each other, which won’t look good. It would be nice to create a pause between these two events. A new action will called ‘wait’ will help us do this. Add one and set its ‘time’ field to 3. Now that we’ve created the pause we need, let’s give the player the new objective. To do this, add another action, choosing ‘moAddMissionObjective’ from the list and setting the ‘target’ field to our ‘reach_first_point’. Save the mission and check if it’s working.
Checking whether the waypoint has been reached
Since we’ve assigned an objective to fly to a waypoint, we need to check whether the waypoint has been reached. To do this, create a new trigger called ‘check_for_reach_point’. Since the objective to reach the point is not assigned right away, the check should also not begin right away, but instead begin after the player receives the objective. This means we uncheck ‘Enabled’ in our trigger. Now add a new condition to the trigger which will check whether the player has reached a given point. Select ‘unitDistanceBetween’ from the ‘Conditions’ list and give it parameters like so:
- In the ‘object’ field, select ‘player’.
- In the ‘target’ field, select ‘factory_point’.
- In the ‘value’ field, indicate a distance of 2,000 meters.
- Leave the ‘math’ field as ‘2D’, which means that for the condition to be reached, the distance between ‘object’ and ‘target’ must be at least 2,000 meters on any axis. If you choose ‘3D’, that will mean that a successful check would require both the object and the target to be on a single horizontal plane.
The check condition has been provided. Now it’s time to provide a reaction. To do this, add a new action and select the now familiar ‘moSetObjectiveStatus’. Set ‘target’ to ‘reach_first_point’ and ‘status’ to 2, for successful objective completion. Since the check trigger isn’t called automatically, we need to call it ourselves from the trigger which assigns the objective to reach the waypoint. Go to the ‘check_for_takeoff’ trigger and add a new action to it, choosing ‘triggerEnable’ from the list and setting ‘target’ to the ‘check_for_reach_point’ trigger.
The final touch is to stop the waypoint from showing up after it is reached. To do this, go to the ‘check_for_reach_point’ trigger and add a new ‘missionMarkAsWaypoint’ action, setting ‘target’ to the ‘factory_point’ and unchecking the box next to ‘visible’. Save the mission and check that everything is working as intended.
Creating enemy bombers
It’s time to create the enemy bombers. To do this, click the ‘Create unit’ button in the toolbar on the Mission Editor tab, first making sure that the field to the right is set to ‘armada’. Now place an airplane a few kilometers from Stalingrad at a height of 1,500 meters and call it ‘enemy_bombers’. In the ‘class’ field, set the airplane’s type to ‘ju88a-4’ and give it the default weaponry. Make sure that the ‘army’ field doesn’t match the ‘army’ field of the player, and set the number of airplanes (‘count’) to 24. Click the ‘+ numInWing’ icon located below the ‘count’ field and set it to 3, which will mean that the 24 bombers will be split into groups of 3.
Creating enemy fighters
Now let’s create the escort fighters. You could use the ‘Create unit’ button again, but you can instead select the already created bombers, click the ‘Move’ button and, holding down the Shift key, drag an airplane along the green arrow upwards by 500 meters. In the window that opens, give the airplane a new name: ‘enemy_fighters’. Select the airplane you got and set its ‘class’ to ‘bf-109f-4’ with default weaponry. Set ‘count’ to 6 and reduce the ‘numInWing’ value to 2.
Logical unification of enemy airplanes
Now that we’ve created the bombers and escort fighters, we have two forces. We’re going to have to perform several identical actions for each force, so it would be nice to unify them. To do this, use the ‘Create unit’ button, first making sure that the field to the right is set to ‘squad’, to create a squad near the enemy airplanes. Call it ‘enemy_squad’. In the squad properties window, you need to configure ‘squad_members’, first adding ‘enemy_bombers’, then ‘enemy_fighters’.
Putting the enemy airplanes to sleep
The enemy airplanes will be created automatically at the start of the mission, but we won’t need them for some time. As they’ve been left to the mercy of fate, the airplanes will probably die by crashing into the ground or each other, or they’ll just fly off in an unknown direction. To make sure this doesn’t happen, we need to put them to sleep and wake them up when we need them.
Go to the ‘mission_start’ trigger and add a new action to it, choosing ‘unitPutToSleep’ from the list and setting its ‘target’ to the recently created ‘enemy_squad’. As you can see, we’re operating on a single object, but putting both the bombers and the fighters to sleep. Soon, when we create a squad of significant size, you’ll be able to appreciate the convenience of working with them.
Creating targets for the Stalingrad factory bomb run
For the bombers to have something to bomb, we need to add some targets for them. To do this, move the camera to factory near Stalingrad and press the ‘Create unit’ button, first making sure that the field to the right is set to ‘structures’. Place the structure on the roof of one of the factory’s buildings. Change the structure’s name to ‘bomb_target01’. Set ‘class’ to ‘dummy’ and be sure to set the ‘army’ to the player’s army (1). Now let’s make a copy of this structure just like we made copies of the planes when we were creating the escort fighters for the bombers. We’ll place these copies on the roofs of the factory buildings. Don’t over do it – we need no more than 16 targets, since the capacity for one squad is limited to 16 units. Now select all the structures you created and raise them up by 100 meters. After this, press the ‘Drop unit’ button located on the Mission Editor toolbar. This will place the selected structures on the surface of the level, so that the bombers can destroy them.
Creating anti-air batteries
To make the player’s job easier, let’s place several anti-air batteries around the factory. To do this, use the ‘Create unit’ button again, first making sure that the field to the right is set to ‘air_defence’. Let’s place one anti-air battery next to the factory and configure it. Set the ‘class’ field to ‘ussr_37mm_61k’, the ‘army’ field to the same as the player’s, and the ‘accuracy’ field to 0.3 – after all, we don’t want these anti-air guns to do all the player’s work for them. Copy the resulting anti-air cannon several times and place the copies around the factory.
Combining targets and weapons
Since we’ve ended up with lots of targets for our bombers and several anti-air cannons, it would be nice to combine them into squads. Create two new squads called ‘bomb_targets’ and ‘air_defence’. Move all the structures to the first squad and all the anti-air batteries to the second.
Waking up the enemy airplanes
All the preparations are complete. Now we need to wake up the enemy airplanes and send them on their way to the factory. To do this, go to the ‘check_for_reach_point’ trigger and add a new action to it, choosing ‘unitWakeUp’ from the list. Set ‘target’ to ‘enemy_squad’. The enemy airplanes have woken up, and they need a job. It would be a good idea to send them to the factory, which is done by adding another action to the current trigger. Select ‘unitMoveTo’ from the list and give it the following parameters:
- Set the ‘object’ field to ‘enemy_squad’.
- Set the ‘target’ field to ‘factory_point’.
- Set the ‘speed’ field to 300. This is done to make sure that all the airplanes set off at the same speed and the fighters don’t pull away from the bombers.
- Find the ‘shouldKeepFormation’ field and enable it. This allows the airplanes to maintain their formation while they fly.
Configuring additional parameters for the enemy airplanes
Let’s make the effectiveness of the enemy airplanes depend on the effectiveness of the player’s actions. In the ‘check_for_reach_point’ trigger, add a ‘unitSetProperties’ command, setting ‘object’ to ‘enemy_bombers’. Expand the ‘plane’ section located above, then the ‘targetDeviation’ section in it. Set this section’s ‘trigger’ field to ‘bombs’ and set ‘limits’ to 0–2.5. Add another ‘targetDeviation’, but set the ‘trigger’ field to ‘gunner’, setting its ‘limits’ parameter to the same value as the bombs. Add the same command with the same parameters for the enemy fighters. Only set the ‘object’ for ‘unitSetProperties’ to ‘enemy_fighters’ and the ‘trigger’ field of the ‘targetDeviation’ section to ‘machine gun’.
Factory defense objective
Now let’s give the player his next objective. To do this, add a line to our csv file: "bombers_engaged";"Defend the factory against the enemy bombers";"Защитите завод от атак вражеских бомбардировщиков". In the mission itself, add a new ‘Mission Objective’ called ‘bombers_engaged’ and uncheck the ‘Enabled’ box, since we want this objective to appear in the journal at a specified time. Now go to the ‘check_for_reach_point’ trigger. As you can see, operations to change the status of objectives have already taken place in it, and that means that before assigning a new objective, we need to make a pause so that the messages don’t appear on top of each other. Add a new ‘wait’ action for 3 seconds. After the pause, add a new action, choosing ‘moAddMissionObjective’ from the list and setting its ‘target’ to ‘bombers_engaged’.
Marking the bombers as targets
Now we can mark the enemy bombers as the targets of the objective, and also provide information about the bombers at the bottom of the screen, so that the player can see how many there are. To do this, add a new action to the ‘check_for_reach_point’ trigger, selecting
Showing a bomber counter
To allow the player to see how many bombers are left, we need to create a new ‘update_indicator’ trigger. This trigger should be called once per second and should not close after it is fulfilled, but continue to operate instead. This means the bomber counter will change once per second. How do we do this?
First, create an ‘update_indicator’ trigger and uncheck its ‘Enabled’ box, since we don’t want the counter to display at the start of the mission. However, we need to check the box next to ‘enableAfterComplete’, which allows the trigger to continue working until we switch it off ourselves.
Now let’s add a new action to this trigger, selecting ‘missionSetTargetsIndicator’ from the list and giving it the parameters:
- Set the ‘target’ field to ‘enemy_bombers’.
- Leave the ‘target_type’ field set to ‘isAlive’, since we need to show the number of bombers still alive.
- Set the ‘icon’ field to ‘air’ to make an airplane icon appear on the counter.
- Set the ‘icon_army’ field to the index of the army that the bombers belong to.
Now go to the ‘check_for_reach_point’ trigger and use an ‘enableTrigger’ action to call the ‘update_indicator’ trigger.
Showing a factory buildings counter
However, we’re also interested in information about how successful the factory defense is. For this purpose, let’s introduce a counter for intact buildings. This will allow the player to assess their effectiveness during the mission. To do this, add a new ‘missionSetTargetsIndicator’ action to the already existing ‘update_indicator’ trigger and give it the following parameters:
- Set the ‘target’ field to ‘bomb_targets’.
- Leave ‘isAlive’ in the ‘target_type’ field, since we need to show the number of buildings still intact.
- Set the ‘icon’ field to ‘building’ to make a building icon appear on the counter.
- Set the ‘icon_army’ field to the index of the army that the player belongs to.
Save and make sure that everything works.
Checking whether all the bombers have been killed
The player can destroy all the enemy bombers before they reach the factory. This means that as soon as the player receives the objective to defend the factory, we need to start checking the number of bombers remaining.
To do this, create a new ‘check_for_mission_completed’ trigger and check its ‘Enabled’ box. In the ‘events’ field of this trigger, change ‘periodicEvent’, setting ‘time’ to 20 seconds so that the check for the destruction of all the bombers is not called very often.
Go to the ‘check_for_reach_point’ trigger. In this trigger’s list of actions we’ve created, there’s already one ‘triggerEnable’. Select it and add another argument: a call for the ‘check_for_mission_completed’ trigger. Return to the ‘check_for_mission_completed’ trigger and add a ‘unitWhenStatus’ check condition, setting the parameters:
- Set ‘target’ to the German bombers—’enemy_bombers’.
- Set ‘object_type’ to ‘isKilled’.
- Set ‘check_object’ to ‘all’.
This will allow the trigger to activate only if all the bombers are destroyed.
Add a new action, selecting ‘missionCompleted’ from the list. Now, if all the bombers are destroyed, the mission will be completed. But what if the last bomber dies just as the objective to defend the factory is failed? The game will first tell us that the mission has been failed, and then that it’s been completed. To make sure this doesn’t happen, let’s add another ‘condition’: ‘misObjStatus’. Set ‘target’ to the ‘bombers_engaged’ objective and ‘status’ to ‘notFailed’. This means that apart from destroying all the bombers, the status of the defense objective will also be checked, and the mission will be failed if that objective is failed.
Checking the open factory defense objective
What will happen if the mission ends, but the objective to defend the factory hasn’t ended yet? It would seem logical to add the end of the objective to the trigger that checks whether all the bombers have been killed. But what if the last bomber dies after the defense objective is complete? Will the player see a second notification that the mission is complete? That’s not ideal. To solve it, let’s create a trigger that will check whether the factory defense objective is active, and if it is, mark it completed.
Create a ‘check_for_defense_completion’ trigger and tick the ‘Enabled’ box. The only check condition in this trigger will be for the status of the objective to defend the factory. Add a ‘misObjStatus’ condition. Set ‘target’ to ‘bombers_engaged’ and ‘status’ to ‘notFailed’. This means we’re checking whether the objective to defend the factory has been failed. And if it isn’t failed, we complete an action which we’ll add right now. This will be an ‘moSetObjectiveStatus’ action, with ‘target’ set to ‘bombers_engaged’ and ‘status’ to 2, which means the objective is complete
Now let’s call this trigger from the trigger that checks whether all the bombers have been destroyed. To do this, add a ‘triggerEnable’ action to the ‘check_for_mission_completed’ trigger, setting its ‘target’ to our ‘check_for_defense_completion’ trigger. Using the ‘Up’ button placed below the list of all the actions, put ‘triggerEnable’ one line above ‘missionCompleted’. Now we need to make a pause between displaying the objective status as complete and ending the mission. Add a ‘wait’ action for 3 seconds and place it between ‘triggerEnable’ and ‘missionCompleted’.
If you play the mission now, you’ll probably feel like it’s too short. Let’s let the player play around a little. To do this, add a new ‘wait’ action to the ‘check_for_mission_failed’ trigger and set it to 120. Place it after ‘triggerDisable’, but before all the other actions. This means that if the bombing run is unsuccessful and the factory survives it, a 2-minute pause will take place before the mission ends and the objective is marked as completed. This is more than enough for the player to shoot down a few more enemy airplanes. At the same time, if the player destroys all the enemy bombers, the ‘check_for_mission_completion’ trigger will be fulfilled, and the mission will end before the 2 minutes is up.
Checking whether the enemy airplanes have reached the factory
It’s time to check whether the enemy bombers have reached the factory and whether it’s time to start bombing it. To do this, create a new ‘check_for_bombers_near_factory’ trigger and uncheck the ‘Enabled’ box. Create ‘unitDistanceBetween’ as the condition and set it up like so:
- Set ‘object’ to ‘enemy_bombers’.
- Set ‘target’ to ‘factory_point’.
- Set ‘value’ to 5,000 meters.
- Set ‘math’ to ‘2D’.
Go to the ‘check_for_reach_point’ trigger and add a call for the ‘check_for_bombers_near_factory’ trigger to the already existing ‘triggerEnable’.
Assigning a bombing objective to the enemy bombers
We just created a trigger that checks whether the bombers have reached their target, and now we need to assign them an objective to attack the factory. Add a new action to this trigger, selecting ‘unitAttackTarget’ from the list and setting it up like so:
- Set ‘object’ to ‘enemy_bombers’.
- Set ‘target’ to ‘bomb_targets’.
- Press the ‘+ firerandom’ button and tick the box, which allows the bombers to attack targets at random rather than based on a list.
Evacuating the bombers
To make sure the bombers don’t keep flying over the factory after their ammo is depleted, we need to give them a command to withdraw. First, we’ll need to create an evacuation point. Using the ‘Create point zone’ button found in the Mission Editor’s toolbar, create a new zone roughly at the bombers’ initial position. Raise it to a height of 500 meters and call it ‘evacuate_point’.
Now go to the ‘check_for_bombers_near_factory’ trigger and add a ‘unitMoveTo’ action to it, setting it up like so:
- Set ‘object’ to ‘enemy_bombers’.
- Set ‘target’ to ‘evacuate_point’.
- Leave ‘speed’ unchanged—each airplane will fly at its maximum possible speed.
- Find ‘shouldKeepFormation’ and make sure the box is unchecked. This allows the airplanes to fly chaotically, creating the illusion that they’re fleeing.
Place this action one line above ‘unitAttackTarget’. As a result of this, the bombers will get an order to evacuate after reaching the factory, along with an order to attack. Since the order to attack has priority, they’ll first attack the target and, when they run out of ammunition, they’ll start to flee in panic.
Determining the end of the bombing run
Now it’s time to enable the check for whether the German bombers have reached their target and destroyed the factory. However, we won’t be assessing the success of the bombing run while it’s still happening, but instead after it’s done. How do we determine whether the bombing run is done or not? To do this, let’s create a trigger called ‘check_for_bombing_end’ and uncheck its ‘Enabled’ box. Now add a check condition, choosing ‘unitWhenStatus’ from the list and configuring it like so:
- Set ‘object’ to ‘enemy_bombers’.
- Set ‘object_type’ to ‘noBombs’.
- Set ‘check_object’ to ‘all’.
We’ve just created a check which will be fulfilled if all the German bombers run out of bombs. Since bombs need time to reach the ground, let’s change the frequency of this check from 1 second to 120 seconds. To do this, select ‘periodicEvent’ in the trigger’s ‘Events’ tree and change its ‘time’ parameter from 1 to 120.
Add a call for this trigger to the ‘check_for_bombers_near_factory’ trigger using ‘triggerEnable’.
Checking the success of the bombing run
The time the bomb run ends is now known to us—now we need to assess its results. To do this, create two new triggers called ‘check_for_mission_failure’ and ‘check_for_mission_failure’. Uncheck ‘Enabled’ in both triggers. Go to the ‘check_for_bombing_end’ trigger and, using a ‘triggerEnable’ action, call both the newly created triggers. This means that as soon as the bombing run reaches its end, we’ll perform both checks.
Go to the ‘check_for_mission_failure’ trigger and add a condition to it, choosing ‘unitWhenCountMatches’ from the list and configuring it like so:
- Set ‘object’ to ‘bomb_targets’
- Set ‘object_type’ to ‘isAlive’
- Set ‘func’ to ‘less’
- Set ‘value’ to 8
This condition will check all the structures in the ‘bomb_targets’ squad, and if there are fewer than 8 left, it will execute an action. Let’s add an action to block the activation of the ‘check_for_mission_failure’ trigger, since we no longer need it—we’ve already determined that the bombing run was successful and the factory was destroyed. Add a ‘triggerDisable’, setting its ‘target’ to ‘check_for_mission_failure’.
Go to the ‘check_for_mission_failure’ trigger and add a condition to it, choosing ‘unitWhenCountMatches’ from the list and configuring it like so:
- Set ‘object’ to ‘bomb_targets’
- Set ‘object_type’ to ‘isAlive’
- Set ‘func’ to ‘noLess’
- Set ‘value’ to 8
This condition will check all the structures in the ‘bomb_targets’ squad, and if they number at least 8, it will execute an action. Let’s add an action to block the activation of the ‘check_for_mission_failure’ trigger, since we no longer need it—we’ve already determined that the bombing run was unsuccessful and the factory was saved. Add a ‘triggerDisable’, setting its ‘target’ to ‘check_for_mission_failure’. Return to the ‘check_for_mission_failure’ trigger and add a new action which will mark the player’s primary objective—defending the factory—failed. Choose ‘moSetObjectiveStatus’ from the list, setting ‘target’ to ‘bombers_engaged’ and ‘status’ to 3, which means the mission is failed. Now add a ‘wait’ action for 3 seconds and end the list by adding ‘missionFailed’. As a result, if the bombing run ends with the factory having less than 8 buildings left, the mission to defend the factory is considered failed, and 3 seconds later, the mission itself is failed. Now it’s time to finish off the logic of the ‘check_for_mission_failure’ trigger. Add ‘moSetObjectiveStatus’ to it, setting ‘target’ to ‘bombers_engaged’ and ‘status’ to 2, which means the mission is complete. Now add a ‘wait’ action for 3 seconds and end the list by adding ‘missionCompleted’. As a result, if the bombing run ends with the factory having at least 8 buildings left, the mission to defend the factory is considered complete, and 3 seconds later, the mission itself is completed.
Assigning an objective to the enemy fighters to protect the bombers
If you’ve already tried playing the mission you’ve created, you probably noticed that the escort fighters react to the player’s airplanes with complete indifference. It’s time to fix that. Let’s create a new ‘check_for_player_near_bombers’ trigger and uncheck its ‘Enabled’ box. Let’s add a new condition to this trigger, choosing ‘unitDistanceBetween’ from the list and configuring it like so:
- Set ‘object’ to ‘player’
- Set ‘target’ to ‘enemy_bombers’
- Set ‘value’ to 3,000 meters
- Set ‘math’ to ‘2D’
Now we’ll add an action that will make the escort airplanes attack the player’s airplanes. Add a ‘unitAttackTarget’ action and configure it:
- Set ‘object’ to ‘enemy_bombers’
- Set ‘target’ to ‘player’
- Check the ‘fireRandom’ box
- Check the ‘playerAttracted’ box
- Set ‘playerAttractedCount’ to 2
- Set ‘playerAttractedEffRate’ to 0.7
This means that when the player comes within 3,000 meters of the bombers, the enemy fighters will attack his airplanes, choosing targets among them at random. At the same time, a minimum of 2 escort fighters will always attack the player’s airplane, and they will fire with 70% accuracy. Add a call for this trigger to the ‘check_for_reach_point’ trigger, using the ‘triggerEnable’ which is already there.