mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Dealing with Group Client bug in 1.5.3
This commit is contained in:
@@ -20,51 +20,52 @@ DESTROYBASETASK = {
|
||||
-- @tparam ?number DestroyPercentage defines the %-tage that needs to be destroyed to achieve mission success. eg. If in the Group there are 10 units, then a value of 75 would require 8 units to be destroyed from the Group to complete the @{TASK}.
|
||||
-- @treturn DESTROYBASETASK
|
||||
function DESTROYBASETASK:New( DestroyGroupType, DestroyUnitType, DestroyGroupPrefixes, DestroyPercentage )
|
||||
trace.f(self.ClassName)
|
||||
|
||||
-- Inheritance
|
||||
local Child = BASE:Inherit( self, TASK:New() )
|
||||
local self = BASE:Inherit( self, TASK:New() )
|
||||
self:T()
|
||||
|
||||
Child.Name = 'Destroy'
|
||||
Child.Destroyed = 0
|
||||
Child.DestroyGroupPrefixes = DestroyGroupPrefixes
|
||||
Child.DestroyGroupType = DestroyGroupType
|
||||
Child.DestroyUnitType = DestroyUnitType
|
||||
Child.TaskBriefing = "Task: Destroy " .. DestroyGroupType .. "."
|
||||
Child.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEGROUPSDESTROYED:New(), STAGEDONE:New() }
|
||||
Child.SetStage( Child, 1 )
|
||||
self.Name = 'Destroy'
|
||||
self.Destroyed = 0
|
||||
self.DestroyGroupPrefixes = DestroyGroupPrefixes
|
||||
self.DestroyGroupType = DestroyGroupType
|
||||
self.DestroyUnitType = DestroyUnitType
|
||||
self.TaskBriefing = "Task: Destroy " .. DestroyGroupType .. "."
|
||||
self.Stages = { STAGEBRIEF:New(), STAGESTART:New(), STAGEGROUPSDESTROYED:New(), STAGEDONE:New() }
|
||||
self.SetStage( self, 1 )
|
||||
|
||||
--Child.AddEvent( Child, world.event.S_EVENT_DEAD, Child.EventDead )
|
||||
--self.AddEvent( self, world.event.S_EVENT_DEAD, self.EventDead )
|
||||
|
||||
--env.info( 'New Table Child = ' .. tostring(Child) )
|
||||
--env.info( 'New Table self = ' .. tostring(self) )
|
||||
--env.info( 'New Table self = ' .. tostring(self) )
|
||||
|
||||
return Child
|
||||
return self
|
||||
end
|
||||
|
||||
--- Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring.
|
||||
-- @param event Event structure of DCS world.
|
||||
function DESTROYBASETASK:EventDead( event )
|
||||
trace.f( self.ClassName, { 'EventDead', event } )
|
||||
self:T( { 'EventDead', event } )
|
||||
|
||||
if event.initiator then
|
||||
local DestroyGroup = Unit.getGroup( event.initiator )
|
||||
local DestroyGroupName = DestroyGroup:getName()
|
||||
local DestroyUnit = event.initiator
|
||||
local DestroyUnitName = DestroyUnit:getName()
|
||||
local DestroyGroup = Unit.getGroup( DestroyUnit )
|
||||
local DestroyGroupName = ""
|
||||
if DestroyGroup and DestroyGroup:isExist() then
|
||||
local DestroyGroupName = DestroyGroup:getName()
|
||||
end
|
||||
local UnitsDestroyed = 0
|
||||
trace.i( self.ClassName, DestroyGroupName )
|
||||
trace.i( self.ClassName, DestroyUnitName )
|
||||
self:T( DestroyGroupName )
|
||||
self:T( DestroyUnitName )
|
||||
for DestroyGroupPrefixID, DestroyGroupPrefix in pairs( self.DestroyGroupPrefixes ) do
|
||||
trace.i( self.ClassName, DestroyGroupPrefix )
|
||||
self:T( DestroyGroupPrefix )
|
||||
if string.find( DestroyGroupName, DestroyGroupPrefix, 1, true ) then
|
||||
trace.i( self.ClassName, BASE:Inherited(self).ClassName )
|
||||
self:T( BASE:Inherited(self).ClassName )
|
||||
UnitsDestroyed = self:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
trace.i( self.ClassName, UnitsDestroyed )
|
||||
self:T( UnitsDestroyed )
|
||||
end
|
||||
end
|
||||
|
||||
trace.i( self.ClassName, { UnitsDestroyed } )
|
||||
self:T( { UnitsDestroyed } )
|
||||
self:IncreaseGoalCount( UnitsDestroyed, self.GoalVerb )
|
||||
end
|
||||
end
|
||||
@@ -73,7 +74,7 @@ end
|
||||
-- @param DestroyGroup Group structure describing the group to be evaluated.
|
||||
-- @param DestroyUnit Unit structure describing the Unit to be evaluated.
|
||||
function DESTROYBASETASK:ReportGoalProgress( DestroyGroup, DestroyUnit )
|
||||
trace.f(self.ClassName)
|
||||
self:T()
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user