Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lua/acf/shared/fuses/c_radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ this.Target = nil
this.Distance = 2000


this.desc = "This fuse tracks around the missile itself in a radius detonating as soon as a target enters the radius. This may lead to early detonations.\nDistance in inches." --This fuse tracks the guidance module's target and detonates when the distance becomes low enough.\nDistance in inches.
this.desc = "This fuse tracks around the missile itself in a radius detonating as soon as a target enters the radius. This may lead to early detonations.\n Useful for countering flares at the cost of detonating further from the target.\nDistance in inches." --This fuse tracks the guidance module's target and detonates when the distance becomes low enough.\nDistance in inches.


-- Configuration information for things like acfmenu.
Expand Down Expand Up @@ -87,6 +87,8 @@ do
--Question: Should radio fuze be limited to detect props in front of the missile only? Its weird it detonates by detecting something behind it.
function this:GetDetonate(missile)

local CPPIOwn = missile:CPPIGetOwner()

if not self:IsArmed() then return false end

local MissilePos = missile.CurPos
Expand All @@ -108,6 +110,8 @@ do

local HitEnt = tr.Entity

if CPPIOwn == HitEnt:CPPIGetOwner() then return false end

if ACF_Check( HitEnt ) then

local HitPos = HitEnt:GetPos()
Expand Down
23 changes: 19 additions & 4 deletions lua/acf/shared/fuses/f_overshoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ this.Target = nil
-- the fuse may trigger at some point under this range - unless it's travelling so fast that it steps right on through.
this.Distance = 2000

this.fuseArmed = false --Arms the fuse once it gets below the target distance. Allows missiles without memory to fuse after losing sight of the target.

this.desc = "If the missile is in the set activation distance, detonates the missile when distance increases as it flys past the target.\nDistance in inches."

this.desc = "Once the arming distance has been reached. Detonates when the missile loses the target which is assumed to be at the closest point.\n NOT reccomended for missiles without inertial guidance.\nDistance in inches."


-- Configuration information for things like acfmenu.
Expand Down Expand Up @@ -49,16 +51,29 @@ do

if not self:IsArmed() then return false end

if (missile.IsDecoyed or false) then return false end
--if (missile.IsDecoyed or false) then return false end

local missilePos = missile:GetPos()
local missileTarget = missile.TargetPos

if not missileTarget then return false end
if not missileTarget then --Target Lost

if not self.fuseArmed then
return false
else --The fuse was armed but we lost sight of the target. Detonate.
return true
end
end

local CurDist = missileTarget:DistToSqr( missilePos )

if CurDist < self.Distance^2 and (missileTarget:DistToSqr( missilePos ) < missileTarget:DistToSqr( missilePos + missile.Flight )) then
if CurDist < self.Distance^2 then
self.fuseArmed = true
--print("isarmed")
end

if self.fuseArmed and (missileTarget:DistToSqr( missilePos ) < missileTarget:DistToSqr( missilePos + missile.Flight )) then


return true

Expand Down
39 changes: 33 additions & 6 deletions lua/acf/shared/guidances/c_antimissile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ end

--Gets all valid targets, does not check angle
function this:GetWhitelistedEntsInCone(missile)

local missilePos = missile:GetPos()
local foundAnim = {}

Expand All @@ -112,7 +111,7 @@ function this:GetWhitelistedEntsInCone(missile)
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

local LOSdata = {}
LOSdata.start = missilePos
Expand All @@ -136,6 +135,8 @@ end
-- Return the first entity found within the seek-tolerance, or the entity within the seek-cone closest to the seek-tolerance.
function this:AcquireLock(missile)

local CPPIOwn = missile:CPPIGetOwner()

local curTime = CurTime()

--We make sure that its seeking between the defined delay
Expand All @@ -150,10 +151,14 @@ function this:AcquireLock(missile)
local missilePos = missile:GetPos()

local bestAng = math.huge
local bestCount = math.huge
local bestent = nil


for _, classifyent in pairs(found) do

if CPPIOwn == classifyent:CPPIGetOwner() then continue end

local entpos = classifyent:GetPos()
local ang = missile:WorldToLocalAngles((entpos - missilePos):Angle()) --Used for testing if inrange
local absang = Angle(math.abs(ang.p),math.abs(ang.y),0) --Since I like ABS so much
Expand All @@ -168,13 +173,35 @@ function this:AcquireLock(missile)
--Could do pythagorean stuff but meh, works 98% of time
local testang = absang.p + absang.y

--Sorts targets as closest to being directly in front of radar
if testang < bestAng then
if classifyent.AMMTarget then --Missile already has an antimissile missile registered to it

