diff --git a/.github/workflows/workshop-upload.yml b/.github/workflows/workshop-upload.yml index 36a3a9bf..2e618d5f 100644 --- a/.github/workflows/workshop-upload.yml +++ b/.github/workflows/workshop-upload.yml @@ -26,7 +26,7 @@ jobs: - name: Upload to Workshop uses: CFC-Servers/gmod-upload@master with: - id: 3182731439 + id: 3248769787 changelog: "${{ github.event.head_commit.message }}" title: "[ACF-3] Armored Combat Framework - Missiles" type: "tool" diff --git a/lua/acf/core/utilities/entity_tracking_sv.lua b/lua/acf/core/utilities/entity_tracking_sv.lua index b23ad43f..2276eedb 100644 --- a/lua/acf/core/utilities/entity_tracking_sv.lua +++ b/lua/acf/core/utilities/entity_tracking_sv.lua @@ -1,8 +1,9 @@ -local ACF = ACF -local Clock = ACF.Utilities.Clock -local NextUpdate = 0 -local Entities = {} -local Ancestors = {} +local ACF = ACF +local Clock = ACF.Utilities.Clock +local Contraption = ACF.Contraption +local NextUpdate = 0 +local Entities = {} +local Ancestors = {} local Whitelist = { -- Garry's Mod entities @@ -40,7 +41,7 @@ local Whitelist = { } local function GetAncestor(Entity) - local Ancestor = ACF_GetAncestor(Entity) + local Ancestor = Contraption.GetAncestor(Entity) if not IsValid(Ancestor) then return end if Ancestor == Entity then return end diff --git a/lua/acf/entities/guidance/wire_mclos.lua b/lua/acf/entities/guidance/wire_mclos.lua index ce95fb63..b803dbb4 100644 --- a/lua/acf/entities/guidance/wire_mclos.lua +++ b/lua/acf/entities/guidance/wire_mclos.lua @@ -1,5 +1,6 @@ local ACF = ACF local Guidances = ACF.Classes.Guidances +local Sounds = ACF.Utilities.Sounds local Guidance = Guidances.Register("Wire (MCLOS)", "Radio (MCLOS)") function Guidance:Configure(Missile) @@ -30,7 +31,7 @@ else LastFired.GuidanceData:SnapRope(LastFired) end - self.Rope = constraint.CreateKeyframeRope(Vector(), 0.1, "cable/cable2", nil, self.Source, self.InPos, 0, Missile, self.OutPos, 0) + self.Rope = constraint.CreateKeyframeRope(Vector(), 0.1, "acf/core/wire", nil, self.Source, self.InPos, 0, Missile, self.OutPos, 0) self.Rope:SetKeyValue("Width", 0.1) end @@ -54,7 +55,7 @@ else self.Rope = nil if IsValid(self.Source) then - self.Source:EmitSound(SnapSound:format(math.random(3)), nil, nil, ACF.Volume) + Sounds.SendSound(self.Source, SnapSound:format(math.random(3)), nil, nil, 1) end end end diff --git a/lua/effects/acf_glatgmexplosion.lua b/lua/effects/acf_glatgmexplosion.lua index 994d2240..0eb364e7 100644 --- a/lua/effects/acf_glatgmexplosion.lua +++ b/lua/effects/acf_glatgmexplosion.lua @@ -1,6 +1,6 @@ local TraceData = { start = true, endpos = true, mask = true } local TraceLine = util.TraceLine - +local Sounds = ACF.Utilities.Sounds function EFFECT:Init(Data) self.DirVec = Data:GetNormal() @@ -31,8 +31,8 @@ function EFFECT:Airburst() local Mult = self.ParticleMul local sndrad = math.Clamp(Radius * 20, 75, 165) local sndradp = 300 - Radius - sound.Play("ambient/explosions/explode_4.wav", self.Origin, sndrad, math.Clamp(sndradp * 25, 15, 170), ACF.Volume) - sound.Play("ambient/explosions/explode_9.wav", self.Origin, sndrad, math.Clamp(sndradp * 22, 15, 120), ACF.Volume) + Sounds.PlaySound(self.Origin, "ambient/explosions/explode_4.wav", sndrad, math.Clamp(sndradp * 25, 15, 170), 1) + Sounds.PlaySound(self.Origin, "ambient/explosions/explode_9.wav", sndrad, math.Clamp(sndradp * 22, 15, 120), 1) local EF = self.Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin ) if EF then EF:SetVelocity(self.DirVec * 100) diff --git a/lua/entities/acf_computer/init.lua b/lua/entities/acf_computer/init.lua index b8e892bf..5d261373 100644 --- a/lua/entities/acf_computer/init.lua +++ b/lua/entities/acf_computer/init.lua @@ -5,9 +5,11 @@ AddCSLuaFile("cl_init.lua") include("shared.lua") local ACF = ACF +local Contraption = ACF.Contraption local Damage = ACF.Damage local Utilities = ACF.Utilities local Clock = Utilities.Clock +local Sounds = Utilities.Sounds ACF.RegisterClassLink("acf_computer", "acf_rack", function(Computer, Target) if Computer.Weapons[Target] then return false, "This rack is already linked to this computer!" end @@ -79,8 +81,8 @@ local function CheckDistantLinks(Entity, Source) if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, 100, ACF.Volume) - Link:EmitSound(Sound, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, 100, 1) + Sounds.SendSound(Link, Sound, 70, 100, 1) Entity:Unlink(Link) end @@ -121,9 +123,8 @@ do -- Spawn and update function local function UpdateComputer(Entity, Data, Class, Computer) Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = Computer.Model -- Must be set before changing model - Entity:SetModel(Computer.Model) + Contraption.SetModel(Entity, Computer.Model) Entity:PhysicsInit(SOLID_VPHYSICS) Entity:SetMoveType(MOVETYPE_VPHYSICS) @@ -158,11 +159,7 @@ do -- Spawn and update function ACF.Activate(Entity, true) - Entity.ACF.LegalMass = Computer.Mass - Entity.ACF.Model = Computer.Model - - local Phys = Entity:GetPhysicsObject() - if IsValid(Phys) then Phys:SetMass(Computer.Mass) end + Contraption.SetMass(Entity, Computer.Mass) if Entity.OnUpdate then Entity:OnUpdate(Data, Class, Computer) diff --git a/lua/entities/acf_missile/init.lua b/lua/entities/acf_missile/init.lua index 63c58632..87a97481 100644 --- a/lua/entities/acf_missile/init.lua +++ b/lua/entities/acf_missile/init.lua @@ -13,6 +13,7 @@ local ActiveMissiles = ACF.ActiveMissiles local Ballistics = ACF.Ballistics local Classes = ACF.Classes local Clock = ACF.Utilities.Clock +local Sounds = ACF.Utilities.Sounds local Damage = ACF.Damage local Missiles = Classes.Missiles local InputActions = ACF.GetInputActions("acf_missile") @@ -69,7 +70,7 @@ local function LaunchEffect(Missile) if ACF_SOUND_EXT then hook.Run("ACF_SOUND_MISSILE", Missile, Sound) else - Missile:EmitSound(Sound, 180, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Missile, Sound, 180, math.random(99, 101), 1) end end @@ -512,7 +513,7 @@ function ENT:Launch(Delay, IsMisfire) self.Filter[#self.Filter + 1] = Missile end - self:EmitSound("phx/epicmetal_hard.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "phx/epicmetal_hard.wav", 70, math.random(99, 101), 1) self:SetNotSolid(false) self:SetNoDraw(false) self:SetParent() diff --git a/lua/entities/acf_rack/init.lua b/lua/entities/acf_rack/init.lua index c9d5d736..7f7c9b94 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -8,9 +8,11 @@ include("shared.lua") local EMPTY = { Type = "Empty", PropMass = 0, ProjMass = 0, Tracer = 0 } local HookRun = hook.Run local ACF = ACF +local Contraption = ACF.Contraption local Classes = ACF.Classes local Utilities = ACF.Utilities local Clock = Utilities.Clock +local Sounds = Utilities.Sounds local MaxDistance = ACF.LinkDistance * ACF.LinkDistance local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav" @@ -34,8 +36,8 @@ local function CheckDistantLink(Entity, Crate, EntPos) if EntPos:DistToSqr(Crate:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) - Crate:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, math.random(99, 109), 1) + Sounds.SendSound(Crate, Sound, 70, math.random(99, 109), 1) CrateUnlinked = Entity:Unlink(Crate) end @@ -93,9 +95,8 @@ do -- Spawning and Updating -------------------- local function UpdateRack(Entity, Data, Rack) Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = Rack.Model -- Must be set before changing model - Entity:SetModel(Rack.Model) + Contraption.SetModel(Entity, Rack.Model) Entity:PhysicsInit(SOLID_VPHYSICS) Entity:SetMoveType(MOVETYPE_VPHYSICS) @@ -130,11 +131,7 @@ do -- Spawning and Updating -------------------- ACF.Activate(Entity, true) - Entity.ACF.Model = Rack.Model - Entity.ACF.LegalMass = Rack.Mass - - local Phys = Entity:GetPhysicsObject() - if IsValid(Phys) then Phys:SetMass(Rack.Mass) end + Contraption.SetMass(Entity, Rack.Mass) do -- Removing old missiles local Missiles = Entity.Missiles @@ -324,7 +321,7 @@ do -- Custom ACF damage ------------------------ util.Effect("Sparks", Effect, true, true) - Rack:EmitSound(SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), ACF.Volume) + Sounds.SendSound(Rack, SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), 1) timer.Simple(math.Rand(0.5, 2), function() if not IsValid(Rack) then return end @@ -477,7 +474,7 @@ do -- Entity Inputs ---------------------------- Entity:UpdatePoint() if Entity.ForcedIndex then - Entity:EmitSound("buttons/blip2.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Entity, "buttons/blip2.wav", 70, math.random(99, 101), 1) end end) @@ -558,7 +555,7 @@ do -- Firing ----------------------------------- self:UpdatePoint() else - self:EmitSound("weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), 1) Delay = 1 end @@ -617,7 +614,7 @@ do -- Loading ---------------------------------- local Pos, Ang = GetMissileAngPos(Crate.BulletData, Point) local Missile = MakeACF_Missile(Rack.Owner, Pos, Ang, Rack, Point, Crate) - Rack:EmitSound("acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Rack, "acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), 1) return Missile end @@ -663,7 +660,7 @@ do -- Loading ---------------------------------- if not IsValid(Missile) then Missile = nil else - self:EmitSound("acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), 1) Point.State = "Loaded" Point.NextFire = nil diff --git a/lua/entities/acf_radar/init.lua b/lua/entities/acf_radar/init.lua index 152933fa..ffbb2f72 100644 --- a/lua/entities/acf_radar/init.lua +++ b/lua/entities/acf_radar/init.lua @@ -4,6 +4,7 @@ AddCSLuaFile("shared.lua") include("shared.lua") local ACF = ACF +local Contraption = ACF.Contraption ACF.RegisterClassLink("acf_radar", "acf_rack", function(Radar, Target) if Radar.Weapons[Target] then return false, "This rack is already linked to this radar!" end @@ -39,6 +40,7 @@ end) local Radars = ACF.ActiveRadars local Damage = ACF.Damage local CheckLegal = ACF.CheckLegal +local Sounds = ACF.Utilities.Sounds local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav" local MaxDistance = ACF.LinkDistance * ACF.LinkDistance local TraceData = { start = true, endpos = true, mask = MASK_SOLID_BRUSHONLY } @@ -212,7 +214,7 @@ local function ScanForEntities(Entity) if Count ~= Entity.TargetCount then if Count > Entity.TargetCount then - Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1) end Entity.TargetCount = Count @@ -271,8 +273,8 @@ local function CheckDistantLinks(Entity, Source) if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, 100, ACF.Volume) - Link:EmitSound(Sound, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, 100, 1) + Sounds.SendSound(Link, Sound, 70, 100, 1) Entity:Unlink(Link) end @@ -332,9 +334,8 @@ do -- Spawn and Update functions local Delay = Radar.ThinkDelay Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = Radar.Model -- Must be set before changing model - Entity:SetModel(Radar.Model) + Contraption.SetModel(Entity, Radar.Model) Entity:PhysicsInit(SOLID_VPHYSICS) Entity:SetMoveType(MOVETYPE_VPHYSICS) @@ -370,11 +371,7 @@ do -- Spawn and Update functions ACF.Activate(Entity, true) - Entity.ACF.Model = Radar.Model - Entity.ACF.LegalMass = Radar.Mass - - local Phys = Entity:GetPhysicsObject() - if IsValid(Phys) then Phys:SetMass(Radar.Mass) end + Contraption.SetMass(Entity, Radar.Mass) end function MakeACF_Radar(Player, Pos, Angle, Data) diff --git a/lua/entities/acf_receiver/init.lua b/lua/entities/acf_receiver/init.lua index 53b89b12..84a87a7c 100644 --- a/lua/entities/acf_receiver/init.lua +++ b/lua/entities/acf_receiver/init.lua @@ -5,6 +5,7 @@ AddCSLuaFile("shared.lua") include("shared.lua") local ACF = ACF +local Contraption = ACF.Contraption --===============================================================================================-- -- Local Funcs and Vars @@ -12,6 +13,7 @@ local ACF = ACF local Damage = ACF.Damage local CheckLegal = ACF.CheckLegal +local Sounds = ACF.Utilities.Sounds local TimerExists = timer.Exists local TimerCreate = timer.Create local TimerRemove = timer.Remove @@ -60,7 +62,7 @@ local function CheckReceive(Entity) WireLib.TriggerOutput(Entity, "Detected", IsDetected and 1 or 0) if IsDetected then - Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1) end Entity:UpdateOverlay() @@ -131,9 +133,8 @@ do -- Spawn and Update functions local Delay = Receiver.ThinkDelay Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = Receiver.Model -- Must be set before changing model - Entity:SetModel(Receiver.Model) + Contraption.SetModel(Entity, Receiver.Model) Entity:PhysicsInit(SOLID_VPHYSICS) Entity:SetMoveType(MOVETYPE_VPHYSICS) @@ -169,11 +170,7 @@ do -- Spawn and Update functions ACF.Activate(Entity, true) - Entity.ACF.Model = Receiver.Model - Entity.ACF.LegalMass = Receiver.Mass - - local Phys = Entity:GetPhysicsObject() - if IsValid(Phys) then Phys:SetMass(Receiver.Mass) end + Contraption.SetMass(Entity, Receiver.Mass) end function MakeACF_Receiver(Player, Pos, Ang, Data) diff --git a/materials/acf/core/wire.vmt b/materials/acf/core/wire.vmt new file mode 100644 index 00000000..293c449d --- /dev/null +++ b/materials/acf/core/wire.vmt @@ -0,0 +1,9 @@ +"UnlitGeneric" +{ + "$basetexture" "acf/core/wire" + "$basetexturetransform" "center 0 0 scale 1 10 rotate 0 translate 1 0" + "$nocull" 1 + "$MinLight" 1 + "$MaxLight" 1 + "$additive" 1 +} \ No newline at end of file diff --git a/materials/acf/core/wire.vtf b/materials/acf/core/wire.vtf new file mode 100644 index 00000000..a57acc5f Binary files /dev/null and b/materials/acf/core/wire.vtf differ