mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 10:46:19 +00:00
RANGE - added option to save target sheet
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
-- * Bomb, rocket and missile impact points can be marked by smoke.
|
-- * Bomb, rocket and missile impact points can be marked by smoke.
|
||||||
-- * Direct hits on targets can trigger flares.
|
-- * Direct hits on targets can trigger flares.
|
||||||
-- * Smoke and flare colors can be adjusted for each player via radio menu.
|
-- * Smoke and flare colors can be adjusted for each player via radio menu.
|
||||||
-- * Range information and weather at the range can be obtained via radio menu.
|
-- * Range information and weather report at the range can be reported via radio menu.
|
||||||
-- * Persistence: Bombing range results can be saved to disk and loaded the next time the mission is started.
|
-- * Persistence: Bombing range results can be saved to disk and loaded the next time the mission is started.
|
||||||
-- * Range control voice overs (>40) for hit assessment.
|
-- * Range control voice overs (>40) for hit assessment.
|
||||||
--
|
--
|
||||||
@@ -50,10 +50,11 @@
|
|||||||
-- @module Functional.Range
|
-- @module Functional.Range
|
||||||
-- @image Range.JPG
|
-- @image Range.JPG
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
--- RANGE class
|
--- RANGE class
|
||||||
-- @type RANGE
|
-- @type RANGE
|
||||||
-- @field #string ClassName Name of the Class.
|
-- @field #string ClassName Name of the Class.
|
||||||
-- @field #boolean Debug If true, debug info is sent as messages on the screen.
|
-- @field #boolean Debug If true, debug info is send as messages on the screen.
|
||||||
-- @field #boolean verbose Verbosity level. Higher means more output to DCS log file.
|
-- @field #boolean verbose Verbosity level. Higher means more output to DCS log file.
|
||||||
-- @field #string id String id of range for output in DCS log.
|
-- @field #string id String id of range for output in DCS log.
|
||||||
-- @field #string rangename Name of the range.
|
-- @field #string rangename Name of the range.
|
||||||
@@ -76,13 +77,13 @@
|
|||||||
-- @field #number Tmsg Time [sec] messages to players are displayed. Default 30 sec.
|
-- @field #number Tmsg Time [sec] messages to players are displayed. Default 30 sec.
|
||||||
-- @field #string examinergroupname Name of the examiner group which should get all messages.
|
-- @field #string examinergroupname Name of the examiner group which should get all messages.
|
||||||
-- @field #boolean examinerexclusive If true, only the examiner gets messages. If false, clients and examiner get messages.
|
-- @field #boolean examinerexclusive If true, only the examiner gets messages. If false, clients and examiner get messages.
|
||||||
-- @field #number strafemaxalt Maximum altitude in meters AGL for registering for a strafe run. Default is 914 m = 3000 ft.
|
-- @field #number strafemaxalt Maximum altitude above ground for registering for a strafe run. Default is 914 m = 3000 ft.
|
||||||
-- @field #number ndisplayresult Number of (player) results that a displayed. Default is 10.
|
-- @field #number ndisplayresult Number of (player) results that a displayed. Default is 10.
|
||||||
-- @field Utilities.Utils#SMOKECOLOR BombSmokeColor Color id used for smoking bomb targets.
|
-- @field Utilities.Utils#SMOKECOLOR BombSmokeColor Color id used for smoking bomb targets.
|
||||||
-- @field Utilities.Utils#SMOKECOLOR StrafeSmokeColor Color id used to smoke strafe targets.
|
-- @field Utilities.Utils#SMOKECOLOR StrafeSmokeColor Color id used to smoke strafe targets.
|
||||||
-- @field Utilities.Utils#SMOKECOLOR StrafePitSmokeColor Color id used to smoke strafe pit approach boxes.
|
-- @field Utilities.Utils#SMOKECOLOR StrafePitSmokeColor Color id used to smoke strafe pit approach boxes.
|
||||||
-- @field #number illuminationminalt Minimum altitude in meters AGL at which illumination bombs are fired. Default is 500 m.
|
-- @field #number illuminationminalt Minimum altitude AGL in meters at which illumination bombs are fired. Default is 500 m.
|
||||||
-- @field #number illuminationmaxalt Maximum altitude in meters AGL at which illumination bombs are fired. Default is 1000 m.
|
-- @field #number illuminationmaxalt Maximum altitude AGL in meters at which illumination bombs are fired. Default is 1000 m.
|
||||||
-- @field #number scorebombdistance Distance from closest target up to which bomb hits are counted. Default 1000 m.
|
-- @field #number scorebombdistance Distance from closest target up to which bomb hits are counted. Default 1000 m.
|
||||||
-- @field #number TdelaySmoke Time delay in seconds between impact of bomb and starting the smoke. Default 3 seconds.
|
-- @field #number TdelaySmoke Time delay in seconds between impact of bomb and starting the smoke. Default 3 seconds.
|
||||||
-- @field #boolean eventmoose If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
|
-- @field #boolean eventmoose If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
|
||||||
@@ -91,13 +92,16 @@
|
|||||||
-- @field #boolean trackmissiles If true (default), all missile types are tracked and impact point to closest bombing target is evaluated.
|
-- @field #boolean trackmissiles If true (default), all missile types are tracked and impact point to closest bombing target is evaluated.
|
||||||
-- @field #boolean defaultsmokebomb If true, initialize player settings to smoke bomb.
|
-- @field #boolean defaultsmokebomb If true, initialize player settings to smoke bomb.
|
||||||
-- @field #boolean autosave If true, automatically save results every X seconds.
|
-- @field #boolean autosave If true, automatically save results every X seconds.
|
||||||
-- @field #number instructorfreq Frequency on which the range control transmits.
|
-- @field #number instructorfreq Frequency on which the range control transmitts.
|
||||||
-- @field Sound.RadioQueue#RADIOQUEUE instructor Instructor radio queue.
|
-- @field Sound.RadioQueue#RADIOQUEUE instructor Instructor radio queue.
|
||||||
-- @field #number rangecontrolfreq Frequency on which the range control transmits.
|
-- @field #number rangecontrolfreq Frequency on which the range control transmitts.
|
||||||
-- @field Sound.RadioQueue#RADIOQUEUE rangecontrol Range control radio queue.
|
-- @field Sound.RadioQueue#RADIOQUEUE rangecontrol Range control radio queue.
|
||||||
-- @field #string rangecontrolrelayname Name of relay unit.
|
-- @field #string rangecontrolrelayname Name of relay unit.
|
||||||
-- @field #string instructorrelayname Name of relay unit.
|
-- @field #string instructorrelayname Name of relay unit.
|
||||||
-- @field #string soundpath Path inside miz file where the sound files are located. Default is "Range Soundfiles/".
|
-- @field #string soundpath Path inside miz file where the sound files are located. Default is "Range Soundfiles/".
|
||||||
|
-- @field #boolean targetsheet If true, players can save their target sheets. Rangeboss will not work if targetsheets do not save.
|
||||||
|
-- @field #string targetpath Path where to save the target sheets.
|
||||||
|
-- @field #string targetprefix File prefix for target sheet files.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *Don't only practice your art, but force your way into its secrets; art deserves that, for it and knowledge can raise man to the Divine.* - Ludwig van Beethoven
|
--- *Don't only practice your art, but force your way into its secrets; art deserves that, for it and knowledge can raise man to the Divine.* - Ludwig van Beethoven
|
||||||
@@ -121,7 +125,7 @@
|
|||||||
--
|
--
|
||||||
-- Due to a DCS bug, it is not possible to directly monitor when a player enters a plane. So in a mission with client slots, it is vital that
|
-- Due to a DCS bug, it is not possible to directly monitor when a player enters a plane. So in a mission with client slots, it is vital that
|
||||||
-- a player first enters as spectator or hits ESC twice and **after that** jumps into the slot of his aircraft!
|
-- a player first enters as spectator or hits ESC twice and **after that** jumps into the slot of his aircraft!
|
||||||
-- If that is not done, the script is not started correctly. This can be checked by looking at the radio menus. If the mission was entered correctly,
|
-- If that is not done, the script is not started correctly. This can be checked by looking at the radio menues. If the mission was entered correctly,
|
||||||
-- there should be an "On the Range" menu items in the "F10. Other..." menu.
|
-- there should be an "On the Range" menu items in the "F10. Other..." menu.
|
||||||
--
|
--
|
||||||
-- # Strafe Pits
|
-- # Strafe Pits
|
||||||
@@ -130,12 +134,12 @@
|
|||||||
--
|
--
|
||||||
-- A strafe pit can be added to the range by the @{#RANGE.AddStrafePit}(*targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline*) function.
|
-- A strafe pit can be added to the range by the @{#RANGE.AddStrafePit}(*targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline*) function.
|
||||||
--
|
--
|
||||||
-- * The first parameter *targetnames* defines the target or targets. This can be a single item or a Table with the name(s) of @{Wrapper.Unit} or @{Static} objects defined in the mission editor.
|
-- * The first parameter *targetnames* defines the target or targets. This has to be given as a lua table which contains the names of @{Wrapper.Unit} or @{Static} objects defined in the mission editor.
|
||||||
-- * In order to perform a valid pass on the strafe pit, the pilot has to begin his run from the correct direction. Therefore, an "approach box" is defined in front
|
-- * In order to perform a valid pass on the strafe pit, the pilot has to begin his run from the correct direction. Therefore, an "approach box" is defined in front
|
||||||
-- of the strafe targets. The parameters *boxlength* and *boxwidth* define the size of the box in meters, while the *heading* parameter defines the heading of the box FROM the target.
|
-- of the strafe targets. The parameters *boxlength* and *boxwidth* define the size of the box while the parameter *heading* defines its direction.
|
||||||
-- For example, if heading 120 is set, the approach box will start FROM the target and extend outwards on heading 120. A strafe run approach must then be flown apx. heading 300 TOWARDS the target.
|
-- If the parameter *heading* is passed as **nil**, the heading is automatically taken from the heading of the first target unit as defined in the ME.
|
||||||
-- If the parameter *heading* is passed as **nil**, the heading is automatically taken from the heading set in the ME for the first target unit.
|
-- The parameter *inverseheading* turns the heading around by 180 degrees. This is sometimes useful, since the default heading of strafe target units point in the
|
||||||
-- * The parameter *inverseheading* turns the heading around by 180 degrees. This is useful when the default heading of strafe target units point in the wrong/opposite direction.
|
-- wrong/opposite direction.
|
||||||
-- * The parameter *goodpass* defines the number of hits a pilot has to achieve during a run to be judged as a "good" pass.
|
-- * The parameter *goodpass* defines the number of hits a pilot has to achieve during a run to be judged as a "good" pass.
|
||||||
-- * The last parameter *foulline* sets the distance from the pit targets to the foul line. Hit from closer than this line are not counted!
|
-- * The last parameter *foulline* sets the distance from the pit targets to the foul line. Hit from closer than this line are not counted!
|
||||||
--
|
--
|
||||||
@@ -149,9 +153,10 @@
|
|||||||
--
|
--
|
||||||
-- One ore multiple bombing targets can be added to the range by the @{#RANGE.AddBombingTargets}(targetnames, goodhitrange, randommove) function.
|
-- One ore multiple bombing targets can be added to the range by the @{#RANGE.AddBombingTargets}(targetnames, goodhitrange, randommove) function.
|
||||||
--
|
--
|
||||||
-- * The first parameter *targetnames* defines the target or targets. This can be a single item or a Table with the name(s) of @{Wrapper.Unit} or @{Static} objects defined in the mission editor.
|
-- * The first parameter *targetnames* has to be a lua table, which contains the names of @{Wrapper.Unit} and/or @{Static} objects defined in the mission editor.
|
||||||
-- * The (optional) parameter *goodhitrange* specifies the radius in metres around the target within which a bomb/rocket hit is considered to be "good".
|
-- Note that the @{Range} logic **automatically** determines, if a name belongs to a @{Wrapper.Unit} or @{Static} object now.
|
||||||
-- * If final (optional) parameter *randommove* can be enabled to create moving targets. If this parameter is set to true, the units of this bombing target will randomly move within the range zone.
|
-- * The (optional) parameter *goodhitrange* specifies the radius around the target. If a bomb or rocket falls at a distance smaller than this number, the hit is considered to be "good".
|
||||||
|
-- * If final (optional) parameter "*randommove*" can be enabled to create moving targets. If this parameter is set to true, the units of this bombing target will randomly move within the range zone.
|
||||||
-- Note that there might be quirks since DCS units can get stuck in buildings etc. So it might be safer to manually define a route for the units in the mission editor if moving targets are desired.
|
-- Note that there might be quirks since DCS units can get stuck in buildings etc. So it might be safer to manually define a route for the units in the mission editor if moving targets are desired.
|
||||||
--
|
--
|
||||||
-- ## Adding Groups
|
-- ## Adding Groups
|
||||||
@@ -186,7 +191,7 @@
|
|||||||
--
|
--
|
||||||
-- The main range menu can be found at "F10. Other..." --> "F*X*. On the Range..." --> "F1. <Range Name>...".
|
-- The main range menu can be found at "F10. Other..." --> "F*X*. On the Range..." --> "F1. <Range Name>...".
|
||||||
--
|
--
|
||||||
-- The range menu contains the following submenus:
|
-- The range menu contains the following submenues:
|
||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
@@ -253,18 +258,19 @@
|
|||||||
-- -- Note that this could also be done manually by simply measuring the distance between the target and the foul line in the ME.
|
-- -- Note that this could also be done manually by simply measuring the distance between the target and the foul line in the ME.
|
||||||
-- GoldwaterRange:GetFoullineDistance("GWR Strafe Pit Left 1", "GWR Foul Line Left")
|
-- GoldwaterRange:GetFoullineDistance("GWR Strafe Pit Left 1", "GWR Foul Line Left")
|
||||||
--
|
--
|
||||||
-- -- Add strafe pits. Each pit (left and right) consists of two targets. Where "nil" is used as input, the default value is used.
|
-- -- Add strafe pits. Each pit (left and right) consists of two targets.
|
||||||
-- GoldwaterRange:AddStrafePit(strafepit_left, 3000, 300, nil, true, 30, 500)
|
-- GoldwaterRange:AddStrafePit(strafepit_left, 3000, 300, nil, true, 20, fouldist)
|
||||||
-- GoldwaterRange:AddStrafePit(strafepit_right, nil, nil, nil, true, nil, 500)
|
-- GoldwaterRange:AddStrafePit(strafepit_right, nil, nil, nil, true, nil, fouldist)
|
||||||
--
|
--
|
||||||
-- -- Add bombing targets. A good hit is if the bomb falls less then 50 m from the target.
|
-- -- Add bombing targets. A good hit is if the bomb falls less then 50 m from the target.
|
||||||
-- GoldwaterRange:AddBombingTargets(bombtargets, 50)
|
-- GoldwaterRange:AddBombingTargets(bombtargets, 50)
|
||||||
--
|
--
|
||||||
-- -- Start Range.
|
-- -- Start range.
|
||||||
-- GoldwaterRange:Start()
|
-- GoldwaterRange:Start()
|
||||||
--
|
--
|
||||||
-- The [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is (implicitly) used in this example.
|
-- The [476th - Air Weapons Range Objects mod](http://www.476vfightergroup.com/downloads.php?do=file&id=287) is (implicitly) used in this example.
|
||||||
--
|
--
|
||||||
|
--
|
||||||
-- # Debugging
|
-- # Debugging
|
||||||
--
|
--
|
||||||
-- In case you have problems, it is always a good idea to have a look at your DCS log file. You find it in your "Saved Games" folder, so for example in
|
-- In case you have problems, it is always a good idea to have a look at your DCS log file. You find it in your "Saved Games" folder, so for example in
|
||||||
@@ -284,6 +290,8 @@
|
|||||||
-- Note that it can happen that the RANGE radio menu is not shown. Check that the range object is defined as a **global** variable rather than a local one.
|
-- Note that it can happen that the RANGE radio menu is not shown. Check that the range object is defined as a **global** variable rather than a local one.
|
||||||
-- The could avoid the lua garbage collection to accidentally/falsely deallocate the RANGE objects.
|
-- The could avoid the lua garbage collection to accidentally/falsely deallocate the RANGE objects.
|
||||||
--
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
-- @field #RANGE
|
-- @field #RANGE
|
||||||
RANGE={
|
RANGE={
|
||||||
ClassName = "RANGE",
|
ClassName = "RANGE",
|
||||||
@@ -330,22 +338,26 @@ RANGE = {
|
|||||||
rangecontrolfreq = nil,
|
rangecontrolfreq = nil,
|
||||||
rangecontrol = nil,
|
rangecontrol = nil,
|
||||||
soundpath = "Range Soundfiles/",
|
soundpath = "Range Soundfiles/",
|
||||||
|
targetsheet = nil,
|
||||||
|
targetpath = nil,
|
||||||
|
targetprefix = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Default range parameters.
|
--- Default range parameters.
|
||||||
-- @list Defaults
|
-- @list Defaults
|
||||||
RANGE.Defaults={
|
RANGE.Defaults={
|
||||||
goodhitrange = 25, -- meters
|
goodhitrange=25,
|
||||||
strafemaxalt = 914, -- meters AGL
|
strafemaxalt=914,
|
||||||
dtBombtrack = 0.005, -- seconds
|
dtBombtrack=0.005,
|
||||||
Tmsg = 30, -- seconds
|
Tmsg=30,
|
||||||
ndisplayresult=10,
|
ndisplayresult=10,
|
||||||
rangeradius = 5000, -- meters
|
rangeradius=5000,
|
||||||
TdelaySmoke = 3.0, -- seconds
|
TdelaySmoke=3.0,
|
||||||
boxlength = 3000, -- meters
|
boxlength=3000,
|
||||||
boxwidth = 300, -- meters
|
boxwidth=300,
|
||||||
goodpass = 20, -- targethits per pass
|
goodpass=20,
|
||||||
foulline = 610, -- meters
|
goodhitrange=25,
|
||||||
|
foulline=610,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Target type, i.e. unit, static, or coordinate.
|
--- Target type, i.e. unit, static, or coordinate.
|
||||||
@@ -359,6 +371,13 @@ RANGE.TargetType = {
|
|||||||
COORD="Coordinate",
|
COORD="Coordinate",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Default range variables for RangeBoss/Hypeman tie in.
|
||||||
|
hypemanStrafeRollIn = "nil"
|
||||||
|
StrafeAircraftType = "strafeAircraftTypeNotSet"
|
||||||
|
Straferesult={}
|
||||||
|
clientRollingIn = false
|
||||||
|
clientStrafed = false
|
||||||
|
invalidStrafe = false
|
||||||
--- Player settings.
|
--- Player settings.
|
||||||
-- @type RANGE.PlayerData
|
-- @type RANGE.PlayerData
|
||||||
-- @field #boolean smokebombimpact Smoke bomb impact points.
|
-- @field #boolean smokebombimpact Smoke bomb impact points.
|
||||||
@@ -828,7 +847,7 @@ end
|
|||||||
|
|
||||||
--- Set maximal strafing altitude. Player entering a strafe pit above that altitude are not registered for a valid pass.
|
--- Set maximal strafing altitude. Player entering a strafe pit above that altitude are not registered for a valid pass.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #number maxalt Maximum altitude in meters AGL. Default is 914 m = 3000 ft.
|
-- @param #number maxalt Maximum altitude AGL in meters. Default is 914 m= 3000 ft.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetMaxStrafeAlt(maxalt)
|
function RANGE:SetMaxStrafeAlt(maxalt)
|
||||||
self.strafemaxalt=maxalt or RANGE.Defaults.strafemaxalt
|
self.strafemaxalt=maxalt or RANGE.Defaults.strafemaxalt
|
||||||
@@ -869,6 +888,22 @@ function RANGE:SetAutosaveOff()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Enable saving of player's target sheets and specify an optional directory path.
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string path (Optional) Path where to save the target sheets.
|
||||||
|
-- @param #string prefix (Optional) Prefix for target sheet files. File name will be saved as *prefix_aircrafttype-0001.csv*, *prefix_aircrafttype-0002.csv*, etc.
|
||||||
|
-- @return #RANGE self
|
||||||
|
function RANGE:SetTargetSheet(path, prefix)
|
||||||
|
if io then
|
||||||
|
self.targetsheet=true
|
||||||
|
self.targetpath=path
|
||||||
|
self.targetprefix=prefix
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: io is not desanitized. Cannot save target sheet.")
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set messages to examiner. The examiner will receive messages from all clients.
|
--- Set messages to examiner. The examiner will receive messages from all clients.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string examinergroupname Name of the group of the examiner.
|
-- @param #string examinergroupname Name of the group of the examiner.
|
||||||
@@ -900,10 +935,10 @@ end
|
|||||||
|
|
||||||
--- Set player setting whether bomb impact points are smoked or not.
|
--- Set player setting whether bomb impact points are smoked or not.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #boolean switch (Optional) If true, impact points of bombs will be smoked. Default is true.
|
-- @param #boolean switch If true nor nil default is to smoke impact points of bombs.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetDefaultPlayerSmokeBomb(switch)
|
function RANGE:SetDefaultPlayerSmokeBomb(switch)
|
||||||
if switch == nil or switch == true then
|
if switch==true or switch==nil then
|
||||||
self.defaultsmokebomb=true
|
self.defaultsmokebomb=true
|
||||||
else
|
else
|
||||||
self.defaultsmokebomb=false
|
self.defaultsmokebomb=false
|
||||||
@@ -1017,6 +1052,7 @@ function RANGE:SetMessagesON()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Enables tracking of all bomb types. Note that this is the default setting.
|
--- Enables tracking of all bomb types. Note that this is the default setting.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
@@ -1065,6 +1101,7 @@ function RANGE:TrackMissilesOFF()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Enable range control and set frequency.
|
--- Enable range control and set frequency.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #number frequency Frequency in MHz. Default 256 MHz.
|
-- @param #number frequency Frequency in MHz. Default 256 MHz.
|
||||||
@@ -1089,7 +1126,7 @@ end
|
|||||||
|
|
||||||
--- Set sound files folder within miz file.
|
--- Set sound files folder within miz file.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string path Path for sound files. Default "Range Soundfiles/". Mind the slash "/" at the end!
|
-- @param #string path Path for sound files. Default "ATIS Soundfiles/". Mind the slash "/" at the end!
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetSoundfilesPath(path)
|
function RANGE:SetSoundfilesPath(path)
|
||||||
self.soundpath=tostring(path or "Range Soundfiles/")
|
self.soundpath=tostring(path or "Range Soundfiles/")
|
||||||
@@ -1098,16 +1135,16 @@ function RANGE:SetSoundfilesPath( path )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Add new strafe pit. For a strafe pit, hits from guns are counted. One pit can consist of several units.
|
--- Add new strafe pit. For a strafe pit, hits from guns are counted. One pit can consist of several units.
|
||||||
-- A strafe run approach is only valid if the player enters via a zone in front of the pit, which is defined by boxlength, boxwidth, and heading.
|
-- Note, an approach is only valid, if the player enters via a zone in front of the pit, which defined by boxlength and boxheading.
|
||||||
-- Furthermore, the player must not be too high and fly in the direction of the pit to make a valid target apporoach.
|
-- Furthermore, the player must not be too high and fly in the direction of the pit to make a valid target apporoach.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #table targetnames Single or multiple (Table) unit or static names defining the strafe targets. The first target in the list determines the approach box origin (heading and box).
|
-- @param #table targetnames Table of unit or static names defining the strafe targets. The first target in the list determines the approach zone (heading and box).
|
||||||
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
||||||
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
||||||
-- @param #number heading (Optional) Approach box heading in degrees (originating FROM the target). Default is the heading set in the ME for the first target unit
|
-- @param #number heading (Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
|
||||||
-- @param #boolean inverseheading (Optional) Use inverse heading (heading --> heading - 180 Degrees). Default is false.
|
-- @param #boolean inverseheading (Optional) Take inverse heading (heading --> heading - 180 Degrees). Default is false.
|
||||||
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
||||||
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default is 610 m = 2000 ft. Set to 0 for no foul line.
|
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddStrafePit(targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline)
|
function RANGE:AddStrafePit(targetnames, boxlength, boxwidth, heading, inverseheading, goodpass, foulline)
|
||||||
self:F({targetnames=targetnames, boxlength=boxlength, boxwidth=boxwidth, heading=heading, inverseheading=inverseheading, goodpass=goodpass, foulline=foulline})
|
self:F({targetnames=targetnames, boxlength=boxlength, boxwidth=boxwidth, heading=heading, inverseheading=inverseheading, goodpass=goodpass, foulline=foulline})
|
||||||
@@ -1183,7 +1220,7 @@ function RANGE:AddStrafePit( targetnames, boxlength, boxwidth, heading, inverseh
|
|||||||
if heading<0 then
|
if heading<0 then
|
||||||
heading=heading+360
|
heading=heading+360
|
||||||
end
|
end
|
||||||
if heading >= 360 then
|
if heading>360 then
|
||||||
heading=heading-360
|
heading=heading-360
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1237,6 +1274,7 @@ function RANGE:AddStrafePit( targetnames, boxlength, boxwidth, heading, inverseh
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add all units of a group as one new strafe target pit.
|
--- Add all units of a group as one new strafe target pit.
|
||||||
-- For a strafe pit, hits from guns are counted. One pit can consist of several units.
|
-- For a strafe pit, hits from guns are counted. One pit can consist of several units.
|
||||||
-- Note, an approach is only valid, if the player enters via a zone in front of the pit, which defined by boxlength and boxheading.
|
-- Note, an approach is only valid, if the player enters via a zone in front of the pit, which defined by boxlength and boxheading.
|
||||||
@@ -1246,7 +1284,7 @@ end
|
|||||||
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
||||||
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
||||||
-- @param #number heading (Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
|
-- @param #number heading (Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
|
||||||
-- @param #boolean inverseheading (Optional) Use inverse heading (heading --> heading - 180 Degrees). Default is false.
|
-- @param #boolean inverseheading (Optional) Take inverse heading (heading --> heading - 180 Degrees). Default is false.
|
||||||
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
||||||
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
|
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
@@ -1280,9 +1318,9 @@ end
|
|||||||
|
|
||||||
--- Add bombing target(s) to range.
|
--- Add bombing target(s) to range.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #table targetnames Single or multiple (Table) names of unit or static objects serving as bomb targets.
|
-- @param #table targetnames Table containing names of unit or static objects serving as bomb targets.
|
||||||
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
-- @param #number goodhitrange (Optional) Max distance from target unit (in meters) which is considered as a good hit. Default is 25 m.
|
||||||
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargets(targetnames, goodhitrange, randommove)
|
function RANGE:AddBombingTargets(targetnames, goodhitrange, randommove)
|
||||||
self:F({targetnames=targetnames, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({targetnames=targetnames, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@@ -1320,8 +1358,8 @@ end
|
|||||||
--- Add a unit or static object as bombing target.
|
--- Add a unit or static object as bombing target.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE unit Positionable (unit or static) of the strafe target.
|
-- @param Wrapper.Positionable#POSITIONABLE unit Positionable (unit or static) of the strafe target.
|
||||||
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
||||||
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
||||||
self:F({unit=unit, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({unit=unit, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@@ -1374,25 +1412,13 @@ function RANGE:AddBombingTargetUnit( unit, goodhitrange, randommove )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a coordinate of a bombing target.
|
|
||||||
|
--- Add a coordinate of a bombing target. This
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Core.Point#COORDINATE coord The coordinate.
|
-- @param Core.Point#COORDINATE coord The coordinate.
|
||||||
-- @param #string name (Optional) Name of target. Default is "Bomb Target".
|
-- @param #string name Name of target.
|
||||||
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
-- @usage
|
|
||||||
--
|
|
||||||
-- -- Setup a Range
|
|
||||||
-- RangeOne = RANGE:New( "Range One" )
|
|
||||||
-- -- Find the STATIC target object as setup in the ME.
|
|
||||||
-- RangeOneBombTarget = STATIC:FindByName( "RangeOneBombTarget" )
|
|
||||||
-- -- Add the coordinate of the STATIC target object as a bomb target (thus keeping the bomb function active, even if the STATIC target is destroyed).
|
|
||||||
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate(), "RangeOneBombTarget", 50)
|
|
||||||
-- -- Or, add the coordinate of the STATIC target object as a bomb target using default values (name will be "Bomb Target", goodhitrange will be 25 m).
|
|
||||||
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate() )
|
|
||||||
-- -- Start Range.
|
|
||||||
-- RangeOne:Start()
|
|
||||||
--
|
|
||||||
function RANGE:AddBombingTargetCoordinate(coord, name, goodhitrange)
|
function RANGE:AddBombingTargetCoordinate(coord, name, goodhitrange)
|
||||||
|
|
||||||
local target={} --#RANGE.BombTarget
|
local target={} --#RANGE.BombTarget
|
||||||
@@ -1413,8 +1439,8 @@ end
|
|||||||
--- Add all units of a group as bombing targets.
|
--- Add all units of a group as bombing targets.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Wrapper.Group#GROUP group Group of bombing targets.
|
-- @param Wrapper.Group#GROUP group Group of bombing targets.
|
||||||
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
||||||
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargetGroup(group, goodhitrange, randommove)
|
function RANGE:AddBombingTargetGroup(group, goodhitrange, randommove)
|
||||||
self:F({group=group, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({group=group, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@@ -1433,22 +1459,11 @@ function RANGE:AddBombingTargetGroup( group, goodhitrange, randommove )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the foul line distance between strafe pit target and a foul line distance marker object.
|
--- Measures the foule line distance between two unit or static objects.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string namepit Name of the strafe pit target object.
|
-- @param #string namepit Name of the strafe pit target object.
|
||||||
-- @param #string namefoulline Name of the foul line distance marker object.
|
-- @param #string namefoulline Name of the fould line distance marker object.
|
||||||
-- @return #number Foul line distance in meters.
|
-- @return #number Foul line distance in meters.
|
||||||
-- @usage
|
|
||||||
--
|
|
||||||
-- -- Setup a Range
|
|
||||||
-- RangeOne = RANGE:New( "Range One" )
|
|
||||||
-- -- Get distance between strafe target objext and foul line distance marker object.
|
|
||||||
-- RangeOneFoulDistance = RangeOne:GetFoullineDistance( "RangeOneStrafeTarget" , "RangeOneFoulLineObject" )
|
|
||||||
-- -- Add a strafe pit using the measured foul line distance. Where nil is used, strafe pit default values will be used - adjust as required.
|
|
||||||
-- RangeOne:AddStrafePit( "RangeOneStrafeTarget", nil, nil, nil, nil, nil, RangeOneFoulDistance )
|
|
||||||
-- -- Start Range.
|
|
||||||
-- RangeOne:Start()
|
|
||||||
--
|
|
||||||
function RANGE:GetFoullineDistance(namepit, namefoulline)
|
function RANGE:GetFoullineDistance(namepit, namefoulline)
|
||||||
self:F({namepit=namepit, namefoulline=namefoulline})
|
self:F({namepit=namepit, namefoulline=namefoulline})
|
||||||
|
|
||||||
@@ -1559,6 +1574,7 @@ function RANGE:onEvent( Event )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Range event handler for event birth.
|
--- Range event handler for event birth.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
@@ -1573,6 +1589,7 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
self:T3(self.id.."BIRTH: player = "..tostring(_playername))
|
self:T3(self.id.."BIRTH: player = "..tostring(_playername))
|
||||||
|
|
||||||
if _unit and _playername then
|
if _unit and _playername then
|
||||||
|
|
||||||
local _uid=_unit:GetID()
|
local _uid=_unit:GetID()
|
||||||
local _group=_unit:GetGroup()
|
local _group=_unit:GetGroup()
|
||||||
local _gid=_group:GetID()
|
local _gid=_group:GetID()
|
||||||
@@ -1609,9 +1626,9 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
self.timerCheckZone=TIMER:New(self._CheckInZone, self, EventData.IniUnitName):Start(1, 1)
|
self.timerCheckZone=TIMER:New(self._CheckInZone, self, EventData.IniUnitName):Start(1, 1)
|
||||||
self.planes[_uid] = true
|
self.planes[_uid] = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Range event handler for event hit.
|
--- Range event handler for event hit.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
@@ -1672,6 +1689,7 @@ function RANGE:OnEventHit( EventData )
|
|||||||
self:_DisplayMessageToGroup(_unit, text)
|
self:_DisplayMessageToGroup(_unit, text)
|
||||||
self:T2(self.id..text)
|
self:T2(self.id..text)
|
||||||
_currentTarget.pastfoulline=true
|
_currentTarget.pastfoulline=true
|
||||||
|
invalidStrafe = true --Rangeboss Edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1701,7 +1719,6 @@ function RANGE:OnEventHit( EventData )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
||||||
@@ -1762,6 +1779,7 @@ function RANGE:OnEventShot( EventData )
|
|||||||
|
|
||||||
-- Only track if distance player to range is < 25 km. Also check that a player shot. No need to track AI weapons.
|
-- Only track if distance player to range is < 25 km. Also check that a player shot. No need to track AI weapons.
|
||||||
if _track and dPR<=self.BombtrackThreshold and _unit and _playername then
|
if _track and dPR<=self.BombtrackThreshold and _unit and _playername then
|
||||||
|
|
||||||
-- Player data.
|
-- Player data.
|
||||||
local playerData=self.PlayerSettings[_playername] --#RANGE.PlayerData
|
local playerData=self.PlayerSettings[_playername] --#RANGE.PlayerData
|
||||||
|
|
||||||
@@ -1775,7 +1793,8 @@ function RANGE:OnEventShot( EventData )
|
|||||||
local function trackBomb(_ordnance)
|
local function trackBomb(_ordnance)
|
||||||
|
|
||||||
-- When the pcall returns a failure the weapon has hit.
|
-- When the pcall returns a failure the weapon has hit.
|
||||||
local _status, _bombPos = pcall( function()
|
local _status,_bombPos = pcall(
|
||||||
|
function()
|
||||||
return _ordnance:getPoint()
|
return _ordnance:getPoint()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1843,7 +1862,9 @@ function RANGE:OnEventShot( EventData )
|
|||||||
_distance = _temp
|
_distance = _temp
|
||||||
_closetTarget = _bombtarget
|
_closetTarget = _bombtarget
|
||||||
_closeCoord=targetcoord
|
_closeCoord=targetcoord
|
||||||
if _distance <= 0.5 * _bombtarget.goodhitrange then
|
if _distance <= 1.53 then -- Rangeboss Edit
|
||||||
|
_hitquality = "SHACK" -- Rangeboss Edit
|
||||||
|
elseif _distance <= 0.5*_bombtarget.goodhitrange then --Rangeboss Edit
|
||||||
_hitquality = "EXCELLENT"
|
_hitquality = "EXCELLENT"
|
||||||
elseif _distance <= _bombtarget.goodhitrange then
|
elseif _distance <= _bombtarget.goodhitrange then
|
||||||
_hitquality = "GOOD"
|
_hitquality = "GOOD"
|
||||||
@@ -1876,6 +1897,10 @@ function RANGE:OnEventShot( EventData )
|
|||||||
result.player=playerData.playername
|
result.player=playerData.playername
|
||||||
result.time=timer.getAbsTime()
|
result.time=timer.getAbsTime()
|
||||||
result.airframe=playerData.airframe
|
result.airframe=playerData.airframe
|
||||||
|
result.roundsFired=0 --Rangeboss Edit
|
||||||
|
result.roundsHit=0 --Rangeboss Edit
|
||||||
|
result.roundsQuality="N/A" --Rangeboss Edit
|
||||||
|
result.rangename = self.rangename
|
||||||
|
|
||||||
-- Add to table.
|
-- Add to table.
|
||||||
table.insert(_results, result)
|
table.insert(_results, result)
|
||||||
@@ -1916,6 +1941,76 @@ end
|
|||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- FSM Functions
|
-- FSM Functions
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
function RANGE:_SaveTargetSheet(_playername, result) --RangeBoss Specific Function
|
||||||
|
|
||||||
|
--- Function that saves data to file
|
||||||
|
local function _savefile(filename, data)
|
||||||
|
local f = io.open(filename, "wb")
|
||||||
|
if f then
|
||||||
|
f:write(data)
|
||||||
|
f:close()
|
||||||
|
else
|
||||||
|
env.info("RANGEBOSS EDIT - could not save target sheet to file")
|
||||||
|
--self:E(self.lid..string.format("ERROR: could not save target sheet to file %s.\nFile may contain invalid characters.", tostring(filename)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Set path or default.
|
||||||
|
local path=self.targetpath
|
||||||
|
if lfs then
|
||||||
|
path=path or lfs.writedir()..[[Logs\]]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create unused file name.
|
||||||
|
local filename=nil
|
||||||
|
for i=1,9999 do
|
||||||
|
|
||||||
|
-- Create file name
|
||||||
|
if self.targetprefix then
|
||||||
|
filename=string.format("%s_%s-%04d.csv", self.targetprefix, playerData.actype, i)
|
||||||
|
else
|
||||||
|
local name=UTILS.ReplaceIllegalCharacters(_playername, "_")
|
||||||
|
filename=string.format("RANGERESULTS-%s_Targetsheet-%s-%04d.csv",self.rangename,name, i)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set path.
|
||||||
|
if path~=nil then
|
||||||
|
filename=path.."\\"..filename
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if file exists.
|
||||||
|
local _exists=UTILS.FileExists(filename)
|
||||||
|
if not _exists then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Header line
|
||||||
|
local data="Name,Target,Distance,Radial,Quality,Rounds Fired,Rounds Hit,Rounds Quality,Attack Heading,Weapon,Airframe,Mission Time,OS Time\n"
|
||||||
|
|
||||||
|
--local result=_result --#RANGE.BombResult
|
||||||
|
local distance=result.distance
|
||||||
|
local weapon=result.weapon
|
||||||
|
local target=result.name
|
||||||
|
local radial=result.radial
|
||||||
|
local quality=result.quality
|
||||||
|
local time=UTILS.SecondsToClock(result.time)
|
||||||
|
local airframe=result.airframe
|
||||||
|
local date="n/a"
|
||||||
|
local roundsFired=result.roundsFired
|
||||||
|
local roundsHit=result.roundsHit
|
||||||
|
local strafeResult=result.roundsQuality
|
||||||
|
local attackHeading=result.heading
|
||||||
|
if os then
|
||||||
|
date=os.date()
|
||||||
|
end
|
||||||
|
data=data..string.format("%s,%s,%.2f,%03d,%s,%03d,%03d,%s,%03d,%s,%s,%s,%s", _playername, target, distance, radial, quality, roundsFired, roundsHit, strafeResult, attackHeading, weapon, airframe, time, date)
|
||||||
|
|
||||||
|
|
||||||
|
-- Save file.
|
||||||
|
_savefile(filename, data)
|
||||||
|
end
|
||||||
|
|
||||||
--- Check spawn queue and spawn aircraft if necessary.
|
--- Check spawn queue and spawn aircraft if necessary.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
@@ -1952,6 +2047,7 @@ function RANGE:onafterStatus( From, Event, To )
|
|||||||
text=text..string.format(", Control %.3f MHz (Relay=%s alive=%s)", self.rangecontrolfreq, tostring(self.rangecontrolrelayname), alive)
|
text=text..string.format(", Control %.3f MHz (Relay=%s alive=%s)", self.rangecontrolfreq, tostring(self.rangecontrolrelayname), alive)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Check range status.
|
-- Check range status.
|
||||||
self:I(self.id..text)
|
self:I(self.id..text)
|
||||||
|
|
||||||
@@ -2003,6 +2099,7 @@ function RANGE:onafterExitRange( From, Event, To, player )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Function called after bomb impact on range.
|
--- Function called after bomb impact on range.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@@ -2012,11 +2109,16 @@ end
|
|||||||
-- @param #RANGE.PlayerData player Player data table.
|
-- @param #RANGE.PlayerData player Player data table.
|
||||||
function RANGE:onafterImpact(From, Event, To, result, player)
|
function RANGE:onafterImpact(From, Event, To, result, player)
|
||||||
|
|
||||||
-- Send message to player.
|
|
||||||
local text = string.format( "%s, impact %03d° for %d m (%d ft)", player.playername, result.radial, result.distance, UTILS.MetersToFeet( result.distance ) )
|
|
||||||
-- Only display target name if there is more than one bomb target.
|
-- Only display target name if there is more than one bomb target.
|
||||||
|
local targetname=nil
|
||||||
if #self.bombingTargets>1 then
|
if #self.bombingTargets>1 then
|
||||||
text = text .. string.format( " from bulls of target %s.", result.name )
|
local targetname=result.name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Send message to player.
|
||||||
|
local text=string.format("%s, impact %03d° for %d ft", player.playername, result.radial, UTILS.MetersToFeet(result.distance))
|
||||||
|
if targetname then
|
||||||
|
text=text..string.format(" from bulls of target %s.")
|
||||||
else
|
else
|
||||||
text=text.."."
|
text=text.."."
|
||||||
end
|
end
|
||||||
@@ -2120,7 +2222,7 @@ function RANGE:onafterSave( From, Event, To )
|
|||||||
_savefile(filename, scores)
|
_savefile(filename, scores)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Function called before load event. Checks that io and lfs are desanitized.
|
--- Function called before save event. Checks that io and lfs are desanitized.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
@@ -2245,9 +2347,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- Sort results table wrt number of hits.
|
-- Sort results table wrt number of hits.
|
||||||
local _sort = function( a, b )
|
local _sort = function( a,b ) return a.hits > b.hits end
|
||||||
return a.hits > b.hits
|
|
||||||
end
|
|
||||||
table.sort(_results,_sort)
|
table.sort(_results,_sort)
|
||||||
|
|
||||||
-- Prepare message of best results.
|
-- Prepare message of best results.
|
||||||
@@ -2321,9 +2421,7 @@ function RANGE:_DisplayStrafePitResults( _unitName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Sort list!
|
--Sort list!
|
||||||
local _sort = function( a, b )
|
local _sort = function( a,b ) return a.hits > b.hits end
|
||||||
return a.hits > b.hits
|
|
||||||
end
|
|
||||||
table.sort(_playerResults,_sort)
|
table.sort(_playerResults,_sort)
|
||||||
|
|
||||||
-- Add top 10 results.
|
-- Add top 10 results.
|
||||||
@@ -2364,9 +2462,7 @@ function RANGE:_DisplayMyBombingResults( _unitName )
|
|||||||
else
|
else
|
||||||
|
|
||||||
-- Sort results wrt to distance.
|
-- Sort results wrt to distance.
|
||||||
local _sort = function( a, b )
|
local _sort = function( a,b ) return a.distance < b.distance end
|
||||||
return a.distance < b.distance
|
|
||||||
end
|
|
||||||
table.sort(_results,_sort)
|
table.sort(_results,_sort)
|
||||||
|
|
||||||
-- Loop over results.
|
-- Loop over results.
|
||||||
@@ -2436,9 +2532,7 @@ function RANGE:_DisplayBombingResults( _unitName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Sort list of player results.
|
-- Sort list of player results.
|
||||||
local _sort = function( a, b )
|
local _sort = function( a,b ) return a.distance < b.distance end
|
||||||
return a.distance < b.distance
|
|
||||||
end
|
|
||||||
table.sort(_playerResults,_sort)
|
table.sort(_playerResults,_sort)
|
||||||
|
|
||||||
-- Loop over player results.
|
-- Loop over player results.
|
||||||
@@ -2489,7 +2583,7 @@ function RANGE:_DisplayRangeInfo( _unitname )
|
|||||||
local range=coord:Get2DDistance(position)
|
local range=coord:Get2DDistance(position)
|
||||||
|
|
||||||
-- Bearing string.
|
-- Bearing string.
|
||||||
local Bs = string.format( "%03d°", angle )
|
local Bs=string.format('%03d°', angle)
|
||||||
|
|
||||||
local texthit
|
local texthit
|
||||||
if self.PlayerSettings[playername].flaredirecthits then
|
if self.PlayerSettings[playername].flaredirecthits then
|
||||||
@@ -2583,7 +2677,7 @@ function RANGE:_DisplayBombTargets( _unitname )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:_DisplayMessageToGroup( _unit, _text, 60, true, true )
|
self:_DisplayMessageToGroup(_unit,_text, 120, true, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2627,6 +2721,7 @@ function RANGE:_DisplayStrafePits( _unitname )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Report weather conditions at range. Temperature, QFE pressure and wind data.
|
--- Report weather conditions at range. Temperature, QFE pressure and wind data.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string _unitname Name of the player unit.
|
-- @param #string _unitname Name of the player unit.
|
||||||
@@ -2656,7 +2751,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
|
|||||||
-- Get Beaufort wind scale.
|
-- Get Beaufort wind scale.
|
||||||
local Bn,Bd=UTILS.BeaufortScale(Ws)
|
local Bn,Bd=UTILS.BeaufortScale(Ws)
|
||||||
|
|
||||||
local WD = string.format( "%03d°", Wd )
|
local WD=string.format('%03d°', Wd)
|
||||||
local Ts=string.format("%d°C",T)
|
local Ts=string.format("%d°C",T)
|
||||||
|
|
||||||
local hPa2inHg=0.0295299830714
|
local hPa2inHg=0.0295299830714
|
||||||
@@ -2667,11 +2762,12 @@ function RANGE:_DisplayRangeWeather( _unitname )
|
|||||||
local tW=string.format("%.1f m/s", Ws)
|
local tW=string.format("%.1f m/s", Ws)
|
||||||
local tP=string.format("%.1f mmHg", P*hPa2mmHg)
|
local tP=string.format("%.1f mmHg", P*hPa2mmHg)
|
||||||
if settings:IsImperial() then
|
if settings:IsImperial() then
|
||||||
-- tT=string.format("%d°F", UTILS.CelsiusToFahrenheit(T))
|
--tT=string.format("%d°F", UTILS.CelciusToFarenheit(T))
|
||||||
tW=string.format("%.1f knots", UTILS.MpsToKnots(Ws))
|
tW=string.format("%.1f knots", UTILS.MpsToKnots(Ws))
|
||||||
tP=string.format("%.2f inHg", P*hPa2inHg)
|
tP=string.format("%.2f inHg", P*hPa2inHg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Message text.
|
-- Message text.
|
||||||
text=text..string.format("Weather Report at %s:\n", self.rangename)
|
text=text..string.format("Weather Report at %s:\n", self.rangename)
|
||||||
text=text..string.format("--------------------------------------------------\n")
|
text=text..string.format("--------------------------------------------------\n")
|
||||||
@@ -2744,6 +2840,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Get player unit and name.
|
-- Get player unit and name.
|
||||||
local _unit, _playername = self:_GetPlayerUnitAndName(_unitName)
|
local _unit, _playername = self:_GetPlayerUnitAndName(_unitName)
|
||||||
|
local unitheading = 0 --RangeBoss
|
||||||
|
|
||||||
if _unit and _playername then
|
if _unit and _playername then
|
||||||
|
|
||||||
@@ -2753,6 +2850,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Heading check.
|
-- Heading check.
|
||||||
local unitheading = _unit:GetHeading()
|
local unitheading = _unit:GetHeading()
|
||||||
|
unitheadingStrafe = _unit:GetHeading() --RangeBoss
|
||||||
local pitheading = targetheading-180
|
local pitheading = targetheading-180
|
||||||
local deltaheading = unitheading-pitheading
|
local deltaheading = unitheading-pitheading
|
||||||
local towardspit = math.abs(deltaheading)<=90 or math.abs(deltaheading-360)<=90
|
local towardspit = math.abs(deltaheading)<=90 or math.abs(deltaheading-360)<=90
|
||||||
@@ -2789,7 +2887,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Check if player is in strafe zone and below max alt.
|
-- Check if player is in strafe zone and below max alt.
|
||||||
if unitinzone then
|
if unitinzone then
|
||||||
|
StrafeAircraftType = _unit:GetTypeName() --RangeBoss
|
||||||
-- Still in zone, keep counting hits. Increase counter.
|
-- Still in zone, keep counting hits. Increase counter.
|
||||||
_currentStrafeRun.time = _currentStrafeRun.time+1
|
_currentStrafeRun.time = _currentStrafeRun.time+1
|
||||||
|
|
||||||
@@ -2821,7 +2919,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
-- Result.
|
-- Result.
|
||||||
local _result = self.strafeStatus[_unitID]
|
local _result = self.strafeStatus[_unitID]
|
||||||
local _sound = nil --#RANGE.Soundfile
|
local _sound = nil --#RANGE.Soundfile
|
||||||
|
--[[ --RangeBoss commented out in order to implement strafe quality based on accuracy percentage, not the number of rounds on target
|
||||||
-- Judge this pass. Text is displayed on summary.
|
-- Judge this pass. Text is displayed on summary.
|
||||||
if _result.hits >= _result.zone.goodPass*2 then
|
if _result.hits >= _result.zone.goodPass*2 then
|
||||||
_result.text = "EXCELLENT PASS"
|
_result.text = "EXCELLENT PASS"
|
||||||
@@ -2836,16 +2934,37 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
_result.text = "POOR PASS"
|
_result.text = "POOR PASS"
|
||||||
_sound=RANGE.Sound.RCPoorPass
|
_sound=RANGE.Sound.RCPoorPass
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
||||||
local shots=_result.ammo-_ammo
|
local shots=_result.ammo-_ammo
|
||||||
local accur=0
|
local accur=0
|
||||||
if shots>0 then
|
if shots>0 then
|
||||||
accur=_result.hits/shots*100
|
accur=_result.hits/shots*100
|
||||||
if accur > 100 then
|
if accur > 100 then accur = 100 end
|
||||||
accur = 100
|
end
|
||||||
|
|
||||||
|
if invalidStrafe == true then--
|
||||||
|
_result.text = "* INVALID - PASSED FOUL LINE *"
|
||||||
|
_sound=RANGE.Sound.RCPoorPass --
|
||||||
|
else
|
||||||
|
if accur >= 90 then
|
||||||
|
_result.text = "DEADEYE PASS"
|
||||||
|
_sound=RANGE.Sound.RCExcellentPass
|
||||||
|
elseif accur >= 75 then
|
||||||
|
_result.text = "EXCELLENT PASS"
|
||||||
|
_sound=RANGE.Sound.RCExcellentPass
|
||||||
|
elseif accur >= 50 then
|
||||||
|
_result.text = "GOOD PASS"
|
||||||
|
_sound=RANGE.Sound.RCGoodPass
|
||||||
|
elseif accur >= 25 then
|
||||||
|
_result.text = "INEFFECTIVE PASS"
|
||||||
|
_sound=RANGE.Sound.RCIneffectivePass
|
||||||
|
else
|
||||||
|
_result.text = "POOR PASS"
|
||||||
|
_sound=RANGE.Sound.RCPoorPass
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
clientStrafed = true --RANGEBOSS
|
||||||
|
|
||||||
-- Message text.
|
-- Message text.
|
||||||
local _text=string.format("%s, hits on target %s: %d", self:_myname(_unitName), _result.zone.name, _result.hits)
|
local _text=string.format("%s, hits on target %s: %d", self:_myname(_unitName), _result.zone.name, _result.hits)
|
||||||
@@ -2857,6 +2976,45 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup(_unit, _text)
|
self:_DisplayMessageToGroup(_unit, _text)
|
||||||
|
|
||||||
|
--RangeBoss Edit for strafe table insert
|
||||||
|
|
||||||
|
-- Local results.
|
||||||
|
|
||||||
|
local result={} --#RANGE.BombResult
|
||||||
|
result.name=_result.zone.name or "unknown"
|
||||||
|
result.distance=0
|
||||||
|
result.radial=0
|
||||||
|
result.weapon="N/A"
|
||||||
|
result.quality="N/A"
|
||||||
|
result.player=_playernamee
|
||||||
|
result.time=timer.getAbsTime()
|
||||||
|
result.airframe=StrafeAircraftType
|
||||||
|
result.roundsFired=shots --RANGEBOSS
|
||||||
|
result.roundsHit=_result.hits --RANGEBOSS
|
||||||
|
result.roundsQuality=_result.text --RANGEBOSS
|
||||||
|
result.strafeAccuracy=accur
|
||||||
|
result.heading =unitheadingStrafe --RANGEBOSS
|
||||||
|
|
||||||
|
Straferesult.name= _result.zone.name or "unknown"
|
||||||
|
Straferesult.distance=0
|
||||||
|
Straferesult.radial=0
|
||||||
|
Straferesult.weapon="N/A"
|
||||||
|
Straferesult.quality="N/A"
|
||||||
|
Straferesult.player=_playername
|
||||||
|
Straferesult.time=timer.getAbsTime()
|
||||||
|
Straferesult.airframe=StrafeAircraftType
|
||||||
|
Straferesult.roundsFired=shots
|
||||||
|
Straferesult.roundsHit= _result.hits
|
||||||
|
Straferesult.roundsQuality=_result.text
|
||||||
|
Straferesult.strafeAccuracy=accur
|
||||||
|
Straferesult.rangename=self.rangename
|
||||||
|
|
||||||
|
-- Save trap sheet.
|
||||||
|
if playerData.targeton and self.targetsheet then
|
||||||
|
self:_SaveTargetSheet(_playername, result)
|
||||||
|
end
|
||||||
|
--RangeBoss edit for strafe data saved to file
|
||||||
|
|
||||||
-- Voice over.
|
-- Voice over.
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
self.rangecontrol:NewTransmission(RANGE.Sound.RCHitsOnTarget.filename, RANGE.Sound.RCHitsOnTarget.duration, self.soundpath)
|
self.rangecontrol:NewTransmission(RANGE.Sound.RCHitsOnTarget.filename, RANGE.Sound.RCHitsOnTarget.duration, self.soundpath)
|
||||||
@@ -2908,9 +3066,11 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
self.rangecontrol:NewTransmission(RANGE.Sound.RCRollingInOnStrafeTarget.filename, RANGE.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath)
|
self.rangecontrol:NewTransmission(RANGE.Sound.RCRollingInOnStrafeTarget.filename, RANGE.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath)
|
||||||
end
|
end
|
||||||
|
clientRollingIn = true --RANGEBOSS
|
||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup(_unit, _msg, 10, true)
|
self:_DisplayMessageToGroup(_unit, _msg, 10, true)
|
||||||
|
hypemanStrafeRollIn = _msg --RANGEBOSS
|
||||||
|
|
||||||
-- We found our player. Skip remaining checks.
|
-- We found our player. Skip remaining checks.
|
||||||
break
|
break
|
||||||
@@ -2959,7 +3119,8 @@ function RANGE:_AddF10Commands( _unitName )
|
|||||||
-- MISSION LEVEL --
|
-- MISSION LEVEL --
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
_rangePath = missionCommands.addSubMenuForGroup( _gid, self.rangename, RANGE.MenuF10Root )
|
--_rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10Root)
|
||||||
|
_rangePath = MENU_GROUP:New(group,"On the Range")
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -2969,54 +3130,57 @@ function RANGE:_AddF10Commands( _unitName )
|
|||||||
|
|
||||||
-- Main F10 menu: F10/On the Range/<Range Name>/
|
-- Main F10 menu: F10/On the Range/<Range Name>/
|
||||||
if RANGE.MenuF10[_gid] == nil then
|
if RANGE.MenuF10[_gid] == nil then
|
||||||
RANGE.MenuF10[_gid] = missionCommands.addSubMenuForGroup( _gid, "On the Range" )
|
--RANGE.MenuF10[_gid]=missionCommands.addSubMenuForGroup(_gid, "On the Range")
|
||||||
|
RANGE.MenuF10[_gid]=MENU_GROUP:New(group,"On the Range")
|
||||||
end
|
end
|
||||||
_rangePath = missionCommands.addSubMenuForGroup( _gid, self.rangename, RANGE.MenuF10[_gid] )
|
--_rangePath = missionCommands.addSubMenuForGroup(_gid, self.rangename, RANGE.MenuF10[_gid])
|
||||||
|
_rangePath = MENU_GROUP:New(group,self.rangename,RANGE.MenuF10[_gid])
|
||||||
end
|
end
|
||||||
|
|
||||||
local _statsPath = missionCommands.addSubMenuForGroup( _gid, "Statistics", _rangePath )
|
local _statsPath = MENU_GROUP:New(group,"Statistics",_rangePath)
|
||||||
local _markPath = missionCommands.addSubMenuForGroup( _gid, "Mark Targets", _rangePath )
|
local _markPath = MENU_GROUP:New(group,"Mark Targets",_rangePath)
|
||||||
local _settingsPath = missionCommands.addSubMenuForGroup( _gid, "My Settings", _rangePath )
|
local _settingsPath = MENU_GROUP:New(group,"My Settings",_rangePath)
|
||||||
local _infoPath = missionCommands.addSubMenuForGroup( _gid, "Range Info", _rangePath )
|
local _infoPath = MENU_GROUP:New(group,"Range Info",_rangePath)
|
||||||
|
|
||||||
-- F10/On the Range/<Range Name>/My Settings/
|
-- F10/On the Range/<Range Name>/My Settings/
|
||||||
local _mysmokePath = missionCommands.addSubMenuForGroup( _gid, "Smoke Color", _settingsPath )
|
local _mysmokePath = MENU_GROUP:New(group,"Smoke Color",_settingsPath)
|
||||||
local _myflarePath = missionCommands.addSubMenuForGroup( _gid, "Flare Color", _settingsPath )
|
local _myflarePath = MENU_GROUP:New(group,"Flare Color",_settingsPath)
|
||||||
|
|
||||||
--F10/On the Range/<Range Name>/Mark Targets/
|
--F10/On the Range/<Range Name>/Mark Targets/
|
||||||
missionCommands.addCommandForGroup( _gid, "Mark On Map", _markPath, self._MarkTargetsOnMap, self, _unitName )
|
local _MoMap = MENU_GROUP_COMMAND:New(group,"Mark On Map",_markPath,self._MarkTargetsOnMap, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Illuminate Range", _markPath, self._IlluminateBombTargets, self, _unitName )
|
local _IllRng = MENU_GROUP_COMMAND:New(group, "Illuminate Range", _markPath, self._IlluminateBombTargets, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Smoke Strafe Pits", _markPath, self._SmokeStrafeTargetBoxes, self, _unitName )
|
local _SSpit = MENU_GROUP_COMMAND:New(group, "Smoke Strafe Pits", _markPath, self._SmokeStrafeTargetBoxes, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Smoke Strafe Tgts", _markPath, self._SmokeStrafeTargets, self, _unitName )
|
local _SStgts = MENU_GROUP_COMMAND:New(group, "Smoke Strafe Tgts", _markPath, self._SmokeStrafeTargets, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Smoke Bomb Tgts", _markPath, self._SmokeBombTargets, self, _unitName )
|
local _SBtgts = MENU_GROUP_COMMAND:New(group, "Smoke Bomb Tgts", _markPath, self._SmokeBombTargets, self, _unitName)
|
||||||
-- F10/On the Range/<Range Name>/Stats/
|
-- F10/On the Range/<Range Name>/Stats/
|
||||||
missionCommands.addCommandForGroup( _gid, "All Strafe Results", _statsPath, self._DisplayStrafePitResults, self, _unitName )
|
local _AllSR = MENU_GROUP_COMMAND:New(group, "All Strafe Results", _statsPath, self._DisplayStrafePitResults, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "All Bombing Results", _statsPath, self._DisplayBombingResults, self, _unitName )
|
local _AllBR = MENU_GROUP_COMMAND:New(group, "All Bombing Results", _statsPath, self._DisplayBombingResults, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "My Strafe Results", _statsPath, self._DisplayMyStrafePitResults, self, _unitName )
|
local _MySR = MENU_GROUP_COMMAND:New(group, "My Strafe Results", _statsPath, self._DisplayMyStrafePitResults, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "My Bomb Results", _statsPath, self._DisplayMyBombingResults, self, _unitName )
|
local _MyBR = MENU_GROUP_COMMAND:New(group, "My Bomb Results", _statsPath, self._DisplayMyBombingResults, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Reset All Stats", _statsPath, self._ResetRangeStats, self, _unitName )
|
local _ResetST = MENU_GROUP_COMMAND:New(group, "Reset All Stats", _statsPath, self._ResetRangeStats, self, _unitName)
|
||||||
-- F10/On the Range/<Range Name>/My Settings/Smoke Color/
|
-- F10/On the Range/<Range Name>/My Settings/Smoke Color/
|
||||||
missionCommands.addCommandForGroup( _gid, "Blue Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Blue )
|
local _BlueSM = MENU_GROUP_COMMAND:New(group, "Blue Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Blue)
|
||||||
missionCommands.addCommandForGroup( _gid, "Green Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Green )
|
local _GrSM = MENU_GROUP_COMMAND:New(group, "Green Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Green)
|
||||||
missionCommands.addCommandForGroup( _gid, "Orange Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Orange )
|
local _OrSM = MENU_GROUP_COMMAND:New(group, "Orange Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Orange)
|
||||||
missionCommands.addCommandForGroup( _gid, "Red Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Red )
|
local _ReSM = MENU_GROUP_COMMAND:New(group, "Red Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.Red)
|
||||||
missionCommands.addCommandForGroup( _gid, "White Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.White )
|
local _WhSm = MENU_GROUP_COMMAND:New(group, "White Smoke", _mysmokePath, self._playersmokecolor, self, _unitName, SMOKECOLOR.White)
|
||||||
-- F10/On the Range/<Range Name>/My Settings/Flare Color/
|
-- F10/On the Range/<Range Name>/My Settings/Flare Color/
|
||||||
missionCommands.addCommandForGroup( _gid, "Green Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Green )
|
local _GrFl = MENU_GROUP_COMMAND:New(group, "Green Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Green)
|
||||||
missionCommands.addCommandForGroup( _gid, "Red Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Red )
|
local _ReFl = MENU_GROUP_COMMAND:New(group, "Red Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Red)
|
||||||
missionCommands.addCommandForGroup( _gid, "White Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.White )
|
local _WhFl = MENU_GROUP_COMMAND:New(group, "White Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.White)
|
||||||
missionCommands.addCommandForGroup( _gid, "Yellow Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Yellow )
|
local _YeFl = MENU_GROUP_COMMAND:New(group, "Yellow Flares", _myflarePath, self._playerflarecolor, self, _unitName, FLARECOLOR.Yellow)
|
||||||
-- F10/On the Range/<Range Name>/My Settings/
|
-- F10/On the Range/<Range Name>/My Settings/
|
||||||
missionCommands.addCommandForGroup( _gid, "Smoke Delay On/Off", _settingsPath, self._SmokeBombDelayOnOff, self, _unitName )
|
local _SmDe = MENU_GROUP_COMMAND:New(group, "Smoke Delay On/Off", _settingsPath, self._SmokeBombDelayOnOff, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Smoke Impact On/Off", _settingsPath, self._SmokeBombImpactOnOff, self, _unitName )
|
local _SmIm = MENU_GROUP_COMMAND:New(group, "Smoke Impact On/Off", _settingsPath, self._SmokeBombImpactOnOff, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Flare Hits On/Off", _settingsPath, self._FlareDirectHitsOnOff, self, _unitName )
|
local _FlHi = MENU_GROUP_COMMAND:New(group, "Flare Hits On/Off", _settingsPath, self._FlareDirectHitsOnOff, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "All Messages On/Off", _settingsPath, self._MessagesToPlayerOnOff, self, _unitName )
|
local _AlMeA = MENU_GROUP_COMMAND:New(group, "All Messages On/Off", _settingsPath, self._MessagesToPlayerOnOff, self, _unitName)
|
||||||
|
local _TrpSh = MENU_GROUP_COMMAND:New(group, "Targetsheet On/Off", _settingsPath, self._TargetsheetOnOff, self, _unitName)
|
||||||
|
|
||||||
-- F10/On the Range/<Range Name>/Range Information
|
-- F10/On the Range/<Range Name>/Range Information
|
||||||
missionCommands.addCommandForGroup( _gid, "General Info", _infoPath, self._DisplayRangeInfo, self, _unitName )
|
local _WeIn = MENU_GROUP_COMMAND:New(group, "General Info", _infoPath, self._DisplayRangeInfo, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Weather Report", _infoPath, self._DisplayRangeWeather, self, _unitName )
|
local _WeRe = MENU_GROUP_COMMAND:New(group, "Weather Report", _infoPath, self._DisplayRangeWeather, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Bombing Targets", _infoPath, self._DisplayBombTargets, self, _unitName )
|
local _BoTgtgs = MENU_GROUP_COMMAND:New(group, "Bombing Targets", _infoPath, self._DisplayBombTargets, self, _unitName)
|
||||||
missionCommands.addCommandForGroup( _gid, "Strafe Pits", _infoPath, self._DisplayStrafePits, self, _unitName )
|
local _StrPits = MENU_GROUP_COMMAND:New(group, "Strafe Pits", _infoPath, self._DisplayStrafePits, self, _unitName):Refresh()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E(self.id.."Could not find group or group ID in AddF10Menu() function. Unit name: ".._unitName)
|
self:E(self.id.."Could not find group or group ID in AddF10Menu() function. Unit name: ".._unitName)
|
||||||
@@ -3031,7 +3195,7 @@ end
|
|||||||
-- Helper Functions
|
-- Helper Functions
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Get the coordinate of a Bomb target.
|
--- Get the number of shells a unit currently has.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #RANGE.BombTarget target Bomb target data.
|
-- @param #RANGE.BombTarget target Bomb target data.
|
||||||
-- @return Core.Point#COORDINATE Target coordinate.
|
-- @return Core.Point#COORDINATE Target coordinate.
|
||||||
@@ -3068,6 +3232,7 @@ function RANGE:_GetBombTargetCoordinate( target )
|
|||||||
return coord
|
return coord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the number of shells a unit currently has.
|
--- Get the number of shells a unit currently has.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string unitname Name of the player unit.
|
-- @param #string unitname Name of the player unit.
|
||||||
@@ -3341,6 +3506,49 @@ function RANGE:_MessagesToPlayerOnOff( unitname )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Targetsheet saves if player on or off.
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string _unitname Name of the player unit.
|
||||||
|
function RANGE:_TargetsheetOnOff(_unitname)
|
||||||
|
self:F2(_unitname)
|
||||||
|
|
||||||
|
-- Get player unit and player name.
|
||||||
|
local unit, playername = self:_GetPlayerUnitAndName(_unitname)
|
||||||
|
|
||||||
|
-- Check if we have a player.
|
||||||
|
if unit and playername then
|
||||||
|
|
||||||
|
-- Player data.
|
||||||
|
local playerData=self.PlayerSettings[playername] --#RANGE.PlayerData
|
||||||
|
|
||||||
|
if playerData then
|
||||||
|
|
||||||
|
-- Check if option is enabled at all.
|
||||||
|
local text=""
|
||||||
|
if self.targetsheet then
|
||||||
|
|
||||||
|
-- Invert current setting.
|
||||||
|
playerData.targeton=not playerData.targeton
|
||||||
|
|
||||||
|
-- Inform player.
|
||||||
|
if playerData.targeton==true then
|
||||||
|
text=string.format("roger, your targetsheets are now SAVED.")
|
||||||
|
else
|
||||||
|
text=string.format("affirm, your targetsheets are NOT SAVED.")
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
text="negative, target sheet data recorder is broken on this range."
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Message to player.
|
||||||
|
--self:MessageToPlayer(playerData, text, nil, playerData.name, 5)
|
||||||
|
self:_DisplayMessageToGroup(unit,text,5,false,false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Toggle status of flaring direct hits of range targets.
|
--- Toggle status of flaring direct hits of range targets.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string unitname Name of the player unit.
|
-- @param #string unitname Name of the player unit.
|
||||||
@@ -3507,7 +3715,7 @@ end
|
|||||||
--- Checks if a static object with a certain name exists. It also added it to the MOOSE data base, if it is not already in there.
|
--- Checks if a static object with a certain name exists. It also added it to the MOOSE data base, if it is not already in there.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string name Name of the potential static object.
|
-- @param #string name Name of the potential static object.
|
||||||
-- @return #boolean Returns true if a static with this name exists. Returns false if a unit with this name exists. Returns nil if neither unit or static exist.
|
-- @return #boolean Returns true if a static with this name exists. Retruns false if a unit with this name exists. Returns nil if neither unit or static exist.
|
||||||
function RANGE:_CheckStatic(name)
|
function RANGE:_CheckStatic(name)
|
||||||
self:F2(name)
|
self:F2(name)
|
||||||
|
|
||||||
@@ -3593,7 +3801,7 @@ function RANGE:_GetPlayerUnitAndName( _unitName )
|
|||||||
return nil,nil
|
return nil,nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a string which consists of the player name.
|
--- Returns a string which consits of this callsign and the player name.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string unitname Name of the player unit.
|
-- @param #string unitname Name of the player unit.
|
||||||
function RANGE:_myname(unitname)
|
function RANGE:_myname(unitname)
|
||||||
@@ -3601,11 +3809,9 @@ function RANGE:_myname( unitname )
|
|||||||
|
|
||||||
local unit=UNIT:FindByName(unitname)
|
local unit=UNIT:FindByName(unitname)
|
||||||
local pname=unit:GetPlayerName()
|
local pname=unit:GetPlayerName()
|
||||||
|
local csign=unit:GetCallsign()
|
||||||
|
|
||||||
-- TODO: Either remove these leftovers, or implement them.
|
|
||||||
-- local csign=unit:GetCallsign()
|
|
||||||
--return string.format("%s (%s)", csign, pname)
|
--return string.format("%s (%s)", csign, pname)
|
||||||
|
|
||||||
return string.format("%s", pname)
|
return string.format("%s", pname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user