diff --git a/lua/acf/shared/sv_ace_networking.lua b/lua/acf/shared/sv_ace_networking.lua index b399a4d0..3446102f 100644 --- a/lua/acf/shared/sv_ace_networking.lua +++ b/lua/acf/shared/sv_ace_networking.lua @@ -8,4 +8,5 @@ util.AddNetworkString( "acf_smokewind" ) util.AddNetworkString( "ACE_CamOverride" ) util.AddNetworkString( "ACE_DPStatus" ) util.AddNetworkString( "ACE_Scalable_Network" ) -util.AddNetworkString( "ACE_SendMessage" ) \ No newline at end of file +util.AddNetworkString( "ACE_SendMessage" ) +util.AddNetworkString( "ACE_Wind" ) \ No newline at end of file diff --git a/lua/autorun/acf_globals.lua b/lua/autorun/acf_globals.lua index 024a10bd..727fa087 100644 --- a/lua/autorun/acf_globals.lua +++ b/lua/autorun/acf_globals.lua @@ -72,7 +72,7 @@ CreateConVar("acf_explosions_scaled_he_max", 100, FCVAR_ARCHIVE) CreateConVar("acf_explosions_scaled_ents_max", 5, FCVAR_ARCHIVE) --Smoke -CreateConVar("acf_wind", 300, FCVAR_ARCHIVE) +CreateConVar("acf_wind", 300, FCVAR_ARCHIVE + FCVAR_REPLICATED) if CLIENT then @@ -474,6 +474,29 @@ do end + +if CLIENT then + ACF.Wind = Vector(math.Rand(-1, 1), math.Rand(-1, 1), 0):GetNormalized() + + net.Receive("ACE_Wind", function() + ACF.Wind = Vector(net.ReadFloat(), net.ReadFloat(), 0) + end) +else + local curveFactor = 2 + local reset_timer = 60 + + timer.Create("ACE_Wind", reset_timer, 0, function() + local smokeDir = Vector(math.Rand(-1, 1), math.Rand(-1, 1), 0):GetNormalized() + local wind = (math.random() ^ curveFactor) * smokeDir * GetConVar("acf_wind"):GetFloat() + net.Start("ACE_Wind") + net.WriteFloat(wind.x) + net.WriteFloat(wind.y) + net.Broadcast() + end) +end + + + cleanup.Register( "aceexplosives" ) AddCSLuaFile("autorun/acf_missile/folder.lua") diff --git a/lua/effects/acf_smoke/init.lua b/lua/effects/acf_smoke/init.lua index 7faac4d1..9dc12e48 100644 --- a/lua/effects/acf_smoke/init.lua +++ b/lua/effects/acf_smoke/init.lua @@ -53,38 +53,15 @@ local smokes = { "particle/smokesprites_0008" } -local lastWindUpdateTime = 0 -local windDirection = Vector(0, 0, 0) -- Initialize with a default wind direction - -local lastWindUpdateTime = 0 -local windStrength = 0 -- Initialize windStrength to 0 -local curveFactor = 2.5 -- How biased the wind strength to 0 is (curvature!!) - -local function smokePuff(self, Ground, ShootVector, Radius, RadiusMod, Density, i, SmokeColor, DeploySpeed, Lifetime) - local currentTime = CurTime() - local wind = GetConVar("acf_wind"):GetFloat() - -- Check if it's time to update the wind direction and windStrength - local reset_timer = 60 -- Update wind direction every n seconds (adjust the time interval as needed) - if currentTime - lastWindUpdateTime > reset_timer then - lastWindUpdateTime = currentTime - - -- Generate a new random wind direction - windDirection = Vector(math.Rand(-1, 1), math.Rand(-1, 1), 0):GetNormalized() - - local randValue = math.Rand(0, 1) - windStrength = (randValue ^ curveFactor) * wind - end +local function smokePuff(self, Ground, ShootVector, Radius, RadiusMod, SmokeColor, DeploySpeed, Lifetime) local Smoke = self.Emitter:Add(smokes[math.random(1, #smokes)], Ground.HitPos) if Smoke then -- Calculate the wind effect on velocity and gravity - local velocity = (ShootVector + Vector(0, 0, 0.2)) * (Radius * RadiusMod) * DeploySpeed - local gravity = Vector(0, 0, math.Rand(5, 15)) - -- Apply wind effect based on wind direction and windStrength - local windEffect = windDirection * (windStrength * math.Rand(0.5, 1.5)) - velocity = velocity + windEffect * (i / Density) - gravity = gravity + windEffect * 0.2 + local velocity = (ShootVector + Vector(0, 0, 0.2)) * DeploySpeed + local gravity = Vector(0, 0, 0) + ACF.Wind * 0.2 + Smoke:SetVelocity(velocity) Smoke:SetLifeTime(0) @@ -95,7 +72,7 @@ local function smokePuff(self, Ground, ShootVector, Radius, RadiusMod, Density, Smoke:SetEndSize(math.Clamp(Radius * RadiusMod * 4, 150, 4000)) Smoke:SetRoll(math.Rand(0, 360)) Smoke:SetRollDelta(math.Rand(-0.2, 0.2)) - Smoke:SetAirResistance(100 * DeploySpeed) + Smoke:SetAirResistance(100) Smoke:SetGravity(gravity) Smoke:SetColor(SmokeColor.x, SmokeColor.y, SmokeColor.z) end @@ -116,9 +93,9 @@ function EFFECT:SmokeFiller( Ground, SmokeColor, Radius, DeploySpeed, Lifetime ) local ShootVector = Ground.HitNormal * 0.5 --print(Radius .. ", " .. Density) - smokePuff(self, Ground, Vector(0, 0, 0.3), Radius, 1.5, Density, 0, SmokeColor, DeploySpeed, Lifetime) --smoke filler initial upward puff + smokePuff(self, Ground, Vector(0, 0, 0.3), Radius, 1.5, SmokeColor, DeploySpeed, Lifetime) --smoke filler initial upward puff for i = 0, math.floor(Density) do - smokePuff(self, Ground, ShootVector, Radius, 1, Density, i, SmokeColor, DeploySpeed, Lifetime) + smokePuff(self, Ground, ShootVector, Radius, 1, SmokeColor, DeploySpeed, Lifetime) ShootVector = Angle and Angle:Up() Angle:RotateAroundAxis(Angle:Forward(), 360 / Density)