Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Applevangelist committed Sep 30, 2024
2 parents 0d87785 + 846aa82 commit 37998fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
21 changes: 14 additions & 7 deletions Moose Development/Moose/Core/Spawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
28 changes: 22 additions & 6 deletions Moose Development/Moose/Functional/Sead.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
--
-- ### Authors: **applevangelist**, **FlightControl**
--
-- Last Update: Dec 2023
-- Last Update: Oct 2024
--
-- ===
--
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -460,14 +471,19 @@ 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)
--self:T({ SEADWeapon })

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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 37998fb

Please sign in to comment.