Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
-networking
-convar changes
-fix
  • Loading branch information
KemGus committed Sep 21, 2023
1 parent 20e15e3 commit 4e23494
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
3 changes: 2 additions & 1 deletion lua/acf/shared/sv_ace_networking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
util.AddNetworkString( "ACE_SendMessage" )
util.AddNetworkString( "ACE_Wind" )
25 changes: 24 additions & 1 deletion lua/autorun/acf_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
37 changes: 7 additions & 30 deletions lua/effects/acf_smoke/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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

Check warning on line 97 in lua/effects/acf_smoke/init.lua

View workflow job for this annotation

GitHub Actions / build

"Unused variable"

Unused variable: i
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)
Expand Down

0 comments on commit 4e23494

Please sign in to comment.