This commit is contained in:
FlightControl_Master 2017-10-05 11:09:10 +02:00
parent feef4c148e
commit fe47783bfa
7 changed files with 60 additions and 75 deletions

View File

@ -1132,44 +1132,23 @@ end
TargetCategory = Event.IniCategory TargetCategory = Event.IniCategory
TargetType = Event.IniTypeName TargetType = Event.IniTypeName
TargetUnitCoalition = _SCORINGCoalition[TargetCoalition]
TargetUnitCategory = _SCORINGCategory[TargetCategory]
TargetUnitType = TargetType TargetUnitType = TargetType
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } ) self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
end end
-- Player contains the score and reference data for the player. self:T( "Something got destroyed" )
for PlayerName, Player in pairs( self.Players ) do
if Player then -- This should normally not happen, but i'll test it anyway. local Destroyed = false
self:T( "Something got destroyed" )
-- What is the player destroying?
-- Some variables if self.HITS[Event.IniUnitName] then -- Was there a hit for this unit for this player before registered???
local InitUnitName = Player.UnitName
local InitUnitType = Player.UnitType
local InitCoalition = Player.UnitCoalition self.DESTROYS[Event.IniUnitName] = self.DESTROYS[Event.IniUnitName] or {}
local InitCategory = Player.UnitCategory
local InitUnitCoalition = _SCORINGCoalition[InitCoalition] self.DESTROYS[Event.IniUnitName] = true
local InitUnitCategory = _SCORINGCategory[InitCategory]
self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } )
local Destroyed = false
-- What is the player destroying?
if self.HITS[TargetUnitName] then -- Was there a hit for this unit for this player before registered???
self.DESTROYS[Event.TgtUnitName] = self.DESTROYS[Event.TgtUnitName] or {}
local PlayerDestroys = self.DESTROYS[Event.TgtUnitName]
if TargetCoalition then
PlayerDestroys = PlayerDestroys or {}
PlayerDestroys[PlayerName] = true
end
end
end
end end
end end

View File

@ -141,15 +141,22 @@ do -- Zone
--- @param #ZONE_GOAL self --- @param #ZONE_GOAL self
-- @param Event#EVENTDATA EventData -- @param Core.Event#EVENTDATA EventData
function ZONE_GOAL:__Destroyed( EventData ) function ZONE_GOAL:__Destroyed( EventData )
self:T( { "EventDead", EventData } ) self:E( { "EventDead", EventData } )
self:E( { EventData.IniUnit } )
local Vec3 = EventData.IniDCSUnit:getPosition().p
self:E( { Vec3 = Vec3 } )
local ZoneGoal = self:GetZone()
self:E({ZoneGoal})
if EventData.IniDCSUnit then if EventData.IniDCSUnit then
if EventData.IniUnit:IsInZone( self:GetZone() ) then if ZoneGoal:IsVec3InZone(Vec3) then
local PlayerHits = _DATABASE.HITS[EventData.IniUnitName] local PlayerHits = _DATABASE.HITS[EventData.IniUnitName]
if PlayerHits then if PlayerHits then
for PlayerName, PlayerHit in pairs( PlayerHits ) do for PlayerName, PlayerHit in pairs( PlayerHits.Players or {} ) do
self.Goal:AddPlayerContribution( PlayerName ) self.Goal:AddPlayerContribution( PlayerName )
self:DestroyedUnit( EventData.IniUnitName, PlayerName ) self:DestroyedUnit( EventData.IniUnitName, PlayerName )
end end

View File

