diff --git a/lua/acf/ballistics/ballistics_cl.lua b/lua/acf/ballistics/ballistics_cl.lua index c9dcadc6e..30dcc4102 100644 --- a/lua/acf/ballistics/ballistics_cl.lua +++ b/lua/acf/ballistics/ballistics_cl.lua @@ -1,4 +1,5 @@ local ACF = ACF +local Debug = ACF.Debug local Yellow = Color(255, 255, 0) ACF.BulletEffect = ACF.BulletEffect or {} @@ -15,7 +16,7 @@ local function BulletFlight(Bullet, DeltaTime) Bullet.Effect:ApplyMovement(Bullet) end - debugoverlay.Line(Bullet.SimPosLast, Bullet.SimPos, 15, Yellow) + Debug.Line(Bullet.SimPosLast, Bullet.SimPos, 15, Yellow) end hook.Add("ACF_OnClock", "ACF_ManageBulletEffects", function(_, DeltaTime) diff --git a/lua/acf/ballistics/ballistics_sv.lua b/lua/acf/ballistics/ballistics_sv.lua index 40d1614fc..ab43bac61 100644 --- a/lua/acf/ballistics/ballistics_sv.lua +++ b/lua/acf/ballistics/ballistics_sv.lua @@ -2,6 +2,7 @@ local ACF = ACF local Ballistics = ACF.Ballistics local Damage = ACF.Damage local Clock = ACF.Utilities.Clock +local Debug = ACF.Debug Ballistics.Bullets = Ballistics.Bullets or {} Ballistics.UnusedIndexes = Ballistics.UnusedIndexes or {} @@ -245,7 +246,7 @@ function Ballistics.DoBulletsFlight(Bullet) local traceRes = ACF.trace(FlightTr) -- Does not modify the bullet's original filter - debugoverlay.Line(Bullet.Pos, traceRes.HitPos, 15, Bullet.Color) + Debug.Line(Bullet.Pos, traceRes.HitPos, 15, Bullet.Color) if Bullet.Fuze and Bullet.Fuze <= Clock.CurTime then if not util.IsInWorld(Bullet.Pos) then -- Outside world, just delete diff --git a/lua/acf/ballistics/world_pen_sv.lua b/lua/acf/ballistics/world_pen_sv.lua index c2f2e6697..b4d55610b 100644 --- a/lua/acf/ballistics/world_pen_sv.lua +++ b/lua/acf/ballistics/world_pen_sv.lua @@ -1,5 +1,6 @@ local ACF = ACF local Ballistics = ACF.Ballistics +local Debug = ACF.Debug function Ballistics.DigTrace(From, To, Filter) local Dig = util.TraceLine({ @@ -8,7 +9,7 @@ function Ballistics.DigTrace(From, To, Filter) mask = MASK_NPCSOLID_BRUSHONLY, -- Map and brushes only }) - debugoverlay.Line(From, Dig.StartPos, 30, ColorRand(100, 255), true) + Debug.Line(From, Dig.StartPos, 30, ColorRand(100, 255), true) if Dig.StartSolid then -- Started inside solid map volume if Dig.FractionLeftSolid == 0 then -- Trace could not move inside diff --git a/lua/acf/core/utilities/debug/debug_sh.lua b/lua/acf/core/utilities/debug/debug_sh.lua new file mode 100644 index 000000000..74c8a816c --- /dev/null +++ b/lua/acf/core/utilities/debug/debug_sh.lua @@ -0,0 +1,12 @@ +local ACF = ACF +ACF.Debug = {} + +local CVar = CreateConVar("acf_developer", 0, FCVAR_REPLICATED, "Extra wrapper convar for debugoverlay, requires 'developer 1' as well. Only applies to ACF", 0, 1) + +for k in pairs(debugoverlay) do + ACF.Debug[k] = function(...) + if CVar:GetBool() == false then return end + + debugoverlay[k](...) + end +end \ No newline at end of file diff --git a/lua/acf/damage/explosion_sv.lua b/lua/acf/damage/explosion_sv.lua index df8716cb7..28f7ed196 100644 --- a/lua/acf/damage/explosion_sv.lua +++ b/lua/acf/damage/explosion_sv.lua @@ -1,7 +1,6 @@ local ents = ents local math = math local util = util -local debugoverlay = debugoverlay local ACF = ACF local Damage = ACF.Damage local Objects = Damage.Objects @@ -12,9 +11,10 @@ local TraceData = { start = true, endpos = true, filter = true, - mask = MASK_SOLID, + mask = MASK_SOLID + CONTENTS_AUX, } local Ballistics = ACF.Ballistics +local Debug = ACF.Debug --- Checks whether an entity can be affected by ACF explosions. -- @param Entity The entity to be checked. @@ -93,8 +93,8 @@ function Damage.createExplosion(Position, FillerMass, FragMass, Filter, DmgInfo) if not Filter then Filter = {} end - debugoverlay.Cross(Position, 15, 15, White, true) - --debugoverlay.Sphere(Position, Radius, 15, White, true) + Debug.Cross(Position, 15, 15, White, true) + --Debug.Sphere(Position, Radius, 15, White, true) do -- Screen shaking local Amp = math.min(Power * 0.0005, 50) @@ -154,7 +154,7 @@ function Damage.createExplosion(Position, FillerMass, FragMass, Filter, DmgInfo) local PowerFraction = Power * AreaFraction -- How much of the total power goes to that prop local BlastResult, FragResult, Losses - debugoverlay.Line(Position, HitPos, 15, Red, true) -- Red line for a successful hit + Debug.Line(Position, HitPos, 15, Red, true) -- Red line for a successful hit DmgInfo:SetHitPos(HitPos) DmgInfo:SetHitGroup(Trace.HitGroup) @@ -196,7 +196,7 @@ function Damage.createExplosion(Position, FillerMass, FragMass, Filter, DmgInfo) local Min = HitEnt:OBBMins() local Max = HitEnt:OBBMaxs() - debugoverlay.BoxAngles(HitEnt:GetPos(), Min, Max, HitEnt:GetAngles(), 15, Red) -- Red box on destroyed entities + Debug.BoxAngles(HitEnt:GetPos(), Min, Max, HitEnt:GetAngles(), 15, Red) -- Red box on destroyed entities Filter[#Filter + 1] = HitEnt -- Filter from traces Targets[HitEnt] = nil -- Remove from list @@ -218,14 +218,14 @@ function Damage.createExplosion(Position, FillerMass, FragMass, Filter, DmgInfo) PowerSpent = PowerSpent + PowerFraction * Losses -- Removing the energy spent killing props elseif not Damaged[HitEnt] then - debugoverlay.Line(Position, HitPos, 15, Blue, true) -- Blue line for an invalid entity + Debug.Line(Position, HitPos, 15, Blue, true) -- Blue line for an invalid entity Filter[#Filter + 1] = HitEnt -- Filter from traces Targets[HitEnt] = nil -- Remove from list end else -- Not removed from future damage sweeps so as to provide multiple chances to be hit - debugoverlay.Line(Position, HitPos, 15, White, true) -- White line for a miss. + Debug.Line(Position, HitPos, 15, White, true) -- White line for a miss. end end diff --git a/lua/acf/entities/ammo_types/heat.lua b/lua/acf/entities/ammo_types/heat.lua index 7ea4110f5..41959eed9 100644 --- a/lua/acf/entities/ammo_types/heat.lua +++ b/lua/acf/entities/ammo_types/heat.lua @@ -1,6 +1,7 @@ local ACF = ACF local Classes = ACF.Classes local Damage = ACF.Damage +local Debug = ACF.Debug local AmmoTypes = Classes.AmmoTypes local Ammo = AmmoTypes.Register("HEAT", "AP") @@ -232,12 +233,14 @@ if SERVER then local SpallingSin = math.sqrt(1 - ACF.HEATSpallingArc * ACF.HEATSpallingArc) function Ammo:Detonate(Bullet, HitPos) + if Bullet.Detonated then return end -- Prevents GLATGM spawned HEAT projectiles from detonating twice, or for that matter this running twice at all + Bullet.Detonated = true + local Filler = Bullet.BoomFillerMass local Fragments = Bullet.CasingMass - local Filter = Bullet.Filter local DmgInfo = Objects.DamageInfo(Bullet.Owner, Bullet.Gun) - Damage.createExplosion(HitPos, Filler, Fragments, Filter, DmgInfo) + Damage.createExplosion(HitPos, Filler, Fragments, nil, DmgInfo) -- Find ACF entities in the range of the damage (or simplify to like 6m) local FoundEnts = ents.FindInSphere(HitPos, 250) @@ -252,9 +255,14 @@ if SERVER then end -- Move the jet start to the impact point and back it up by the passive standoff + local Start = Bullet.Standoff * 39.37 + local End = Bullet.BreakupDist * 10 * 39.37 local Direction = Bullet.Flight:GetNormalized() - local JetStart = HitPos - Direction * Bullet.Standoff * 39.37 - local JetEnd = HitPos + Direction * 3000 + local JetStart = HitPos - Direction * Start + local JetEnd = HitPos + Direction * End + + Debug.Cross(JetStart, 15, 15, Color(0,255,0), true) + Debug.Cross(JetEnd, 15, 15, Color(255,0,0), true) local TraceData = {start = JetStart, endpos = JetEnd, filter = {}, mask = Bullet.Mask} local Penetrations = 0 @@ -264,13 +272,16 @@ if SERVER then local TraceRes = ACF.trace(TraceData) local PenHitPos = TraceRes.HitPos local Ent = TraceRes.Entity - debugoverlay.Line(JetStart, PenHitPos, 15, ColorRand(100, 255)) + + if TraceRes.Fraction == 1 and not IsValid(Ent) then break end + + Debug.Line(JetStart, PenHitPos, 15, ColorRand(100, 255)) if Ballistics.TestFilter(Ent, Bullet) == false then TraceData.filter[#TraceData.filter + 1] = TraceRes.Entity print("Skipped",Ent) continue end -- Get the (full jet's) penetration local Standoff = (PenHitPos - JetStart):Length() * 0.0254 -- Back to m - local Penetration = self:GetPenetration(Bullet, Standoff) + local Penetration = self:GetPenetration(Bullet, Standoff) * math.max(0, JetMassPct) -- If it's out of range, stop here if Penetration == 0 then break end @@ -322,11 +333,6 @@ if SERVER then if JetMassPct < 0 then break end - -- If the target is explosive and the armor is penetrated, detonate - if Ent.Detonate then - Ent:Detonate() - end - -- Filter the hit entity if TraceRes.Entity then TraceData.filter[#TraceData.filter + 1] = TraceRes.Entity end diff --git a/lua/effects/acf_explosion.lua b/lua/effects/acf_explosion.lua index 88e719a78..4e3b9df12 100644 --- a/lua/effects/acf_explosion.lua +++ b/lua/effects/acf_explosion.lua @@ -3,6 +3,7 @@ local TraceLine = util.TraceLine local GetIndex = ACF.GetAmmoDecalIndex local GetDecal = ACF.GetRicochetDecal local Sounds = ACF.Utilities.Sounds +local Debug = ACF.Debug local White = Color(255, 255, 255) local Yellow = Color(255, 255, 0) @@ -29,8 +30,8 @@ function EFFECT:Init(Data) local Emitter = ParticleEmitter(Origin) local Mult = LocalPlayer():GetInfoNum("acf_cl_particlemul", 1) - debugoverlay.Cross(Origin, 15, 15, Yellow, true) - --debugoverlay.Sphere(Origin, Size, 15, Yellow, true) + Debug.Cross(Origin, 15, 15, Yellow, true) + --Debug.Sphere(Origin, Size, 15, Yellow, true) TraceData.start = Origin - Normal * 5 TraceData.endpos = Origin + Normal * Radius diff --git a/lua/entities/acf_armor/shared.lua b/lua/entities/acf_armor/shared.lua index 3806658b3..3441bb2d9 100644 --- a/lua/entities/acf_armor/shared.lua +++ b/lua/entities/acf_armor/shared.lua @@ -5,6 +5,8 @@ ENT.WireDebugName = "ACF Armor" ENT.PluralName = "ACF Armor" ENT.IsACFArmor = true +local Debug = ACF.Debug + local function FindOtherSide(Ent, Origin, Dire) local Mesh = Ent:GetPhysicsObject():GetMeshConvexes() local Min = math.huge @@ -77,9 +79,9 @@ function ENT:GetArmor(Trace) local Enter = Trace.HitPos local Length, Exit = TraceThroughObject(Trace) - debugoverlay.Cross(Enter, 3, 0.015, Color(0, 255, 0), true) - debugoverlay.Cross(Exit, 3, 0.015, Color(255, 0, 0), true) - debugoverlay.Line(Enter, Exit, 0.015, Color(0, 255, 255), true) + Debug.Cross(Enter, 3, 0.015, Color(0, 255, 0), true) + Debug.Cross(Exit, 3, 0.015, Color(255, 0, 0), true) + Debug.Line(Enter, Exit, 0.015, Color(0, 255, 255), true) return ACF.RHAe(Length, self.Density) end \ No newline at end of file diff --git a/lua/entities/acf_turret/cl_init.lua b/lua/entities/acf_turret/cl_init.lua index aec71275a..89e9e8854 100644 --- a/lua/entities/acf_turret/cl_init.lua +++ b/lua/entities/acf_turret/cl_init.lua @@ -145,8 +145,6 @@ do -- Overlay local Pos = self:LocalToWorld(self:OBBCenter()) local Origin = Pos + (FWD * X * 1.1) - --debugoverlay.Text(Origin, tostring(Axis), 0.015, false) - render.DrawQuad(Pos, Pos, Pos + (FWD * X * 1.1) + (WorldRightDir * -UX / 4), Pos + (FWD * X * 1.1) + (WorldRightDir * UX / 4), orange) render.DrawQuad(Origin + FWD * UX, Origin + WorldRightDir * UX + FWD * (-UX / 2), Origin, Origin + WorldRightDir * -UX + FWD * (-UX / 2), orange) end diff --git a/lua/entities/acf_turret_computer/init.lua b/lua/entities/acf_turret_computer/init.lua index 47196b845..476c276de 100644 --- a/lua/entities/acf_turret_computer/init.lua +++ b/lua/entities/acf_turret_computer/init.lua @@ -9,6 +9,7 @@ local ACF = ACF local Contraption = ACF.Contraption local Classes = ACF.Classes local Utilities = ACF.Utilities +local Debug = ACF.Debug local Sounds = Utilities.Sounds local Clock = Utilities.Clock local HookRun = hook.Run @@ -262,7 +263,7 @@ do -- Metamethods and other important stuff StartAngle:Normalize() - debugoverlay.Line(Gun:LocalToWorld(Gun.Muzzle),Gun:LocalToWorld(Gun.Muzzle) + StartAngle:Forward() * 32,3,Color(255,0,0),true) + Debug.Line(Gun:LocalToWorld(Gun.Muzzle),Gun:LocalToWorld(Gun.Muzzle) + StartAngle:Forward() * 32,3,Color(255,0,0),true) self.SimData = { MuzzleVel = BD.MuzzleVel, @@ -379,7 +380,7 @@ do -- Metamethods and other important stuff self.SimData.StartAngle = StartAngle self.SimData.Flight = StartAngle:Forward() * Sim.MuzzleVel * 39.37 - debugoverlay.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) + Debug.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) self.SimData.Pos = Vector() @@ -415,7 +416,7 @@ do -- Metamethods and other important stuff local ErrorDir2D = ((Sim.TargetPos - (Sim.StartPos + Sim.Pos)) * Vector(1,1,0)):GetNormalized() local ErrorDist = (Sim.StartPos + Sim.Pos):Distance2D(Sim.TargetPos) - debugoverlay.Line(Sim.StartPos + Sim.Pos,(Sim.StartPos + Sim.Pos) + ErrorDir2D * ErrorDist, 3, Color(255,0,0), true) + Debug.Line(Sim.StartPos + Sim.Pos,(Sim.StartPos + Sim.Pos) + ErrorDir2D * ErrorDist, 3, Color(255,0,0), true) local LocalPosition = (Sim.AdjustedTargetPos - Sim.StartPos) @@ -430,7 +431,7 @@ do -- Metamethods and other important stuff self.SimData.StartAngle = StartAngle self.SimData.Flight = StartAngle:Forward() * Sim.MuzzleVel * 39.37 - debugoverlay.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) + Debug.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) self.SimData.Pos = Vector() @@ -482,7 +483,7 @@ do -- Metamethods and other important stuff Sim.TotalTime = Sim.TotalTime + DeltaTime - debugoverlay.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,5,Color(255,0,0),true) + Debug.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,5,Color(255,0,0),true) local Dir = (Sim.NextPos - Sim.Pos):GetNormalized() @@ -495,15 +496,15 @@ do -- Metamethods and other important stuff local Ratio = (Sim.Pos:Distance(Point)) / FlightDistance Sim.FlightTime = Sim.FlightTime + (DeltaTime * Ratio) - debugoverlay.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,8,Color(0,255,0),true) - debugoverlay.Cross(Sim.StartPos + Sim.Pos,15,8,Color(255,0,0),true) + Debug.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,8,Color(0,255,0),true) + Debug.Cross(Sim.StartPos + Sim.Pos,15,8,Color(255,0,0),true) Sim.Pos = Point Sim.FlightDistance = Sim.FlightDistance + (FlightDistance * Ratio) - debugoverlay.Cross(Sim.StartPos + Point,15,8,Color(255,255,255),true) - debugoverlay.Cross(Sim.StartPos + Sim.NextPos,15,8,Color(0,255,0),true) + Debug.Cross(Sim.StartPos + Point,15,8,Color(255,255,255),true) + Debug.Cross(Sim.StartPos + Sim.NextPos,15,8,Color(0,255,0),true) return self:AdjustSimulation() else