if classifyent.AMMTarget == missile then --Is the assigned target this missile?

bestAng = testang
bestent = classifyent
--print("AMM: owned target")
break

bestAng = testang
bestent = classifyent
elseif testang < bestAng then --Sorts targets as closest to being directly in front of radar

bestAng = testang
bestent = classifyent
--print("AMM: standard assignment")

end

else --Missile has no Anti Missile Missile registered to it. TARGET IT.

classifyent.AMMTarget = missile
bestAng = testang
bestent = classifyent
--print("AMM: assigned to target")
break

end



end
end

Expand Down
13 changes: 11 additions & 2 deletions lua/acf/shared/guidances/d_infrared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function this:Configure(missile)
self.HeatAboveAmbient = self.HeatAboveAmbient / (ACF_GetGunValue(missile.BulletData, "seeksensitivity") or 1)
--self.SeekSensitivity = ACF_GetGunValue(missile.BulletData, "seeksensitivity") or this.SeekSensitivity
self.HasIRCCM = ACF_GetGunValue(missile.BulletData, "irccm") or this.HasIRCCM
self.seekReduction = ACF_GetGunValue(missile.BulletData, "seekreduction") or 1

--print("CEent")
--for i, ent in ipairs(ACE.contraptionEnts) do
Expand Down Expand Up @@ -173,7 +174,7 @@ function this:GetWhitelistedContraptionsInCone(missile)
dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

-- skip any ent far than maximum distance
if dist > self.MaximumDistance then continue end
Expand Down Expand Up @@ -231,6 +232,12 @@ function this:AcquireLock(missile)

local DifSeek = vector_origin


local SeekMul = 3 --Seeker Cone multiplier. Used for Seeker Expanded Acquisition making the missile search in a larger area if it lacks a target.
if self.Target then
SeekMul = self.seekReduction or 1
end

if missile.TargetPos then
--print("HasTpos")
DifSeek = missile.TargetPos - missilePos
Expand Down Expand Up @@ -299,7 +306,9 @@ function this:AcquireLock(missile)

absang = Angle(math.abs(ang.p),math.abs(ang.y),0) --Since I like ABS so much

if absang.p < self.SeekCone and absang.y < self.SeekCone then --Entity is within missile cone

local SeekExpanded = self.SeekCone*SeekMul --Expanded Seeker Angle used for searching without a target.
if absang.p < SeekExpanded and absang.y < SeekExpanded then --Entity is within missile cone

testang = absang.p + absang.y --Could do pythagorean stuff but meh, works 98% of time

Expand Down
13 changes: 11 additions & 2 deletions lua/acf/shared/guidances/f_radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function this:Configure(missile)
self.SeekCone = ACF_GetGunValue(missile.BulletData, "seekcone") or this.SeekCone
self.GCMultiplier = ACF_GetGunValue(missile.BulletData, "groundclutterfactor") or this.GCMultiplier
self.HasIRCCM = ACF_GetGunValue(missile.BulletData, "irccm") or this.HasIRCCM
self.seekReduction = ACF_GetGunValue(missile.BulletData, "seekreduction") or 1
end

--TODO: still a bit messy, refactor this so we can check if a flare exits the viewcone too.
Expand Down Expand Up @@ -171,7 +172,8 @@ function this:GetWhitelistedEntsInCone(missile)
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second


local LOSdata = {}
LOSdata.start = missilePos
Expand Down Expand Up @@ -232,6 +234,12 @@ function this:AcquireLock(missile)
local bestAng = math.huge
local bestent = nil


local SeekMul = 3 --Seeker Cone multiplier. Used for Seeker Expanded Acquisition making the missile search in a larger area if it lacks a target.
if self.Target then
SeekMul = self.seekReduction or 1
end

if missile.TargetPos then
--print("HasTpos")
DifSeek = missile.TargetPos - missilePos
Expand Down Expand Up @@ -269,7 +277,8 @@ function this:AcquireLock(missile)
--print(absang.p)
--print(absang.y)

if (absang.p < self.SeekCone and absang.y < self.SeekCone) then --Entity is within missile cone
local SeekExpanded = self.SeekCone*SeekMul --Expanded Seeker Angle used for searching without a target.
if absang.p < SeekExpanded and absang.y < SeekExpanded then --Entity is within missile cone

debugoverlay.Sphere(entpos, 100, 5, Color(255,100,0,255))

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/shared/guidances/h_antiradiation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function this:GetWhitelistedEntsInCone(missile)
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

