mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Small changes
#CSAR - add option for IR strobe
This commit is contained in:
parent
d62025dfe0
commit
7f572a1a9b
@ -117,6 +117,8 @@
|
||||
-- mycsar.topmenuname = "CSAR" -- set the menu entry name
|
||||
-- mycsar.ADFRadioPwr = 1000 -- ADF Beacons sending with 1KW as default
|
||||
-- mycsar.PilotWeight = 80 -- Loaded pilots weigh 80kgs each
|
||||
-- mycsar.AllowIRStrobe = false -- Allow a menu item to request an IR strobe to find a downed pilot at night (requires NVGs to see it).
|
||||
-- mycsar.IRStrobeRuntime = 300 -- If an IR Strobe is activated, it runs for 300 seconds (5 mins).
|
||||
--
|
||||
-- ## 2.1 Create own SET_GROUP to manage CTLD Pilot groups
|
||||
--
|
||||
@ -267,6 +269,8 @@ CSAR = {
|
||||
PilotWeight = 80,
|
||||
CreateRadioBeacons = true,
|
||||
UserSetGroup = nil,
|
||||
AllowIRStrobe = false,
|
||||
IRStrobeRuntime = 300,
|
||||
}
|
||||
|
||||
--- Downed pilots info.
|
||||
@ -309,7 +313,7 @@ CSAR.AircraftType["CH-47Fbl1"] = 31
|
||||
|
||||
--- CSAR class version.
|
||||
-- @field #string version
|
||||
CSAR.version="1.0.28"
|
||||
CSAR.version="1.0.29"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@ -753,7 +757,6 @@ function CSAR:_SpawnPilotInField(country,point,frequency,wetfeet)
|
||||
:NewWithAlias(template,alias)
|
||||
:InitCoalition(coalition)
|
||||
:InitCountry(country)
|
||||
--:InitAIOnOff(pilotcacontrol)
|
||||
:InitDelayOff()
|
||||
:SpawnFromCoordinate(point)
|
||||
|
||||
@ -1818,9 +1821,6 @@ function CSAR:_DisplayMessageToSAR(_unit, _text, _time, _clear, _speak, _overrid
|
||||
end
|
||||
_text = string.gsub(_text,"km"," kilometer")
|
||||
_text = string.gsub(_text,"nm"," nautical miles")
|
||||
--self.msrs:SetVoice(self.SRSVoice)
|
||||
--self.SRSQueue:NewTransmission(_text,nil,self.msrs,nil,1)
|
||||
--self:I("Voice = "..self.SRSVoice)
|
||||
self.SRSQueue:NewTransmission(_text,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,self.SRSVoice,volume,label,coord)
|
||||
end
|
||||
return self
|
||||
@ -1966,7 +1966,7 @@ function CSAR:_SignalFlare(_unitName)
|
||||
else
|
||||
_distance = string.format("%.1fkm",_closest.distance/1000)
|
||||
end
|
||||
local _msg = string.format("%s - Popping signal flare at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
|
||||
local _msg = string.format("%s - Firing signal flare at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
|
||||
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
|
||||
|
||||
local _coord = _closest.pilot:GetCoordinate()
|
||||
@ -2000,7 +2000,7 @@ function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
|
||||
if self.msrs:GetProvider() == MSRS.Provider.WINDOWS then
|
||||
voice = self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
|
||||
end
|
||||
self:F("Voice = "..voice)
|
||||
--self:F("Voice = "..voice)
|
||||
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
|
||||
end
|
||||
if ToScreen == true or ToScreen == nil then
|
||||
@ -2014,6 +2014,41 @@ function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
|
||||
return self
|
||||
end
|
||||
|
||||
---(Internal) Request IR Strobe at closest downed pilot.
|
||||
--@param #CSAR self
|
||||
--@param #string _unitName Name of the helicopter
|
||||
function CSAR:_ReqIRStrobe( _unitName )
|
||||
self:T(self.lid .. " _ReqIRStrobe")
|
||||
local _heli = self:_GetSARHeli(_unitName)
|
||||
if _heli == nil then
|
||||
return
|
||||
end
|
||||
local smokedist = 8000
|
||||
if smokedist < self.approachdist_far then smokedist = self.approachdist_far end
|
||||
local _closest = self:_GetClosestDownedPilot(_heli)
|
||||
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance > 0 and _closest.distance < smokedist then
|
||||
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
|
||||
local _distance = string.format("%.1fkm",_closest.distance/1000)
|
||||
if _SETTINGS:IsImperial() then
|
||||
_distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
|
||||
else
|
||||
_distance = string.format("%.1fkm",_closest.distance/1000)
|
||||
end
|
||||
local _msg = string.format("%s - IR Strobe active at your %s o\'clock. Distance %s", self:_GetCustomCallSign(_unitName), _clockDir, _distance)
|
||||
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true, true)
|
||||
_closest.pilot:NewIRMarker(true,self.IRStrobeRuntime or 300)
|
||||
else
|
||||
local _distance = string.format("%.1fkm",smokedist/1000)
|
||||
if _SETTINGS:IsImperial() then
|
||||
_distance = string.format("%.1fnm",UTILS.MetersToNM(smokedist))
|
||||
else
|
||||
_distance = string.format("%.1fkm",smokedist/1000)
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",_distance), self.messageTime, false, false, true)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
---(Internal) Request smoke at closest downed pilot.
|
||||
--@param #CSAR self
|
||||
--@param #string _unitName Name of the helicopter
|
||||
@ -2165,7 +2200,12 @@ function CSAR:_AddMedevacMenuItem()
|
||||
local _rootMenu1 = MENU_GROUP_COMMAND:New(_group,"List Active CSAR",_rootPath, self._DisplayActiveSAR,self,_unitName)
|
||||
local _rootMenu2 = MENU_GROUP_COMMAND:New(_group,"Check Onboard",_rootPath, self._CheckOnboard,self,_unitName)
|
||||
local _rootMenu3 = MENU_GROUP_COMMAND:New(_group,"Request Signal Flare",_rootPath, self._SignalFlare,self,_unitName)
|
||||
local _rootMenu4 = MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath, self._Reqsmoke,self,_unitName):Refresh()
|
||||
local _rootMenu4 = MENU_GROUP_COMMAND:New(_group,"Request Smoke",_rootPath, self._Reqsmoke,self,_unitName)
|
||||
if self.AllowIRStrobe then
|
||||
local _rootMenu5 = MENU_GROUP_COMMAND:New(_group,"Request IR Strobe",_rootPath, self._ReqIRStrobe,self,_unitName):Refresh()
|
||||
else
|
||||
_rootMenu4:Refresh()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -360,14 +360,25 @@ end
|
||||
-- @return DCS#Group The DCS Group.
|
||||
function GROUP:GetDCSObject()
|
||||
|
||||
-- Get DCS group.
|
||||
local DCSGroup = Group.getByName( self.GroupName )
|
||||
if (not self.LastCallDCSObject) or (self.LastCallDCSObject and timer.getTime() - self.LastCallDCSObject > 1) then
|
||||
|
||||
if DCSGroup then
|
||||
return DCSGroup
|
||||
-- Get DCS group.
|
||||
local DCSGroup = Group.getByName( self.GroupName )
|
||||
|
||||
if DCSGroup then
|
||||
self.LastCallDCSObject = timer.getTime()
|
||||
self.DCSObject = DCSGroup
|
||||
return DCSGroup
|
||||
else
|
||||
self.DCSObject = nil
|
||||
self.LastCallDCSObject = nil
|
||||
end
|
||||
|
||||
else
|
||||
return self.DCSObject
|
||||
end
|
||||
|
||||
--self:T2(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.GroupName)))
|
||||
|
||||
--self:E(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.GroupName)))
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@ -219,6 +219,7 @@ function UNIT:Name()
|
||||
return self.UnitName
|
||||
end
|
||||
|
||||
--[[
|
||||
--- Get the DCS unit object.
|
||||
-- @param #UNIT self
|
||||
-- @return DCS#Unit The DCS unit object.
|
||||
@ -230,10 +231,34 @@ function UNIT:GetDCSObject()
|
||||
return DCSUnit
|
||||
end
|
||||
|
||||
--if self.DCSUnit then
|
||||
--return self.DCSUnit
|
||||
--end
|
||||
return nil
|
||||
end
|
||||
--]]
|
||||
|
||||
--- Returns the DCS Unit.
|
||||
-- @param #UNIT self
|
||||
-- @return DCS#Unit The DCS Group.
|
||||
function UNIT:GetDCSObject()
|
||||
|
||||
if (not self.LastCallDCSObject) or (self.LastCallDCSObject and timer.getTime() - self.LastCallDCSObject > 1) then
|
||||
|
||||
-- Get DCS group.
|
||||
local DCSUnit = Unit.getByName( self.UnitName )
|
||||
|
||||
if DCSUnit then
|
||||
self.LastCallDCSObject = timer.getTime()
|
||||
self.DCSObject = DCSUnit
|
||||
return DCSUnit
|
||||
else
|
||||
self.DCSObject = nil
|
||||
self.LastCallDCSObject = nil
|
||||
end
|
||||
|
||||
else
|
||||
return self.DCSObject
|
||||
end
|
||||
|
||||
--self:E(string.format("ERROR: Could not get DCS group object of group %s because DCS object could not be found!", tostring(self.UnitName)))
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -243,7 +268,7 @@ end
|
||||
-- @return #number The height of the group or nil if is not existing or alive.
|
||||
function UNIT:GetAltitude(FromGround)
|
||||
|
||||
local DCSUnit = Unit.getByName( self.UnitName )
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
if DCSUnit then
|
||||
local altitude = 0
|
||||
@ -273,12 +298,12 @@ end
|
||||
-- @param #number Heading The heading of the unit respawn.
|
||||
function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
|
||||
self:T( self:Name() )
|
||||
--self:T( self:Name() )
|
||||
local SpawnGroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplateFromUnitName( self:Name() ) )
|
||||
self:T( SpawnGroupTemplate )
|
||||
--self:T( SpawnGroupTemplate )
|
||||
|
||||
local SpawnGroup = self:GetGroup()
|
||||
self:T( { SpawnGroup = SpawnGroup } )
|
||||
--self:T( { SpawnGroup = SpawnGroup } )
|
||||
|
||||
if SpawnGroup then
|
||||
|
||||
@ -286,10 +311,10 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
SpawnGroupTemplate.x = Coordinate.x
|
||||
SpawnGroupTemplate.y = Coordinate.z
|
||||
|
||||
self:F( #SpawnGroupTemplate.units )
|
||||
--self:F( #SpawnGroupTemplate.units )
|
||||
for UnitID, UnitData in pairs( SpawnGroup:GetUnits() or {} ) do
|
||||
local GroupUnit = UnitData -- #UNIT
|
||||
self:F( GroupUnit:GetName() )
|
||||
--self:F( GroupUnit:GetName() )
|
||||
if GroupUnit:IsAlive() then
|
||||
local GroupUnitVec3 = GroupUnit:GetVec3()
|
||||
local GroupUnitHeading = GroupUnit:GetHeading()
|
||||
@ -297,23 +322,23 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
SpawnGroupTemplate.units[UnitID].x = GroupUnitVec3.x
|
||||
SpawnGroupTemplate.units[UnitID].y = GroupUnitVec3.z
|
||||
SpawnGroupTemplate.units[UnitID].heading = GroupUnitHeading
|
||||
self:F( { UnitID, SpawnGroupTemplate.units[UnitID], SpawnGroupTemplate.units[UnitID] } )
|
||||
--self:F( { UnitID, SpawnGroupTemplate.units[UnitID], SpawnGroupTemplate.units[UnitID] } )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for UnitTemplateID, UnitTemplateData in pairs( SpawnGroupTemplate.units ) do
|
||||
self:T( { UnitTemplateData.name, self:Name() } )
|
||||
--self:T( { UnitTemplateData.name, self:Name() } )
|
||||
SpawnGroupTemplate.units[UnitTemplateID].unitId = nil
|
||||
if UnitTemplateData.name == self:Name() then
|
||||
self:T("Adjusting")
|
||||
--self:T("Adjusting")
|
||||
SpawnGroupTemplate.units[UnitTemplateID].alt = Coordinate.y
|
||||
SpawnGroupTemplate.units[UnitTemplateID].x = Coordinate.x
|
||||
SpawnGroupTemplate.units[UnitTemplateID].y = Coordinate.z
|
||||
SpawnGroupTemplate.units[UnitTemplateID].heading = Heading
|
||||
self:F( { UnitTemplateID, SpawnGroupTemplate.units[UnitTemplateID], SpawnGroupTemplate.units[UnitTemplateID] } )
|
||||
--self:F( { UnitTemplateID, SpawnGroupTemplate.units[UnitTemplateID], SpawnGroupTemplate.units[UnitTemplateID] } )
|
||||
else
|
||||
self:F( SpawnGroupTemplate.units[UnitTemplateID].name )
|
||||
--self:F( SpawnGroupTemplate.units[UnitTemplateID].name )
|
||||
local GroupUnit = UNIT:FindByName( SpawnGroupTemplate.units[UnitTemplateID].name ) -- #UNIT
|
||||
if GroupUnit and GroupUnit:IsAlive() then
|
||||
local GroupUnitVec3 = GroupUnit:GetVec3()
|
||||
@ -324,7 +349,7 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
UnitTemplateData.heading = GroupUnitHeading
|
||||
else
|
||||
if SpawnGroupTemplate.units[UnitTemplateID].name ~= self:Name() then
|
||||
self:T("nilling")
|
||||
--self:T("nilling")
|
||||
SpawnGroupTemplate.units[UnitTemplateID].delete = true
|
||||
end
|
||||
end
|
||||
@ -336,7 +361,7 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
while i <= #SpawnGroupTemplate.units do
|
||||
|
||||
local UnitTemplateData = SpawnGroupTemplate.units[i]
|
||||
self:T( UnitTemplateData.name )
|
||||
--self:T( UnitTemplateData.name )
|
||||
|
||||
if UnitTemplateData.delete then
|
||||
table.remove( SpawnGroupTemplate.units, i )
|
||||
@ -347,7 +372,7 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||
|
||||
SpawnGroupTemplate.groupId = nil
|
||||
|
||||
self:T( SpawnGroupTemplate )
|
||||
--self:T( SpawnGroupTemplate )
|
||||
|
||||
_DATABASE:Spawn( SpawnGroupTemplate )
|
||||
end
|
||||
@ -358,7 +383,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
||||
function UNIT:IsActive()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -395,7 +420,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean Returns `true` if Unit is alive and active, `false` if it exists but is not active and `nil` if the object does not exist or DCS `isExist` function returns false.
|
||||
function UNIT:IsAlive()
|
||||
self:F3( self.UnitName )
|
||||
--self:F3( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject() -- DCS#Unit
|
||||
|
||||
@ -418,7 +443,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #string The Callsign of the Unit.
|
||||
function UNIT:GetCallsign()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -430,7 +455,7 @@ function UNIT:GetCallsign()
|
||||
return UnitCallSign
|
||||
end
|
||||
|
||||
self:F( self.ClassName .. " " .. self.UnitName .. " not found!" )
|
||||
--self:F( self.ClassName .. " " .. self.UnitName .. " not found!" )
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -477,7 +502,7 @@ end
|
||||
-- @return #string Player Name
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
function UNIT:GetPlayerName()
|
||||
self:F( self.UnitName )
|
||||
--self:F( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject() -- DCS#Unit
|
||||
|
||||
@ -551,7 +576,7 @@ end
|
||||
-- @return #number The Unit number.
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
function UNIT:GetNumber()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -568,7 +593,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number Speed in km/h.
|
||||
function UNIT:GetSpeedMax()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local Desc = self:GetDesc()
|
||||
|
||||
@ -585,7 +610,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number Range in meters.
|
||||
function UNIT:GetRange()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local Desc = self:GetDesc()
|
||||
|
||||
@ -607,7 +632,7 @@ end
|
||||
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
|
||||
-- @return #number Refueling system (if any): 0=boom, 1=probe.
|
||||
function UNIT:IsRefuelable()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local refuelable=self:HasAttribute("Refuelable")
|
||||
|
||||
@ -626,7 +651,7 @@ end
|
||||
-- @return #boolean If true, unit is a tanker (checks for the attribute "Tankers").
|
||||
-- @return #number Refueling system (if any): 0=boom, 1=probe.
|
||||
function UNIT:IsTanker()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local tanker=self:HasAttribute("Tankers")
|
||||
|
||||
@ -725,7 +750,7 @@ end
|
||||
-- @param Wrapper.Unit#UNIT self
|
||||
-- @return Wrapper.Group#GROUP The Group of the Unit or `nil` if the unit does not exist.
|
||||
function UNIT:GetGroup()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
local UnitGroup = GROUP:FindByName(self.GroupName)
|
||||
if UnitGroup then
|
||||
return UnitGroup
|
||||
@ -749,13 +774,13 @@ end
|
||||
-- @return #string The name of the DCS Unit.
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
function UNIT:GetPrefix()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
if DCSUnit then
|
||||
local UnitPrefix = string.match( self.UnitName, ".*#" ):sub( 1, -2 )
|
||||
self:T3( UnitPrefix )
|
||||
--self:T3( UnitPrefix )
|
||||
return UnitPrefix
|
||||
end
|
||||
|
||||
@ -766,7 +791,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return DCS#Unit.Ammo Table with ammuntion of the unit (or nil). This can be a complex table!
|
||||
function UNIT:GetAmmo()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
if DCSUnit then
|
||||
--local status, unitammo = pcall(
|
||||
@ -958,7 +983,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return DCS#Unit.Sensors Table of sensors.
|
||||
function UNIT:GetSensors()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -977,7 +1002,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean returns true if the unit has specified types of sensors. This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.
|
||||
function UNIT:HasSensors( ... )
|
||||
self:F2( arg )
|
||||
--self:F2( arg )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -993,7 +1018,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean returns true if the unit is SEADable.
|
||||
function UNIT:HasSEAD()
|
||||
self:F2()
|
||||
--self:F2()
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1021,7 +1046,7 @@ end
|
||||
-- @return #boolean Indicates if at least one of the unit's radar(s) is on.
|
||||
-- @return DCS#Object The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
|
||||
function UNIT:GetRadar()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1037,7 +1062,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number The relative amount of fuel (from 0.0 to 1.0) or *nil* if the DCS Unit is not existing or alive.
|
||||
function UNIT:GetFuel()
|
||||
self:F3( self.UnitName )
|
||||
--self:F3( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1054,14 +1079,14 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #list<Wrapper.Unit#UNIT> A list of one @{Wrapper.Unit}.
|
||||
function UNIT:GetUnits()
|
||||
self:F3( { self.UnitName } )
|
||||
--self:F3( { self.UnitName } )
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
local Units = {}
|
||||
|
||||
if DCSUnit then
|
||||
Units[1] = UNIT:Find( DCSUnit )
|
||||
self:T3( Units )
|
||||
-self:T3( Units )
|
||||
return Units
|
||||
end
|
||||
|
||||
@ -1073,7 +1098,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number The Unit's health value or -1 if unit does not exist any more.
|
||||
function UNIT:GetLife()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1089,7 +1114,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number The Unit's initial health value or 0 if unit does not exist any more.
|
||||
function UNIT:GetLife0()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1105,7 +1130,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number The Unit's relative health value, i.e. a number in [0,1] or -1 if unit does not exist any more.
|
||||
function UNIT:GetLifeRelative()
|
||||
self:F2(self.UnitName)
|
||||
--self:F2(self.UnitName)
|
||||
|
||||
if self and self:IsAlive() then
|
||||
local life0=self:GetLife0()
|
||||
@ -1120,7 +1145,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number The Unit's relative health value, i.e. a number in [0,1] or 1 if unit does not exist any more.
|
||||
function UNIT:GetDamageRelative()
|
||||
self:F2(self.UnitName)
|
||||
--self:F2(self.UnitName)
|
||||
|
||||
if self and self:IsAlive() then
|
||||
return 1-self:GetLifeRelative()
|
||||
@ -1158,7 +1183,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #number Unit category from `getDesc().category`.
|
||||
function UNIT:GetUnitCategory()
|
||||
self:F3( self.UnitName )
|
||||
--self:F3( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
if DCSUnit then
|
||||
@ -1172,7 +1197,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
|
||||
function UNIT:GetCategoryName()
|
||||
self:F3( self.UnitName )
|
||||
--self:F3( self.UnitName )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
if DCSUnit then
|
||||
@ -1184,7 +1209,7 @@ function UNIT:GetCategoryName()
|
||||
[Unit.Category.STRUCTURE] = "Structure",
|
||||
}
|
||||
local UnitCategory = DCSUnit:getDesc().category
|
||||
self:T3( UnitCategory )
|
||||
--self:T3( UnitCategory )
|
||||
|
||||
return CategoryNames[UnitCategory]
|
||||
end
|
||||
@ -1412,7 +1437,7 @@ end
|
||||
-- @return true If the other DCS Unit is within the radius of the 2D point of the DCS Unit.
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
||||
self:F2( { self.UnitName, AwaitUnit.UnitName, Radius } )
|
||||
--self:F2( { self.UnitName, AwaitUnit.UnitName, Radius } )
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
@ -1421,10 +1446,10 @@ function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
||||
local AwaitUnitVec3 = AwaitUnit:GetVec3()
|
||||
|
||||
if (((UnitVec3.x - AwaitUnitVec3.x)^2 + (UnitVec3.z - AwaitUnitVec3.z)^2)^0.5 <= Radius) then
|
||||
self:T3( "true" )
|
||||
--self:T3( "true" )
|
||||
return true
|
||||
else
|
||||
self:T3( "false" )
|
||||
--self:T3( "false" )
|
||||
return false
|
||||
end
|
||||
end
|
||||
@ -1442,17 +1467,17 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean IsFriendly evaluation result.
|
||||
function UNIT:IsFriendly( FriendlyCoalition )
|
||||
self:F2()
|
||||
--self:F2()
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
if DCSUnit then
|
||||
local UnitCoalition = DCSUnit:getCoalition()
|
||||
self:T3( { UnitCoalition, FriendlyCoalition } )
|
||||
--self:T3( { UnitCoalition, FriendlyCoalition } )
|
||||
|
||||
local IsFriendlyResult = ( UnitCoalition == FriendlyCoalition )
|
||||
|
||||
self:F( IsFriendlyResult )
|
||||
--self:F( IsFriendlyResult )
|
||||
return IsFriendlyResult
|
||||
end
|
||||
|
||||
@ -1464,17 +1489,17 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #boolean Ship category evaluation result.
|
||||
function UNIT:IsShip()
|
||||
self:F2()
|
||||
--self:F2()
|
||||
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
if DCSUnit then
|
||||
local UnitDescriptor = DCSUnit:getDesc()
|
||||
self:T3( { UnitDescriptor.category, Unit.Category.SHIP } )
|
||||
--self:T3( { UnitDescriptor.category, Unit.Category.SHIP } )
|
||||
|
||||
local IsShipResult = ( UnitDescriptor.category == Unit.Category.SHIP )
|
||||
|
||||
self:T3( IsShipResult )
|
||||
--self:T3( IsShipResult )
|
||||
return IsShipResult
|
||||
end
|
||||
|
||||
@ -1486,7 +1511,7 @@ end
|
||||
-- @param #boolean NoHeloCheck If true, no additonal checks for helos are performed.
|
||||
-- @return #boolean Return true if in the air or #nil if the UNIT is not existing or alive.
|
||||
function UNIT:InAir(NoHeloCheck)
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
-- Get DCS unit object.
|
||||
local DCSUnit = self:GetDCSObject() --DCS#Unit
|
||||
@ -1513,7 +1538,7 @@ function UNIT:InAir(NoHeloCheck)
|
||||
end
|
||||
end
|
||||
|
||||
self:T3( UnitInAir )
|
||||
--self:T3( UnitInAir )
|
||||
return UnitInAir
|
||||
end
|
||||
|
||||
@ -1708,7 +1733,7 @@ end
|
||||
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled.
|
||||
-- @return #UNIT self
|
||||
function UNIT:EnableEmission(switch)
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
|
||||
local switch = switch or false
|
||||
|
||||
@ -1727,7 +1752,7 @@ end
|
||||
-- @param #UNIT self
|
||||
-- @return #string Skill String of skill name.
|
||||
function UNIT:GetSkill()
|
||||
self:F2( self.UnitName )
|
||||
--self:F2( self.UnitName )
|
||||
local name = self.UnitName
|
||||
local skill = "Random"
|
||||
if _DATABASE.Templates.Units[name] and _DATABASE.Templates.Units[name].Template and _DATABASE.Templates.Units[name].Template.skill then
|
||||
@ -1743,7 +1768,7 @@ end
|
||||
-- @return #string VCN Voice Callsign Number or nil if not set/capable.
|
||||
-- @return #string Lead If true, unit is Flight Lead, else false or nil.
|
||||
function UNIT:GetSTN()
|
||||
self:F2(self.UnitName)
|
||||
--self:F2(self.UnitName)
|
||||
local STN = nil -- STN/TN
|
||||
local VCL = nil -- VoiceCallsignLabel
|
||||
local VCN = nil -- VoiceCallsignNumber
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user