From 4fe64cb8e77099595b5cdddcba00f0cdce0062f5 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:03:54 -0400 Subject: [PATCH 1/5] Use new sound library functions --- lua/acf/entities/guidance/wire_mclos.lua | 3 ++- lua/effects/acf_glatgmexplosion.lua | 6 +++--- lua/entities/acf_computer/init.lua | 5 +++-- lua/entities/acf_missile/init.lua | 5 +++-- lua/entities/acf_rack/init.lua | 15 ++++++++------- lua/entities/acf_radar/init.lua | 7 ++++--- lua/entities/acf_receiver/init.lua | 3 ++- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lua/acf/entities/guidance/wire_mclos.lua b/lua/acf/entities/guidance/wire_mclos.lua index ce95fb63..b4aa4013 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) @@ -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..f0eedcf6 100644 --- a/lua/entities/acf_computer/init.lua +++ b/lua/entities/acf_computer/init.lua @@ -8,6 +8,7 @@ local ACF = ACF 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 +80,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 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 63dbe355..425c2d49 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -11,6 +11,7 @@ local ACF = ACF local Classes = ACF.Classes local Utilities = ACF.Utilities local Clock = Utilities.Clock +local Sounds = Utilities.Sounds local function UpdateTotalAmmo(Entity) local Total = 0 @@ -164,8 +165,8 @@ do -- Spawning and Updating -------------------- if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) - Link:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, math.random(99, 109), 1) + Sounds.SendSound(Link, Sound, 70, math.random(99, 109), 1) Entity:Unlink(Link) end @@ -312,7 +313,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 @@ -464,7 +465,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) @@ -545,7 +546,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 @@ -604,7 +605,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 @@ -650,7 +651,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 4be2b3c2..68ed209f 100644 --- a/lua/entities/acf_radar/init.lua +++ b/lua/entities/acf_radar/init.lua @@ -39,6 +39,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 +213,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 +272,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 diff --git a/lua/entities/acf_receiver/init.lua b/lua/entities/acf_receiver/init.lua index 53b89b12..1357be3c 100644 --- a/lua/entities/acf_receiver/init.lua +++ b/lua/entities/acf_receiver/init.lua @@ -12,6 +12,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 +61,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() From 1d3eb785732549fa2efafd5817b3a3e0f29e0c4d Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Thu, 25 Jan 2024 22:59:24 -0500 Subject: [PATCH 2/5] Move stuff to ACF.Contraption namespace --- lua/acf/core/utilities/entity_tracking_sv.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 From 8a84150e6e4ca3af58eedeecb3aa9dc84b2dbfb6 Mon Sep 17 00:00:00 2001 From: LiddulBOFH <13317534+LiddulBOFH@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:25:13 -0600 Subject: [PATCH 3/5] Use new detoured mass/model change functions Contraption.SetMass/Contraption.SetModel are convenience functions which will set Entity.ACF.Mass and Entity.ACF.Model respectively --- lua/entities/acf_computer/init.lua | 10 +++------- lua/entities/acf_rack/init.lua | 10 +++------- lua/entities/acf_radar/init.lua | 10 +++------- lua/entities/acf_receiver/init.lua | 10 +++------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/lua/entities/acf_computer/init.lua b/lua/entities/acf_computer/init.lua index f0eedcf6..5d261373 100644 --- a/lua/entities/acf_computer/init.lua +++ b/lua/entities/acf_computer/init.lua @@ -5,6 +5,7 @@ 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 @@ -122,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) @@ -159,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_rack/init.lua b/lua/entities/acf_rack/init.lua index 425c2d49..0e1105d9 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -8,6 +8,7 @@ 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 @@ -79,9 +80,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) @@ -116,11 +116,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 diff --git a/lua/entities/acf_radar/init.lua b/lua/entities/acf_radar/init.lua index 925e4b91..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 @@ -333,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) @@ -371,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 1357be3c..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 @@ -132,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) @@ -170,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) From f5329ea523381953efff5bb2c821adc9492a38ea Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:21:58 -0400 Subject: [PATCH 4/5] Add new missile wire texture by ghosteh --- lua/acf/entities/guidance/wire_mclos.lua | 2 +- materials/acf/core/wire.vmt | 9 +++++++++ materials/acf/core/wire.vtf | Bin 0 -> 5624 bytes 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 materials/acf/core/wire.vmt create mode 100644 materials/acf/core/wire.vtf diff --git a/lua/acf/entities/guidance/wire_mclos.lua b/lua/acf/entities/guidance/wire_mclos.lua index b4aa4013..b803dbb4 100644 --- a/lua/acf/entities/guidance/wire_mclos.lua +++ b/lua/acf/entities/guidance/wire_mclos.lua @@ -31,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 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 0000000000000000000000000000000000000000..a57acc5f7ecb598887483ea093aa4dd90a2950b0 GIT binary patch literal 5624 zcmeHKziZS`9Dhv*W6wfB0v+$bOf^u42!bGS5Goc#?lqx=lw7A$3Y9KryM(g{itXfW z3Z)K054&Y_a*)HJAY?C85UxTM|A6}W{&!DM|M|H= z{f}{>&d0xAf8rALf4Q@K^7&VBD*6I_)J&zk`#93~8cBT$`0_&ESNpvv`!L#xLw=bQ zv`_aV-5zPp(ryrT_k~V9#8F~7$?j@NuLjl4_r*+K(8lLj=&t z*SXfOXLWN9W^j%Q+8*;a(h4Q>7xYnw1Nx5uNP}vu9p}B;X(w+@Ilu>bK>jp4!*f6Q z=lMn0;4kUGf6Vg>{ChmV{otSY0esR!la>PIN{7w8%thu`7IF0`W|LmXW+rU5O z;3@FW`u$D(59a@1{txEA%)U2F^!>s7AI$&3{6GEo|6u Date: Sat, 18 May 2024 00:52:07 -0400 Subject: [PATCH 5/5] Swap IDs --- .github/workflows/workshop-upload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"