mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPSGROUP
- Cargo bay of element remains after respawn - Added some docs for CHIEF
This commit is contained in:
parent
0f4d466953
commit
de5d9195f3
@ -2,7 +2,13 @@
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Stuff
|
||||
-- * Automatic target engagement based on detection network
|
||||
-- * Define multiple border, conflict and attack zones
|
||||
-- * Define strategic "capture" zones
|
||||
-- * Set stragegy of chief from passive to agressive
|
||||
-- * Manual target engagement via AUFTRAG and TARGET classes
|
||||
-- * Add AIRWINGS, BRIGADES and FLEETS as resources
|
||||
-- * Seamless air-to-air, air-to-ground, ground-to-ground dispatching
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -28,7 +34,7 @@
|
||||
-- @field Ops.Commander#COMMANDER commander Commander of assigned legions.
|
||||
-- @extends Ops.Intelligence#INTEL
|
||||
|
||||
--- Be surprised!
|
||||
--- *In preparing for battle I have always found that plans are useless, but planning is indispensable* -- Dwight D Eisenhower
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -36,6 +42,87 @@
|
||||
--
|
||||
-- The Chief of staff gathers INTEL and assigns missions (AUFTRAG) the airforce, army and/or navy.
|
||||
--
|
||||
-- # Territory
|
||||
--
|
||||
-- The chief class allows you to define boarder zones, conflict zones and attack zones.
|
||||
--
|
||||
-- ## Border Zones
|
||||
--
|
||||
-- Border zones define your own territory.
|
||||
-- They can be set via the @{#CHIEF.SetBorderZones}() function as a set or added zone by zone via the @{#CHIEF.AddBorderZone}() function.
|
||||
--
|
||||
-- ## Conflict Zones
|
||||
--
|
||||
-- Conflict zones define areas, which usually are under dispute of different coalitions.
|
||||
-- They can be set via the @{#CHIEF.SetConflictZones}() function as a set or added zone by zone via the @{#CHIEF.AddConflictZone}() function.
|
||||
--
|
||||
-- ## Attack Zones
|
||||
--
|
||||
-- Attack zones are zones that usually lie within the enemy territory. They are only enganged with an agressive strategy.
|
||||
-- They can be set via the @{#CHIEF.SetAttackZones}() function as a set or added zone by zone via the @{#CHIEF.AddAttackZone}() function.
|
||||
--
|
||||
-- # Defense Condition
|
||||
--
|
||||
-- The defence condition (DEFCON) depends on enemy activity detected in the different zone types and is set automatically.
|
||||
--
|
||||
-- * `CHIEF.Defcon.GREEN`: No enemy activities detected.
|
||||
-- * `CHIEF.Defcon.YELLOW`: Enemy activity detected in conflict zones.
|
||||
-- * `CHIEF.Defcon.RED`: Enemy activity detected in border zones.
|
||||
--
|
||||
-- The current DEFCON can be retrieved with the @(#CHIEF.GetDefcon)() function.
|
||||
--
|
||||
-- When the DEFCON changed, an FSM event @{#CHIEF.DefconChange} is triggered. Mission designers can hook into this event via the @{#CHIEF.OnAfterDefconChange}() function:
|
||||
--
|
||||
-- --- Function called when the DEFCON changes.
|
||||
-- function myChief:OnAfterDefconChange(From, Event, To, Defcon)
|
||||
-- local text=string.format("Changed DEFCON to %s", Defcon)
|
||||
-- MESSAGE:New(text, 120):ToAll()
|
||||
-- end
|
||||
--
|
||||
-- # Strategy
|
||||
--
|
||||
-- The strategy of the chief determines, in which areas targets are engaged automatically.
|
||||
--
|
||||
-- * `CHIEF.Strategy.PASSIVE`: Chief is completely passive. No targets at all are engaged automatically.
|
||||
-- * `CHIEF.Strategy.DEFENSIVE`: Chief acts defensively. Only targets in his own territory are engaged.
|
||||
-- * `CHIEF.Strategy.OFFENSIVE`: Chief behaves offensively. Targets in his own territory and in conflict zones are enganged.
|
||||
-- * `CHIEF.Strategy.AGGRESSIVE`: Chief is aggressive. Targets in his own territory, in conflict zones and in attack zones are enganged.
|
||||
-- * `CHIEF.Strategy.TOTALWAR`: Anything anywhere is enganged.
|
||||
--
|
||||
-- The strategy can be set by the @(#CHIEF.SetStrategy)() and retrieved with the @(#CHIEF.GetStrategy)() function.
|
||||
--
|
||||
-- When the strategy is changed, the FSM event @{#CHIEF.StrategyChange} is triggered and customized code can be added to the @{#CHIEF.OnAfterStrategyChange}() function:
|
||||
--
|
||||
-- --- Function called when the STRATEGY changes.
|
||||
-- function myChief:OnAfterStrategyChange(From, Event, To, Strategy)
|
||||
-- local text=string.format("Strategy changd to %s", Strategy)
|
||||
-- MESSAGE:New(text, 120):ToAll()
|
||||
-- end
|
||||
--
|
||||
-- # Strategic (Capture) Zones
|
||||
--
|
||||
-- Strategically important zones, which should be captured can be added via the @{#CHIEF.AddStrateticZone}() function.
|
||||
--
|
||||
-- If the zone is currently owned by another coalition and enemy ground troops are present in the zone, a CAS mission is lauchned.
|
||||
--
|
||||
-- Once the zone is cleaned of enemy forces, ground (infantry) troops are send there. These require a transportation via helicopters.
|
||||
-- So in order to deploy our own troops, infantry assets with `AUFTRAG.Type.ONGUARD` and helicopters with `AUFTRAG.Type.OPSTRANSPORT` need to be available.
|
||||
--
|
||||
-- Whenever a strategic zone is captured by us the FSM event @{#CHIEF.ZoneCaptured} is triggered and customized further actions can be executed
|
||||
-- with the @{#CHIEF.OnAfterZoneCaptured}() function.
|
||||
--
|
||||
-- Whenever a strategic zone is lost (captured by the enemy), the FSM event @{#CHIEF.ZoneLost} is triggered and customized further actions can be executed
|
||||
-- with the @{#CHIEF.OnAfterZoneLost}() function.
|
||||
--
|
||||
-- Further events are
|
||||
--
|
||||
-- * @{#CHIEF.ZoneEmpty}, once the zone is completely empty of ground troops. Code can be added to the @{#CHIEF.OnAfterZoneEmpty}() function.
|
||||
-- * @{#CHIEF.ZoneAttacked}, once the zone is under attack. Code can be added to the @{#CHIEF.OnAfterZoneAttacked}() function.
|
||||
--
|
||||
-- Note that the ownership of a zone is determined via zone scans, i.e. not via the detection network. In other words, there is an all knowing eye.
|
||||
-- Think of it as the local population providing the intel. It's not totally realistic but the best compromise within the limits of DCS.
|
||||
--
|
||||
--
|
||||
--
|
||||
-- @field #CHIEF
|
||||
CHIEF = {
|
||||
@ -377,13 +464,13 @@ function CHIEF:New(Coalition, AgentSet, Alias)
|
||||
--- Triggers the FSM event "ZoneAttacked".
|
||||
-- @function [parent=#CHIEF] ZoneAttacked
|
||||
-- @param #CHIEF self
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is beeing attacked.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is being attacked.
|
||||
|
||||
--- Triggers the FSM event "ZoneAttacked" after a delay.
|
||||
-- @function [parent=#CHIEF] __ZoneAttacked
|
||||
-- @param #CHIEF self
|
||||
-- @param #number delay Delay in seconds.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is beeing attacked.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is being attacked.
|
||||
|
||||
--- On after "ZoneAttacked" event.
|
||||
-- @function [parent=#CHIEF] OnAfterZoneAttacked
|
||||
@ -391,7 +478,7 @@ function CHIEF:New(Coalition, AgentSet, Alias)
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is beeing attacked.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone Zone that is being attacked.
|
||||
|
||||
return self
|
||||
end
|
||||
@ -1326,7 +1413,7 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone The zone that beeing attacked.
|
||||
-- @param Ops.OpsZone#OPSZONE OpsZone The zone that being attacked.
|
||||
function CHIEF:onafterZoneAttacked(From, Event, To, OpsZone)
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Zone %s attacked!", OpsZone:GetName()))
|
||||
@ -2006,8 +2093,16 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
|
||||
-- Target position.
|
||||
local TargetVec2=StratZone.opszone.zone:GetVec2()
|
||||
|
||||
-- Max range in meters.
|
||||
local RangeMax=nil
|
||||
|
||||
-- Set max range to 250 NM because we use helos as transport for the infantry.
|
||||
if MissionType==AUFTRAG.Type.PATROLZONE or MissionType==AUFTRAG.Type.ONGUARD then
|
||||
RangeMax=UTILS.NMToMeters(250)
|
||||
end
|
||||
|
||||
-- Recruite infantry assets.
|
||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2, nil, nil, nil, nil, Categories, Attributes)
|
||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2, nil, RangeMax, nil, nil, Categories, Attributes)
|
||||
|
||||
if recruited then
|
||||
|
||||
@ -2057,8 +2152,10 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
|
||||
-- TODO: Need a better way!
|
||||
StratZone.missionPatrol=mission
|
||||
|
||||
return true
|
||||
else
|
||||
LEGION.UnRecruitAssets(assets)
|
||||
return false
|
||||
end
|
||||
|
||||
elseif MissionType==AUFTRAG.Type.CAS then
|
||||
@ -2078,11 +2175,12 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
|
||||
-- TODO: Need a better way!
|
||||
StratZone.missionCAS=mission
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return nil
|
||||
return false
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Manages AIRWINGS, BRIGADEs and FLOTILLAs
|
||||
-- * Handles missions (AUFTRAG) and finds the best man for the job
|
||||
-- * Handles missions (AUFTRAG) and finds the best assets for the job
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -30,7 +30,7 @@
|
||||
-- @field Ops.Chief#CHIEF chief Chief of staff.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Be surprised!
|
||||
--- *He who has never leared to obey cannot be a good commander* -- Aristotle
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
@ -60,8 +60,6 @@
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- 
|
||||
--
|
||||
-- # The FLIGHTGROUP Concept
|
||||
--
|
||||
-- # Events
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
--- **Ops** - Legion Warehouse.
|
||||
--
|
||||
-- Parent class of Airwings and Brigades.
|
||||
-- Parent class of Airwings, Brigades and Fleets.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -21,16 +21,18 @@
|
||||
-- @field Ops.Chief#CHIEF chief Chief of this legion.
|
||||
-- @extends Functional.Warehouse#WAREHOUSE
|
||||
|
||||
--- Be surprised!
|
||||
--- *Per aspera ad astra*
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # The LEGION Concept
|
||||
--
|
||||
-- The LEGION class contains all functions that are common for the AIRWING, BRIGADE and XXX classes, which inherit the LEGION class.
|
||||
-- The LEGION class contains all functions that are common for the AIRWING, BRIGADE and FLEET classes, which inherit the LEGION class.
|
||||
--
|
||||
-- An LEGION consists of multiple COHORTs. These cohorts "live" in a WAREHOUSE, i.e. a physical structure that can be destroyed or captured.
|
||||
--
|
||||
-- ** The LEGION class is not meant to be used directly. Use AIRWING, BRIGADE or FLEET instead! **
|
||||
--
|
||||
-- @field #LEGION
|
||||
LEGION = {
|
||||
ClassName = "LEGION",
|
||||
|
||||
@ -6731,7 +6731,7 @@ function OPSGROUP:GetWeightCargo(UnitName, IncludeReserved)
|
||||
|
||||
if (UnitName==nil or UnitName==element.name) and element.status~=OPSGROUP.ElementStatus.DEAD then
|
||||
|
||||
weight=weight+element.weightCargo
|
||||
weight=weight+element.weightCargo or 0
|
||||
|
||||
end
|
||||
|
||||
@ -10871,12 +10871,6 @@ function OPSGROUP:_AddElementByName(unitname)
|
||||
|
||||
-- Weight and cargo.
|
||||
element.weightEmpty=element.descriptors.massEmpty or 666
|
||||
element.weightCargo=0
|
||||
element.weight=element.weightEmpty+element.weightCargo
|
||||
|
||||
-- Looks like only aircraft have a massMax value in the descriptors.
|
||||
element.weightMaxTotal=element.descriptors.massMax or element.weightEmpty+8*95 --If max mass is not given, we assume 8 soldiers.
|
||||
|
||||
|
||||
if self.isArmygroup then
|
||||
|
||||
@ -10886,6 +10880,11 @@ function OPSGROUP:_AddElementByName(unitname)
|
||||
|
||||
element.weightMaxTotal=element.weightEmpty+10*1000
|
||||
|
||||
else
|
||||
|
||||
-- Looks like only aircraft have a massMax value in the descriptors.
|
||||
element.weightMaxTotal=element.descriptors.massMax or element.weightEmpty+8*95 --If max mass is not given, we assume 8 soldiers.
|
||||
|
||||
end
|
||||
|
||||
-- Max cargo weight:
|
||||
@ -10893,7 +10892,14 @@ function OPSGROUP:_AddElementByName(unitname)
|
||||
element.weightMaxCargo=unit.__.CargoBayWeightLimit
|
||||
|
||||
-- Cargo bay (empty).
|
||||
if element.cargoBay then
|
||||
-- After a respawn, the cargo bay might not be empty!
|
||||
element.weightCargo=self:GetWeightCargo(element.name, false)
|
||||
else
|
||||
element.cargoBay={}
|
||||
element.weightCargo=0
|
||||
end
|
||||
element.weight=element.weightEmpty+element.weightCargo
|
||||
|
||||
-- FLIGHTGROUP specific.
|
||||
if self.isFlightgroup then
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
-- @field #boolean isDestroyed If true, target objects were destroyed.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- **It is far more important to be able to hit the target than it is to haggle over who makes a weapon or who pulls a trigger** -- Dwight D. Eisenhower
|
||||
--- **It is far more important to be able to hit the target than it is to haggle over who makes a weapon or who pulls a trigger** -- Dwight D Eisenhower
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user