mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#ZONE_CAPTURE_COALITION - allow zone to be a ZONE_POLYGON
#RANGE Messaging changes in case >1 player per group
This commit is contained in:
parent
9121624c3c
commit
5e5f1398fa
@ -910,9 +910,6 @@ function ZONE_RADIUS:GetVec3( Height )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- Scan the zone for the presence of units of the given ObjectCategories.
|
||||
-- Note that **only after** a zone has been scanned, the zone can be evaluated by:
|
||||
--
|
||||
@ -921,7 +918,6 @@ end
|
||||
-- * @{ZONE_RADIUS.IsSomeInZoneOfCoalition}(): Scan if there is some presence of units in the zone of the given coalition.
|
||||
-- * @{ZONE_RADIUS.IsNoneInZoneOfCoalition}(): Scan if there isn't any presence of units in the zone of an other coalition than the given one.
|
||||
-- * @{ZONE_RADIUS.IsNoneInZone}(): Scan if the zone is empty.
|
||||
-- @{#ZONE_RADIUS.
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @param ObjectCategories An array of categories of the objects to find in the zone. E.g. `{Object.Category.UNIT}`
|
||||
-- @param UnitCategories An array of unit categories of the objects to find in the zone. E.g. `{Unit.Category.GROUND_UNIT,Unit.Category.SHIP}`
|
||||
@ -953,7 +949,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
||||
if ZoneObject then
|
||||
|
||||
local ObjectCategory = ZoneObject:getCategory()
|
||||
|
||||
|
||||
--local name=ZoneObject:getName()
|
||||
--env.info(string.format("Zone object %s", tostring(name)))
|
||||
--self:E(ZoneObject)
|
||||
@ -2417,6 +2413,296 @@ function ZONE_POLYGON:FindByName( ZoneName )
|
||||
return ZoneFound
|
||||
end
|
||||
|
||||
--- Scan the zone for the presence of units of the given ObjectCategories. Does **not** scan for scenery at the moment.
|
||||
-- Note that **only after** a zone has been scanned, the zone can be evaluated by:
|
||||
--
|
||||
-- * @{ZONE_POLYGON.IsAllInZoneOfCoalition}(): Scan the presence of units in the zone of a coalition.
|
||||
-- * @{ZONE_POLYGON.IsAllInZoneOfOtherCoalition}(): Scan the presence of units in the zone of an other coalition.
|
||||
-- * @{ZONE_POLYGON.IsSomeInZoneOfCoalition}(): Scan if there is some presence of units in the zone of the given coalition.
|
||||
-- * @{ZONE_POLYGON.IsNoneInZoneOfCoalition}(): Scan if there isn't any presence of units in the zone of an other coalition than the given one.
|
||||
-- * @{ZONE_POLYGON.IsNoneInZone}(): Scan if the zone is empty.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param ObjectCategories An array of categories of the objects to find in the zone. E.g. `{Object.Category.UNIT}`
|
||||
-- @param UnitCategories An array of unit categories of the objects to find in the zone. E.g. `{Unit.Category.GROUND_UNIT,Unit.Category.SHIP}`
|
||||
-- @usage
|
||||
-- myzone:Scan({Object.Category.UNIT},{Unit.Category.GROUND_UNIT})
|
||||
-- local IsAttacked = myzone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||
function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
|
||||
self.ScanData = {}
|
||||
self.ScanData.Coalitions = {}
|
||||
self.ScanData.Scenery = {}
|
||||
self.ScanData.Units = {}
|
||||
|
||||
local function EvaluateZone( ZoneObject )
|
||||
|
||||
if ZoneObject then
|
||||
|
||||
local ObjectCategory = ZoneObject:getCategory()
|
||||
|
||||
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive() ) or (ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then
|
||||
|
||||
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||
|
||||
local Include = false
|
||||
if not UnitCategories then
|
||||
-- Anything found is included.
|
||||
Include = true
|
||||
else
|
||||
-- Check if found object is in specified categories.
|
||||
local CategoryDCSUnit = ZoneObject:getDesc().category
|
||||
|
||||
for UnitCategoryID, UnitCategory in pairs( UnitCategories ) do
|
||||
if UnitCategory == CategoryDCSUnit then
|
||||
Include = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if Include then
|
||||
|
||||
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||
|
||||
-- This coalition is inside the zone.
|
||||
self.ScanData.Coalitions[CoalitionDCSUnit] = true
|
||||
|
||||
self.ScanData.Units[ZoneObject] = ZoneObject
|
||||
|
||||
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
-- no scenery possible at the moment
|
||||
if ObjectCategory == Object.Category.SCENERY then
|
||||
local SceneryType = ZoneObject:getTypeName()
|
||||
local SceneryName = ZoneObject:getName()
|
||||
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
|
||||
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
|
||||
self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
|
||||
end
|
||||
--]]
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Search objects.
|
||||
local inzoneunits = SET_UNIT:New():FilterZones({self}):FilterOnce()
|
||||
local inzonestatics = SET_STATIC:New():FilterZones({self}):FilterOnce()
|
||||
|
||||
inzoneunits:ForEach(
|
||||
function(unit)
|
||||
local Unit = unit --Wrapper.Unit#UNIT
|
||||
local DCS = Unit:GetDCSObject()
|
||||
EvaluateZone(DCS)
|
||||
end
|
||||
)
|
||||
|
||||
inzonestatics:ForEach(
|
||||
function(static)
|
||||
local Static = static --Wrapper.Static#STATIC
|
||||
local DCS = Static:GetDCSObject()
|
||||
EvaluateZone(DCS)
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
--- Count the number of different coalitions inside the zone.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #table Table of DCS units and DCS statics inside the zone.
|
||||
function ZONE_POLYGON:GetScannedUnits()
|
||||
return self.ScanData.Units
|
||||
end
|
||||
|
||||
--- Get a set of scanned units.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
||||
function ZONE_POLYGON:GetScannedSetUnit()
|
||||
|
||||
local SetUnit = SET_UNIT:New()
|
||||
|
||||
if self.ScanData then
|
||||
for ObjectID, UnitObject in pairs( self.ScanData.Units ) do
|
||||
local UnitObject = UnitObject -- DCS#Unit
|
||||
if UnitObject:isExist() then
|
||||
local FoundUnit = UNIT:FindByName( UnitObject:getName() )
|
||||
if FoundUnit then
|
||||
SetUnit:AddUnit( FoundUnit )
|
||||
else
|
||||
local FoundStatic = STATIC:FindByName( UnitObject:getName() )
|
||||
if FoundStatic then
|
||||
SetUnit:AddUnit( FoundStatic )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return SetUnit
|
||||
end
|
||||
|
||||
--- Get a set of scanned units.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return Core.Set#SET_GROUP Set of groups.
|
||||
function ZONE_POLYGON:GetScannedSetGroup()
|
||||
|
||||
self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP
|
||||
|
||||
self.ScanSetGroup.Set={}
|
||||
|
||||
if self.ScanData then
|
||||
for ObjectID, UnitObject in pairs( self.ScanData.Units ) do
|
||||
local UnitObject = UnitObject -- DCS#Unit
|
||||
if UnitObject:isExist() then
|
||||
|
||||
local FoundUnit=UNIT:FindByName(UnitObject:getName())
|
||||
if FoundUnit then
|
||||
local group=FoundUnit:GetGroup()
|
||||
self.ScanSetGroup:AddGroup(group)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self.ScanSetGroup
|
||||
end
|
||||
|
||||
--- Count the number of different coalitions inside the zone.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #number Counted coalitions.
|
||||
function ZONE_POLYGON:CountScannedCoalitions()
|
||||
|
||||
local Count = 0
|
||||
|
||||
for CoalitionID, Coalition in pairs( self.ScanData.Coalitions ) do
|
||||
Count = Count + 1
|
||||
end
|
||||
|
||||
return Count
|
||||
end
|
||||
|
||||
--- Check if a certain coalition is inside a scanned zone.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param #number Coalition The coalition id, e.g. coalition.side.BLUE.
|
||||
-- @return #boolean If true, the coalition is inside the zone.
|
||||
function ZONE_POLYGON:CheckScannedCoalition( Coalition )
|
||||
if Coalition then
|
||||
return self.ScanData.Coalitions[Coalition]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get Coalitions of the units in the Zone, or Check if there are units of the given Coalition in the Zone.
|
||||
-- Returns nil if there are none to two Coalitions in the zone!
|
||||
-- Returns one Coalition if there are only Units of one Coalition in the Zone.
|
||||
-- Returns the Coalition for the given Coalition if there are units of the Coalition in the Zone.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #table
|
||||
function ZONE_POLYGON:GetScannedCoalition( Coalition )
|
||||
|
||||
if Coalition then
|
||||
return self.ScanData.Coalitions[Coalition]
|
||||
else
|
||||
local Count = 0
|
||||
local ReturnCoalition = nil
|
||||
|
||||
for CoalitionID, Coalition in pairs( self.ScanData.Coalitions ) do
|
||||
Count = Count + 1
|
||||
ReturnCoalition = CoalitionID
|
||||
end
|
||||
|
||||
if Count ~= 1 then
|
||||
ReturnCoalition = nil
|
||||
end
|
||||
|
||||
return ReturnCoalition
|
||||
end
|
||||
end
|
||||
|
||||
--- Get scanned scenery type (currently not implemented in ZONE_POLYGON)
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #table Table of DCS scenery type objects.
|
||||
function ZONE_POLYGON:GetScannedSceneryType( SceneryType )
|
||||
return self.ScanData.Scenery[SceneryType]
|
||||
end
|
||||
|
||||
--- Get scanned scenery table (currently not implemented in ZONE_POLYGON)
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #table Table of DCS scenery objects.
|
||||
function ZONE_POLYGON:GetScannedScenery()
|
||||
return self.ScanData.Scenery
|
||||
end
|
||||
|
||||
--- Is All in Zone of Coalition?
|
||||
-- Check if only the specifed coalition is inside the zone and noone else.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone.
|
||||
-- @return #boolean True, if **only** that coalition is inside the zone and no one else.
|
||||
-- @usage
|
||||
-- self.Zone:Scan()
|
||||
-- local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )
|
||||
function ZONE_POLYGON:IsAllInZoneOfCoalition( Coalition )
|
||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
||||
end
|
||||
|
||||
--- Is All in Zone of Other Coalition?
|
||||
-- Check if only one coalition is inside the zone and the specified coalition is not the one.
|
||||
-- You first need to use the @{#ZONE_POLYGON.Scan} method to scan the zone before it can be evaluated!
|
||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param #number Coalition Coalition ID of the coalition which is not supposed to be in the zone.
|
||||
-- @return #boolean True, if and only if only one coalition is inside the zone and the specified coalition is not it.
|
||||
-- @usage
|
||||
-- self.Zone:Scan()
|
||||
-- local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )
|
||||
function ZONE_POLYGON:IsAllInZoneOfOtherCoalition( Coalition )
|
||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
||||
end
|
||||
|
||||
--- Is Some in Zone of Coalition?
|
||||
-- Check if more than one coaltion is inside the zone and the specifed coalition is one of them.
|
||||
-- You first need to use the @{#ZONE_POLYGON.Scan} method to scan the zone before it can be evaluated!
|
||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param #number Coalition ID of the coaliton which is checked to be inside the zone.
|
||||
-- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them.
|
||||
-- @usage
|
||||
-- self.Zone:Scan()
|
||||
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||
function ZONE_POLYGON:IsSomeInZoneOfCoalition( Coalition )
|
||||
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
||||
end
|
||||
|
||||
--- Is None in Zone of Coalition?
|
||||
-- You first need to use the @{#ZONE_POLYGON.Scan} method to scan the zone before it can be evaluated!
|
||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @param Coalition
|
||||
-- @return #boolean
|
||||
-- @usage
|
||||
-- self.Zone:Scan()
|
||||
-- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )
|
||||
function ZONE_POLYGON:IsNoneInZoneOfCoalition( Coalition )
|
||||
return self:GetScannedCoalition( Coalition ) == nil
|
||||
end
|
||||
|
||||
--- Is None in Zone?
|
||||
-- You first need to use the @{#ZONE_POLYGON.Scan} method to scan the zone before it can be evaluated!
|
||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||
-- @param #ZONE_POLYGON self
|
||||
-- @return #boolean
|
||||
-- @usage
|
||||
-- self.Zone:Scan()
|
||||
-- local IsEmpty = self.Zone:IsNoneInZone()
|
||||
function ZONE_POLYGON:IsNoneInZone()
|
||||
return self:CountScannedCoalitions() == 0
|
||||
end
|
||||
|
||||
|
||||
do -- ZONE_ELASTIC
|
||||
|
||||
--- @type ZONE_ELASTIC
|
||||
|
||||
@ -2570,7 +2570,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
||||
self:F( _unitName )
|
||||
|
||||
-- Get player unit and name
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||
local _unit, _playername, _multiplayer = self:_GetPlayerUnitAndName( _unitName )
|
||||
|
||||
if _unit and _playername then
|
||||
|
||||
@ -2622,7 +2622,7 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
||||
end
|
||||
|
||||
-- Send message to group.
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2633,7 +2633,7 @@ function RANGE:_DisplayStrafePitResults( _unitName )
|
||||
self:F( _unitName )
|
||||
|
||||
-- Get player unit and name.
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||
local _unit, _playername, _multiplayer = self:_GetPlayerUnitAndName( _unitName )
|
||||
|
||||
-- Check if we have a unit which is a player.
|
||||
if _unit and _playername then
|
||||
@ -2680,7 +2680,7 @@ function RANGE:_DisplayStrafePitResults( _unitName )
|
||||
end
|
||||
|
||||
-- Send message.
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2691,7 +2691,7 @@ function RANGE:_DisplayMyBombingResults( _unitName )
|
||||
self:F( _unitName )
|
||||
|
||||
-- Get player unit and name.
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )
|
||||
local _unit, _playername, _multiplayer = self:_GetPlayerUnitAndName( _unitName )
|
||||
|
||||
if _unit and _playername then
|
||||
|
||||
@ -2737,7 +2737,7 @@ function RANGE:_DisplayMyBombingResults( _unitName )
|
||||
end
|
||||
|
||||
-- Send message.
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2751,7 +2751,7 @@ function RANGE:_DisplayBombingResults( _unitName )
|
||||
local _playerResults = {}
|
||||
|
||||
-- Get player unit and name.
|
||||
local _unit, _player = self:_GetPlayerUnitAndName( _unitName )
|
||||
local _unit, _player, _multiplayer = self:_GetPlayerUnitAndName( _unitName )
|
||||
|
||||
-- Check if we have a unit with a player.
|
||||
if _unit and _player then
|
||||
@ -2795,7 +2795,7 @@ function RANGE:_DisplayBombingResults( _unitName )
|
||||
end
|
||||
|
||||
-- Send message.
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _message, nil, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2806,7 +2806,7 @@ function RANGE:_DisplayRangeInfo( _unitname )
|
||||
self:F( _unitname )
|
||||
|
||||
-- Get player unit and player name.
|
||||
local unit, playername = self:_GetPlayerUnitAndName( _unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( _unitname )
|
||||
|
||||
-- Check if we have a player.
|
||||
if unit and playername then
|
||||
@ -2901,7 +2901,7 @@ function RANGE:_DisplayRangeInfo( _unitname )
|
||||
text = text .. textdelay
|
||||
|
||||
-- Send message to player group.
|
||||
self:_DisplayMessageToGroup( unit, text, nil, true, true )
|
||||
self:_DisplayMessageToGroup( unit, text, nil, true, true, _multiplayer )
|
||||
|
||||
-- Debug output.
|
||||
self:T2( self.id .. text )
|
||||
@ -2916,7 +2916,7 @@ function RANGE:_DisplayBombTargets( _unitname )
|
||||
self:F( _unitname )
|
||||
|
||||
-- Get player unit and player name.
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitname )
|
||||
local _unit, _playername, _multiplayer = self:_GetPlayerUnitAndName( _unitname )
|
||||
|
||||
-- Check if we have a player.
|
||||
if _unit and _playername then
|
||||
@ -2948,7 +2948,7 @@ function RANGE:_DisplayBombTargets( _unitname )
|
||||
end
|
||||
end
|
||||
|
||||
self:_DisplayMessageToGroup( _unit, _text, 120, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _text, 120, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2959,7 +2959,7 @@ function RANGE:_DisplayStrafePits( _unitname )
|
||||
self:F( _unitname )
|
||||
|
||||
-- Get player unit and player name.
|
||||
local _unit, _playername = self:_GetPlayerUnitAndName( _unitname )
|
||||
local _unit, _playername, _multiplayer = self:_GetPlayerUnitAndName( _unitname )
|
||||
|
||||
-- Check if we have a player.
|
||||
if _unit and _playername then
|
||||
@ -2988,7 +2988,7 @@ function RANGE:_DisplayStrafePits( _unitname )
|
||||
_text = _text .. string.format( "\n- %s: heading %03d°\n%s", _strafepit.name, heading, mycoord )
|
||||
end
|
||||
|
||||
self:_DisplayMessageToGroup( _unit, _text, nil, true, true )
|
||||
self:_DisplayMessageToGroup( _unit, _text, nil, true, true, _multiplayer )
|
||||
end
|
||||
end
|
||||
|
||||
@ -2999,7 +2999,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
|
||||
self:F( _unitname )
|
||||
|
||||
-- Get player unit and player name.
|
||||
local unit, playername = self:_GetPlayerUnitAndName( _unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( _unitname )
|
||||
|
||||
-- Check if we have a player.
|
||||
if unit and playername then
|
||||
@ -3048,7 +3048,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
|
||||
end
|
||||
|
||||
-- Send message to player group.
|
||||
self:_DisplayMessageToGroup( unit, text, nil, true, true )
|
||||
self:_DisplayMessageToGroup( unit, text, nil, true, true, _multiplayer )
|
||||
|
||||
-- Debug output.
|
||||
self:T2( self.id .. text )
|
||||
@ -3666,7 +3666,8 @@ end
|
||||
-- @param #number _time Duration how long the message is displayed.
|
||||
-- @param #boolean _clear Clear up old messages.
|
||||
-- @param #boolean display If true, display message regardless of player setting "Messages Off".
|
||||
function RANGE:_DisplayMessageToGroup( _unit, _text, _time, _clear, display )
|
||||
-- @param #boolean _togroup If true, display the message to the group in any case
|
||||
function RANGE:_DisplayMessageToGroup( _unit, _text, _time, _clear, display, _togroup )
|
||||
self:F( { unit = _unit, text = _text, time = _time, clear = _clear } )
|
||||
|
||||
-- Defaults
|
||||
@ -3694,8 +3695,13 @@ function RANGE:_DisplayMessageToGroup( _unit, _text, _time, _clear, display )
|
||||
local playermessage = self.PlayerSettings[playername].messages
|
||||
|
||||
-- Send message to player if messages enabled and not only for the examiner.
|
||||
|
||||
if _gid and (playermessage == true or display) and (not self.examinerexclusive) then
|
||||
local m = MESSAGE:New(_text,_time,nil,_clear):ToUnit(_unit)
|
||||
if _togroup and _grp then
|
||||
local m = MESSAGE:New(_text,_time,nil,_clear):ToGroup(_grp)
|
||||
else
|
||||
local m = MESSAGE:New(_text,_time,nil,_clear):ToUnit(_unit)
|
||||
end
|
||||
end
|
||||
|
||||
-- Send message to examiner.
|
||||
@ -3715,7 +3721,7 @@ end
|
||||
function RANGE:_SmokeBombImpactOnOff( unitname )
|
||||
self:F( unitname )
|
||||
|
||||
local unit, playername = self:_GetPlayerUnitAndName( unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( unitname )
|
||||
if unit and playername then
|
||||
local text
|
||||
if self.PlayerSettings[playername].smokebombimpact == true then
|
||||
@ -3736,7 +3742,7 @@ end
|
||||
function RANGE:_SmokeBombDelayOnOff( unitname )
|
||||
self:F( unitname )
|
||||
|
||||
local unit, playername = self:_GetPlayerUnitAndName( unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( unitname )
|
||||
if unit and playername then
|
||||
local text
|
||||
if self.PlayerSettings[playername].delaysmoke == true then
|
||||
@ -3757,7 +3763,7 @@ end
|
||||
function RANGE:_MessagesToPlayerOnOff( unitname )
|
||||
self:F( unitname )
|
||||
|
||||
local unit, playername = self:_GetPlayerUnitAndName( unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( unitname )
|
||||
if unit and playername then
|
||||
local text
|
||||
if self.PlayerSettings[playername].messages == true then
|
||||
@ -3778,7 +3784,7 @@ function RANGE:_TargetsheetOnOff( _unitname )
|
||||
self:F2( _unitname )
|
||||
|
||||
-- Get player unit and player name.
|
||||
local unit, playername = self:_GetPlayerUnitAndName( _unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( _unitname )
|
||||
|
||||
-- Check if we have a player.
|
||||
if unit and playername then
|
||||
@ -3820,7 +3826,7 @@ end
|
||||
function RANGE:_FlareDirectHitsOnOff( unitname )
|
||||
self:F( unitname )
|
||||
|
||||
local unit, playername = self:_GetPlayerUnitAndName( unitname )
|
||||
local unit, playername, _multiplayer = self:_GetPlayerUnitAndName( unitname )
|
||||
if unit and playername then
|
||||
local text
|
||||
if self.PlayerSettings[playername].flaredirecthits == true then
|
||||
@ -4039,12 +4045,14 @@ end
|
||||
-- @param #string _unitName Name of the player unit.
|
||||
-- @return Wrapper.Unit#UNIT Unit of player.
|
||||
-- @return #string Name of the player.
|
||||
-- @return nil If player does not exist.
|
||||
-- @return #boolean If true, group has > 1 player in it
|
||||
function RANGE:_GetPlayerUnitAndName( _unitName )
|
||||
self:F2( _unitName )
|
||||
|
||||
if _unitName ~= nil then
|
||||
|
||||
|
||||
local multiplayer = false
|
||||
|
||||
-- Get DCS unit from its name.
|
||||
local DCSunit = Unit.getByName( _unitName )
|
||||
|
||||
@ -4056,7 +4064,11 @@ function RANGE:_GetPlayerUnitAndName( _unitName )
|
||||
self:T2( { DCSunit = DCSunit, unit = unit, playername = playername } )
|
||||
if DCSunit and unit and playername then
|
||||
self:F2(playername)
|
||||
return unit, playername
|
||||
local grp = unit:GetGroup()
|
||||
if grp and grp:CountAliveUnits() > 1 then
|
||||
multiplayer = true
|
||||
end
|
||||
return unit, playername, multiplayer
|
||||
end
|
||||
|
||||
end
|
||||
@ -4064,7 +4076,7 @@ function RANGE:_GetPlayerUnitAndName( _unitName )
|
||||
end
|
||||
|
||||
-- Return nil if we could not find a player.
|
||||
return nil, nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
|
||||
--- Returns a string which consists of the player name.
|
||||
|
||||
@ -363,7 +363,7 @@ do -- ZONE_CAPTURE_COALITION
|
||||
|
||||
--- ZONE_CAPTURE_COALITION Constructor.
|
||||
-- @param #ZONE_CAPTURE_COALITION self
|
||||
-- @param Core.Zone#ZONE Zone A @{Zone} object with the goal to be achieved.
|
||||
-- @param Core.Zone#ZONE Zone A @{Zone} object with the goal to be achieved. Alternatively, can be handed as the name of late activated group describing a @{ZONE_POLYGON} with its waypoints.
|
||||
-- @param DCSCoalition.DCSCoalition#coalition Coalition The initial coalition owning the zone.
|
||||
-- @param #table UnitCategories Table of unit categories. See [DCS Class Unit](https://wiki.hoggitworld.com/view/DCS_Class_Unit). Default {Unit.Category.GROUND_UNIT}.
|
||||
-- @param #table ObjectCategories Table of unit categories. See [DCS Class Object](https://wiki.hoggitworld.com/view/DCS_Class_Object). Default {Object.Category.UNIT, Object.Category.STATIC}, i.e. all UNITS and STATICS.
|
||||
|
||||
@ -59,10 +59,15 @@ do -- Zone
|
||||
-- @param Core.Zone#ZONE_RADIUS Zone A @{Zone} object with the goal to be achieved.
|
||||
-- @return #ZONE_GOAL
|
||||
function ZONE_GOAL:New( Zone )
|
||||
|
||||
local self = BASE:Inherit( self, ZONE_RADIUS:New( Zone:GetName(), Zone:GetVec2(), Zone:GetRadius() ) ) -- #ZONE_GOAL
|
||||
self:F( { Zone = Zone } )
|
||||
|
||||
|
||||
BASE:I({Zone=Zone})
|
||||
local self = BASE:Inherit( self, BASE:New())
|
||||
if type(Zone) == "string" then
|
||||
self = BASE:Inherit( self, ZONE_POLYGON:NewFromGroupName(Zone) )
|
||||
else
|
||||
self = BASE:Inherit( self, ZONE_RADIUS:New( Zone:GetName(), Zone:GetVec2(), Zone:GetRadius() ) ) -- #ZONE_GOAL
|
||||
self:F( { Zone = Zone } )
|
||||
end
|
||||
-- Goal object.
|
||||
self.Goal = GOAL:New()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user