mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-12 04:31:09 +00:00
Ops
This commit is contained in:
@@ -202,6 +202,11 @@ function AIRWING:AddSquadron(Squadron)
|
||||
|
||||
-- Set airwing to squadron.
|
||||
Squadron:SetAirwing(self)
|
||||
|
||||
-- Start squadron.
|
||||
if Squadron:IsStopped() then
|
||||
Squadron:Start()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -267,6 +267,7 @@ AUFTRAG.version="0.0.9"
|
||||
-- DONE: NewAUTO() NewA2G NewA2A
|
||||
-- TODO: Transport mission.
|
||||
-- TODO: Recon mission.
|
||||
-- TODO: Set mission coalition, e.g. for F10 markers.
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
@@ -1874,15 +1875,22 @@ end
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:UpdateMarker()
|
||||
|
||||
-- Marker text.
|
||||
local text=string.format("%s %s", self.name, self.status)
|
||||
text=text..string.format("Targets=%d", self:CountMissionTargets())
|
||||
|
||||
|
||||
-- Remove old marker.
|
||||
if self.markerID then
|
||||
COORDINATE.RemoveMark(nil, self.markerID)
|
||||
end
|
||||
|
||||
self.markerID=self:GetTargetCoordinate():MarkToAll(text, true)
|
||||
-- Get target coordinates. Can be nil!
|
||||
local targetcoord=self:GetTargetCoordinate()
|
||||
|
||||
-- New marker!
|
||||
if targetcoord then
|
||||
self.markerID=targetcoord:MarkToAll(text, true)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1262,6 +1262,31 @@ function FLIGHTGROUP:GetFuelMin()
|
||||
return fuelmin*100
|
||||
end
|
||||
|
||||
--- Self destruction of group. An explosion is created at the position of each element.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #number Delay Delay in seconds. Default now.
|
||||
-- @param #number ExplosionPower (Optional) Explosion power in kg TNT. Default 500 kg.
|
||||
-- @return #number Relative fuel in percent.
|
||||
function FLIGHTGROUP:SelfDestruction(Delay, ExplosionPower)
|
||||
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, FLIGHTGROUP.SelfDestruction, self, 0, ExplosionPower)
|
||||
else
|
||||
|
||||
-- Loop over all elements.
|
||||
for i,_element in pairs(self.elements) do
|
||||
local element=_element --#FLIGHTGROUP.Element
|
||||
|
||||
local unit=element.unit
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
unit:Explode(ExplosionPower)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Start & Status
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Stuff
|
||||
-- * Set parameters like livery, skill valid for all squadron members.
|
||||
-- * Define modex and callsigns.
|
||||
-- * Define mission types, this squadron can perform (see Ops.Auftrag#AUFTRAG).
|
||||
-- * Pause/unpause squadron operations.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -67,11 +70,6 @@ SQUADRON = {
|
||||
refuelSystem = nil,
|
||||
}
|
||||
|
||||
--- Flight group element.
|
||||
-- @type SQUADRON.Flight
|
||||
-- @field Ops.FlightGroup#FLIGHTGROUP flightgroup The flight group object.
|
||||
-- @field #string mission Mission assigned to the flight.
|
||||
|
||||
--- SQUADRON class version.
|
||||
-- @field #string version
|
||||
SQUADRON.version="0.0.5"
|
||||
@@ -133,10 +131,10 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
||||
|
||||
-- Add FSM transitions.
|
||||
-- From State --> Event --> To State
|
||||
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
||||
self:AddTransition("Stopped", "Start", "OnDuty") -- Start FSM.
|
||||
self:AddTransition("*", "Status", "*") -- Status update.
|
||||
self:AddTransition("Running", "Pause", "Paused") -- Pause squadron.
|
||||
self:AddTransition("Paused", "Unpause", "Running") -- Unpause squadron.
|
||||
self:AddTransition("OnDuty", "Pause", "Paused") -- Pause squadron.
|
||||
self:AddTransition("Paused", "Unpause", "OnDuty") -- Unpause squadron.
|
||||
self:AddTransition("*", "Stop", "Stopped") -- Stop squadron.
|
||||
|
||||
|
||||
@@ -329,7 +327,7 @@ function SQUADRON:GetCallsign(Asset)
|
||||
|
||||
Asset.callsign[i]=callsign
|
||||
|
||||
self:I({callsign=callsign})
|
||||
self:T3({callsign=callsign})
|
||||
|
||||
--TODO: there is also a table entry .name, which is a string.
|
||||
end
|
||||
@@ -355,7 +353,7 @@ function SQUADRON:GetModex(Asset)
|
||||
|
||||
self.modexcounter=self.modexcounter+1
|
||||
|
||||
self:I({modex=Asset.modex[i]})
|
||||
self:T3({modex=Asset.modex[i]})
|
||||
|
||||
end
|
||||
|
||||
@@ -363,6 +361,28 @@ function SQUADRON:GetModex(Asset)
|
||||
|
||||
end
|
||||
|
||||
--- Check if squadron is "OnDuty".
|
||||
-- @param #SQUADRON self
|
||||
-- @return #boolean If true, squdron is in state "OnDuty".
|
||||
function SQUADRON:IsOnDuty()
|
||||
return self:Is("OnDuty")
|
||||
end
|
||||
|
||||
--- Check if squadron is "Stopped".
|
||||
-- @param #SQUADRON self
|
||||
-- @return #boolean If true, squdron is in state "Stopped".
|
||||
function SQUADRON:IsStopped()
|
||||
return self:Is("Stopped")
|
||||
end
|
||||
|
||||
--- Check if squadron is "Paused".
|
||||
-- @param #SQUADRON self
|
||||
-- @return #boolean If true, squdron is in state "Paused".
|
||||
function SQUADRON:IsPaused()
|
||||
return self:Is("Paused")
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Start & Status
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -375,7 +395,7 @@ end
|
||||
function SQUADRON:onafterStart(From, Event, To)
|
||||
|
||||
-- Short info.
|
||||
local text=string.format("Starting SQUADRON %s.", self.name)
|
||||
local text=string.format("Starting SQUADRON", self.name)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Start the status monitoring.
|
||||
@@ -396,11 +416,12 @@ function SQUADRON:onafterStatus(From, Event, To)
|
||||
--self:_CheckAssetStatus()
|
||||
|
||||
-- Short info.
|
||||
local text=string.format("Status %s", fsmstate)
|
||||
self:I(self.sid..text)
|
||||
local text=string.format("Status %s: Assets %d", fsmstate, #self.assets)
|
||||
self:I(self.lid..text)
|
||||
|
||||
|
||||
self:__Status(-30)
|
||||
if not self:IsStopped() then
|
||||
self:__Status(-30)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -424,10 +445,12 @@ end
|
||||
-- @param #string To To state.
|
||||
function SQUADRON:onafterStop(From, Event, To)
|
||||
|
||||
self:I(self.lid.."STOPPING Squadron!")
|
||||
|
||||
-- Remove all assets.
|
||||
for i=#self.assets,1,-1 do
|
||||
local asset=self.assets[i]
|
||||
self:DelAsqsset(asset)
|
||||
self:DelAsset(asset)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -466,16 +489,16 @@ function SQUADRON:CanMission(Mission)
|
||||
local TargetDistance=Mission:GetTargetDistance(self.airwing:GetCoordinate())
|
||||
|
||||
for _,_asset in pairs(self.assets) do
|
||||
local asset=_asset --#AIRWING.SquadronAsset
|
||||
local asset=_asset --Ops.AirWing#AIRWING.SquadronAsset
|
||||
|
||||
-- Set range is valid.
|
||||
-- Set range is valid. Mission engage distance can overrule the squad engage range.
|
||||
if TargetDistance<=self.engageRange or (Mission.engageMaxDistance and TargetDistance<=Mission.engageMaxDistance) then
|
||||
|
||||
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
||||
if self.airwing:IsAssetOnMission(asset) then
|
||||
|
||||
---
|
||||
-- This asset is already on a mission
|
||||
-- Asset is already on a mission
|
||||
---
|
||||
|
||||
-- Check if this asset is currently on a PATROL mission (STARTED or EXECUTING).
|
||||
@@ -493,11 +516,15 @@ function SQUADRON:CanMission(Mission)
|
||||
else
|
||||
|
||||
---
|
||||
-- This asset as no current mission
|
||||
-- Asset as no current mission
|
||||
---
|
||||
|
||||
if asset.spawned then
|
||||
|
||||
---
|
||||
-- Asset is already SPAWNED (could be uncontrolled on the airfield)
|
||||
---
|
||||
|
||||
local combatready=false
|
||||
local flightgroup=asset.flightgroup
|
||||
if flightgroup then
|
||||
@@ -515,6 +542,11 @@ function SQUADRON:CanMission(Mission)
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
-- Asset is still in STOCK
|
||||
---
|
||||
|
||||
-- Check that asset is not already requeseted for another mission.
|
||||
if not asset.requested then
|
||||
|
||||
-- Check if we got a payload and reserve it for this asset.
|
||||
|
||||
@@ -96,7 +96,7 @@ ENUMS.WeaponFlag={
|
||||
ENUMS.MissionTask={
|
||||
NOTHING="Nothing",
|
||||
AFAC="AFAC",
|
||||
ANTISHIPSTRIKE="Anti-ship Strike",
|
||||
ANTISHIPSTRIKE="Antiship Strike",
|
||||
AWACS="AWACS",
|
||||
CAP="CAP",
|
||||
CAS="CAS",
|
||||
|
||||
@@ -65,7 +65,7 @@ CALLSIGN={
|
||||
Enfield=1,
|
||||
Springfield=2,
|
||||
Uzi=3,
|
||||
Cold=4,
|
||||
Colt=4,
|
||||
Dodge=5,
|
||||
Ford=6,
|
||||
Chevy=7,
|
||||
|
||||
Reference in New Issue
Block a user