mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 19:45:29 +00:00
SUPPRESSION
This commit is contained in:
@@ -336,7 +336,7 @@ function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
|||||||
Schedule.ScheduleID = nil
|
Schedule.ScheduleID = nil
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(string.format("Error no ScheduleID for CallID=%s", tostring(CallID)))
|
self:T(string.format("Error no ScheduleID for CallID=%s", tostring(CallID)))
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ SUPPRESSION.MenuF10=nil
|
|||||||
|
|
||||||
--- PSEUDOATC version.
|
--- PSEUDOATC version.
|
||||||
-- @field #number version
|
-- @field #number version
|
||||||
SUPPRESSION.version="0.9.1"
|
SUPPRESSION.version="0.9.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -363,6 +363,7 @@ function SUPPRESSION:New(group)
|
|||||||
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
self:AddTransition("FallingBack", "FightBack", "CombatReady")
|
||||||
self:AddTransition("Retreating", "Retreated", "Retreated")
|
self:AddTransition("Retreating", "Retreated", "Retreated")
|
||||||
self:AddTransition("*", "Dead", "*")
|
self:AddTransition("*", "Dead", "*")
|
||||||
|
self:AddTransition("*", "Stop", "Stopped")
|
||||||
|
|
||||||
self:AddTransition("TakingCover", "Hit", "TakingCover")
|
self:AddTransition("TakingCover", "Hit", "TakingCover")
|
||||||
self:AddTransition("FallingBack", "Hit", "FallingBack")
|
self:AddTransition("FallingBack", "Hit", "FallingBack")
|
||||||
@@ -874,28 +875,14 @@ function SUPPRESSION:StatusReport(message)
|
|||||||
local roe=self.CurrentROE
|
local roe=self.CurrentROE
|
||||||
local state=self.CurrentAlarmState
|
local state=self.CurrentAlarmState
|
||||||
local life_min, life_max, life_ave, life_ave0, groupstrength=self:_GetLife()
|
local life_min, life_max, life_ave, life_ave0, groupstrength=self:_GetLife()
|
||||||
local ammotot=self.Controllable:GetAmmunition()
|
local ammotot=group:GetAmmunition()
|
||||||
|
|
||||||
--[[
|
|
||||||
local text=string.format("Status of group %s\n", name)
|
|
||||||
text=text..string.format("Number of units: %d of %d\n", nunits, self.IniGroupStrength)
|
|
||||||
text=text..string.format("Current state: %s\n", self:GetState())
|
|
||||||
text=text..string.format("ROE: %s\n", roe)
|
|
||||||
text=text..string.format("Alarm state: %s\n", state)
|
|
||||||
text=text..string.format("Hits taken: %d\n", self.Nhit)
|
|
||||||
text=text..string.format("Life min: %3.0f\n", life_min)
|
|
||||||
text=text..string.format("Life max: %3.0f\n", life_max)
|
|
||||||
text=text..string.format("Life ave: %3.0f\n", life_ave)
|
|
||||||
text=text..string.format("Life ave0: %3.0f\n", life_ave0)
|
|
||||||
text=text..string.format("Ammo tot: %d\n", at)
|
|
||||||
text=text..string.format("Group strength: %3.0f", groupstrength)
|
|
||||||
]]
|
|
||||||
|
|
||||||
local text=string.format("State %s, Units=%d/%d, ROE=%s Alarm State=%s, Hits=%d, Life=%d/%d/%d/%d, Ammo=%d",
|
local text=string.format("State %s, Units=%d/%d, ROE=%s, AlarmState=%s, Hits=%d, Life(min/max/ave/ave0)=%d/%d/%d/%d, Total Ammo=%d",
|
||||||
self:GetState(), nunits, self.IniGroupStrength, self.CurrentROE, self.CurrentAlarmState, self.Nhit, life_min, life_max, life_ave, life_ave0, ammotot)
|
self:GetState(), nunits, self.IniGroupStrength, self.CurrentROE, self.CurrentAlarmState, self.Nhit, life_min, life_max, life_ave, life_ave0, ammotot)
|
||||||
|
|
||||||
MESSAGE:New(text, 10):ToAllIf(message or self.Debug)
|
MESSAGE:New(text, 10):ToAllIf(message or self.Debug)
|
||||||
self:I(self.lid.."\n"..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -983,7 +970,6 @@ function SUPPRESSION:onafterStart(Controllable, From, Event, To)
|
|||||||
world.addEventHandler(self)
|
world.addEventHandler(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self:__Status(-1)
|
self:__Status(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -995,24 +981,41 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
function SUPPRESSION:onafterStatus(Controllable, From, Event, To)
|
||||||
|
|
||||||
--local text=string.format("State=%s, ROE %d, Life=%.1f", Controllable:GetName())
|
-- Suppressed group.
|
||||||
--MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
|
||||||
|
|
||||||
local group=self.Controllable --Wrapper.Group#GROUP
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
local n=group:GetAmmunition()
|
-- Check if group object exists.
|
||||||
|
if group then
|
||||||
|
|
||||||
self:StatusReport(false)
|
-- Number of alive units.
|
||||||
|
local nunits=group:CountAliveUnits()
|
||||||
|
|
||||||
|
-- Check if there are units.
|
||||||
|
if nunits>0 then
|
||||||
|
|
||||||
-- Retreat if completely out of ammo and retreat zone defined.
|
-- Retreat if completely out of ammo and retreat zone defined.
|
||||||
if n==0 and self.RetreatZone then
|
local nammo=group:GetAmmunition()
|
||||||
|
if nammo==0 and self.RetreatZone then
|
||||||
self:Retreat()
|
self:Retreat()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Status report.
|
||||||
|
self:StatusReport(false)
|
||||||
|
|
||||||
|
-- Call status again if not "Stopped".
|
||||||
|
if self:GetState()~="Stopped" then
|
||||||
self:__Status(-30)
|
self:__Status(-30)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Before "Hit" event. (Of course, this is not really before the group got hit.)
|
--- Before "Hit" event. (Of course, this is not really before the group got hit.)
|
||||||
@@ -1409,8 +1412,12 @@ end
|
|||||||
function SUPPRESSION:onafterDead(Controllable, From, Event, To)
|
function SUPPRESSION:onafterDead(Controllable, From, Event, To)
|
||||||
self:_EventFromTo("onafterDead", Event, From, To)
|
self:_EventFromTo("onafterDead", Event, From, To)
|
||||||
|
|
||||||
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
|
if group then
|
||||||
|
|
||||||
-- Number of units left in the group.
|
-- Number of units left in the group.
|
||||||
local nunits=#self.Controllable:GetUnits()
|
local nunits=group:CountAliveUnits()
|
||||||
|
|
||||||
local text=string.format("Group %s: One of our units just died! %d units left.", self.Controllable:GetName(), nunits)
|
local text=string.format("Group %s: One of our units just died! %d units left.", self.Controllable:GetName(), nunits)
|
||||||
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
||||||
@@ -1418,18 +1425,41 @@ function SUPPRESSION:onafterDead(Controllable, From, Event, To)
|
|||||||
|
|
||||||
-- Go to stop state.
|
-- Go to stop state.
|
||||||
if nunits==0 then
|
if nunits==0 then
|
||||||
self:T(self.lid..string.format("Stopping SUPPRESSION for group %s.", Controllable:GetName()))
|
|
||||||
self:Stop()
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- After "Stop" event.
|
||||||
|
-- @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:onafterStop(Controllable, From, Event, To)
|
||||||
|
self:_EventFromTo("onafterStop", Event, From, To)
|
||||||
|
|
||||||
|
local text=string.format("Stopping SUPPRESSION for group %s", self.Controllable:GetName())
|
||||||
|
MESSAGE:New(text, 10):ToAllIf(self.Debug)
|
||||||
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
-- Clear all pending schedules
|
||||||
|
self.CallScheduler:Clear()
|
||||||
|
|
||||||
if self.mooseevents then
|
if self.mooseevents then
|
||||||
self:UnHandleEvent(EVENTS.Dead)
|
self:UnHandleEvent(EVENTS.Dead)
|
||||||
self:UnHandleEvent(EVENTS.Hit)
|
self:UnHandleEvent(EVENTS.Hit)
|
||||||
else
|
else
|
||||||
world.removeEventHandler(self)
|
world.removeEventHandler(self)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
--- Event Handler
|
--- Event Handler
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1623,6 +1653,8 @@ function SUPPRESSION:_Run(fin, speed, formation, wait)
|
|||||||
|
|
||||||
local group=self.Controllable -- Wrapper.Controllable#CONTROLLABLE
|
local group=self.Controllable -- Wrapper.Controllable#CONTROLLABLE
|
||||||
|
|
||||||
|
if group and group:IsAlive() then
|
||||||
|
|
||||||
-- Clear all tasks.
|
-- Clear all tasks.
|
||||||
group:ClearTasks()
|
group:ClearTasks()
|
||||||
|
|
||||||
@@ -1713,6 +1745,10 @@ function SUPPRESSION:_Run(fin, speed, formation, wait)
|
|||||||
-- Submit task and route group along waypoints.
|
-- Submit task and route group along waypoints.
|
||||||
group:Route(Waypoints)
|
group:Route(Waypoints)
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("ERROR: Group is not alive!"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Function called when group is passing a waypoint. At the last waypoint we set the group back to CombatReady.
|
--- Function called when group is passing a waypoint. At the last waypoint we set the group back to CombatReady.
|
||||||
|
|||||||
Reference in New Issue
Block a user