mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
fixes for #SEAD and #SPAWN
This commit is contained in:
parent
68298fc585
commit
846aa823d4
@ -3956,12 +3956,17 @@ end
|
||||
-- @return #number count
|
||||
function SPAWN:_CountAliveUnits()
|
||||
local count = 0
|
||||
--self:I("self.SpawnAliasPrefix="..tostring(self.SpawnAliasPrefix).." | self.SpawnTemplatePrefix="..tostring(self.SpawnTemplatePrefix))
|
||||
if self.SpawnAliasPrefix then
|
||||
if not self.SpawnAliasPrefixEscaped then self.SpawnAliasPrefixEscaped = string.gsub(self.SpawnAliasPrefix,"[%p%s]",".") end
|
||||
--self:I("self.SpawnAliasPrefixEscaped="..tostring(self.SpawnAliasPrefixEscaped))
|
||||
local SpawnAliasPrefix = self.SpawnAliasPrefixEscaped
|
||||
local agroups = GROUP:FindAllByMatching(SpawnAliasPrefix)
|
||||
for _,_grp in pairs(agroups) do
|
||||
--self:I("Group Name = " .. _grp:GetName())
|
||||
local game = self:_GetPrefixFromGroupName(_grp.GroupName)
|
||||
--self:I("Game = "..game)
|
||||
--self:I("Count = ".._grp:CountAliveUnits())
|
||||
if game and game == self.SpawnAliasPrefix then
|
||||
count = count + _grp:CountAliveUnits()
|
||||
end
|
||||
@ -3977,15 +3982,16 @@ function SPAWN:_CountAliveUnits()
|
||||
end
|
||||
end
|
||||
end
|
||||
return count
|
||||
self.AliveUnits = count
|
||||
return self
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #SPAWN self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function SPAWN:_OnDeadOrCrash( EventData )
|
||||
--self:T2( "Dead or crash event ID "..tostring(EventData.id or 0))
|
||||
--self:T2( "Dead or crash event for "..tostring(EventData.IniUnitName or "none") )
|
||||
--self:I( "Dead or crash event ID "..tostring(EventData.id or 0))
|
||||
--self:I( "Dead or crash event for "..tostring(EventData.IniUnitName or "none") )
|
||||
|
||||
--if EventData.id == EVENTS.Dead then return end
|
||||
|
||||
@ -3997,11 +4003,12 @@ function SPAWN:_OnDeadOrCrash( EventData )
|
||||
local EventPrefix = self:_GetPrefixFromGroupName(unit.GroupName)
|
||||
|
||||
if EventPrefix then -- EventPrefix can be nil if no # is found, which means, no spawnable group!
|
||||
--self:T2(string.format("EventPrefix = %s | SpawnAliasPrefix = %s | Old AliveUnits = %d",EventPrefix or "",self.SpawnAliasPrefix or "",self.AliveUnits or 0))
|
||||
--self:I(string.format("EventPrefix = %s | SpawnAliasPrefix = %s | Old AliveUnits = %d",EventPrefix or "",self.SpawnAliasPrefix or "",self.AliveUnits or 0))
|
||||
if EventPrefix == self.SpawnTemplatePrefix or ( self.SpawnAliasPrefix and EventPrefix == self.SpawnAliasPrefix ) and self.AliveUnits > 0 then
|
||||
--self:I( { "Dead event: " .. EventPrefix } )
|
||||
--self.AliveUnits = self.AliveUnits - 1
|
||||
self.AliveUnits = self:_CountAliveUnits()
|
||||
--self:I( { "Dead event: " .. EventPrefix } )
|
||||
--self.AliveUnits = self.AliveUnits - 1
|
||||
self:ScheduleOnce(1,self._CountAliveUnits,self)
|
||||
--self.AliveUnits = self:_CountAliveUnits()
|
||||
--self:I( "New Alive Units: " .. self.AliveUnits )
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
--
|
||||
-- ### Authors: **applevangelist**, **FlightControl**
|
||||
--
|
||||
-- Last Update: Dec 2023
|
||||
-- Last Update: Oct 2024
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -28,6 +28,16 @@
|
||||
|
||||
---
|
||||
-- @type SEAD
|
||||
-- @field #string ClassName The Class Name.
|
||||
-- @field #table TargetSkill Table of target skills.
|
||||
-- @field #table SEADGroupPrefixes Table of SEAD prefixes.
|
||||
-- @field #table SuppressedGroups Table of currently suppressed groups.
|
||||
-- @field #number EngagementRange Engagement Range.
|
||||
-- @field #number Padding Padding in seconds.
|
||||
-- @field #function CallBack Callback function for suppression plans.
|
||||
-- @field #boolean UseCallBack Switch for callback function to be used.
|
||||
-- @field #boolean debug Debug switch.
|
||||
-- @field #boolen WeaponTrack Track switch, if true track weapon speed for 30 secs.
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- Make SAM sites execute evasive and defensive behaviour when being fired upon.
|
||||
@ -56,10 +66,11 @@ SEAD = {
|
||||
SEADGroupPrefixes = {},
|
||||
SuppressedGroups = {},
|
||||
EngagementRange = 75, -- default 75% engagement range Feature Request #1355
|
||||
Padding = 10,
|
||||
Padding = 15,
|
||||
CallBack = nil,
|
||||
UseCallBack = false,
|
||||
debug = false,
|
||||
WeaponTrack = false,
|
||||
}
|
||||
|
||||
--- Missile enumerators
|
||||
@ -144,7 +155,7 @@ function SEAD:New( SEADGroupPrefixes, Padding )
|
||||
self:AddTransition("*", "ManageEvasion", "*")
|
||||
self:AddTransition("*", "CalculateHitZone", "*")
|
||||
|
||||
self:I("*** SEAD - Started Version 0.4.6")
|
||||
self:I("*** SEAD - Started Version 0.4.7")
|
||||
return self
|
||||
end
|
||||
|
||||
@ -371,7 +382,7 @@ function SEAD:onafterManageEvasion(From,Event,To,_targetskill,_targetgroup,SEADP
|
||||
reach = wpndata[1] * 1.1
|
||||
local mach = wpndata[2]
|
||||
wpnspeed = math.floor(mach * 340.29)
|
||||
if Weapon then
|
||||
if Weapon and Weapon:GetSpeed() > 0 then
|
||||
wpnspeed = Weapon:GetSpeed()
|
||||
self:T(string.format("*** SEAD - Weapon Speed from WEAPON: %f m/s",wpnspeed))
|
||||
end
|
||||
@ -460,7 +471,7 @@ function SEAD:HandleEventShot( EventData )
|
||||
local SEADWeapon = EventData.Weapon -- Identify the weapon fired
|
||||
local SEADWeaponName = EventData.WeaponName -- return weapon type
|
||||
|
||||
local WeaponWrapper = WEAPON:New(EventData.Weapon)
|
||||
local WeaponWrapper = WEAPON:New(EventData.Weapon) -- Wrapper.Weapon#WEAPON
|
||||
--local SEADWeaponSpeed = WeaponWrapper:GetSpeed() -- mps
|
||||
|
||||
self:T( "*** SEAD - Missile Launched = " .. SEADWeaponName)
|
||||
@ -468,6 +479,11 @@ function SEAD:HandleEventShot( EventData )
|
||||
|
||||
if self:_CheckHarms(SEADWeaponName) then
|
||||
self:T( '*** SEAD - Weapon Match' )
|
||||
if self.WeaponTrack == true then
|
||||
WeaponWrapper:SetFuncTrack(function(weapon) env.info(string.format("*** Weapon Speed: %d m/s",weapon:GetSpeed() or -1)) end)
|
||||
WeaponWrapper:StartTrack(0.1)
|
||||
WeaponWrapper:StopTrack(30)
|
||||
end
|
||||
local _targetskill = "Random"
|
||||
local _targetgroupname = "none"
|
||||
local _target = EventData.Weapon:getTarget() -- Identify target
|
||||
@ -520,7 +536,7 @@ function SEAD:HandleEventShot( EventData )
|
||||
end
|
||||
if SEADGroupFound == true then -- yes we are being attacked
|
||||
if string.find(SEADWeaponName,"ADM_141",1,true) then
|
||||
self:__ManageEvasion(2,_targetskill,_targetgroup,SEADPlanePos,SEADWeaponName,SEADGroup,0,WeaponWrapper)
|
||||
self:__ManageEvasion(2,_targetskill,_targetgroup,SEADPlanePos,SEADWeaponName,SEADGroup,2,WeaponWrapper)
|
||||
else
|
||||
self:ManageEvasion(_targetskill,_targetgroup,SEADPlanePos,SEADWeaponName,SEADGroup,0,WeaponWrapper)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user