Skip to main content

Missile Training Script

Introduction

The Missile Training Script allows live missiles to be fired at players, without them causing any actual damage to the aircraft. This is by done by detecting a missile launch and checking if the distance between the missile and the player's aircraft is greater than a certain range. If it is within a certain range, it will remove the missile object and display a kill message to all players. This simulates a kill and is useful for training enviroments. It works with both air- and ground launched missiles, no matter if launched by a player or by the AI.

Basic Setup

In the mission editor, create a "ONCE" trigger with Event set to "NO EVENT". Leave Conditions empty. Under the Actions tab two actions are required. The first "DO SCRIPT FILE" loads the main threat_script.lua file. The second can be set to "DO SCRIPT" with the follwing script:

local Trainer = MISSILETRAINER
  :New( 300, "Missile Training Script ACTIVE" )
  :InitMessagesOnOff(true)
  :InitAlertsToAll(true) 
  :InitAlertsHitsOnOff(true)
  :InitAlertsLaunchesOnOff(false) 
  :InitBearingOnOff(false)
  :InitRangeOnOff(false)
  :InitTrackingOnOff(false)
  :InitTrackingToAll(false)
  :InitMenusOnOff(false)

This will allow changes to the Missile Training Script to be made within the mission editor. It is also recommended to colour code your triggers for easier organisation. A finished trigger setup will look like this:

grafik.png

Advanced Setup

If we want to enable or disable the Missile Training Script while the mission is running through the radio radio or other disired triggers, this can be done through a slightly more advanced setup. Start by reproducing the trigger setup above. 

Switch the "ONCE" trigger to "SWITCHED CONDITION" and add a "FLAG IS TRUE ("Insert Flag")" condition. This will activate the Missile Training Script once the flag is true. 

grafik.png

Create an additional "ONCE" trigger. If you want the ability to also disable the script while the mission runs, add a FLAG IS FALSE ("Insert Flag") condition, otherwise leave it empty.

Under the actions tab, add a "RADIO ITEM ADD" with the text you want to have displayed in the radio menu. Select the Flag you wish (Insert this flag under "Insert Flag"). 

grafik.png

Now your Missile Training Script will load once a player enables it through the radio menu. You can add a disable function similiarly by reversing the flag logic and making sure the Missile Training Script is only active if the Flag is True.