mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
CSAR additions by Shagrat
Added functionality for Casevac
This commit is contained in:
parent
e7e2184760
commit
f6f29db9f1
@ -45,6 +45,7 @@
|
||||
-- * Object oriented refactoring of Ciribob\'s fantastic CSAR script.
|
||||
-- * No need for extra MIST loading.
|
||||
-- * Additional events to tailor your mission.
|
||||
-- * Optional SpawnCASEVAC to create casualties without beacon (e.g. handling dead ground vehicles and create CASVAC requests).
|
||||
--
|
||||
-- ## 0. Prerequisites
|
||||
--
|
||||
@ -105,7 +106,7 @@
|
||||
-- self.countryblue= country.id.USA
|
||||
-- self.countryred = country.id.RUSSIA
|
||||
-- self.countryneutral = country.id.UN_PEACEKEEPERS
|
||||
--
|
||||
--
|
||||
-- ## 2.1 Experimental Features
|
||||
--
|
||||
-- WARNING - Here\'ll be dragons!
|
||||
@ -115,7 +116,9 @@
|
||||
-- self.SRSPath = "E:\\Progra~1\\DCS-SimpleRadio-Standalone\\" -- adjust your own path in your SRS installation -- server(!)
|
||||
-- self.SRSchannel = 300 -- radio channel
|
||||
-- self.SRSModulation = radio.modulation.AM -- modulation
|
||||
--
|
||||
-- --
|
||||
-- self.csarUsePara = false -- If set to true, will use the LandingAfterEjection Event instead of Ejection --shagrat
|
||||
--
|
||||
-- ## 3. Results
|
||||
--
|
||||
-- Number of successful landings with save pilots and aggregated number of saved pilots is stored in these variables in the object:
|
||||
@ -175,6 +178,8 @@
|
||||
-- -- 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 )
|
||||
--
|
||||
-- --Create a casualty and CASEVAC request from a "Point" (VEC2) for the blue coalition --shagrat
|
||||
-- my_csar:SpawnCASEVAC(Point, coalition.side.BLUE)
|
||||
--
|
||||
-- @field #CSAR
|
||||
CSAR = {
|
||||
@ -238,11 +243,11 @@ CSAR.AircraftType["Mi-8MTV2"] = 12
|
||||
CSAR.AircraftType["Mi-8MT"] = 12
|
||||
CSAR.AircraftType["Mi-24P"] = 8
|
||||
CSAR.AircraftType["Mi-24V"] = 8
|
||||
CSAR.AircraftType["Bell-47"] = 2
|
||||
CSAR.AircraftType["Bell-47"] = 2
|
||||
|
||||
--- CSAR class version.
|
||||
-- @field #string version
|
||||
CSAR.version="0.1.11r2"
|
||||
CSAR.version="0.1.12r2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@ -250,7 +255,7 @@ CSAR.version="0.1.11r2"
|
||||
|
||||
-- DONE: SRS Integration (to be tested)
|
||||
-- TODO: Maybe - add option to smoke/flare closest MASH
|
||||
|
||||
-- TODO: shagrat Add cargoWeight to helicopter when pilot boarded
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -380,7 +385,10 @@ function CSAR:New(Coalition, Template, Alias)
|
||||
self.countryblue= country.id.USA
|
||||
self.countryred = country.id.RUSSIA
|
||||
self.countryneutral = country.id.UN_PEACEKEEPERS
|
||||
|
||||
|
||||
-- added 0.1.3
|
||||
self.csarUsePara = true -- shagrat set to true, will use the LandingAfterEjection Event instead of Ejection
|
||||
|
||||
-- WARNING - here\'ll be dragons
|
||||
-- for this to work you need to de-sanitize your mission environment in <DCS root>\Scripts\MissionScripting.lua
|
||||
-- needs SRS => 1.9.6 to work (works on the *server* side)
|
||||
@ -645,10 +653,14 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
||||
local _typeName = _typeName or "Pilot"
|
||||
|
||||
if not noMessage then
|
||||
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, self.messageTime)
|
||||
if _freq ~= 0 then --shagrat different CASEVAC msg
|
||||
self:_DisplayToAllSAR("MAYDAY MAYDAY! " .. _typeName .. " is down. ", self.coalition, self.messageTime)
|
||||
else
|
||||
self:_DisplayToAllSAR("Troops In Contact. " .. _typeName .. " requests CASEVAC. ", self.coalition, self.messageTime)
|
||||
end
|
||||
end
|
||||
|
||||
if _freq then
|
||||
if (_freq and _freq ~= 0) then --shagrat only add beacon if _freq is NOT 0
|
||||
self:_AddBeaconToGroup(_spawnedGroup, _freq)
|
||||
end
|
||||
|
||||
@ -657,10 +669,18 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
||||
local _text = _description
|
||||
if not forcedesc then
|
||||
if _playerName ~= nil then
|
||||
_text = "Pilot " .. _playerName
|
||||
if _freq ~= 0 then --shagrat
|
||||
_text = "Pilot " .. _playerName
|
||||
else
|
||||
_text = "TIC - " .. _playerName
|
||||
end
|
||||
elseif _unitName ~= nil then
|
||||
_text = "AI Pilot of " .. _unitName
|
||||
end
|
||||
if _freq ~= 0 then --shagrat
|
||||
_text = "AI Pilot of " .. _unitName
|
||||
else
|
||||
_text = "TIC - " .. _unitName
|
||||
end
|
||||
end
|
||||
end
|
||||
self:T({_spawnedGroup, _alias})
|
||||
|
||||
@ -668,7 +688,7 @@ function CSAR:_AddCsar(_coalition , _country, _point, _typeName, _unitName, _pla
|
||||
|
||||
self:_CreateDownedPilotTrack(_spawnedGroup,_GroupName,_coalition,_unitName,_text,_typeName,_freq,_playerName)
|
||||
|
||||
self:_InitSARForPilot(_spawnedGroup, _GroupName, _freq, noMessage)
|
||||
self:_InitSARForPilot(_spawnedGroup, _unitName, _freq, noMessage) --shagrat use unitName to have the aircraft callsign / descriptive "name" etc.
|
||||
|
||||
return self
|
||||
end
|
||||
@ -737,6 +757,58 @@ function CSAR:SpawnCSARAtZone(Zone, Coalition, Description, RandomPoint, Nomessa
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Function to add a CSAR object into the scene at a Point coordinate (VEC_2). For mission designers wanting to add e.g. casualties to the scene, that don't use beacons.
|
||||
-- @param #CSAR self
|
||||
-- @param #string _Point a POINT_VEC2.
|
||||
-- @param #number _coalition Coalition.
|
||||
-- @param #string _description (optional) Description.
|
||||
-- @param #boolean _nomessage (optional) If true, don\'t send a message to SAR.
|
||||
-- @param #string unitname (optional) Name of the lost unit.
|
||||
-- @param #string typename (optional) Type of plane.
|
||||
-- @param #boolean forcedesc (optional) Force to use the description passed only for the pilot track entry. Use to have fully custom names.
|
||||
function CSAR:_SpawnCASEVAC( _Point, _coalition, _description, _nomessage, unitname, typename, forcedesc) --shagrat added internal Function _SpawnCASEVAC
|
||||
self:T(self.lid .. " _SpawnCASEVAC")
|
||||
|
||||
local _description = _description or "CASEVAC"
|
||||
local unitname = unitname or "CASEVAC"
|
||||
local typename = typename or "Ground Commander"
|
||||
|
||||
local pos = {}
|
||||
pos = _Point
|
||||
|
||||
local _country = 0
|
||||
if _coalition == coalition.side.BLUE then
|
||||
_country = self.countryblue
|
||||
elseif _coalition == coalition.side.RED then
|
||||
_country = self.countryred
|
||||
else
|
||||
_country = self.countryneutral
|
||||
end
|
||||
--shagrat set frequency to 0 as "flag" for no beacon
|
||||
self:_AddCsar(_coalition, _country, pos, typename, unitname, _description, 0, _nomessage, _description, forcedesc)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Function to add a CSAR object into the scene at a zone coordinate. For mission designers wanting to add e.g. PoWs to the scene.
|
||||
-- @param #CSAR self
|
||||
-- @param #string Point a POINT_VEC2.
|
||||
-- @param #number Coalition Coalition.
|
||||
-- @param #string Description (optional) Description.
|
||||
-- @param #boolean addBeacon (optional) yes or no.
|
||||
-- @param #boolean Nomessage (optional) If true, don\'t send a message to SAR.
|
||||
-- @param #string Unitname (optional) Name of the lost unit.
|
||||
-- @param #string Typename (optional) Type of plane.
|
||||
-- @param #boolean Forcedesc (optional) Force to use the **description passed only** for the pilot track entry. Use to have fully custom names.
|
||||
-- @usage If missions designers want to spawn downed pilots into the field, e.g. at mission begin, to give the helicopter guys work, they can do this like so:
|
||||
--
|
||||
-- -- Create casualty "CASEVAC" at Point #POINT_VEC2 for the blue coalition.
|
||||
-- my_csar:SpawnCASEVAC( POINT_VEC2, coalition.side.BLUE )
|
||||
function CSAR:SpawnCASEVAC(Point, Coalition, Description, Nomessage, Unitname, Typename, Forcedesc)
|
||||
self:_SpawnCASEVAC(Point, Coalition, Description, Nomessage, Unitname, Typename, Forcedesc)
|
||||
return self
|
||||
end --shagrat end added CASEVAC
|
||||
|
||||
--- (Internal) Event handler.
|
||||
-- @param #CSAR self
|
||||
function CSAR:_EventHandler(EventData)
|
||||
@ -748,7 +820,7 @@ function CSAR:_EventHandler(EventData)
|
||||
-- no event
|
||||
if _event == nil or _event.initiator == nil then
|
||||
return false
|
||||
|
||||
|
||||
-- take off
|
||||
elseif _event.id == EVENTS.Takeoff then -- taken off
|
||||
self:T(self.lid .. " Event unit - Takeoff")
|
||||
@ -824,12 +896,12 @@ function CSAR:_EventHandler(EventData)
|
||||
local _unit = _event.IniUnit
|
||||
local _unitname = _event.IniUnitName
|
||||
local _group = _event.IniGroup
|
||||
|
||||
|
||||
if _unit == nil then
|
||||
return -- error!
|
||||
end
|
||||
|
||||
local _coalition = _unit:GetCoalition()
|
||||
|
||||
local _coalition = _unit:GetCoalition()
|
||||
if _coalition ~= self.coalition then
|
||||
return --ignore!
|
||||
end
|
||||
@ -852,11 +924,27 @@ function CSAR:_EventHandler(EventData)
|
||||
return
|
||||
end
|
||||
|
||||
-- all checks passed, get going.
|
||||
local _freq = self:_GenerateADFFrequency()
|
||||
self:_AddCsar(_coalition, _unit:GetCountry(), _unit:GetCoordinate() , _unit:GetTypeName(), _unit:GetName(), _event.IniPlayerName, _freq, false, "none")
|
||||
|
||||
return true
|
||||
-- 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
|
||||
local _freq = self:_GenerateADFFrequency()
|
||||
self:_AddCsar(_coalition, _unit:GetCountry(), _unit:GetCoordinate() , _unit:GetTypeName(), _unit:GetName(), _event.IniPlayerName, _freq, false, "none")
|
||||
return true
|
||||
end
|
||||
---- shagrat on event LANDING_AFTER_EJECTION spawn pilot at parachute location
|
||||
elseif (_event.id == EVENTS.LandingAfterEjection and self.csarUsePara == true) then
|
||||
self:I({EVENT=_event})
|
||||
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 _typename = "Ejected Pilot" --_event.Initiator.getTypeName() or "Ejected Pilot"
|
||||
local _country = _event.initiator:getCountry()
|
||||
local _coalition = coalition.getCountryCoalition( _country )
|
||||
local _freq = self:_GenerateADFFrequency()
|
||||
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.
|
||||
|
||||
Unit.destroy(_event.initiator) -- shagrat remove static Pilot model
|
||||
|
||||
return true
|
||||
|
||||
elseif _event.id == EVENTS.Land then
|
||||
self:T(self.lid .. " Landing")
|
||||
@ -921,8 +1009,13 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage)
|
||||
local _leadername = _leader:GetName()
|
||||
|
||||
if not _nomessage then
|
||||
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _leadername, _coordinatesText, _freqk)
|
||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||
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'
|
||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||
else --shagrat CASEVAC msg
|
||||
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
|
||||
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
|
||||
end
|
||||
end
|
||||
|
||||
for _,_heliName in pairs(self.csarUnits) do
|
||||
@ -1060,7 +1153,7 @@ function CSAR:_PopSmokeForGroup(_woundedGroupName, _woundedLeader)
|
||||
if _lastSmoke == nil or timer.getTime() > _lastSmoke then
|
||||
|
||||
local _smokecolor = self.smokecolor
|
||||
local _smokecoord = _woundedLeader:GetCoordinate()
|
||||
local _smokecoord = _woundedLeader:GetCoordinate():Translate( 6, math.random( 1, 360) ) --shagrat place smoke at a random 6 m distance, so smoke does not obscure the pilot
|
||||
_smokecoord:Smoke(_smokecolor)
|
||||
self.smokeMarkers[_woundedGroupName] = timer.getTime() + 300 -- next smoke time
|
||||
end
|
||||
@ -1435,7 +1528,11 @@ function CSAR:_DisplayActiveSAR(_unitName)
|
||||
else
|
||||
distancetext = string.format("%.1fkm", _distance/1000.0)
|
||||
end
|
||||
table.insert(_csarList, { dist = _distance, msg = string.format("%s at %s - %.2f KHz ADF - %s ", _value.desc, _coordinatesText, _value.frequency / 1000, distancetext) })
|
||||
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) })
|
||||
else
|
||||
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
|
||||
|
||||
@ -1876,6 +1973,7 @@ function CSAR:onafterStart(From, Event, To)
|
||||
self:HandleEvent(EVENTS.Takeoff, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.Land, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.Ejection, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.LandingAfterEjection, self._EventHandler) --shagrat
|
||||
self:HandleEvent(EVENTS.PlayerEnterAircraft, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.PlayerEnterUnit, self._EventHandler)
|
||||
self:HandleEvent(EVENTS.PilotDead, self._EventHandler)
|
||||
@ -1986,6 +2084,7 @@ function CSAR:onafterStop(From, Event, To)
|
||||
self:UnHandleEvent(EVENTS.Takeoff)
|
||||
self:UnHandleEvent(EVENTS.Land)
|
||||
self:UnHandleEvent(EVENTS.Ejection)
|
||||
self:UnHandleEvent(EVENTS.LandingAfterEjection) -- shagrat
|
||||
self:UnHandleEvent(EVENTS.PlayerEnterUnit)
|
||||
self:UnHandleEvent(EVENTS.PlayerEnterAircraft)
|
||||
self:UnHandleEvent(EVENTS.PilotDead)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user