@ -16,10 +16,10 @@
do -- ZoneGoal do -- ZoneGoal
--- @type ZONE_GOAL_COALITION --- @type ZONE_GOAL_COALITION
-- @extends Core.ZoneGoal#ZONE_GOAL_COALITION -- @extends Core.ZoneGoal#ZONE_GOAL
--- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL_COALITION} --- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL}
-- --
-- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. -- ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition.
-- Derived classes implement the ways how the achievements can be realized. -- Derived classes implement the ways how the achievements can be realized.
@ -67,7 +67,7 @@ do -- ZoneGoal
-- @return #ZONE_GOAL_COALITION -- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:New( Zone, Coalition ) function ZONE_GOAL_COALITION:New( Zone, Coalition )
local self = BASE:Inherit( self, ZONE_GOAL_COALITION:New( Zone ) ) -- #ZONE_GOAL_COALITION local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION
self:F( { Zone = Zone, Coalition = Coalition } ) self:F( { Zone = Zone, Coalition = Coalition } )
self:SetCoalition( Coalition ) self:SetCoalition( Coalition )
@ -431,8 +431,6 @@ do -- ZoneGoal
-- @param #ZONE_GOAL_COALITION self -- @param #ZONE_GOAL_COALITION self
function ZONE_GOAL_COALITION:StatusZone() function ZONE_GOAL_COALITION:StatusZone()
self:GetParent( self, ZONE_GOAL_COALITION ).StatusZone( self )
local State = self:GetState() local State = self:GetState()
self:E( { State = self:GetState() } ) self:E( { State = self:GetState() } )

View File

@ -738,8 +738,8 @@ function SCORING:_AddMissionGoalScore( Mission, PlayerName, Text, Score )
PlayerData.Score = self.Players[PlayerName].Score + Score PlayerData.Score = self.Players[PlayerName].Score + Score
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
MESSAGE:NewType( self.DisplayMessagePrefix .. MissionName .. " : " .. Text .. " Score: " .. Score, MESSAGE.Type.Information ):ToAll() MESSAGE:NewType( string.format( "%s%s: %s! Player %s receives %d score!", self.DisplayMessagePrefix, MissionName, Text, PlayerName, Score ), MESSAGE.Type.Information ):ToAll()
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score ) self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score )
end end
end end

View File

