Skip to content

Commit

Permalink
gravgun support
Browse files Browse the repository at this point in the history
  • Loading branch information
meetric1 committed Jul 25, 2024
1 parent 880bb8b commit 9deacd1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
10 changes: 9 additions & 1 deletion lua/autorun/gwater2_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,12 @@ timer.Create("gwater2_tick", limit_fps, 0, function()
end)

hook.Add("InitPostEntity", "gwater2_addprop", gwater2.reset_solver)
hook.Add("OnEntityCreated", "gwater2_addprop", function(ent) timer.Simple(0, function() add_prop(ent) end) end) // timer.0 so data values are setup correctly
hook.Add("OnEntityCreated", "gwater2_addprop", function(ent) timer.Simple(0, function() add_prop(ent) end) end) // timer.0 so data values are setup correctly

hook.Add("gwater2_pretick", "gravgun", function()
local lp = LocalPlayer()
if !lp:KeyDown(IN_ATTACK2) then return end
if IsValid(LocalPlayer():GetActiveWeapon()) and LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physcannon" then
gwater2.solver:AddForceField(LocalPlayer():EyePos() + LocalPlayer():GetAimVector() * 170, 150, -60, 0, true)
end
end)
10 changes: 5 additions & 5 deletions lua/entities/gwater2_blackhole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function ENT:SetupDataTables()

self.PARTICLE_EMITTER = ParticleEmitter(self:GetPos(), false)
hook.Add("gwater2_pretick", self, function()
gwater2.solver:AddForceField(self:GetPos(), self:GetRadius(), self:GetStrength(), self:GetMode(), self:GetLinear())
gwater2.solver:AddForceField(self:GetPos(), self:GetRadius(), -self:GetStrength(), self:GetMode(), self:GetLinear())
end)
end

Expand All @@ -45,7 +45,7 @@ if SERVER then
ent:Activate()

ent:SetRadius(1000)
ent:SetStrength(-50)
ent:SetStrength(50)
ent:SetMode(0)
ent:SetLinear(1)

Expand All @@ -59,7 +59,7 @@ elseif CLIENT then
local part = self.PARTICLE_EMITTER:Add("particle/warp_ripple", self:GetPos())
part:SetVelocity(Vector())
part:SetGravity(Vector())
part:SetDieTime(0.1)
part:SetDieTime(FrameTime() * 10)
//part:SetColor(Color(255, 255, 255, 0))
part:SetStartSize(50)
part:SetEndSize(50)
Expand All @@ -69,10 +69,10 @@ elseif CLIENT then
local part = self.PARTICLE_EMITTER:Add("particle/warp1_warp", self:GetPos())
part:SetVelocity(Vector())
part:SetGravity(Vector())
part:SetDieTime(0.2)
part:SetDieTime(FrameTime() * 20)
part:SetColor(Color(255, 255, 255))
part:SetStartSize(25 + (math.sin(CurTime() * 2) * 3))
part:SetEndSize(0)
part:SetEndSize(22)
//part:SetStartAlpha(255)
part:SetLighting(false)
self:SetNextClientThink(CurTime() + 0.001)
Expand Down
2 changes: 1 addition & 1 deletion lua/gwater2_shaders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ hook.Add("PostDrawOpaqueRenderables", "gwater2_render", function(depth, sky, sky
else
-- no absorption calculations, so just use solid color
render.PushRenderTarget(cache_absorption)
render.Clear(10, 10, 10, 10)
render.Clear(15, 15, 15, 10)
render.PopRenderTarget()
end

Expand Down
2 changes: 1 addition & 1 deletion lua/gwater2_swimming.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

local GWATER2_PARTICLES_TO_SWIM = 30
local GWATER2_PARTICLES_TO_SWIM = 50

-- swim code provided by kodya (with permission)
local gravity_convar = GetConVar("sv_gravity")
Expand Down
2 changes: 1 addition & 1 deletion materials/gwater2/finalpass.vmt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GWaterFinalpass {
$envmap "env_cubemap"
$radius 10
$ior 1.333
$reflectance 0.6
$reflectance 0.65
$screentexture "_rt_fullframefb"
$color2 "[209 237 255 25]"
$flashlight 1
Expand Down

0 comments on commit 9deacd1

Please sign in to comment.