Various improvements

This commit is contained in:
FlightControl 2019-03-21 07:01:24 +01:00
commit f849732f55
9 changed files with 68 additions and 83 deletions

View File

@ -142,6 +142,7 @@ do -- Goal
-- @param #GOAL self
-- @param #string PlayerName The name of the player.
function GOAL:AddPlayerContribution( PlayerName )
self:F({PlayerName})
self.Players[PlayerName] = self.Players[PlayerName] or 0
self.Players[PlayerName] = self.Players[PlayerName] + 1
self.TotalContributions = self.TotalContributions + 1

View File

@ -710,7 +710,18 @@ function ZONE_RADIUS:GetScannedSetUnit()
if self.ScanData then
for ObjectID, UnitObject in pairs( self.ScanData.Units ) do
SetUnit:AddUnit( UNIT:FindByName(UnitObject:getName() ) )
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

View File

@ -212,7 +212,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
if EventGroup and self:HasGroup( EventGroup ) then
local CommandCenterMenu = MENU_GROUP:New( EventGroup, self:GetText() )
local MenuReporting = MENU_GROUP:New( EventGroup, "Missions Reports", CommandCenterMenu )
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Status Report", MenuReporting, self.ReportMissionsStatus, self, EventGroup )
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Status Report", MenuReporting, self.ReportSummary, self, EventGroup )
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Players Report", MenuReporting, self.ReportMissionsPlayers, self, EventGroup )
self:ReportSummary( EventGroup )
local PlayerUnit = EventData.IniUnit
@ -507,14 +507,18 @@ function COMMANDCENTER:AssignTask( TaskGroup )
end
local Task = Tasks[ math.random( 1, #Tasks ) ] -- Tasking.Task#TASK
if Task then
self:I( "Assigning task " .. Task:GetName() .. " using auto assign method " .. self.AutoAssignMethod .. " to " .. TaskGroup:GetName() .. " with task priority " .. AssignPriority )
if not self.AutoAcceptTasks == true then
Task:SetAutoAssignMethod( ACT_ASSIGN_MENU_ACCEPT:New( Task.TaskBriefing ) )
self:I( "Assigning task " .. Task:GetName() .. " using auto assign method " .. self.AutoAssignMethod .. " to " .. TaskGroup:GetName() .. " with task priority " .. AssignPriority )
if not self.AutoAcceptTasks == true then
Task:SetAutoAssignMethod( ACT_ASSIGN_MENU_ACCEPT:New( Task.TaskBriefing ) )
end
Task:AssignToGroup( TaskGroup )
end
Task:AssignToGroup( TaskGroup )
end

View File

@ -1808,7 +1808,7 @@ function TASK:GetPlayerNames() --R2.1 Get a map of the players.
if PlayerGroup:IsAlive() == true then
if self:IsGroupAssigned( PlayerGroup ) then
local PlayerNames = PlayerGroup:GetPlayerNames()
for PlayerNameID, PlayerName in pairs( PlayerNames ) do
for PlayerNameID, PlayerName in pairs( PlayerNames or {} ) do
PlayerNameMap[PlayerName] = PlayerGroup
end
end

View File

@ -284,7 +284,7 @@ do -- TASK_CAPTURE_DISPATCHER
end
function CaptureZone.Task.OnEnterSuccess( Task, From, Event, To )
self:Success( Task )
--self:Success( Task )
if self.AI_A2G_Dispatcher then
self.AI_A2G_Dispatcher:Lock( Task.TaskZoneName ) -- This will lock the zone from being defended by AI.
end

View File

@ -211,7 +211,9 @@ do -- TASK_CAPTURE_ZONE
"Capture Zone " .. self.TaskZoneName
)
self:UpdateTaskInfo()
self:UpdateTaskInfo( true )
self:SetGoalTotal( 1 )
return self
end
@ -219,18 +221,18 @@ do -- TASK_CAPTURE_ZONE
--- Instantiates a new TASK_CAPTURE_ZONE.
-- @param #TASK_CAPTURE_ZONE self
function TASK_CAPTURE_ZONE:UpdateTaskInfo( DetectedItem )
function TASK_CAPTURE_ZONE:UpdateTaskInfo( Persist )
self:F({"Update"})
Persist = Persist or false
local ZoneCoordinate = self.ZoneGoal:GetZone():GetCoordinate()
self.TaskInfo:AddTaskName( 0, "MSOD" )
self.TaskInfo:AddCoordinate( ZoneCoordinate, 1, "SOD" )
self.TaskInfo:AddText( "Zone Name", self.ZoneGoal:GetZoneName(), 10, "MOD" )
self.TaskInfo:AddText( "Zone Coalition", self.ZoneGoal:GetCoalitionName(), 11, "MOD" )
self.TaskInfo:AddTaskName( 0, "MSOD", Persist )
self.TaskInfo:AddCoordinate( ZoneCoordinate, 1, "SOD", Persist )
self.TaskInfo:AddText( "Zone Name", self.ZoneGoal:GetZoneName(), 10, "MOD", Persist )
self.TaskInfo:AddText( "Zone Coalition", self.ZoneGoal:GetCoalitionName(), 11, "MOD", Persist )
local SetUnit = self.ZoneGoal.Zone:GetScannedSetUnit()
local ThreatLevel, ThreatText = SetUnit:CalculateThreatLevelA2G()
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MOD" )
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MSOD", Persist )
end
@ -251,7 +253,6 @@ do -- TASK_CAPTURE_ZONE
if self.ZoneGoal then
if self.ZoneGoal.Goal:IsAchieved() then
self:Success()
local TotalContributions = self.ZoneGoal.Goal:GetTotalContributions()
local PlayerContributions = self.ZoneGoal.Goal:GetPlayerContributions()
self:F( { TotalContributions = TotalContributions, PlayerContributions = PlayerContributions } )
@ -261,6 +262,7 @@ do -- TASK_CAPTURE_ZONE
Scoring:_AddMissionGoalScore( self.Mission, PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", PlayerContribution * 200 / TotalContributions )
end
end
self:Success()
end
end

View File

@ -1479,3 +1479,33 @@ function POSITIONABLE:SmokeBlue()
end
--- Returns true if the unit is within a @{Zone}.
-- @param #STPOSITIONABLEATIC self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is within the @{Core.Zone#ZONE_BASE}
function POSITIONABLE:IsInZone( Zone )
self:F2( { self.PositionableName, Zone } )
if self:IsAlive() then
local IsInZone = Zone:IsVec3InZone( self:GetVec3() )
return IsInZone
end
return false
end
--- Returns true if the unit is not within a @{Zone}.
-- @param #POSITIONABLE self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is not within the @{Core.Zone#ZONE_BASE}
function POSITIONABLE:IsNotInZone( Zone )
self:F2( { self.PositionableName, Zone } )
if self:IsAlive() then
local IsNotInZone = not Zone:IsVec3InZone( self:GetVec3() )
return IsNotInZone
else
return false
end
end

View File

@ -214,35 +214,3 @@ function STATIC:ReSpawnAt( Coordinate, Heading )
SpawnStatic:ReSpawnAt( Coordinate, Heading )
end
--- Returns true if the unit is within a @{Zone}.
-- @param #STATIC self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is within the @{Core.Zone#ZONE_BASE}
function STATIC:IsInZone( Zone )
self:F2( { self.StaticName, Zone } )
if self:IsAlive() then
local IsInZone = Zone:IsVec3InZone( self:GetVec3() )
return IsInZone
end
return false
end
--- Returns true if the unit is not within a @{Zone}.
-- @param #STATIC self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is not within the @{Core.Zone#ZONE_BASE}
function STATIC:IsNotInZone( Zone )
self:F2( { self.StaticName, Zone } )
if self:IsAlive() then
local IsInZone = not Zone:IsVec3InZone( self:GetVec3() )
self:T( { IsInZone } )
return IsInZone
else
return false
end
end

View File

@ -348,7 +348,7 @@ end
-- @return #string Player Name
-- @return #nil The DCS Unit is not existing or alive.
function UNIT:GetPlayerName()
self:F2( self.UnitName )
self:F( self.UnitName )
local DCSUnit = self:GetDCSObject() -- DCS#Unit
@ -831,37 +831,6 @@ end
-- Is functions
--- Returns true if the unit is within a @{Zone}.
-- @param #UNIT self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is within the @{Core.Zone#ZONE_BASE}
function UNIT:IsInZone( Zone )
self:F2( { self.UnitName, Zone } )
if self:IsAlive() then
local IsInZone = Zone:IsVec3InZone( self:GetVec3() )
return IsInZone
end
return false
end
--- Returns true if the unit is not within a @{Zone}.
-- @param #UNIT self
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
-- @return #boolean Returns true if the unit is not within the @{Core.Zone#ZONE_BASE}
function UNIT:IsNotInZone( Zone )
self:F2( { self.UnitName, Zone } )
if self:IsAlive() then
local IsInZone = not Zone:IsVec3InZone( self:GetVec3() )
self:T( { IsInZone } )
return IsInZone
else
return false
end
end
--- Returns true if there is an **other** DCS Unit within a radius of the current 2D point of the DCS Unit.