mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
parent
454c0e5543
commit
feef4c148e
@ -285,26 +285,5 @@ do -- ACT_ACCOUNT_DEADS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #ACT_ACCOUNT_DEADS self
|
|
||||||
-- @param Event#EVENTDATA EventData
|
|
||||||
function ACT_ACCOUNT_DEADS:onfuncEventDead( EventData )
|
|
||||||
self:T( { "EventDead", EventData } )
|
|
||||||
|
|
||||||
if EventData.IniDCSUnit then
|
|
||||||
self:Event( EventData )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- DCS Events
|
|
||||||
|
|
||||||
--- @param #ACT_ACCOUNT_DEADS self
|
|
||||||
-- @param Event#EVENTDATA EventData
|
|
||||||
function ACT_ACCOUNT_DEADS:onfuncEventCrash( EventData )
|
|
||||||
self:T( { "EventDead", EventData } )
|
|
||||||
|
|
||||||
if EventData.IniDCSUnit then
|
|
||||||
self:Event( EventData )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end -- ACT_ACCOUNT DEADS
|
end -- ACT_ACCOUNT DEADS
|
||||||
|
|||||||
@ -45,8 +45,11 @@ do -- Goal
|
|||||||
ClassName = "GOAL",
|
ClassName = "GOAL",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @field #table GOAL.States
|
--- @field #table GOAL.Players
|
||||||
GOAL.States = {}
|
GOAL.Players = {}
|
||||||
|
|
||||||
|
--- @field #number GOAL.TotalContributions
|
||||||
|
GOAL.TotalContributions = 0
|
||||||
|
|
||||||
--- GOAL Constructor.
|
--- GOAL Constructor.
|
||||||
-- @param #GOAL self
|
-- @param #GOAL self
|
||||||
@ -56,51 +59,6 @@ do -- Goal
|
|||||||
local self = BASE:Inherit( self, FSM:New() ) -- #GOAL
|
local self = BASE:Inherit( self, FSM:New() ) -- #GOAL
|
||||||
self:F( {} )
|
self:F( {} )
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
|
|
||||||
--- On State for GOAL
|
|
||||||
-- @field GOAL.On
|
|
||||||
|
|
||||||
--- On State Handler OnLeave for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnLeaveOn
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- On State Handler OnEnter for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnEnterOn
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
|
|
||||||
--- Off State for GOAL
|
|
||||||
-- @field GOAL.Off
|
|
||||||
|
|
||||||
--- Off State Handler OnLeave for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnLeaveOff
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Off State Handler OnEnter for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnEnterOff
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Achieved State for GOAL
|
--- Achieved State for GOAL
|
||||||
-- @field GOAL.Achieved
|
-- @field GOAL.Achieved
|
||||||
|
|
||||||
@ -120,86 +78,7 @@ do -- Goal
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
|
||||||
|
|
||||||
self:SetStartState( "Idle" )
|
self:SetStartState( "Pending" )
|
||||||
self:AddTransition( "Idle", "Start", "On" )
|
|
||||||
|
|
||||||
--- Start Handler OnBefore for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnBeforeStart
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Start Handler OnAfter for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnAfterStart
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
--- Start Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] Start
|
|
||||||
-- @param #GOAL self
|
|
||||||
|
|
||||||
--- Start Asynchronous Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] __Start
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #number Delay
|
|
||||||
|
|
||||||
self:AddTransition( "On", "Stop", "Idle" )
|
|
||||||
|
|
||||||
--- Stop Handler OnBefore for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnBeforeStop
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Stop Handler OnAfter for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnAfterStop
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
--- Stop Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] Stop
|
|
||||||
-- @param #GOAL self
|
|
||||||
|
|
||||||
--- Stop Asynchronous Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] __Stop
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #number Delay
|
|
||||||
|
|
||||||
|
|
||||||
self:AddTransition( "On", "IsAchieved", "On" )
|
|
||||||
|
|
||||||
--- IsAchieved Handler OnBefore for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnBeforeIsAchieved
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- IsAchieved Handler OnAfter for GOAL
|
|
||||||
-- @function [parent=#GOAL] OnAfterIsAchieved
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
--- IsAchieved Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] IsAchieved
|
|
||||||
-- @param #GOAL self
|
|
||||||
|
|
||||||
--- IsAchieved Asynchronous Trigger for GOAL
|
|
||||||
-- @function [parent=#GOAL] __IsAchieved
|
|
||||||
-- @param #GOAL self
|
|
||||||
-- @param #number Delay
|
|
||||||
|
|
||||||
self:AddTransition( "*", "Achieved", "Achieved" )
|
self:AddTransition( "*", "Achieved", "Achieved" )
|
||||||
|
|
||||||
--- Achieved Handler OnBefore for GOAL
|
--- Achieved Handler OnBefore for GOAL
|
||||||
@ -226,9 +105,6 @@ do -- Goal
|
|||||||
-- @param #GOAL self
|
-- @param #GOAL self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
|
||||||
|
|
||||||
self.AchievedScheduler = nil
|
|
||||||
|
|
||||||
self:SetEventPriority( 5 )
|
self:SetEventPriority( 5 )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -236,30 +112,38 @@ do -- Goal
|
|||||||
|
|
||||||
|
|
||||||
--- @param #GOAL self
|
--- @param #GOAL self
|
||||||
-- @param From
|
-- @param #string PlayerName
|
||||||
-- @param Event
|
function GOAL:AddPlayerContribution( PlayerName )
|
||||||
-- @param To
|
self.Players[PlayerName] = self.Players[PlayerName] or 0
|
||||||
function GOAL:onafterOn( From, Event, To )
|
self.Players[PlayerName] = self.Players[PlayerName] + 1
|
||||||
if not self.AchievedScheduler then
|
self.TotalContributions = self.TotalContributions + 1
|
||||||
self.AchievedScheduler = self:ScheduleRepeat( 15, 15, 0, nil, self.CheckAchieved, self )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #GOAL self
|
--- @param #GOAL self
|
||||||
-- @param From
|
-- @param #number Player contribution.
|
||||||
-- @param Event
|
function GOAL:GetPlayerContribution( PlayerName )
|
||||||
-- @param To
|
return self.Players[PlayerName] or 0
|
||||||
function GOAL:onafterOff( From, Event, To )
|
|
||||||
self:ScheduleStop( self.CheckAchieved )
|
|
||||||
self.ArchievedScheduler = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @param #GOAL self
|
--- @param #GOAL self
|
||||||
-- @param From
|
function GOAL:GetPlayerContributions()
|
||||||
-- @param Event
|
return self.Players or {}
|
||||||
-- @param To
|
end
|
||||||
function GOAL:CheckAchieved( From, Event, To )
|
|
||||||
self:IsAchieved()
|
|
||||||
|
--- @param #GOAL self
|
||||||
|
function GOAL:GetTotalContributions()
|
||||||
|
return self.TotalContributions or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- @param #GOAL self
|
||||||
|
-- @return #boolean true if the goal is Achieved
|
||||||
|
function GOAL:IsAchieved()
|
||||||
|
return self:Is( "Achieved" )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -43,9 +43,6 @@ do -- Zone
|
|||||||
ClassName = "ZONE_GOAL",
|
ClassName = "ZONE_GOAL",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @field #table ZONE_GOAL.States
|
|
||||||
ZONE_GOAL.States = {}
|
|
||||||
|
|
||||||
--- ZONE_GOAL Constructor.
|
--- ZONE_GOAL Constructor.
|
||||||
-- @param #ZONE_GOAL self
|
-- @param #ZONE_GOAL self
|
||||||
-- @param Core.Zone#ZONE_BASE Zone A @{Zone} object with the goal to be achieved.
|
-- @param Core.Zone#ZONE_BASE Zone A @{Zone} object with the goal to be achieved.
|
||||||
@ -58,101 +55,20 @@ do -- Zone
|
|||||||
self.Zone = Zone -- Core.Zone#ZONE_BASE
|
self.Zone = Zone -- Core.Zone#ZONE_BASE
|
||||||
self.Goal = GOAL:New()
|
self.Goal = GOAL:New()
|
||||||
|
|
||||||
do
|
|
||||||
|
|
||||||
--- Guarded State Handler OnLeave for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnLeaveGuarded
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Guarded State Handler OnEnter for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnEnterGuarded
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
do
|
|
||||||
|
|
||||||
--- Empty State Handler OnLeave for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnLeaveEmpty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Empty State Handler OnEnter for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnEnterEmpty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
self:AddTransition( "*", "Guard", "Guarded" )
|
|
||||||
|
|
||||||
--- Guard Handler OnBefore for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnBeforeGuard
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Guard Handler OnAfter for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnAfterGuard
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
--- Guard Trigger for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] Guard
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
|
|
||||||
--- Guard Asynchronous Trigger for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] __Guard
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #number Delay
|
|
||||||
|
|
||||||
self:AddTransition( "*", "Empty", "Empty" )
|
|
||||||
|
|
||||||
--- Empty Handler OnBefore for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnBeforeEmpty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
-- @return #boolean
|
|
||||||
|
|
||||||
--- Empty Handler OnAfter for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] OnAfterEmpty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #string From
|
|
||||||
-- @param #string Event
|
|
||||||
-- @param #string To
|
|
||||||
|
|
||||||
--- Empty Trigger for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] Empty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
|
|
||||||
--- Empty Asynchronous Trigger for ZONE_GOAL
|
|
||||||
-- @function [parent=#ZONE_GOAL] __Empty
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
-- @param #number Delay
|
|
||||||
|
|
||||||
|
|
||||||
self.SmokeTime = nil
|
self.SmokeTime = nil
|
||||||
|
|
||||||
|
|
||||||
|
self:AddTransition( "*", "DestroyedUnit", "*" )
|
||||||
|
|
||||||
|
--- DestroyedUnit Handler OnAfter for ZONE_GOAL
|
||||||
|
-- @function [parent=#ZONE_GOAL] OnAfterDestroyedUnit
|
||||||
|
-- @param #ZONE_GOAL self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @param Wrapper.Unit#UNIT DestroyedUnit The destroyed unit.
|
||||||
|
-- @param #string PlayerName The name of the player.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -171,6 +87,7 @@ do -- Zone
|
|||||||
return self.Zone:GetName()
|
return self.Zone:GetName()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Smoke the center of theh zone.
|
--- Smoke the center of theh zone.
|
||||||
-- @param #ZONE_GOAL self
|
-- @param #ZONE_GOAL self
|
||||||
-- @param #SMOKECOLOR.Color SmokeColor
|
-- @param #SMOKECOLOR.Color SmokeColor
|
||||||
@ -204,40 +121,6 @@ do -- Zone
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ZONE_GOAL:IsGuarded()
|
|
||||||
|
|
||||||
local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )
|
|
||||||
self:E( { IsGuarded = IsGuarded } )
|
|
||||||
return IsGuarded
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function ZONE_GOAL:IsEmpty()
|
|
||||||
|
|
||||||
local IsEmpty = self.Zone:IsNoneInZone()
|
|
||||||
self:E( { IsEmpty = IsEmpty } )
|
|
||||||
return IsEmpty
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Check status Zone.
|
|
||||||
-- @param #ZONE_GOAL self
|
|
||||||
function ZONE_GOAL:StatusZone()
|
|
||||||
|
|
||||||
local State = self:GetState()
|
|
||||||
self:E( { State = self:GetState() } )
|
|
||||||
|
|
||||||
self.Zone:Scan()
|
|
||||||
|
|
||||||
if State ~= "Guarded" and self:IsGuarded() then
|
|
||||||
self:Guard()
|
|
||||||
end
|
|
||||||
|
|
||||||
if State ~= "Empty" and self:IsEmpty() then
|
|
||||||
self:Empty()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Check status Smoke.
|
--- Check status Smoke.
|
||||||
-- @param #ZONE_GOAL self
|
-- @param #ZONE_GOAL self
|
||||||
@ -256,4 +139,33 @@ do -- Zone
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- @param #ZONE_GOAL self
|
||||||
|
-- @param Event#EVENTDATA EventData
|
||||||
|
function ZONE_GOAL:__Destroyed( EventData )
|
||||||
|
self:T( { "EventDead", EventData } )
|
||||||
|
|
||||||
|
if EventData.IniDCSUnit then
|
||||||
|
if EventData.IniUnit:IsInZone( self:GetZone() ) then
|
||||||
|
local PlayerHits = _DATABASE.HITS[EventData.IniUnitName]
|
||||||
|
if PlayerHits then
|
||||||
|
for PlayerName, PlayerHit in pairs( PlayerHits ) do
|
||||||
|
self.Goal:AddPlayerContribution( PlayerName )
|
||||||
|
self:DestroyedUnit( EventData.IniUnitName, PlayerName )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Activate the event UnitDestroyed to be fired when a unit is destroyed in the zone.
|
||||||
|
-- @param #ZONE_GOAL self
|
||||||
|
function ZONE_GOAL:MonitorDestroyedUnits()
|
||||||
|
|
||||||
|
self:HandleEvent( EVENTS.Dead, self.__Destroyed )
|
||||||
|
self:HandleEvent( EVENTS.Crash, self.__Destroyed )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,10 +16,10 @@
|
|||||||
do -- ZoneGoal
|
do -- ZoneGoal
|
||||||
|
|
||||||
--- @type ZONE_GOAL_COALITION
|
--- @type ZONE_GOAL_COALITION
|
||||||
-- @extends Core.ZoneGoal#ZONE_GOAL
|
-- @extends Core.ZoneGoal#ZONE_GOAL_COALITION
|
||||||
|
|
||||||
|
|
||||||
--- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL}
|
--- # ZONE_GOAL_COALITION class, extends @{ZoneGoal#ZONE_GOAL_COALITION}
|
||||||
--
|
--
|
||||||
-- 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:New( Zone ) ) -- #ZONE_GOAL_COALITION
|
local self = BASE:Inherit( self, ZONE_GOAL_COALITION:New( Zone ) ) -- #ZONE_GOAL_COALITION
|
||||||
self:F( { Zone = Zone, Coalition = Coalition } )
|
self:F( { Zone = Zone, Coalition = Coalition } )
|
||||||
|
|
||||||
self:SetCoalition( Coalition )
|
self:SetCoalition( Coalition )
|
||||||
@ -111,8 +111,96 @@ do -- ZoneGoal
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E( { Guarded = "Guarded" } )
|
do
|
||||||
|
|
||||||
|
--- Guarded State Handler OnLeave for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveGuarded
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- Guarded State Handler OnEnter for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterGuarded
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
--- Empty State Handler OnLeave for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnLeaveEmpty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- Empty State Handler OnEnter for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnEnterEmpty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
self:AddTransition( "*", "Guard", "Guarded" )
|
||||||
|
|
||||||
|
--- Guard Handler OnBefore for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeGuard
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- Guard Handler OnAfter for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterGuard
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
--- Guard Trigger for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] Guard
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
|
||||||
|
--- Guard Asynchronous Trigger for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] __Guard
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #number Delay
|
||||||
|
|
||||||
|
self:AddTransition( "*", "Empty", "Empty" )
|
||||||
|
|
||||||
|
--- Empty Handler OnBefore for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnBeforeEmpty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- Empty Handler OnAfter for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] OnAfterEmpty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
--- Empty Trigger for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] Empty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
|
||||||
|
--- Empty Asynchronous Trigger for ZONE_GOAL_COALITION
|
||||||
|
-- @function [parent=#ZONE_GOAL_COALITION] __Empty
|
||||||
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
|
-- @param #number Delay
|
||||||
|
|
||||||
|
|
||||||
self:AddTransition( { "Guarded", "Empty" }, "Attack", "Attacked" )
|
self:AddTransition( { "Guarded", "Empty" }, "Attack", "Attacked" )
|
||||||
@ -215,6 +303,15 @@ do -- ZoneGoal
|
|||||||
return IsGuarded
|
return IsGuarded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function ZONE_GOAL_COALITION:IsEmpty()
|
||||||
|
|
||||||
|
local IsEmpty = self.Zone:IsNoneInZone()
|
||||||
|
self:E( { IsEmpty = IsEmpty } )
|
||||||
|
return IsEmpty
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function ZONE_GOAL_COALITION:IsCaptured()
|
function ZONE_GOAL_COALITION:IsCaptured()
|
||||||
|
|
||||||
local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )
|
local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )
|
||||||
@ -300,7 +397,7 @@ do -- ZoneGoal
|
|||||||
|
|
||||||
|
|
||||||
--- When started, check the Coalition status.
|
--- When started, check the Coalition status.
|
||||||
-- @param #ZONE_GOAL self
|
-- @param #ZONE_GOAL_COALITION self
|
||||||
function ZONE_GOAL_COALITION:onafterGuard()
|
function ZONE_GOAL_COALITION:onafterGuard()
|
||||||
|
|
||||||
--self:E({BASE:GetParent( self )})
|
--self:E({BASE:GetParent( self )})
|
||||||
@ -334,10 +431,20 @@ 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() } )
|
||||||
|
|
||||||
self:GetParent( self, ZONE_GOAL_COALITION ).StatusZone( self )
|
self.Zone:Scan()
|
||||||
|
|
||||||
|
if State ~= "Guarded" and self:IsGuarded() then
|
||||||
|
self:Guard()
|
||||||
|
end
|
||||||
|
|
||||||
|
if State ~= "Empty" and self:IsEmpty() then
|
||||||
|
self:Empty()
|
||||||
|
end
|
||||||
|
|
||||||
if State ~= "Attacked" and self:IsAttacked() then
|
if State ~= "Attacked" and self:IsAttacked() then
|
||||||
self:Attack()
|
self:Attack()
|
||||||
|
|||||||
@ -710,6 +710,39 @@ function SCORING:_AddMissionTaskScore( Mission, PlayerUnit, Text, Score )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Registers Scores the players completing a Mission Task.
|
||||||
|
-- @param #SCORING self
|
||||||
|
-- @param Tasking.Mission#MISSION Mission
|
||||||
|
-- @param #string PlayerName
|
||||||
|
-- @param #string Text
|
||||||
|
-- @param #number Score
|
||||||
|
function SCORING:_AddMissionGoalScore( Mission, PlayerName, Text, Score )
|
||||||
|
|
||||||
|
local MissionName = Mission:GetName()
|
||||||
|
|
||||||
|
self:E( { Mission:GetName(), PlayerName, Text, Score } )
|
||||||
|
|
||||||
|
-- PlayerName can be nil, if the Unit with the player crashed or due to another reason.
|
||||||
|
if PlayerName then
|
||||||
|
local PlayerData = self.Players[PlayerName]
|
||||||
|
|
||||||
|
if not PlayerData.Mission[MissionName] then
|
||||||
|
PlayerData.Mission[MissionName] = {}
|
||||||
|
PlayerData.Mission[MissionName].ScoreTask = 0
|
||||||
|
PlayerData.Mission[MissionName].ScoreMission = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
self:T( PlayerName )
|
||||||
|
self:T( PlayerData.Mission[MissionName] )
|
||||||
|
|
||||||
|
PlayerData.Score = self.Players[PlayerName].Score + Score
|
||||||
|
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
|
||||||
|
|
||||||
|
MESSAGE:NewType( self.DisplayMessagePrefix .. MissionName .. " : " .. Text .. " Score: " .. Score, MESSAGE.Type.Information ):ToAll()
|
||||||
|
|
||||||
|
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Registers Mission Scores for possible multiple players that contributed in the Mission.
|
--- Registers Mission Scores for possible multiple players that contributed in the Mission.
|
||||||
-- @param #SCORING self
|
-- @param #SCORING self
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
--
|
--
|
||||||
-- ====
|
-- ====
|
||||||
--
|
--
|
||||||
-- @module Task_Protect
|
-- @module TaskZoneCapture
|
||||||
|
|
||||||
do -- TASK_ZONE_GOAL
|
do -- TASK_ZONE_GOAL
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ do -- TASK_ZONE_GOAL
|
|||||||
-- @param Tasking.Task#TASK_ZONE_GOAL Task
|
-- @param Tasking.Task#TASK_ZONE_GOAL Task
|
||||||
function Fsm:onafterStartMonitoring( TaskUnit, Task )
|
function Fsm:onafterStartMonitoring( TaskUnit, Task )
|
||||||
self:E( { self } )
|
self:E( { self } )
|
||||||
self:__Protect( 0.1 )
|
self:__Monitor( 0.1 )
|
||||||
self:__RouteToTarget( 0.1 )
|
self:__RouteToTarget( 0.1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ do -- TASK_ZONE_GOAL
|
|||||||
-- @param Tasking.Task#TASK_ZONE_GOAL Task
|
-- @param Tasking.Task#TASK_ZONE_GOAL Task
|
||||||
function Fsm:onafterMonitor( TaskUnit, Task )
|
function Fsm:onafterMonitor( TaskUnit, Task )
|
||||||
self:E( { self } )
|
self:E( { self } )
|
||||||
self:__Protect( 15 )
|
self:__Monitor( 15 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Test
|
--- Test
|
||||||
@ -146,9 +146,9 @@ do -- TASK_ZONE_GOAL
|
|||||||
return ActRouteZone:GetZone()
|
return ActRouteZone:GetZone()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TASK_ZONE_GOAL:SetGoalTotal()
|
function TASK_ZONE_GOAL:SetGoalTotal( GoalTotal )
|
||||||
|
|
||||||
self.GoalTotal = 1
|
self.GoalTotal = GoalTotal
|
||||||
end
|
end
|
||||||
|
|
||||||
function TASK_ZONE_GOAL:GetGoalTotal()
|
function TASK_ZONE_GOAL:GetGoalTotal()
|
||||||
@ -164,7 +164,7 @@ do -- TASK_CAPTURE_ZONE
|
|||||||
--- The TASK_CAPTURE_ZONE class
|
--- The TASK_CAPTURE_ZONE class
|
||||||
-- @type TASK_CAPTURE_ZONE
|
-- @type TASK_CAPTURE_ZONE
|
||||||
-- @field Set#SET_UNIT TargetSetUnit
|
-- @field Set#SET_UNIT TargetSetUnit
|
||||||
-- @extends Tasking.TaskZoneGoal#TASK_ZONE_GOAL
|
-- @extends #TASK_ZONE_GOAL
|
||||||
|
|
||||||
--- # TASK_CAPTURE_ZONE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL}
|
--- # TASK_CAPTURE_ZONE class, extends @{TaskZoneGoal#TASK_ZONE_GOAL}
|
||||||
--
|
--
|
||||||
@ -184,18 +184,18 @@ do -- TASK_CAPTURE_ZONE
|
|||||||
-- @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.ZoneGoal#ZONE_GOAL ZoneGoal
|
-- @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_CAPTURE_ZONE self
|
||||||
function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, ZoneGoal, TaskBriefing)
|
function TASK_CAPTURE_ZONE:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, TaskBriefing)
|
||||||
local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoal, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE
|
local self = BASE:Inherit( self, TASK_ZONE_GOAL:New( Mission, SetGroup, TaskName, ZoneGoalCoalition, "CAPTURE", TaskBriefing ) ) -- #TASK_CAPTURE_ZONE
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
Mission:AddTask( self )
|
Mission:AddTask( self )
|
||||||
|
|
||||||
self.TaskCoalition = ZoneGoal:GetCoalition()
|
self.TaskCoalition = ZoneGoalCoalition:GetCoalition()
|
||||||
self.TaskCoalitionName = ZoneGoal:GetCoalitionName()
|
self.TaskCoalitionName = ZoneGoalCoalition:GetCoalitionName()
|
||||||
self.TaskZoneName = self.ZoneGoal:GetZoneName()
|
self.TaskZoneName = ZoneGoalCoalition:GetZoneName()
|
||||||
|
|
||||||
self:SetBriefing(
|
self:SetBriefing(
|
||||||
TaskBriefing or
|
TaskBriefing or
|
||||||
@ -234,66 +234,21 @@ do -- TASK_CAPTURE_ZONE
|
|||||||
self:E( { PlayerUnit = PlayerUnit } )
|
self:E( { PlayerUnit = PlayerUnit } )
|
||||||
|
|
||||||
if self.ZoneGoal then
|
if self.ZoneGoal then
|
||||||
local ProtectCoalition = self.ZoneGoal:GetCoalition()
|
if self.ZoneGoal.Goal:IsAchieved() then
|
||||||
local TaskCoalition = self.Coalition
|
|
||||||
|
|
||||||
self:E( { ProtectCoalition = ProtectCoalition, TaskCoalition = TaskCoalition } )
|
|
||||||
|
|
||||||
if ProtectCoalition ~= TaskCoalition then
|
|
||||||
self:Success()
|
self:Success()
|
||||||
|
local TotalContributions = self.ZoneGoal.Goal:GetTotalContributions()
|
||||||
|
for PlayerName, PlayerContribution in pairs( self.ZoneGoal.Goal:GetPlayerContributions() ) do
|
||||||
|
local Task = self.Task
|
||||||
|
local Scoring = Task:GetScoring()
|
||||||
|
if Scoring then
|
||||||
|
Scoring:_AddMissionGoalScore( Task.Mission, PlayerName, "Captured Zone", PlayerContribution * 200 / TotalContributions )
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:__Goal( -10, PlayerUnit, PlayerName )
|
self:__Goal( -10, PlayerUnit, PlayerName )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a score when a target in scope of the A2G attack, has been destroyed .
|
|
||||||
-- @param #TASK_CAPTURE_ZONE self
|
|
||||||
-- @param #string PlayerName The name of the player.
|
|
||||||
-- @param #number Score The score in points to be granted when task process has been achieved.
|
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
|
||||||
-- @return #TASK_CAPTURE_ZONE
|
|
||||||
function TASK_CAPTURE_ZONE:SetScoreOnProgress( PlayerName, Score, TaskUnit )
|
|
||||||
self:F( { PlayerName, Score, TaskUnit } )
|
|
||||||
|
|
||||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
|
||||||
|
|
||||||
--ProcessUnit:AddScoreProcess( "Protecting", "ZoneGoal", "Captured", "Player " .. PlayerName .. " has SEADed a target.", Score )
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set a score when all the targets in scope of the A2G attack, have been destroyed.
|
|
||||||
-- @param #TASK_CAPTURE_ZONE self
|
|
||||||
-- @param #string PlayerName The name of the player.
|
|
||||||
-- @param #number Score The score in points.
|
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
|
||||||
-- @return #TASK_CAPTURE_ZONE
|
|
||||||
function TASK_CAPTURE_ZONE:SetScoreOnSuccess( PlayerName, Score, TaskUnit )
|
|
||||||
self:F( { PlayerName, Score, TaskUnit } )
|
|
||||||
|
|
||||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
|
||||||
|
|
||||||
ProcessUnit:AddScore( "Success", "The zone has been captured!", Score )
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set a penalty when the A2G attack has failed.
|
|
||||||
-- @param #TASK_CAPTURE_ZONE self
|
|
||||||
-- @param #string PlayerName The name of the player.
|
|
||||||
-- @param #number Penalty The penalty in points, must be a negative value!
|
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
|
||||||
-- @return #TASK_CAPTURE_ZONE
|
|
||||||
function TASK_CAPTURE_ZONE:SetScoreOnFail( PlayerName, Penalty, TaskUnit )
|
|
||||||
self:F( { PlayerName, Penalty, TaskUnit } )
|
|
||||||
|
|
||||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
|
||||||
|
|
||||||
ProcessUnit:AddScore( "Failed", "The zone has been lost!", Penalty )
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,6 +72,6 @@ Tasking/Task_A2G.lua
|
|||||||
Tasking/Task_A2A_Dispatcher.lua
|
Tasking/Task_A2A_Dispatcher.lua
|
||||||
Tasking/Task_A2A.lua
|
Tasking/Task_A2A.lua
|
||||||
Tasking/Task_Cargo.lua
|
Tasking/Task_Cargo.lua
|
||||||
Tasking/Task_Protect.lua
|
Tasking/TaskZoneCapture.lua
|
||||||
|
|
||||||
Moose.lua
|
Moose.lua
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user