From 985282ba555a24d53f4d4f0992c29daf715f9dd6 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Wed, 20 Mar 2019 18:03:24 +0100 Subject: [PATCH 01/10] Debug --- Moose Development/Moose/Wrapper/Group.lua | 3 +++ Moose Development/Moose/Wrapper/Unit.lua | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index a790deddd..afe7667f2 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2107,8 +2107,11 @@ do -- Players local PlayerNames = {} + self:F({Group = self:GetName()}) + local Units = self:GetUnits() for UnitID, UnitData in pairs( Units ) do + self:F({UnitData:GetName()}) local Unit = UnitData -- Wrapper.Unit#UNIT local PlayerName = Unit:GetPlayerName() if PlayerName and PlayerName ~= "" then diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 91d157515..51b5f2ecb 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -324,13 +324,16 @@ 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 if DCSUnit then + self:F({self:GetName()}) + local PlayerName = DCSUnit:getPlayerName() + self:F({PlayerName = PlayerName}) -- TODO Workaround DCS-BUG-3 - https://github.com/FlightControl-Master/MOOSE/issues/696 -- if PlayerName == nil or PlayerName == "" then -- local PlayerCategory = DCSUnit:getDesc().category From 964a6d07088b3000da95239b0df5d3643a29c8c6 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Wed, 20 Mar 2019 18:15:37 +0100 Subject: [PATCH 02/10] Debug --- Moose Development/Moose/Tasking/Task.lua | 2 +- Moose Development/Moose/Wrapper/Group.lua | 3 --- Moose Development/Moose/Wrapper/Unit.lua | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index a99012590..797de7d61 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -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 diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index afe7667f2..a790deddd 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2107,11 +2107,8 @@ do -- Players local PlayerNames = {} - self:F({Group = self:GetName()}) - local Units = self:GetUnits() for UnitID, UnitData in pairs( Units ) do - self:F({UnitData:GetName()}) local Unit = UnitData -- Wrapper.Unit#UNIT local PlayerName = Unit:GetPlayerName() if PlayerName and PlayerName ~= "" then diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 51b5f2ecb..363e42e08 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -330,10 +330,7 @@ function UNIT:GetPlayerName() if DCSUnit then - self:F({self:GetName()}) - local PlayerName = DCSUnit:getPlayerName() - self:F({PlayerName = PlayerName}) -- TODO Workaround DCS-BUG-3 - https://github.com/FlightControl-Master/MOOSE/issues/696 -- if PlayerName == nil or PlayerName == "" then -- local PlayerCategory = DCSUnit:getDesc().category From d9fb9c49282a9754e3edffe4dd26c55a2871322c Mon Sep 17 00:00:00 2001 From: FlightControl Date: Wed, 20 Mar 2019 18:36:55 +0100 Subject: [PATCH 03/10] Report Mission fix --- Moose Development/Moose/Tasking/CommandCenter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 5c98fc1e0..ef35a5a24 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -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 From e996a30333eb392d2f2c364bda27c733f84c9166 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 05:21:16 +0100 Subject: [PATCH 04/10] Updates --- .../Moose/Wrapper/Positionable.lua | 30 +++++++++++++++++ Moose Development/Moose/Wrapper/Static.lua | 32 ------------------- Moose Development/Moose/Wrapper/Unit.lua | 31 ------------------ 3 files changed, 30 insertions(+), 63 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 09d17a92c..400c2d3be 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -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 \ No newline at end of file diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index fb3d73296..68c224922 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -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 diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 363e42e08..9dc6d4d6c 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -807,37 +807,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. From ca65154ecddd6dc8e3d61435b37c9886e4ec6d3b Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 05:49:48 +0100 Subject: [PATCH 05/10] Fixes --- Moose Development/Moose/Core/Zone.lua | 5 ++++- .../Moose/Tasking/Task_Capture_Zone.lua | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 8c6d420e6..7e137253d 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -710,7 +710,10 @@ 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 + SetUnit:AddUnit( UNIT:FindByName( UnitObject:getName() ) ) + end end end diff --git a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua index dae324456..71b96a8d7 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua @@ -211,7 +211,7 @@ do -- TASK_CAPTURE_ZONE "Capture Zone " .. self.TaskZoneName ) - self:UpdateTaskInfo() + self:UpdateTaskInfo( true ) return self end @@ -219,18 +219,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 From e8b74f0fc7a56f4cffca9a217433090f3db0e7b7 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 06:03:13 +0100 Subject: [PATCH 06/10] handling static in scan --- Moose Development/Moose/Core/Zone.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 7e137253d..871404e96 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -712,7 +712,15 @@ function ZONE_RADIUS:GetScannedSetUnit() for ObjectID, UnitObject in pairs( self.ScanData.Units ) do local UnitObject = UnitObject -- DCS#Unit if UnitObject:isExist() then - SetUnit:AddUnit( UNIT:FindByName( UnitObject:getName() ) ) + 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 From 565a3062cb8cebd8799830a53062654e62cc80bf Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 06:11:59 +0100 Subject: [PATCH 07/10] Fixing goal state machine rule --- Moose Development/Moose/Tasking/Task.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 797de7d61..6a26a3d6f 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -432,7 +432,7 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType, TaskBriefing ) self:AddTransition( "Assigned", "Fail", "Failed" ) self:AddTransition( { "Planned", "Assigned" }, "Abort", "Aborted" ) self:AddTransition( "Assigned", "Cancel", "Cancelled" ) - self:AddTransition( "Assigned", "Goal", "*" ) + self:AddTransition( "*", "Goal", "*" ) self.Fsm = {} From 310ba9bb8a51853ef149013d4082775965ef3bb9 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 06:18:48 +0100 Subject: [PATCH 08/10] Reverse --- Moose Development/Moose/Tasking/Task.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 6a26a3d6f..797de7d61 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -432,7 +432,7 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType, TaskBriefing ) self:AddTransition( "Assigned", "Fail", "Failed" ) self:AddTransition( { "Planned", "Assigned" }, "Abort", "Aborted" ) self:AddTransition( "Assigned", "Cancel", "Cancelled" ) - self:AddTransition( "*", "Goal", "*" ) + self:AddTransition( "Assigned", "Goal", "*" ) self.Fsm = {} From b1e99dc31782ae9b054defbe7fefe46b2844b2f2 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 06:31:13 +0100 Subject: [PATCH 09/10] Goal --- Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua | 2 +- Moose Development/Moose/Tasking/Task_Capture_Zone.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua index 3fc4a86c8..74dff588e 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua @@ -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 diff --git a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua index 71b96a8d7..10645599a 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua @@ -212,6 +212,8 @@ do -- TASK_CAPTURE_ZONE ) self:UpdateTaskInfo( true ) + + self:SetGoalTotal( 1 ) return self end @@ -261,6 +263,7 @@ do -- TASK_CAPTURE_ZONE Scoring:_AddMissionGoalScore( self.Mission, PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", PlayerContribution * 200 / TotalContributions ) end end + self:AddProgress( PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", timer.getTime() , 1 ) end end From 9856a8625dfa5ff60719a8af691a1b7a8cbdca47 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 21 Mar 2019 06:57:04 +0100 Subject: [PATCH 10/10] Goal --- Moose Development/Moose/Core/Goal.lua | 1 + .../Moose/Tasking/CommandCenter.lua | 16 ++++++++++------ .../Moose/Tasking/Task_Capture_Zone.lua | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Goal.lua b/Moose Development/Moose/Core/Goal.lua index 4165e7f3f..ac1f616b9 100644 --- a/Moose Development/Moose/Core/Goal.lua +++ b/Moose Development/Moose/Core/Goal.lua @@ -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 diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index ef35a5a24..dcef1bb72 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -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 diff --git a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua index 10645599a..e39e8b2c9 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua @@ -253,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 } ) @@ -263,7 +262,7 @@ do -- TASK_CAPTURE_ZONE Scoring:_AddMissionGoalScore( self.Mission, PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", PlayerContribution * 200 / TotalContributions ) end end - self:AddProgress( PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", timer.getTime() , 1 ) + self:Success() end end