mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Update Shorad.lua
Own picture and quote, cleanup docs, link missions, less overhead by avoiding checks on friendly fire.
This commit is contained in:
parent
8cff2eaac0
commit
9491b18ff4
@ -3,33 +3,33 @@
|
|||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- **SHORAD** - Short Range Air Defense System
|
-- **SHORAD** - Short Range Air Defense System
|
||||||
-- Controls a network of short range AAA groups. Uses events to detect a missile attack
|
-- Controls a network of short range air/missile defense groups.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Missions:
|
-- ## Missions:
|
||||||
--
|
--
|
||||||
-- ### [SHORAD - Short Range Air Defense](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/tbd)
|
-- ### [SHORAD - Short Range Air Defense](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/SRD%20-%20SHORAD%20Defense)
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Author : **applevangelist **
|
-- ### Author : **applevangelist **
|
||||||
--
|
--
|
||||||
-- @module Functional.Shorad
|
-- @module Functional.Shorad
|
||||||
-- @image Functional.Mantis.jpg
|
-- @image Functional.Shorad.jpg
|
||||||
--
|
--
|
||||||
-- Date: Feb 2021
|
-- Date: Feb 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **SHORAD** class, extends @{#Core.Base#BASE}
|
--- **SHORAD** class, extends Core.Base#BASE
|
||||||
-- @type SHORAD
|
-- @type SHORAD
|
||||||
-- @field #string ClassName
|
-- @field #string ClassName
|
||||||
-- @field #string name Name of this Shorad
|
-- @field #string name Name of this Shorad
|
||||||
-- @field #boolean debug Set the debug state
|
-- @field #boolean debug Set the debug state
|
||||||
-- @field #string Prefixes String to be used to build the @{#Core.Set#SET_GROUP}
|
-- @field #string Prefixes String to be used to build the @{#Core.Set#SET_GROUP}
|
||||||
-- @field #number Radius Shorad defense radius in meters
|
-- @field #number Radius Shorad defense radius in meters
|
||||||
-- @field @{#Core.Set#SET_GROUP} Groupset The set of Shorad groups
|
-- @field Core.Set#SET_GROUP Groupset The set of Shorad groups
|
||||||
-- @field @{#Core.Set#SET_GROUP} Samset The set of SAM groups to defend
|
-- @field Core.Set#SET_GROUP Samset The set of SAM groups to defend
|
||||||
-- @field #string Coalition The coalition of this Shorad
|
-- @field #string Coalition The coalition of this Shorad
|
||||||
-- @field #number ActiveTimer How long a Shorad stays active after wake-up in seconds
|
-- @field #number ActiveTimer How long a Shorad stays active after wake-up in seconds
|
||||||
-- @field #table ActiveGroups Table for the timer function
|
-- @field #table ActiveGroups Table for the timer function
|
||||||
@ -40,14 +40,14 @@
|
|||||||
-- @field #number DefenseHighProb Default 90, maximim detection limit
|
-- @field #number DefenseHighProb Default 90, maximim detection limit
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- *The worst thing that can happen to a good cause is, not to be skillfully attacked, but to be ineptly defended.* - Frédéric Bastiat
|
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
|
||||||
--
|
--
|
||||||
-- Simple Class for a more intelligent Short Range Air Defense System
|
-- Simple Class for a more intelligent Short Range Air Defense System
|
||||||
--
|
--
|
||||||
-- #SHORAD
|
-- #SHORAD
|
||||||
-- Moose derived missile intercepting short range defense system
|
-- Moose derived missile intercepting short range defense system.
|
||||||
-- Protects a network of SAM sites. Uses events to switch on the defense groups closest to the enemy
|
-- Protects a network of SAM sites. Uses events to switch on the defense groups closest to the enemy.
|
||||||
-- Integrate with @{Functional.Mantis#MANTIS} to complete the defensive system setup.
|
-- Easily integrated with @{Functional.Mantis#MANTIS} to complete the defensive system setup.
|
||||||
--
|
--
|
||||||
-- ## Usage
|
-- ## Usage
|
||||||
--
|
--
|
||||||
@ -77,8 +77,6 @@
|
|||||||
-- * SHORAD:SetDefenseLimits(low,high)
|
-- * SHORAD:SetDefenseLimits(low,high)
|
||||||
-- * SHORAD:SetActiveTimer(seconds)
|
-- * SHORAD:SetActiveTimer(seconds)
|
||||||
-- * SHORAD:SetDefenseRadius(meters)
|
-- * SHORAD:SetDefenseRadius(meters)
|
||||||
-- * SHORAD:SetActiveTimer(seconds)
|
|
||||||
-- * SHORAD:SetDefenseRadius(meters)
|
|
||||||
--
|
--
|
||||||
-- @field #SHORAD
|
-- @field #SHORAD
|
||||||
SHORAD = {
|
SHORAD = {
|
||||||
@ -176,7 +174,7 @@ 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:I("*** SHORAD - Started Version 0.0.1")
|
self:I("*** SHORAD - Started Version 0.0.2")
|
||||||
-- 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()
|
||||||
@ -289,7 +287,7 @@ do
|
|||||||
return hit
|
return hit
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if a Maverick was fired
|
--- Check if an AGM was fired
|
||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #string WeaponName
|
-- @param #string WeaponName
|
||||||
-- @return #boolean Returns true for a match
|
-- @return #boolean Returns true for a match
|
||||||
@ -380,6 +378,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
|
||||||
|
-- @usage Use this function to integrate with other systems.
|
||||||
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer)
|
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer)
|
||||||
self:F({TargetGroup, Radius, ActiveTimer})
|
self:F({TargetGroup, Radius, ActiveTimer})
|
||||||
local targetgroup = GROUP:FindByName(TargetGroup)
|
local targetgroup = GROUP:FindByName(TargetGroup)
|
||||||
@ -414,6 +413,7 @@ do
|
|||||||
|
|
||||||
--- Main function - work on the EventData
|
--- Main function - work on the EventData
|
||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
|
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
||||||
function SHORAD:OnEventShot( EventData )
|
function SHORAD:OnEventShot( EventData )
|
||||||
self:F( { EventData } )
|
self:F( { EventData } )
|
||||||
|
|
||||||
@ -421,7 +421,10 @@ do
|
|||||||
--local ShootingUnitName = EventData.IniDCSUnitName
|
--local ShootingUnitName = EventData.IniDCSUnitName
|
||||||
local ShootingWeapon = EventData.Weapon -- Identify the weapon fired
|
local ShootingWeapon = EventData.Weapon -- Identify the weapon fired
|
||||||
local ShootingWeaponName = EventData.WeaponName -- return weapon type
|
local ShootingWeaponName = EventData.WeaponName -- return weapon type
|
||||||
|
-- get firing coalition
|
||||||
|
local weaponcoalition = EventData.IniGroup:GetCoalition()
|
||||||
-- get detection probability
|
-- get detection probability
|
||||||
|
if self:_CheckCoalition(weaponcoalition) then --avoid overhead on friendly fire
|
||||||
local IsDetected = self:_ShotIsDetected()
|
local IsDetected = self:_ShotIsDetected()
|
||||||
-- convert to text
|
-- convert to text
|
||||||
local DetectedText = "false"
|
local DetectedText = "false"
|
||||||
@ -431,9 +434,8 @@ do
|
|||||||
local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText)
|
local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText)
|
||||||
self:T( text )
|
self:T( text )
|
||||||
local m = MESSAGE:New(text,15,"Info"):ToAllIf(self.debug)
|
local m = MESSAGE:New(text,15,"Info"):ToAllIf(self.debug)
|
||||||
-- get firing coalition
|
--
|
||||||
local weaponcoalition = EventData.IniGroup:GetCoalition()
|
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
||||||
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and self:_CheckCoalition(weaponcoalition) and IsDetected then
|
|
||||||
-- get target data
|
-- get target data
|
||||||
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
||||||
local targetunitname = Unit.getName(targetdata) -- Unit name
|
local targetunitname = Unit.getName(targetdata) -- Unit name
|
||||||
@ -450,6 +452,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
--
|
--
|
||||||
end
|
end
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user