mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-20 07:43:07 +00:00
Misc
This commit is contained in:
@@ -2186,20 +2186,6 @@ do -- SET_UNIT
|
|||||||
return IsNotInZone
|
return IsNotInZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if minimal one element of the SET_UNIT is in the Zone.
|
|
||||||
-- @param #SET_UNIT self
|
|
||||||
-- @param #function IteratorFunction The function that will be called when there is an alive UNIT in the SET_UNIT. The function needs to accept a UNIT parameter.
|
|
||||||
-- @return #SET_UNIT self
|
|
||||||
function SET_UNIT:ForEachUnitInZone( IteratorFunction, ... )
|
|
||||||
self:F2( arg )
|
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, arg, self:GetSet() )
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -949,7 +949,7 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
|||||||
|
|
||||||
local function EvaluateZone( ZoneDCSUnit )
|
local function EvaluateZone( ZoneDCSUnit )
|
||||||
|
|
||||||
env.info( ZoneDCSUnit:getName() )
|
--env.info( ZoneDCSUnit:getName() )
|
||||||
|
|
||||||
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@
|
|||||||
-- @field #string DefaultAlarmState Alarm state the group will go to when it is changed back from another state. Default is "Auto".
|
-- @field #string DefaultAlarmState Alarm state the group will go to when it is changed back from another state. Default is "Auto".
|
||||||
-- @field #string DefaultROE ROE the group will get once suppression is over. Default is "Free".
|
-- @field #string DefaultROE ROE the group will get once suppression is over. Default is "Free".
|
||||||
-- @field #boolean eventmoose If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
|
-- @field #boolean eventmoose If true, events are handled by MOOSE. If false, events are handled directly by DCS eventhandler. Default true.
|
||||||
|
-- @field Core.Zone#ZONE BattleZone
|
||||||
|
-- @field #boolean AutoEngage
|
||||||
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
||||||
--
|
--
|
||||||
|
|
||||||
@@ -307,8 +309,7 @@ SUPPRESSION.version="0.9.3"
|
|||||||
--- Creates a new AI_suppression object.
|
--- Creates a new AI_suppression object.
|
||||||
-- @param #SUPPRESSION self
|
-- @param #SUPPRESSION self
|
||||||
-- @param Wrapper.Group#GROUP group The GROUP object for which suppression should be applied.
|
-- @param Wrapper.Group#GROUP group The GROUP object for which suppression should be applied.
|
||||||
-- @return #SUPPRESSION SUPPRESSION object.
|
-- @return #SUPPRESSION SUPPRESSION object or *nil* if group does not exist or is not a ground group.
|
||||||
-- @return nil If group does not exist or is not a ground group.
|
|
||||||
function SUPPRESSION:New(group)
|
function SUPPRESSION:New(group)
|
||||||
|
|
||||||
-- Inherits from FSM_CONTROLLABLE
|
-- Inherits from FSM_CONTROLLABLE
|
||||||
@@ -333,18 +334,16 @@ function SUPPRESSION:New(group)
|
|||||||
self:SetControllable(group)
|
self:SetControllable(group)
|
||||||
|
|
||||||
-- Get DCS descriptors of group.
|
-- Get DCS descriptors of group.
|
||||||
local DCSgroup=Group.getByName(group:GetName())
|
self.DCSdesc=group:GetDCSDesc(1)
|
||||||
local DCSunit=DCSgroup:getUnit(1)
|
|
||||||
self.DCSdesc=DCSunit:getDesc()
|
|
||||||
|
|
||||||
-- Get max speed the group can do and convert to km/h.
|
-- Get max speed the group can do and convert to km/h.
|
||||||
self.SpeedMax=self.DCSdesc.speedMaxOffRoad*3.6
|
self.SpeedMax=group:GetSpeedMax()
|
||||||
|
|
||||||
-- Set speed to maximum.
|
-- Set speed to maximum.
|
||||||
self.Speed=self.SpeedMax
|
self.Speed=self.SpeedMax
|
||||||
|
|
||||||
-- Is this infantry or not.
|
-- Is this infantry or not.
|
||||||
self.IsInfantry=DCSunit:hasAttribute("Infantry")
|
self.IsInfantry=group:GetUnit(1):HasAttribute("Infantry")
|
||||||
|
|
||||||
-- Type of group.
|
-- Type of group.
|
||||||
self.Type=group:GetTypeName()
|
self.Type=group:GetTypeName()
|
||||||
@@ -368,6 +367,7 @@ function SUPPRESSION:New(group)
|
|||||||
self:AddTransition("TakingCover", "FightBack", "CombatReady")
|
self:AddTransition("TakingCover", "FightBack", "CombatReady")
|
||||||
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
||||||
self:AddTransition("Retreating", "Retreated", "Retreated")
|
self:AddTransition("Retreating", "Retreated", "Retreated")
|
||||||
|
self:AddTransition("*", "OutOfAmmo", "*")
|
||||||
self:AddTransition("*", "Dead", "*")
|
self:AddTransition("*", "Dead", "*")
|
||||||
self:AddTransition("*", "Stop", "Stopped")
|
self:AddTransition("*", "Stop", "Stopped")
|
||||||
|
|
||||||
@@ -598,6 +598,24 @@ function SUPPRESSION:New(group)
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
|
|
||||||
|
|
||||||
|
--- Trigger "OutOfAmmo" event.
|
||||||
|
-- @function [parent=#SUPPRESSION] OutOfAmmo
|
||||||
|
-- @param #SUPPRESSION self
|
||||||
|
|
||||||
|
--- Trigger "OutOfAmmo" event after a delay.
|
||||||
|
-- @function [parent=#SUPPRESSION] __OutOfAmmo
|
||||||
|
-- @param #SUPPRESSION self
|
||||||
|
-- @param #number Delay Delay in seconds.
|
||||||
|
|
||||||
|
--- User function for OnAfter "OutOfAmmo" event.
|
||||||
|
-- @function [parent=#SUPPRESSION] OnAfterOutOfAmmo
|
||||||
|
-- @param #SUPPRESSION self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
|
||||||
|
|
||||||
--- Trigger "Dead" event.
|
--- Trigger "Dead" event.
|
||||||
-- @function [parent=#SUPPRESSION] Dead
|
-- @function [parent=#SUPPRESSION] Dead
|
||||||
-- @param #SUPPRESSION self
|
-- @param #SUPPRESSION self
|
||||||
@@ -1002,9 +1020,8 @@ function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
|||||||
|
|
||||||
-- Retreat if completely out of ammo and retreat zone defined.
|
-- Retreat if completely out of ammo and retreat zone defined.
|
||||||
local nammo=group:GetAmmunition()
|
local nammo=group:GetAmmunition()
|
||||||
if nammo==0 and self.RetreatZone then
|
if nammo==0 then
|
||||||
self:I(self.lid..string.format("Out of ammo!"))
|
self:OutOfAmmo()
|
||||||
self:Retreat()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Status report.
|
-- Status report.
|
||||||
@@ -1016,34 +1033,18 @@ function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- Stop FSM as there are no units left.
|
||||||
self:Stop()
|
self:Stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- Stop FSM as there group object does not exist.
|
||||||
self:Stop()
|
self:Stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Before "Hit" event. (Of course, this is not really before the group got hit.)
|
|
||||||
-- @param #SUPPRESSION self
|
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
-- @param Wrapper.Unit#UNIT Unit Unit that was hit.
|
|
||||||
-- @param Wrapper.Unit#UNIT AttackUnit Unit that attacked.
|
|
||||||
-- @return boolean
|
|
||||||
function SUPPRESSION:onbeforeHit(Controllable, From, Event, To, Unit, AttackUnit)
|
|
||||||
self:_EventFromTo("onbeforeHit", Event, From, To)
|
|
||||||
|
|
||||||
--local Tnow=timer.getTime()
|
|
||||||
--env.info(self.lid..string.format("Last hit = %s %s", tostring(self.LastHit), tostring(Tnow)))
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
--- After "Hit" event.
|
--- After "Hit" event.
|
||||||
-- @param #SUPPRESSION self
|
-- @param #SUPPRESSION self
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
@@ -1314,6 +1315,25 @@ function SUPPRESSION:onafterTakeCover(Controllable, From, Event, To, Hideout)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- After "OutOfAmmo" event. Triggered when group is completely out of ammo.
|
||||||
|
-- @param #SUPPRESSION self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function SUPPRESSION:onafterOutOfAmmo(Controllable, From, Event, To)
|
||||||
|
self:_EventFromTo("onafterOutOfAmmo", Event, From, To)
|
||||||
|
|
||||||
|
-- Info to log.
|
||||||
|
self:I(self.lid..string.format("Out of ammo!"))
|
||||||
|
|
||||||
|
-- Order retreat if retreat zone was specified.
|
||||||
|
if self.RetreatZone then
|
||||||
|
self:Retreat()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Before "Retreat" event. We check that the group is not already retreating.
|
--- Before "Retreat" event. We check that the group is not already retreating.
|
||||||
|
|||||||
@@ -874,14 +874,16 @@ do -- ZONE_CAPTURE_COALITION
|
|||||||
self:Capture()
|
self:Capture()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:IsAttacked() then
|
-- Get red and blue unit sets.
|
||||||
local unitset=self:GetScannedSetUnit() --Core.Set#SET_UNIT
|
local unitsetRed=self:GetScannedSetUnit():FilterCoalitions(coalition.side.RED):FilterActive(true):FilterOnce()
|
||||||
|
local unitsetBlu=self:GetScannedSetUnit():FilterCoalitions(coalition.side.BLUE):FilterActive(true):FilterOnce()
|
||||||
unitset:ForEachUnitInZone(self)
|
|
||||||
end
|
-- Count number of units.
|
||||||
|
local nRed=unitsetRed:Count()
|
||||||
|
local nBlu=unitsetBlu:Count()
|
||||||
|
|
||||||
-- Status text.
|
-- Status text.
|
||||||
local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), State)
|
local text=string.format("CAPTURE ZONE %s: Owner=%s (Previous=%s): #blue=%d, #red=%d, Status %s", self:GetZoneName(), self:GetCoalitionName(), UTILS.GetCoalitionName(self:GetPreviousCoalition()), nBlu, nRed, State)
|
||||||
local NewState = self:GetState()
|
local NewState = self:GetState()
|
||||||
if NewState~=State then
|
if NewState~=State then
|
||||||
text=text..string.format(" --> %s", NewState)
|
text=text..string.format(" --> %s", NewState)
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ _ATIS={}
|
|||||||
|
|
||||||
--- ATIS class version.
|
--- ATIS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ATIS.version="0.6.0"
|
ATIS.version="0.6.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -996,9 +996,15 @@ function ATIS:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- Get FSM state.
|
-- Get FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
|
local relayunitstatus="N/A"
|
||||||
|
if self.relayunitname then
|
||||||
|
local ru=UNIT:FindByName(self.relayunitname)
|
||||||
|
relayunitstatus=tostring(ru:IsAlive())
|
||||||
|
end
|
||||||
|
|
||||||
-- Info text.
|
-- Info text.
|
||||||
local text=string.format("State %s", fsmstate)
|
local text=string.format("State %s: Freq=%.3f MHz %s, Relay unit=%s (alive=%s)", fsmstate, self.frequency, UTILS.GetModulationName(self.modulation), tostring(self.relayunitname), relayunitstatus)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
self:__Status(-60)
|
self:__Status(-60)
|
||||||
|
|||||||
@@ -1060,3 +1060,23 @@ function UTILS.GetCoalitionName(Coalition)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the modulation name from its numerical value.
|
||||||
|
-- @param #number Modulation The modulation enumerator number. Can be either 0 or 1.
|
||||||
|
-- @return #string The modulation name, i.e. "AM"=0 or "FM"=1. Anything else will return "Unknown".
|
||||||
|
function UTILS.GetModulationName(Modulation)
|
||||||
|
|
||||||
|
if Modulation then
|
||||||
|
if Modulation==0 then
|
||||||
|
return "AM"
|
||||||
|
elseif Modulation==1 then
|
||||||
|
return "FM"
|
||||||
|
else
|
||||||
|
return "Unknown"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Unknown"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user