mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
CSAR - make beacon length configureable
This commit is contained in:
parent
f6b55da0c6
commit
ea926f173a
@ -45,7 +45,7 @@
|
|||||||
-- * Object oriented refactoring of Ciribob\'s fantastic CSAR script.
|
-- * Object oriented refactoring of Ciribob\'s fantastic CSAR script.
|
||||||
-- * No need for extra MIST loading.
|
-- * No need for extra MIST loading.
|
||||||
-- * Additional events to tailor your mission.
|
-- * Additional events to tailor your mission.
|
||||||
-- * Optional SpawnCASEVAC to create casualties without beacon (e.g. handling dead ground vehicles and create CASVAC requests).
|
-- * Optional SpawnCASEVAC to create casualties without beacon (e.g. handling dead ground vehicles and create CASVAC requests).
|
||||||
--
|
--
|
||||||
-- ## 0. Prerequisites
|
-- ## 0. Prerequisites
|
||||||
--
|
--
|
||||||
@ -117,7 +117,7 @@
|
|||||||
-- self.SRSchannel = 300 -- radio channel
|
-- self.SRSchannel = 300 -- radio channel
|
||||||
-- self.SRSModulation = radio.modulation.AM -- modulation
|
-- self.SRSModulation = radio.modulation.AM -- modulation
|
||||||
-- --
|
-- --
|
||||||
-- self.csarUsePara = false -- If set to true, will use the LandingAfterEjection Event instead of Ejection --shagrat
|
-- self.csarUsePara = false -- If set to true, will use the LandingAfterEjection Event instead of Ejection --shagrat
|
||||||
--
|
--
|
||||||
-- ## 3. Results
|
-- ## 3. Results
|
||||||
--
|
--
|
||||||
@ -178,8 +178,8 @@
|
|||||||
-- -- Create downed "Pilot Wagner" in #ZONE "CSAR_Start_1" at a random point for the blue coalition
|
-- -- Create downed "Pilot Wagner" in #ZONE "CSAR_Start_1" at a random point for the blue coalition
|
||||||
-- my_csar:SpawnCSARAtZone( "CSAR_Start_1", coalition.side.BLUE, "Pilot Wagner", true )
|
-- my_csar:SpawnCSARAtZone( "CSAR_Start_1", coalition.side.BLUE, "Pilot Wagner", true )
|
||||||
--
|
--
|
||||||
-- --Create a casualty and CASEVAC request from a "Point" (VEC2) for the blue coalition --shagrat
|
-- --Create a casualty and CASEVAC request from a "Point" (VEC2) for the blue coalition --shagrat
|
||||||
-- my_csar:SpawnCASEVAC(Point, coalition.side.BLUE)
|
-- my_csar:SpawnCASEVAC(Point, coalition.side.BLUE)
|
||||||
--
|
--
|
||||||
-- @field #CSAR
|
-- @field #CSAR
|
||||||
CSAR = {
|
CSAR = {
|
||||||
@ -247,7 +247,7 @@ CSAR.AircraftType["Bell-47"] = 2
|
|||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="0.1.12r6"
|
CSAR.version="1.0.1r1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -356,6 +356,7 @@ function CSAR:New(Coalition, Template, Alias)
|
|||||||
self.extractDistance = 500 -- Distance the Downed pilot will run to the rescue helicopter
|
self.extractDistance = 500 -- Distance the Downed pilot will run to the rescue helicopter
|
||||||
self.loadtimemax = 135 -- seconds
|
self.loadtimemax = 135 -- seconds
|
||||||
self.radioSound = "beacon.ogg" -- the name of the sound file to use for the Pilot radio beacons. If this isnt added to the mission BEACONS WONT WORK!
|
self.radioSound = "beacon.ogg" -- the name of the sound file to use for the Pilot radio beacons. If this isnt added to the mission BEACONS WONT WORK!
|
||||||
|
self.beaconRefresher = 29 -- seconds
|
||||||
self.allowFARPRescue = true --allows pilot to be rescued by landing at a FARP or Airbase
|
self.allowFARPRescue = true --allows pilot to be rescued by landing at a FARP or Airbase
|
||||||
self.FARPRescueDistance = 1000 -- you need to be this close to a FARP or Airport for the pilot to be rescued.
|
self.FARPRescueDistance = 1000 -- you need to be this close to a FARP or Airport for the pilot to be rescued.
|
||||||
self.max_units = 6 --max number of pilots that can be carried
|
self.max_units = 6 --max number of pilots that can be carried
|
||||||
@ -654,10 +655,10 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
|||||||
|
|
||||||
if not noMessage then
|
if not noMessage then
|
||||||
if _freq ~= 0 then --shagrat different CASEVAC msg
|
if _freq ~= 0 then --shagrat different CASEVAC msg
|
||||||
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, self.messageTime)
|
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, self.messageTime)
|
||||||
else
|
else
|
||||||
self:_DisplayToAllSAR("Troops In Contact. " .. _typeName .. " requests CASEVAC. ", self.coalition, self.messageTime)
|
self:_DisplayToAllSAR("Troops In Contact. " .. _typeName .. " requests CASEVAC. ", self.coalition, self.messageTime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (_freq and _freq ~= 0) then --shagrat only add beacon if _freq is NOT 0
|
if (_freq and _freq ~= 0) then --shagrat only add beacon if _freq is NOT 0
|
||||||
@ -669,18 +670,18 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
|||||||
local _text = _description
|
local _text = _description
|
||||||
if not forcedesc then
|
if not forcedesc then
|
||||||
if _playerName ~= nil then
|
if _playerName ~= nil then
|
||||||
if _freq ~= 0 then --shagrat
|
if _freq ~= 0 then --shagrat
|
||||||
_text = "Pilot " .. _playerName
|
_text = "Pilot " .. _playerName
|
||||||
else
|
else
|
||||||
_text = "TIC - " .. _playerName
|
_text = "TIC - " .. _playerName
|
||||||
end
|
end
|
||||||
elseif _unitName ~= nil then
|
elseif _unitName ~= nil then
|
||||||
if _freq ~= 0 then --shagrat
|
if _freq ~= 0 then --shagrat
|
||||||
_text = "AI Pilot of " .. _unitName
|
_text = "AI Pilot of " .. _unitName
|
||||||
else
|
else
|
||||||
_text = "TIC - " .. _unitName
|
_text = "TIC - " .. _unitName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T({_spawnedGroup, _alias})
|
self:T({_spawnedGroup, _alias})
|
||||||
|
|
||||||
@ -906,7 +907,7 @@ function CSAR:_EventHandler(EventData)
|
|||||||
return -- error!
|
return -- error!
|
||||||
end
|
end
|
||||||
|
|
||||||
local _coalition = _unit:GetCoalition()
|
local _coalition = _unit:GetCoalition()
|
||||||
if _coalition ~= self.coalition then
|
if _coalition ~= self.coalition then
|
||||||
return --ignore!
|
return --ignore!
|
||||||
end
|
end
|
||||||
@ -926,28 +927,28 @@ function CSAR:_EventHandler(EventData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- all checks passed, get going.
|
-- all checks passed, get going.
|
||||||
if self.csarUsePara == false then --shagrat check parameter LandingAfterEjection, if true don't spawn a Pilot from EJECTION event, wait for the Chute to land
|
if self.csarUsePara == false then --shagrat check parameter LandingAfterEjection, if true don't spawn a Pilot from EJECTION event, wait for the Chute to land
|
||||||
local _freq = self:_GenerateADFFrequency()
|
local _freq = self:_GenerateADFFrequency()
|
||||||
self:_AddCsar(_coalition, _unit:GetCountry(), _unit:GetCoordinate() , _unit:GetTypeName(), _unit:GetName(), _event.IniPlayerName, _freq, false, "none")
|
self:_AddCsar(_coalition, _unit:GetCountry(), _unit:GetCoordinate() , _unit:GetTypeName(), _unit:GetName(), _event.IniPlayerName, _freq, false, "none")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---- shagrat on event LANDING_AFTER_EJECTION spawn pilot at parachute location
|
---- shagrat on event LANDING_AFTER_EJECTION spawn pilot at parachute location
|
||||||
elseif (_event.id == EVENTS.LandingAfterEjection and self.csarUsePara == true) then
|
elseif (_event.id == EVENTS.LandingAfterEjection and self.csarUsePara == true) then
|
||||||
self:I({EVENT=_event})
|
self:I({EVENT=_event})
|
||||||
local _LandingPos = COORDINATE:NewFromVec3(_event.initiator:getPosition().p)
|
local _LandingPos = COORDINATE:NewFromVec3(_event.initiator:getPosition().p)
|
||||||
local _unitname = "Aircraft" --_event.initiator:getName() or "Aircraft" --shagrat Optional use of Object name which is unfortunately 'f15_Pilot_Parachute'
|
local _unitname = "Aircraft" --_event.initiator:getName() or "Aircraft" --shagrat Optional use of Object name which is unfortunately 'f15_Pilot_Parachute'
|
||||||
local _typename = "Ejected Pilot" --_event.Initiator.getTypeName() or "Ejected Pilot"
|
local _typename = "Ejected Pilot" --_event.Initiator.getTypeName() or "Ejected Pilot"
|
||||||
local _country = _event.initiator:getCountry()
|
local _country = _event.initiator:getCountry()
|
||||||
local _coalition = coalition.getCountryCoalition( _country )
|
local _coalition = coalition.getCountryCoalition( _country )
|
||||||
if _coalition == self.coalition then
|
if _coalition == self.coalition then
|
||||||
local _freq = self:_GenerateADFFrequency()
|
local _freq = self:_GenerateADFFrequency()
|
||||||
self:I({coalition=_coalition,country= _country, coord=_LandingPos, name=_unitname, player=_event.IniPlayerName, freq=_freq})
|
self:I({coalition=_coalition,country= _country, coord=_LandingPos, name=_unitname, player=_event.IniPlayerName, freq=_freq})
|
||||||
self:_AddCsar(_coalition, _country, _LandingPos, nil, _unitname, _event.IniPlayerName, _freq, false, "none")--shagrat add CSAR at Parachute location.
|
self:_AddCsar(_coalition, _country, _LandingPos, nil, _unitname, _event.IniPlayerName, _freq, false, "none")--shagrat add CSAR at Parachute location.
|
||||||
|
|
||||||
Unit.destroy(_event.initiator) -- shagrat remove static Pilot model
|
Unit.destroy(_event.initiator) -- shagrat remove static Pilot model
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
||||||
elseif _event.id == EVENTS.Land then
|
elseif _event.id == EVENTS.Land then
|
||||||
self:T(self.lid .. " Landing")
|
self:T(self.lid .. " Landing")
|
||||||
@ -1012,13 +1013,13 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
|||||||
local _leadername = _leader:GetName()
|
local _leadername = _leader:GetName()
|
||||||
|
|
||||||
if not _nomessage then
|
if not _nomessage then
|
||||||
if _freq ~= 0 then --shagrat
|
if _freq ~= 0 then --shagrat
|
||||||
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _groupName, _coordinatesText, _freqk)--shagrat _groupName to prevent 'f15_Pilot_Parachute'
|
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _groupName, _coordinatesText, _freqk)--shagrat _groupName to prevent 'f15_Pilot_Parachute'
|
||||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||||
else --shagrat CASEVAC msg
|
else --shagrat CASEVAC msg
|
||||||
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
|
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
|
||||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,_heliName in pairs(self.csarUnits) do
|
for _,_heliName in pairs(self.csarUnits) do
|
||||||
@ -1532,11 +1533,11 @@ function CSAR:_DisplayActiveSAR(_unitName)
|
|||||||
else
|
else
|
||||||
distancetext = string.format("%.1fkm", _distance/1000.0)
|
distancetext = string.format("%.1fkm", _distance/1000.0)
|
||||||
end
|
end
|
||||||
if _value.frequency == 0 then--shagrat insert CASEVAC without Frequency
|
if _value.frequency == 0 then--shagrat insert CASEVAC without Frequency
|
||||||
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %s ", _value.desc, _coordinatesText, distancetext) })
|
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %s ", _value.desc, _coordinatesText, distancetext) })
|
||||||
else
|
else
|
||||||
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %.2f KHz ADF - %s ", _value.desc, _coordinatesText, _value.frequency / 1000, distancetext) })
|
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %.2f KHz ADF - %s ", _value.desc, _coordinatesText, _value.frequency / 1000, distancetext) })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2021,7 +2022,12 @@ function CSAR:onbeforeStatus(From, Event, To)
|
|||||||
self:T({From, Event, To})
|
self:T({From, Event, To})
|
||||||
-- housekeeping
|
-- housekeeping
|
||||||
self:_AddMedevacMenuItem()
|
self:_AddMedevacMenuItem()
|
||||||
self:_RefreshRadioBeacons()
|
|
||||||
|
if not self.BeaconTimer or (self.BeaconTimer and not self.BeaconTimer:IsRunning()) then
|
||||||
|
self.BeaconTimer = TIMER:New(self._RefreshRadioBeacons,self)
|
||||||
|
self.BeaconTimer:Start(2,self.beaconRefresher)
|
||||||
|
end
|
||||||
|
|
||||||
self:_CheckDownedPilotTable()
|
self:_CheckDownedPilotTable()
|
||||||
for _,_sar in pairs (self.csarUnits) do
|
for _,_sar in pairs (self.csarUnits) do
|
||||||
local PilotTable = self.downedPilots
|
local PilotTable = self.downedPilots
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user