Skip to content

Commit d6d9c9d

Browse files
Merge remote-tracking branch 'origin/master' into develop
2 parents 6800730 + 7f572a1 commit d6d9c9d

3 files changed

Lines changed: 94 additions & 18 deletions

File tree

Moose Development/Moose/Ops/CSAR.lua

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
-- mycsar.topmenuname = "CSAR" -- set the menu entry name
118118
-- mycsar.ADFRadioPwr = 1000 -- ADF Beacons sending with 1KW as default
119119
-- mycsar.PilotWeight = 80 -- Loaded pilots weigh 80kgs each
120+
-- mycsar.AllowIRStrobe = false -- Allow a menu item to request an IR strobe to find a downed pilot at night (requires NVGs to see it).
121+
-- mycsar.IRStrobeRuntime = 300 -- If an IR Strobe is activated, it runs for 300 seconds (5 mins).
120122
--
121123
-- ## 2.1 Create own SET_GROUP to manage CTLD Pilot groups
122124
--
@@ -267,6 +269,8 @@ CSAR = {
267269
PilotWeight = 80,
268270
CreateRadioBeacons = true,
269271
UserSetGroup = nil,
272+
AllowIRStrobe = false,
273+
IRStrobeRuntime = 300,
270274
}
271275

272276
--- Downed pilots info.
@@ -309,7 +313,7 @@ CSAR.AircraftType["CH-47Fbl1"] = 31
309313

310314
--- CSAR class version.
311315
-- @field #string version
312-
CSAR.version="1.0.28"
316+
CSAR.version="1.0.29"
313317

314318
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
315319
-- ToDo list
@@ -753,7 +757,6 @@ function CSAR:_SpawnPilotInField(country,point,frequency,wetfeet)
753757
:NewWithAlias(template,alias)
754758
:InitCoalition(coalition)
755759
:InitCountry(country)
756-
--:InitAIOnOff(pilotcacontrol)
757760
:InitDelayOff()
758761
:SpawnFromCoordinate(point)
759762