@ -62,7 +62,7 @@ do -- TASK_ZONE_GOAL
Fsm:AddTransition( "Assigned", "StartMonitoring", "Monitoring" ) Fsm:AddTransition( "Assigned", "StartMonitoring", "Monitoring" )
Fsm:AddTransition( "Monitoring", "Monitor", "Monitoring", {} ) Fsm:AddTransition( "Monitoring", "Monitor", "Monitoring", {} )
Fsm:AddTransition( "Monitoring", "RouteToTarget", "Monitoring" ) Fsm:AddTransition( "Monitoring", "RouteTo", "Monitoring" )
Fsm:AddProcess( "Monitoring", "RouteToZone", ACT_ROUTE_ZONE:New(), {} ) Fsm:AddProcess( "Monitoring", "RouteToZone", ACT_ROUTE_ZONE:New(), {} )
--Fsm:AddTransition( "Accounted", "DestroyedAll", "Accounted" ) --Fsm:AddTransition( "Accounted", "DestroyedAll", "Accounted" )
@ -79,7 +79,7 @@ do -- TASK_ZONE_GOAL
function Fsm:onafterStartMonitoring( TaskUnit, Task ) function Fsm:onafterStartMonitoring( TaskUnit, Task )
self:E( { self } ) self:E( { self } )
self:__Monitor( 0.1 ) self:__Monitor( 0.1 )
self:__RouteToTarget( 0.1 ) self:__RouteTo( 0.1 )
end end
--- Monitor Loop --- Monitor Loop
@ -95,12 +95,12 @@ do -- TASK_ZONE_GOAL
-- @param #FSM_PROCESS self -- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
-- @param Tasking.Task_A2G#TASK_ZONE_GOAL Task -- @param Tasking.Task_A2G#TASK_ZONE_GOAL Task
function Fsm:onafterRouteToTarget( TaskUnit, Task ) function Fsm:onafterRouteTo( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
-- Determine the first Unit from the self.TargetSetUnit -- Determine the first Unit from the self.TargetSetUnit
if Task:GetTargetZone( TaskUnit ) then if Task:GetTargetZone( TaskUnit ) then
self:__RouteToTargetZone( 0.1 ) self:__RouteTo( 0.1 )
end end
end end
@ -159,36 +159,36 @@ do -- TASK_ZONE_GOAL
end end
do -- TASK_CAPTURE_ZONE do -- TASK_ZONE_CAPTURE
--- The TASK_CAPTURE_ZONE class --- The TASK_ZONE_CAPTURE class
-- @type TASK_CAPTURE_ZONE -- @type TASK_ZONE_CAPTURE
-- @field Set#SET_UNIT TargetSetUnit -- @field Set#SET_UNIT TargetSetUnit
-- @extends #TASK_ZONE_GOAL -- @extends #TASK_ZONE_GOAL
--- # TASK_CAPTURE_ZONE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL} --- # TASK_ZONE_CAPTURE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL}
-- --
-- The TASK_CAPTURE_ZONE class defines an Suppression or Extermination of Air Defenses task for a human player to be executed. -- The TASK_ZONE_CAPTURE class defines an Suppression or Extermination of Air Defenses task for a human player to be executed.
-- These tasks are important to be executed as they will help to achieve air superiority at the vicinity. -- These tasks are important to be executed as they will help to achieve air superiority at the vicinity.
-- --
-- The TASK_CAPTURE_ZONE is used by the @{Task_A2G_Dispatcher#TASK_A2G_DISPATCHER} to automatically create SEAD tasks -- The TASK_ZONE_CAPTURE is used by the @{Task_A2G_Dispatcher#TASK_A2G_DISPATCHER} to automatically create SEAD tasks
-- based on detected enemy ground targets. -- based on detected enemy ground targets.
-- --
-- @field #TASK_CAPTURE_ZONE -- @field #TASK_ZONE_CAPTURE
TASK_CAPTURE_ZONE = { TASK_ZONE_CAPTURE = {
ClassName = "TASK_CAPTURE_ZONE", ClassName = "TASK_ZONE_CAPTURE",
} }
--- Instantiates a new TASK_CAPTURE_ZONE. --- Instantiates a new TASK_ZONE_CAPTURE.
-- @param #TASK_CAPTURE_ZONE self -- @param #TASK_ZONE_CAPTURE self
-- @param Tasking.Mission#MISSION Mission -- @param Tasking.Mission#MISSION Mission
-- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned. -- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned.
-- @param #string TaskName The name of the Task. -- @param #string TaskName The name of the Task.
-- @param Core.ZoneGoalCoalition#ZONE_GOAL_COALITION ZoneGoalCoalition -- @param Core.ZoneGoalCoalition#ZONE_GOAL_COALITION ZoneGoalCoalition
-- @param #string TaskBriefing The briefing of the task. -- @param #string TaskBriefing The briefing of the task.
-- @return #TASK_CAPTURE_ZONE self -- @return #TASK_ZONE_CAPTURE self
function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, TaskBriefing) function TASK_ZONE_CAPTURE:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, TaskBriefing)
local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, "CAPTURE", TaskBriefing ) ) -- #TASK_ZONE_CAPTURE
self:F() self:F()
Mission:AddTask( self ) Mission:AddTask( self )
@ -207,9 +207,9 @@ do -- TASK_CAPTURE_ZONE
return self return self
end end
--- Instantiates a new TASK_CAPTURE_ZONE. --- Instantiates a new TASK_ZONE_CAPTURE.
-- @param #TASK_CAPTURE_ZONE self -- @param #TASK_ZONE_CAPTURE self
function TASK_CAPTURE_ZONE:UpdateTaskInfo() function TASK_ZONE_CAPTURE:UpdateTaskInfo()
local ZoneCoordinate = self.ZoneGoal:GetZone():GetCoordinate() local ZoneCoordinate = self.ZoneGoal:GetZone():GetCoordinate()
@ -218,7 +218,7 @@ do -- TASK_CAPTURE_ZONE
self:SetInfo( "Zone Coalition", self.TaskCoalitionName, 11 ) self:SetInfo( "Zone Coalition", self.TaskCoalitionName, 11 )
end end
function TASK_CAPTURE_ZONE:ReportOrder( ReportGroup ) function TASK_ZONE_CAPTURE:ReportOrder( ReportGroup )
local Coordinate = self:GetInfo( "Coordinates" ) local Coordinate = self:GetInfo( "Coordinates" )
--local Coordinate = self.TaskInfo.Coordinates.TaskInfoText --local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate ) local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
@ -227,9 +227,9 @@ do -- TASK_CAPTURE_ZONE
end end
--- @param #TASK_CAPTURE_ZONE self --- @param #TASK_ZONE_CAPTURE self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
function TASK_CAPTURE_ZONE:OnAfterGoal( From, Event, To, PlayerUnit, PlayerName ) function TASK_ZONE_CAPTURE:OnAfterGoal( From, Event, To, PlayerUnit, PlayerName )
self:E( { PlayerUnit = PlayerUnit } ) self:E( { PlayerUnit = PlayerUnit } )
@ -237,11 +237,12 @@ do -- TASK_CAPTURE_ZONE
if self.ZoneGoal.Goal:IsAchieved() then if self.ZoneGoal.Goal:IsAchieved() then
self:Success() self:Success()
local TotalContributions = self.ZoneGoal.Goal:GetTotalContributions() local TotalContributions = self.ZoneGoal.Goal:GetTotalContributions()
for PlayerName, PlayerContribution in pairs( self.ZoneGoal.Goal:GetPlayerContributions() ) do local PlayerContributions = self.ZoneGoal.Goal:GetPlayerContributions()
local Task = self.Task self:E( { TotalContributions = TotalContributions, PlayerContributions = PlayerContributions } )
local Scoring = Task:GetScoring() for PlayerName, PlayerContribution in pairs( PlayerContributions ) do
local Scoring = self:GetScoring()
if Scoring then if Scoring then
Scoring:_AddMissionGoalScore( Task.Mission, PlayerName, "Captured Zone", PlayerContribution * 200 / TotalContributions ) Scoring:_AddMissionGoalScore( self.Mission, PlayerName, "Zone " .. self.ZoneGoal:GetZoneName() .." captured", PlayerContribution * 200 / TotalContributions )
end end
end end
end end

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20171003_1355' ) env.info( 'Moose Generation Timestamp: 20171005_0644' )
local base = _G local base = _G
@ -89,7 +89,7 @@ __Moose.Include( 'Tasking/Task_A2G.lua' )
__Moose.Include( 'Tasking/Task_A2A_Dispatcher.lua' ) __Moose.Include( 'Tasking/Task_A2A_Dispatcher.lua' )
__Moose.Include( 'Tasking/Task_A2A.lua' ) __Moose.Include( 'Tasking/Task_A2A.lua' )
__Moose.Include( 'Tasking/Task_Cargo.lua' ) __Moose.Include( 'Tasking/Task_Cargo.lua' )
__Moose.Include( 'Tasking/Task_Protect.lua' ) __Moose.Include( 'Tasking/TaskZoneCapture.lua' )
__Moose.Include( 'Moose.lua' ) __Moose.Include( 'Moose.lua' )
BASE:TraceOnOff( true ) BASE:TraceOnOff( true )
env.info( '*** MOOSE INCLUDE END *** ' ) env.info( '*** MOOSE INCLUDE END *** ' )