local LOSdata = {}
LOSdata.start = missilePos
Expand Down
13 changes: 10 additions & 3 deletions lua/acf/shared/guidances/i_radarsemi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function this:Configure(missile)
self.ViewCone = ACF_GetGunValue(missile.BulletData, "viewcone") or this.ViewCone
self.ViewConeCos = math.cos(math.rad(self.ViewCone))
self.HasIRCCM = ACF_GetGunValue(missile.BulletData, "irccm") or this.HasIRCCM
self.seekReduction = ACF_GetGunValue(missile.BulletData, "seekreduction") or 1

local ScanArray = ACE.radarEntities
local MyRadars = {}
Expand Down Expand Up @@ -156,7 +157,7 @@ function this:GetWhitelistedEntsInCone(missile)
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

local LOSdata = {}
LOSdata.start = missilePos
Expand Down Expand Up @@ -202,6 +203,12 @@ function this:AcquireLock(missile)
local bestAng = math.huge
local bestent = nil


local SeekMul = 3 --Seeker Cone multiplier. Used for Seeker Expanded Acquisition making the missile search in a larger area if it lacks a target.
if self.Target then
SeekMul = self.seekReduction or 1
end

if missile.TargetPos then
--print("HasTpos")
DifSeek = missile.TargetPos - missilePos
Expand Down Expand Up @@ -236,8 +243,8 @@ function this:AcquireLock(missile)

--print(absang.p)
--print(absang.y)

if (absang.p < self.ViewCone and absang.y < self.ViewCone) then --Entity is within missile cone
local SeekExpanded = self.SeekCone*SeekMul --Expanded Seeker Angle used for searching without a target.
if absang.p < SeekExpanded and absang.y < SeekExpanded then --Entity is within missile cone

debugoverlay.Sphere(entpos, 100, 5, Color(255,100,0,255))

Expand Down
11 changes: 9 additions & 2 deletions lua/acf/shared/guidances/j_topattackir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function this:Configure(missile)
self.HeatAboveAmbient = self.HeatAboveAmbient / (ACF_GetGunValue(missile.BulletData, "seeksensitivity") or 10)
--self.SeekSensitivity = ACF_GetGunValue(missile.BulletData, "seeksensitivity") or this.SeekSensitivity
self.HasIRCCM = ACF_GetGunValue(missile.BulletData, "irccm") or this.HasIRCCM
self.seekReduction = ACF_GetGunValue(missile.BulletData, "seekreduction") or 1

--print("CEent")
--for i, ent in ipairs(ACE.contraptionEnts) do
Expand Down Expand Up @@ -192,7 +193,7 @@ function this:GetWhitelistedContraptionsInCone(missile)
dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

-- skip any ent far than maximum distance
if dist > self.MaximumDistance then continue end
Expand Down Expand Up @@ -248,6 +249,11 @@ function this:AcquireLock(missile)
local absang = Angle()
local testang = Angle()

local SeekMul = 3 --Seeker Cone multiplier. Used for Seeker Expanded Acquisition making the missile search in a larger area if it lacks a target.
if self.Target then
SeekMul = self.seekReduction or 1
end

if missile.TargetPos then
--print("HasTpos")
DifSeek = missile.TargetPos - missilePos
Expand Down Expand Up @@ -315,7 +321,8 @@ function this:AcquireLock(missile)

absang = Angle(math.abs(ang.p),math.abs(ang.y),0) --Since I like ABS so much

if absang.p < self.SeekCone and absang.y < self.SeekCone then --Entity is within missile cone
local SeekExpanded = self.SeekCone*SeekMul --Expanded Seeker Angle used for searching without a target.
if absang.p < SeekExpanded and absang.y < SeekExpanded then --Entity is within missile cone

testang = absang.p + absang.y --Could do pythagorean stuff but meh, works 98% of time

Expand Down
4 changes: 2 additions & 2 deletions lua/acf/shared/guidances/m_acoustic_spiral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ function this:GetWhitelistedEntsInCone(missile)
local difpos = entpos - missilePos
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
-- skip any ent outside of minimun distance
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

-- skip any ent outside of minimun distance
if dist > self.MaxDistance then continue end
Expand Down
4 changes: 2 additions & 2 deletions lua/acf/shared/guidances/m_acoustic_straight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ function this:GetWhitelistedEntsInCone(missile)
local difpos = entpos - missilePos
local dist = difpos:Length()

-- skip any ent outside of minimun distance
if dist < self.MinimumDistance then continue end
-- skip any ent outside of minimun distance
if dist < self.MinimumDistance and ACF.CurTime < (missile.ActivationTime or math.huge) + 0.5 then continue end --Disables the minimum distance check after a missile has existed for more than a second

-- skip any ent outside of minimun distance
if dist > self.MaxDistance then continue end
Expand Down
Loading
Loading