mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
commit
18c6ea39ce
@ -21,7 +21,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module AI.AI_Cargo_Dispatcher_Ship
|
-- @module AI.AI_Cargo_Dispatcher_Ship
|
||||||
-- @image AI_Cargo_Dispatching_For_Ship.JPG
|
-- @image AI_Cargo_Dispatcher.JPG
|
||||||
|
|
||||||
--- @type AI_CARGO_DISPATCHER_SHIP
|
--- @type AI_CARGO_DISPATCHER_SHIP
|
||||||
-- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER
|
-- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER
|
||||||
|
|||||||
@ -277,7 +277,7 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
|
|||||||
self:F( { Helicopter:GetName(), Height = Helicopter:GetHeight( true ), Velocity = Helicopter:GetVelocityKMH() } )
|
self:F( { Helicopter:GetName(), Height = Helicopter:GetHeight( true ), Velocity = Helicopter:GetVelocityKMH() } )
|
||||||
|
|
||||||
if self.RoutePickup == true then
|
if self.RoutePickup == true then
|
||||||
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 10 then
|
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 15 then
|
||||||
--self:Load( Helicopter:GetPointVec2() )
|
--self:Load( Helicopter:GetPointVec2() )
|
||||||
self:Load( self.PickupZone )
|
self:Load( self.PickupZone )
|
||||||
self.RoutePickup = false
|
self.RoutePickup = false
|
||||||
@ -285,7 +285,7 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.RouteDeploy == true then
|
if self.RouteDeploy == true then
|
||||||
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 10 then
|
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 15 then
|
||||||
self:Unload( self.DeployZone )
|
self:Unload( self.DeployZone )
|
||||||
self.RouteDeploy = false
|
self.RouteDeploy = false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module AI.AI_Cargo_Ship
|
-- @module AI.AI_Cargo_Ship
|
||||||
-- @image AI_Cargo_Dispatching_For_Ship.JPG
|
-- @image AI_Cargo_Dispatcher.JPG
|
||||||
|
|
||||||
--- @type AI_CARGO_SHIP
|
--- @type AI_CARGO_SHIP
|
||||||
-- @extends AI.AI_Cargo#AI_CARGO
|
-- @extends AI.AI_Cargo#AI_CARGO
|
||||||
|
|||||||
251
Moose Development/Moose/Core/MarkerOps_Base.lua
Normal file
251
Moose Development/Moose/Core/MarkerOps_Base.lua
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
--- **Core** - MarkerOps_Base.
|
||||||
|
--
|
||||||
|
-- **Main Features:**
|
||||||
|
--
|
||||||
|
-- * Create an easy way to tap into markers added to the F10 map by users.
|
||||||
|
-- * Recognize own tag and list of keywords.
|
||||||
|
-- * Matched keywords are handed down to functions.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- ### Author: **Applevangelist**
|
||||||
|
--
|
||||||
|
-- Date: 5 May 2021
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
---
|
||||||
|
-- @module Core.MarkerOps_Base
|
||||||
|
-- @image MOOSE_Core.JPG
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
-- MARKEROPS_BASE Class Definition.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- MARKEROPS_BASE class.
|
||||||
|
-- @type MARKEROPS_BASE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
-- @field #string Tag Tag to identify commands.
|
||||||
|
-- @field #table Keywords Table of keywords to recognize.
|
||||||
|
-- @field #string version Version of #MARKEROPS_BASE.
|
||||||
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
--- *Fiat lux.* -- Latin proverb.
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- # The MARKEROPS_BASE Concept
|
||||||
|
--
|
||||||
|
-- This class enable scripting text-based actions from markers.
|
||||||
|
--
|
||||||
|
-- @field #MARKEROPS_BASE
|
||||||
|
MARKEROPS_BASE = {
|
||||||
|
ClassName = "MARKEROPS",
|
||||||
|
Tag = "mytag",
|
||||||
|
Keywords = {},
|
||||||
|
version = "0.0.1",
|
||||||
|
debug = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Function to instantiate a new #MARKEROPS_BASE object.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string Tagname Name to identify us from the event text.
|
||||||
|
-- @param #table Keywords Table of keywords recognized from the event text.
|
||||||
|
-- @return #MARKEROPS_BASE self
|
||||||
|
function MARKEROPS_BASE:New(Tagname,Keywords)
|
||||||
|
-- Inherit FSM
|
||||||
|
local self=BASE:Inherit(self, FSM:New()) -- #MARKEROPS_BASE
|
||||||
|
|
||||||
|
-- Set some string id for output to DCS.log file.
|
||||||
|
self.lid=string.format("MARKEROPS_BASE %s | ", tostring(self.version))
|
||||||
|
|
||||||
|
self.Tag = Tagname or "mytag"-- #string
|
||||||
|
self.Keywords = Keywords or {} -- #table - might want to use lua regex here, too
|
||||||
|
self.debug = false
|
||||||
|
|
||||||
|
-----------------------
|
||||||
|
--- FSM Transitions ---
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
-- Start State.
|
||||||
|
self:SetStartState("Stopped")
|
||||||
|
|
||||||
|
-- Add FSM transitions.
|
||||||
|
-- From State --> Event --> To State
|
||||||
|
self:AddTransition("Stopped", "Start", "Running") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkAdded", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkChanged", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("*", "MarkDeleted", "*") -- Start the FSM.
|
||||||
|
self:AddTransition("Running", "Stop", "Stopped") -- Stop the FSM.
|
||||||
|
|
||||||
|
self:HandleEvent(EVENTS.MarkAdded, self.OnEventMark)
|
||||||
|
self:HandleEvent(EVENTS.MarkChange, self.OnEventMark)
|
||||||
|
self:HandleEvent(EVENTS.MarkRemoved, self.OnEventMark)
|
||||||
|
|
||||||
|
-- start
|
||||||
|
self:I(self.lid..string.format("started for %s",self.Tag))
|
||||||
|
self:__Start(1)
|
||||||
|
return self
|
||||||
|
|
||||||
|
-------------------
|
||||||
|
-- PSEUDO Functions
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
--- On after "MarkAdded" event. Triggered when a Marker is added to the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkAdded
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
|
||||||
|
--- On after "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkChanged
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
|
||||||
|
--- On after "MarkDeleted" event. Triggered when a Marker is deleted from the F10 map.
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] OnAfterMarkDeleted
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
|
||||||
|
--- "Stop" trigger. Used to stop the function an unhandle events
|
||||||
|
-- @function [parent=#MARKEROPS_BASE] Stop
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Handle events.
|
||||||
|
-- @param #MARKEROPS self
|
||||||
|
-- @param Core.Event#EVENTDATA Event
|
||||||
|
function MARKEROPS_BASE:OnEventMark(Event)
|
||||||
|
self:T({Event})
|
||||||
|
if Event == nil or Event.idx == nil then
|
||||||
|
self:E("Skipping onEvent. Event or Event.idx unknown.")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
--position
|
||||||
|
local vec3={y=Event.pos.y, x=Event.pos.x, z=Event.pos.z}
|
||||||
|
local coord=COORDINATE:NewFromVec3(vec3)
|
||||||
|
if self.debug then
|
||||||
|
local coordtext = coord:ToStringLLDDM()
|
||||||
|
local text = tostring(Event.text)
|
||||||
|
local m = MESSAGE:New(string.format("Mark added at %s with text: %s",coordtext,text),10,"Info",false):ToAll()
|
||||||
|
end
|
||||||
|
-- decision
|
||||||
|
if Event.id==world.event.S_EVENT_MARK_ADDED then
|
||||||
|
self:T({event="S_EVENT_MARK_ADDED", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Handle event
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
|
self:MarkAdded(Eventtext,matchtable,coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Event.id==world.event.S_EVENT_MARK_CHANGE then
|
||||||
|
self:T({event="S_EVENT_MARK_CHANGE", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Handle event.
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
local matchtable = self:_MatchKeywords(Eventtext)
|
||||||
|
self:MarkChanged(Eventtext,matchtable,coord)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Event.id==world.event.S_EVENT_MARK_REMOVED then
|
||||||
|
self:T({event="S_EVENT_MARK_REMOVED", carrier=self.groupname, vec3=Event.pos})
|
||||||
|
-- Hande event.
|
||||||
|
local Eventtext = tostring(Event.text)
|
||||||
|
if Eventtext~=nil then
|
||||||
|
if self:_MatchTag(Eventtext) then
|
||||||
|
self:MarkDeleted()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Match tag.
|
||||||
|
-- @param #MARKEROPS self
|
||||||
|
-- @param #string Eventtext Text added to the marker.
|
||||||
|
-- @return #boolean
|
||||||
|
function MARKEROPS_BASE:_MatchTag(Eventtext)
|
||||||
|
local matches = false
|
||||||
|
local type = string.lower(self.Tag) -- #string
|
||||||
|
if string.find(string.lower(Eventtext),type) then
|
||||||
|
matches = true --event text contains tag
|
||||||
|
end
|
||||||
|
return matches
|
||||||
|
end
|
||||||
|
|
||||||
|
--- (internal) Match keywords table.
|
||||||
|
-- @param #MARKEROPS self
|
||||||
|
-- @param #string Eventtext Text added to the marker.
|
||||||
|
-- @return #table
|
||||||
|
function MARKEROPS_BASE:_MatchKeywords(Eventtext)
|
||||||
|
local matchtable = {}
|
||||||
|
local keytable = self.Keywords
|
||||||
|
for _index,_word in pairs (keytable) do
|
||||||
|
if string.find(string.lower(Eventtext),string.lower(_word))then
|
||||||
|
table.insert(matchtable,_word)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return matchtable
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkAdded" event. Triggered when a Marker is added to the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkAdded(From,Event,To,Text,Keywords,Coord)
|
||||||
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkChanged" event. Triggered when a Marker is changed on the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
-- @param #string Text The text on the marker
|
||||||
|
-- @param #table Keywords Table of matching keywords found in the Event text
|
||||||
|
-- @param Core.Point#COORDINATE Coord Coordinate of the marker.
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkChanged(From,Event,To,Text,Keywords,Coord)
|
||||||
|
self:T({self.lid,From,Event,To,Text,Keywords,Coord:ToStringLLDDM()})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "MarkDeleted" event. Triggered when a Marker is removed from the F10 map.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
function MARKEROPS_BASE:onbeforeMarkDeleted(From,Event,To)
|
||||||
|
self:T({self.lid,From,Event,To})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On enter "Stopped" event. Unsubscribe events.
|
||||||
|
-- @param #MARKEROPS_BASE self
|
||||||
|
-- @param #string From The From state
|
||||||
|
-- @param #string Event The Event called
|
||||||
|
-- @param #string To The To state
|
||||||
|
function MARKEROPS_BASE:onenterStopped(From,Event,To)
|
||||||
|
self:T({self.lid,From,Event,To})
|
||||||
|
-- unsubscribe from events
|
||||||
|
self:UnHandleEvent(EVENTS.MarkAdded)
|
||||||
|
self:UnHandleEvent(EVENTS.MarkChange)
|
||||||
|
self:UnHandleEvent(EVENTS.MarkRemoved)
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
-- MARKEROPS_BASE Class Definition End.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
@ -1239,7 +1239,7 @@ do -- COORDINATE
|
|||||||
|
|
||||||
-- ETA.
|
-- ETA.
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
-- Waypoint description.
|
-- Waypoint description.
|
||||||
RoutePoint.name=description
|
RoutePoint.name=description
|
||||||
@ -1388,7 +1388,7 @@ do -- COORDINATE
|
|||||||
RoutePoint.formation_template=""
|
RoutePoint.formation_template=""
|
||||||
|
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
||||||
RoutePoint.speed_locked = true
|
RoutePoint.speed_locked = true
|
||||||
@ -1423,7 +1423,7 @@ do -- COORDINATE
|
|||||||
RoutePoint.formation_template = ""
|
RoutePoint.formation_template = ""
|
||||||
|
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
||||||
RoutePoint.speed_locked = true
|
RoutePoint.speed_locked = true
|
||||||
|
|||||||
@ -3267,7 +3267,7 @@ do -- SET_STATIC
|
|||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
-- @param Core.Zone#ZONE Zone The Zone to be tested for.
|
-- @param Core.Zone#ZONE Zone The Zone to be tested for.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function SET_STATIC:IsPatriallyInZone( Zone )
|
function SET_STATIC:IsPartiallyInZone( Zone )
|
||||||
|
|
||||||
local IsPartiallyInZone = false
|
local IsPartiallyInZone = false
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Authors: **FlightControl**, **applevangelist**
|
-- ### Authors: **FlightControl**, **applevangelist**
|
||||||
--
|
--
|
||||||
-- Last Update: Feb 2021
|
-- Last Update: April 2021
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
|
|||||||
@ -159,7 +159,7 @@ do
|
|||||||
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
||||||
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition)
|
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition)
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
self:F({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
self:T({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
||||||
|
|
||||||
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
||||||
|
|
||||||
@ -176,8 +176,8 @@ do
|
|||||||
self.DefendMavs = true
|
self.DefendMavs = true
|
||||||
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
||||||
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
||||||
self.UseEmOnOff = false -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
self.UseEmOnOff = true -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
self:I("*** SHORAD - Started Version 0.2.1")
|
self:I("*** SHORAD - Started Version 0.2.5")
|
||||||
-- Set the string id for output to DCS.log file.
|
-- Set the string id for output to DCS.log file.
|
||||||
self.lid=string.format("SHORAD %s | ", self.name)
|
self.lid=string.format("SHORAD %s | ", self.name)
|
||||||
self:_InitState()
|
self:_InitState()
|
||||||
@ -209,7 +209,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean debug Switch debug on (true) or off (false)
|
-- @param #boolean debug Switch debug on (true) or off (false)
|
||||||
function SHORAD:SwitchDebug(debug)
|
function SHORAD:SwitchDebug(debug)
|
||||||
self:F( { debug } )
|
self:T( { debug } )
|
||||||
local onoff = debug or false
|
local onoff = debug or false
|
||||||
if debug then
|
if debug then
|
||||||
self.debug = true
|
self.debug = true
|
||||||
@ -226,7 +226,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean onoff
|
-- @param #boolean onoff
|
||||||
function SHORAD:SwitchHARMDefense(onoff)
|
function SHORAD:SwitchHARMDefense(onoff)
|
||||||
self:F( { onoff } )
|
self:T( { onoff } )
|
||||||
local onoff = onoff or true
|
local onoff = onoff or true
|
||||||
self.DefendHarms = onoff
|
self.DefendHarms = onoff
|
||||||
end
|
end
|
||||||
@ -235,7 +235,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean onoff
|
-- @param #boolean onoff
|
||||||
function SHORAD:SwitchAGMDefense(onoff)
|
function SHORAD:SwitchAGMDefense(onoff)
|
||||||
self:F( { onoff } )
|
self:T( { onoff } )
|
||||||
local onoff = onoff or true
|
local onoff = onoff or true
|
||||||
self.DefendMavs = onoff
|
self.DefendMavs = onoff
|
||||||
end
|
end
|
||||||
@ -245,7 +245,7 @@ do
|
|||||||
-- @param #number low Minimum detection limit, integer 1-100
|
-- @param #number low Minimum detection limit, integer 1-100
|
||||||
-- @param #number high Maximum detection limit integer 1-100
|
-- @param #number high Maximum detection limit integer 1-100
|
||||||
function SHORAD:SetDefenseLimits(low,high)
|
function SHORAD:SetDefenseLimits(low,high)
|
||||||
self:F( { low, high } )
|
self:T( { low, high } )
|
||||||
local low = low or 70
|
local low = low or 70
|
||||||
local high = high or 90
|
local high = high or 90
|
||||||
if (low < 0) or (low > 100) or (low > high) then
|
if (low < 0) or (low > 100) or (low > high) then
|
||||||
@ -292,7 +292,7 @@ do
|
|||||||
-- @param #string WeaponName
|
-- @param #string WeaponName
|
||||||
-- @return #boolean Returns true for a match
|
-- @return #boolean Returns true for a match
|
||||||
function SHORAD:_CheckHarms(WeaponName)
|
function SHORAD:_CheckHarms(WeaponName)
|
||||||
self:F( { WeaponName } )
|
self:T( { WeaponName } )
|
||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendHarms then
|
if self.DefendHarms then
|
||||||
for _,_name in pairs (SHORAD.Harms) do
|
for _,_name in pairs (SHORAD.Harms) do
|
||||||
@ -307,7 +307,7 @@ do
|
|||||||
-- @param #string WeaponName
|
-- @param #string WeaponName
|
||||||
-- @return #boolean Returns true for a match
|
-- @return #boolean Returns true for a match
|
||||||
function SHORAD:_CheckMavs(WeaponName)
|
function SHORAD:_CheckMavs(WeaponName)
|
||||||
self:F( { WeaponName } )
|
self:T( { WeaponName } )
|
||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendMavs then
|
if self.DefendMavs then
|
||||||
for _,_name in pairs (SHORAD.Mavs) do
|
for _,_name in pairs (SHORAD.Mavs) do
|
||||||
@ -352,6 +352,7 @@ do
|
|||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1) then
|
||||||
returnname = true
|
returnname = true
|
||||||
|
_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return returnname
|
return returnname
|
||||||
@ -364,7 +365,8 @@ do
|
|||||||
function SHORAD:_CheckShotAtSams(TargetGroupName)
|
function SHORAD:_CheckShotAtSams(TargetGroupName)
|
||||||
local tgtgrp = TargetGroupName
|
local tgtgrp = TargetGroupName
|
||||||
local shorad = self.Samset
|
local shorad = self.Samset
|
||||||
local shoradset = shorad:GetAliveSet() --#table
|
--local shoradset = shorad:GetAliveSet() --#table
|
||||||
|
local shoradset = shorad:GetSet() --#table
|
||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
@ -393,6 +395,7 @@ do
|
|||||||
-- @param #string TargetGroup Name of the target group used to build the #ZONE
|
-- @param #string TargetGroup Name of the target group used to build the #ZONE
|
||||||
-- @param #number Radius Radius of the #ZONE
|
-- @param #number Radius Radius of the #ZONE
|
||||||
-- @param #number ActiveTimer Number of seconds to stay active
|
-- @param #number ActiveTimer Number of seconds to stay active
|
||||||
|
-- @param #number TargetCat (optional) Category, i.e. Object.Category.UNIT or Object.Category.STATIC
|
||||||
-- @usage Use this function to integrate with other systems, example
|
-- @usage Use this function to integrate with other systems, example
|
||||||
--
|
--
|
||||||
-- local SamSet = SET_GROUP:New():FilterPrefixes("Blue SAM"):FilterCoalitions("blue"):FilterStart()
|
-- local SamSet = SET_GROUP:New():FilterPrefixes("Blue SAM"):FilterCoalitions("blue"):FilterStart()
|
||||||
@ -401,10 +404,21 @@ do
|
|||||||
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
||||||
-- mymantis:AddShorad(myshorad,720)
|
-- mymantis:AddShorad(myshorad,720)
|
||||||
-- mymantis:Start()
|
-- mymantis:Start()
|
||||||
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer)
|
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer, TargetCat)
|
||||||
self:F({TargetGroup, Radius, ActiveTimer})
|
self:T({TargetGroup, Radius, ActiveTimer, TargetCat})
|
||||||
local targetgroup = GROUP:FindByName(TargetGroup)
|
local targetcat = TargetCat or Object.Category.UNIT
|
||||||
local targetzone = ZONE_GROUP:New("Shorad",targetgroup,Radius) -- create a defense zone to check
|
local targetgroup = TargetGroup
|
||||||
|
local targetvec2 = nil
|
||||||
|
if targetcat == Object.Category.UNIT then
|
||||||
|
targetvec2 = GROUP:FindByName(targetgroup):GetVec2()
|
||||||
|
elseif targetcat == Object.Category.STATIC then
|
||||||
|
targetvec2 = STATIC:FindByName(targetgroup,false):GetVec2()
|
||||||
|
else
|
||||||
|
local samset = self.Samset
|
||||||
|
local sam = samset:GetRandom()
|
||||||
|
targetvec2 = sam:GetVec2()
|
||||||
|
end
|
||||||
|
local targetzone = ZONE_RADIUS:New("Shorad",targetvec2,Radius) -- create a defense zone to check
|
||||||
local groupset = self.Groupset --Core.Set#SET_GROUP
|
local groupset = self.Groupset --Core.Set#SET_GROUP
|
||||||
local shoradset = groupset:GetAliveSet() --#table
|
local shoradset = groupset:GetAliveSet() --#table
|
||||||
-- local function to switch off shorad again
|
-- local function to switch off shorad again
|
||||||
@ -446,7 +460,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
||||||
function SHORAD:OnEventShot( EventData )
|
function SHORAD:OnEventShot( EventData )
|
||||||
self:F( { EventData } )
|
self:T( { EventData } )
|
||||||
|
|
||||||
--local ShootingUnit = EventData.IniDCSUnit
|
--local ShootingUnit = EventData.IniDCSUnit
|
||||||
--local ShootingUnitName = EventData.IniDCSUnitName
|
--local ShootingUnitName = EventData.IniDCSUnitName
|
||||||
@ -469,13 +483,27 @@ do
|
|||||||
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
||||||
-- get target data
|
-- get target data
|
||||||
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
||||||
local targetunit = UNIT:Find(targetdata)
|
local targetcat = targetdata:getCategory() -- Identify category
|
||||||
|
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
||||||
|
local targetunit = nil
|
||||||
|
if targetcat == Object.Category.UNIT then -- UNIT
|
||||||
|
targetunit = UNIT:Find(targetdata)
|
||||||
|
elseif targetcat == Object.Category.STATIC then -- STATIC
|
||||||
|
targetunit = STATIC:Find(targetdata)
|
||||||
|
end
|
||||||
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
||||||
if targetunit and targetunit:IsAlive() then
|
if targetunit and targetunit:IsAlive() then
|
||||||
local targetunitname = targetunit:GetName()
|
local targetunitname = targetunit:GetName()
|
||||||
--local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group
|
--local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group
|
||||||
local targetgroup = targetunit:GetGroup()
|
local targetgroup = nil
|
||||||
local targetgroupname = targetgroup:GetName() -- group name
|
local targetgroupname = "none"
|
||||||
|
if targetcat == Object.Category.UNIT then
|
||||||
|
targetgroup = targetunit:GetGroup()
|
||||||
|
targetgroupname = targetgroup:GetName() -- group name
|
||||||
|
elseif targetcat == Object.Category.STATIC then
|
||||||
|
targetgroup = targetunit
|
||||||
|
targetgroupname = targetunitname
|
||||||
|
end
|
||||||
local text = string.format("%s Missile Target = %s", self.lid, tostring(targetgroupname))
|
local text = string.format("%s Missile Target = %s", self.lid, tostring(targetgroupname))
|
||||||
self:T( text )
|
self:T( text )
|
||||||
local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
|
local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
|
||||||
@ -486,7 +514,7 @@ do
|
|||||||
-- if being shot at, find closest SHORADs to activate
|
-- if being shot at, find closest SHORADs to activate
|
||||||
if shotatsams or shotatus then
|
if shotatsams or shotatus then
|
||||||
self:T({shotatsams=shotatsams,shotatus=shotatus})
|
self:T({shotatsams=shotatsams,shotatus=shotatus})
|
||||||
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer)
|
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer, targetcat)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -29,6 +29,7 @@ __Moose.Include( 'Scripts/Moose/Core/Timer.lua' )
|
|||||||
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Goal.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Spot.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Astar.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Core/MarkerOps_Base.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
__Moose.Include( 'Scripts/Moose/Wrapper/Object.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
__Moose.Include( 'Scripts/Moose/Wrapper/Identifiable.lua' )
|
||||||
|
|||||||
@ -615,7 +615,7 @@ end
|
|||||||
|
|
||||||
--- Get all airbase names of the current map. This includes ships and FARPS.
|
--- Get all airbase names of the current map. This includes ships and FARPS.
|
||||||
-- @param DCS#Coalition coalition (Optional) Return only airbases belonging to the specified coalition. By default, all airbases of the map are returned.
|
-- @param DCS#Coalition coalition (Optional) Return only airbases belonging to the specified coalition. By default, all airbases of the map are returned.
|
||||||
-- @param #number category (Optional) Return only airbases of a certain category, e.g. Airbase.Category.FARP
|
-- @param #number category (Optional) Return only airbases of a certain category, e.g. `Airbase.Category.HELIPAD`.
|
||||||
-- @return #table Table containing all airbase names of the current map.
|
-- @return #table Table containing all airbase names of the current map.
|
||||||
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Author: **funkyfranky**
|
-- ### Author: **funkyfranky**
|
||||||
-- @module Wrapper.Marker
|
-- @module Wrapper.Marker
|
||||||
-- @image Wrapper_Marker.png
|
-- @image MOOSE_Core.JPG
|
||||||
|
|
||||||
|
|
||||||
--- Marker class.
|
--- Marker class.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user