View File

@ -1,5 +1,5 @@
env.info('*** MOOSE DYNAMIC INCLUDE START *** ') env.info('*** MOOSE DYNAMIC INCLUDE START *** ')
env.info('Moose Generation Timestamp: 20171003_1355') env.info('Moose Generation Timestamp: 20171005_0644')
local base=_G local base=_G
__Moose={} __Moose={}
__Moose.Include=function(IncludeFile) __Moose.Include=function(IncludeFile)
@ -84,7 +84,7 @@ __Moose.Include('Tasking/Task_A2G.lua')
__Moose.Include('Tasking/Task_A2A_Dispatcher.lua') __Moose.Include('Tasking/Task_A2A_Dispatcher.lua')
__Moose.Include('Tasking/Task_A2A.lua') __Moose.Include('Tasking/Task_A2A.lua')
__Moose.Include('Tasking/Task_Cargo.lua') __Moose.Include('Tasking/Task_Cargo.lua')
__Moose.Include('Tasking/Task_Protect.lua') __Moose.Include('Tasking/TaskZoneCapture.lua')
__Moose.Include('Moose.lua') __Moose.Include('Moose.lua')
BASE:TraceOnOff(true) BASE:TraceOnOff(true)
env.info('*** MOOSE INCLUDE END *** ') env.info('*** MOOSE INCLUDE END *** ')