@@ -1818,9 +1821,6 @@ function CSAR:_DisplayMessageToSAR(_unit, _text, _time, _clear, _speak, _overrid
18181821
end
18191822
_text = string.gsub(_text,"km"," kilometer")
18201823
_text = string.gsub(_text,"nm"," nautical miles")
1821-
--self.msrs:SetVoice(self.SRSVoice)
1822-
--self.SRSQueue:NewTransmission(_text,nil,self.msrs,nil,1)
1823-
--self:I("Voice = "..self.SRSVoice)
18241824
self.SRSQueue:NewTransmission(_text,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,self.SRSVoice,volume,label,coord)
18251825
end
18261826
return self
@@ -1966,7 +1966,7 @@ function CSAR:_SignalFlare(_unitName)
19661966
else
19671967
_distance = string.format("%.1fkm",_closest.distance/1000)
19681968
end
1969-
local _msg = string.format("%s - Popping signal flare at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
1969+
local _msg = string.format("%s - Firing signal flare at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
19701970
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
19711971

19721972
local _coord = _closest.pilot:GetCoordinate()
@@ -2000,7 +2000,7 @@ function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
20002000
if self.msrs:GetProvider() == MSRS.Provider.WINDOWS then
20012001
voice = self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
20022002
end
2003-
self:F("Voice = "..voice)
2003+
--self:F("Voice = "..voice)
20042004
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
20052005
end
20062006
if ToScreen == true or ToScreen == nil then
@@ -2014,6 +2014,41 @@ function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
20142014
return self
20152015
end
20162016

2017+
---(Internal) Request IR Strobe at closest downed pilot.
2018+
--@param #CSAR self
2019+
--@param #string _unitName Name of the helicopter
2020+
function CSAR:_ReqIRStrobe( _unitName )
2021+
self:T(self.lid .. " _ReqIRStrobe")
2022+
local _heli = self:_GetSARHeli(_unitName)
2023+
if _heli == nil then
2024+
return
2025+
end
2026+
local smokedist = 8000
2027+
if smokedist < self.approachdist_far then smokedist = self.approachdist_far end
2028+
local _closest = self:_GetClosestDownedPilot(_heli)
2029+
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance > 0 and _closest.distance < smokedist then
2030+
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
2031+
local _distance = string.format("%.1fkm",_closest.distance/1000)
2032+
if _SETTINGS:IsImperial() then
2033+
_distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
2034+
else
2035+
_distance = string.format("%.1fkm",_closest.distance/1000)
2036+
end
2037+
local _msg = string.format("%s - IR Strobe active at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
2038+
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
2039+
_closest.pilot:NewIRMarker(true,self.IRStrobeRuntime or 300)
2040+
else
2041+
local _distance = string.format("%.1fkm",smokedist/1000)
2042+
if _SETTINGS:IsImperial() then
2043+
_distance = string.format("%.1fnm",UTILS.MetersToNM(smokedist))
2044+
else
2045+
_distance = string.format("%.1fkm",smokedist/1000)
2046+
end
2047+
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",_distance), self.messageTime, false, false, true)
2048+
end
2049+
return self
2050+
end
2051+
20172052
---(Internal) Request smoke at closest downed pilot.
20182053
--@param #CSAR self
20192054
--@param #string _unitName Name of the helicopter
@@ -2165,7 +2200,12 @@ function CSAR:_AddMedevacMenuItem()
21652200
local _rootMenu1 = MENU_GROUP_COMMAND:New(_group,"List Active CSAR",_rootPath, self._DisplayActiveSAR,self,_unitName)
21662201
local _rootMenu2 = MENU_GROUP_COMMAND:New(_group,"Check Onboard",_rootPath, self._CheckOnboard,self,_unitName)
21672202
local _rootMenu3 = MENU_GROUP_COMMAND:New(_group,"Request Signal Flare",_rootPath, self._SignalFlare,self,_unitName)
2168-
local _rootMenu4 = MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath, self._Reqsmoke,self,_unitName):Refresh()
2203+
local _rootMenu4 = MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath, self._Reqsmoke,self,_unitName)
2204+
if self.AllowIRStrobe then
2205+
local _rootMenu5 = MENU_GROUP_COMMAND:New(_group,"Request IR Strobe",_rootPath, self._ReqIRStrobe,self,_unitName):Refresh()
2206+
else
2207+
_rootMenu4:Refresh()
2208+
end
21692209
end
21702210
end
21712211
end

Moose Development/Moose/Wrapper/Group.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,25 @@ end
360360
-- @return DCS#Group The DCS Group.
361361
function GROUP:GetDCSObject()
362362

363-
-- Get DCS group.
364-
local DCSGroup = Group.getByName( self.GroupName )
363+
if (not self.LastCallDCSObject) or (self.LastCallDCSObject and timer.getTime() - self.LastCallDCSObject > 1) then
365364

366-
if DCSGroup then
367-
return DCSGroup
368-
end
365+
-- Get DCS group.
366+
local DCSGroup = Group.getByName( self.GroupName )
369367

370-
--self:T2(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.GroupName)))
368+
if DCSGroup then
369+
self.LastCallDCSObject = timer.getTime()
370+
self.DCSObject = DCSGroup
371+
return DCSGroup
372+
else
373+
self.DCSObject = nil
374+
self.LastCallDCSObject = nil
375+
end
376+
377+
else
378+
return self.DCSObject
379+
end
380+
381+
--self:E(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.GroupName)))
371382
return nil
372383
end
373384

Moose Development/Moose/Wrapper/Unit.lua

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ function UNIT:Name()
219219
return self.UnitName
220220
end
221221

222+
--[[
222223
--- Get the DCS unit object.
223224
-- @param #UNIT self
224225
-- @return DCS#Unit The DCS unit object.
@@ -230,10 +231,34 @@ function UNIT:GetDCSObject()
230231
return DCSUnit
231232
end
232233
233-
--if self.DCSUnit then
234-
--return self.DCSUnit
235-
--end
234+
return nil
235+
end
236+
--]]
237+
238+
--- Returns the DCS Unit.
239+
-- @param #UNIT self
240+
-- @return DCS#Unit The DCS Group.
241+
function UNIT:GetDCSObject()
242+
243+
if (not self.LastCallDCSObject) or (self.LastCallDCSObject and timer.getTime() - self.LastCallDCSObject > 1) then
244+
245+
-- Get DCS group.
246+
local DCSUnit = Unit.getByName( self.UnitName )
247+
248+
if DCSUnit then
249+
self.LastCallDCSObject = timer.getTime()
250+
self.DCSObject = DCSUnit
251+
return DCSUnit
252+
else
253+
self.DCSObject = nil
254+
self.LastCallDCSObject = nil
255+
end
256+
257+
else
258+
return self.DCSObject
259+
end
236260

261+
--self:E(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.UnitName)))
237262
return nil
238263
end
239264

@@ -243,7 +268,7 @@ end
243268
-- @return #number The height of the group or nil if is not existing or alive.
244269
function UNIT:GetAltitude(FromGround)
245270

246-
local DCSUnit = Unit.getByName( self.UnitName )
271+
local DCSUnit = self:GetDCSObject()
247272

248273
if DCSUnit then
249274
local altitude = 0

0 commit comments

Comments
 (0)