ZONE_CAPTURE_COALITON & RANGE

This commit is contained in:
Frank
2019-12-28 23:59:39 +01:00
parent 6dd73dba44
commit 8b506a2f20
5 changed files with 159 additions and 52 deletions

View File

@@ -17,6 +17,10 @@
do -- ZoneGoal
--- @type ZONE_GOAL_COALITION
-- @field #string ClassName Name of the Class.
-- @field #number Coalition The current coalition ID of the zone owner.
-- @field #table UnitCategories Table of unit categories that are able to capture and hold the zone. Default is only GROUND units.
-- @field #table ObjectCategories Table of object categories that are able to hold a zone. Default is UNITS and STATICS.
-- @extends Functional.ZoneGoal#ZONE_GOAL
@@ -37,9 +41,10 @@ do -- ZoneGoal
--
-- @field #ZONE_GOAL_COALITION
ZONE_GOAL_COALITION = {
ClassName = "ZONE_GOAL_COALITION",
Coalition = nil,
ClassName = "ZONE_GOAL_COALITION",
Coalition = nil,
UnitCategories = nil,
ObjectCategories = nil,
}
--- @field #table ZONE_GOAL_COALITION.States
@@ -48,27 +53,69 @@ do -- ZoneGoal
--- ZONE_GOAL_COALITION Constructor.
-- @param #ZONE_GOAL_COALITION self
-- @param Core.Zone#ZONE Zone A @{Zone} object with the goal to be achieved.
-- @param DCSCoalition.DCSCoalition#coalition Coalition The initial coalition owning the zone.
-- @param DCSCoalition.DCSCoalition#coalition Coalition The initial coalition owning the zone. Default coalition.side.NEUTRAL.
-- @param #table UnitCategories Table of unit categories. See [DCS Class Unit](https://wiki.hoggitworld.com/view/DCS_Class_Unit). Default {Unit.Category.GROUND_UNIT}.
-- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:New( Zone, Coalition )
function ZONE_GOAL_COALITION:New( Zone, Coalition, UnitCategories )
if not Zone then
BASE:E("ERROR: No Zone specified in ZONE_GOAL_COALITON!")
return nil
end
-- Inherit ZONE_GOAL.
local self = BASE:Inherit( self, ZONE_GOAL:New( Zone ) ) -- #ZONE_GOAL_COALITION
self:F( { Zone = Zone, Coalition = Coalition } )
self:SetCoalition( Coalition )
-- Set initial owner.
self:SetCoalition( Coalition or coalition.side.NEUTRAL)
-- Set default unit and object categories for the zone scan.
self:SetUnitCategories(UnitCategories)
self:SetObjectCategories()
return self
end
--- Set the owning coalition of the zone.
-- @param #ZONE_GOAL_COALITION self
-- @param DCSCoalition.DCSCoalition#coalition Coalition
-- @param DCSCoalition.DCSCoalition#coalition Coalition The coalition ID, e.g. *coalition.side.RED*.
-- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:SetCoalition( Coalition )
self.Coalition = Coalition
return self
end
--- Set the owning coalition of the zone.
-- @param #ZONE_GOAL_COALITION self
-- @param #table UnitCategories Table of unit categories. See [DCS Class Unit](https://wiki.hoggitworld.com/view/DCS_Class_Unit). Default {Unit.Category.GROUND_UNIT}.
-- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:SetUnitCategories( UnitCategories )
if UnitCategories and type(UnitCategories)~="table" then
UnitCategories={UnitCategories}
end
self.UnitCategories=UnitCategories or {Unit.Category.GROUND_UNIT}
return self
end
--- Set the owning coalition of the zone.
-- @param #ZONE_GOAL_COALITION self
-- @param #table ObjectCategories Table of unit categories. See [DCS Class Object](https://wiki.hoggitworld.com/view/DCS_Class_Object). Default {Object.Category.UNIT, Object.Category.STATIC}, i.e. all UNITS and STATICS.
-- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:SetObjectCategories( ObjectCategories )
if ObjectCategories and type(ObjectCategories)~="table" then
ObjectCategories={ObjectCategories}
end
self.ObjectCategories=ObjectCategories or {Object.Category.UNIT, Object.Category.STATIC}
return self
end
--- Get the owning coalition of the zone.
-- @param #ZONE_GOAL_COALITION self
@@ -95,20 +142,25 @@ do -- ZoneGoal
return "Neutral"
end
return ""
return "Unknown"
end
--- Check status Coalition ownership.
-- @param #ZONE_GOAL_COALITION self
-- @return #ZONE_GOAL_COALITION
function ZONE_GOAL_COALITION:StatusZone()
local State = self:GetState()
self:F( { State = self:GetState() } )
env.info("scanning")
self:Scan( { Object.Category.UNIT, Object.Category.STATIC } )
-- Debug text.
local text=string.format("Zone state=%s, Owner=%s, Scanning...", State, self:GetCoalitionName())
env.info(text)
self:Scan( self.ObjectCategories, self.UnitCategories )
return self
end
end