Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lua/entities/gmod_wire_turret.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ ENT.WireDebugName = "Turret"

if ( CLIENT ) then return end -- No more client

local NumEnabled = CreateConVar("wire_turret_numbullets_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or Disable the numbullets function of wire turrets")
local TracerEnabled = CreateConVar("wire_turret_tracer_enabled", 1, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Enable or disable the tracer per x bullet function of wire turrets")
local MinTurretDelay = CreateConVar("wire_turret_delay_minimum", 0.05, {FCVAR_NOTIFY, FCVAR_ARCHIVE}, "Set the minimum allowed value for wire turrets")

function ENT:Initialize()
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
Expand Down Expand Up @@ -114,20 +118,16 @@ function ENT:SetSound( sound )
end

function ENT:SetDelay( delay )
local check = game.SinglePlayer() -- clamp delay if it's not single player
local limit = check and 0.01 or 0.05
self.delay = math.Clamp( delay, limit, 1 )
self.delay = math.Clamp( delay, MinTurretDelay:GetFloat(), 2 )
end

function ENT:SetNumBullets( numbullets )
local check = game.SinglePlayer() -- clamp num bullets if it's not single player
local limit = math.floor( math.max( 1, numbullets ) )
self.numbullets = check and limit or math.Clamp( limit, 1, 10 )
self.numbullets = NumEnabled:GetBool() and math.Clamp( math.floor( numbullets ), 1, 10 ) or 1
end

function ENT:SetTracer( tracer )
local tracer = string.Trim(tracer)
self.tracer = ValidTracers[tracer] and tracer or ""
tracer = string.Trim(tracer)
self.tracer = TracerEnabled:GetBool() and ValidTracers[tracer] and tracer or ""
end

function ENT:SetSpread( spread )
Expand All @@ -145,7 +145,7 @@ function ENT:SetForce( force )
end

function ENT:SetTraceNum( tracernum )
self.tracernum = math.floor( math.max( tracernum or 1 ) )
self.tracernum = TracerEnabled:GetBool() and math.Clamp( math.floor( tracernum ), 0, 15 ) or 0
end

function ENT:TriggerInput( iname, value )
Expand Down
14 changes: 3 additions & 11 deletions lua/wire/stools/turret.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ function TOOL.BuildCPanel( CPanel )
CPanel:AddControl("ComboBox", TracerType )

-- Various controls that you should play with!
if game.SinglePlayer() then
CPanel:NumSlider("#Tool_wire_turret_numbullets", "wire_turret_numbullets", 1, 10, 0)
end
CPanel:NumSlider("#Tool_wire_turret_numbullets", "wire_turret_numbullets", 1, 10, 0)
CPanel:NumSlider("#Damage", "wire_turret_damage", 0, 100, 0)
CPanel:NumSlider("#Tool_wire_turret_spread", "wire_turret_spread", 0, 1.0, 2)
CPanel:NumSlider("#Tool_wire_turret_force", "wire_turret_force", 0, 500, 1)

-- The delay between shots.
if game.SinglePlayer() then
CPanel:NumSlider("#Delay", "wire_turret_delay", 0.01, 1.0, 2)
CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0)
else
CPanel:NumSlider("#Delay", "wire_turret_delay", 0.05, 1.0, 2)
end
CPanel:NumSlider("#Tool_wire_turret_tracernum", "wire_turret_tracernum", 0, 15, 0)
CPanel:NumSlider("#Delay", "wire_turret_delay", 0, 1.0, 2)

end