<commit_before>AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName		= "Wire Turret"
ENT.WireDebugName 	= "Turret"

if CLIENT then return end -- No more client

function ENT:Initialize()
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )

	self:DrawShadow( false )
	self:SetCollisionGroup( COLLISION_GROUP_WEAPON )

	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end

	self.Firing 	= false
	self.NextShot 	= 0

	self.Inputs = Wire_CreateInputs(self, { "Fire" })
end

function ENT:FireShot()

	if ( self.NextShot > CurTime() ) then return end

	self.NextShot = CurTime() + self.delay

	-- Make a sound if you want to.
	if self.sound then
		self:EmitSound(self.sound)
	end

	-- Get the muzzle attachment (this is pretty much always 1)
	local Attachment = self:GetAttachment( 1 )

	-- Get the shot angles and stuff.
	local shootOrigin = Attachment.Pos
	local shootAngles = self:GetAngles()

	-- Shoot a bullet
	local bullet = {}
		bullet.Num 			= self.numbullets
		bullet.Src 			= shootOrigin
		bullet.Dir 			= shootAngles:Forward()
		bullet.Spread 		= self.spread
		bullet.Tracer		= self.tracernum
		bullet.TracerName 	= self.tracer
		bullet.Force		= self.force
		bullet.Damage		= self.damage
		bullet.Attacker 	= self:GetPlayer()
	self:FireBullets( bullet )

	-- Make a muzzle flash
	local effectdata = EffectData()
		effectdata:SetOrigin( shootOrigin )
		effectdata:SetAngles( shootAngles )
		effectdata:SetScale( 1 )
	util.Effect( "MuzzleEffect", effectdata )

end

function ENT:OnTakeDamage( dmginfo )
	self:TakePhysicsDamage( dmginfo )
end

function ENT:Think()
	self.BaseClass.Think(self)

	if( self.Firing ) then
		self:FireShot()
	end

	self:NextThink(CurTime())
	return true
end

function ENT:TriggerInput(iname, value)
	if (iname == "Fire") then
		self.Firing = value > 0
	end
end

local ValidTracers = {
	["Tracer"]=true,
	["AR2Tracer"]=true,
	["AirboatGunHeavyTracer"]=true,
	["LaserTracer"]=true,
	[""]=true,
}

function ENT:Setup(delay, damage, force, sound, numbullets, spread, tracer, tracernum)
	self.delay = delay
	self.damage = damage
	self.force = force
	-- Preventing client crashes
	if string.find(sound, '["?]') then
		self.sound = ""
	else
		self.sound = sound
	end
	self.numbullets = numbullets
	self.spread = Vector(spread, spread, 0)

	self.tracer = ValidTracers[string.Trim(tracer)] and string.Trim(tracer) or ""
	self.tracernum = tracernum or 1
end

duplicator.RegisterEntityClass( "gmod_wire_turret", WireLib.MakeWireEnt, "Data", "delay", "damage", "force", "sound", "numbullets", "spread", "tracer", "tracernum" )<commit_msg>Fixed wire turret's spread not duplicating<commit_after>AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName		= "Wire Turret"
ENT.WireDebugName 	= "Turret"

if CLIENT then return end -- No more client

function ENT:Initialize()
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )

	self:DrawShadow( false )
	self:SetCollisionGroup( COLLISION_GROUP_WEAPON )

	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end

	self.Firing 	= false
	self.NextShot 	= 0

	self.Inputs = Wire_CreateInputs(self, { "Fire" })
end

function ENT:FireShot()

	if ( self.NextShot > CurTime() ) then return end

	self.NextShot = CurTime() + self.delay

	-- Make a sound if you want to.
	if self.sound then
		self:EmitSound(self.sound)
	end

	-- Get the muzzle attachment (this is pretty much always 1)
	local Attachment = self:GetAttachment( 1 )

	-- Get the shot angles and stuff.
	local shootOrigin = Attachment.Pos
	local shootAngles = self:GetAngles()

	-- Shoot a bullet
	local bullet = {}
		bullet.Num 			= self.numbullets
		bullet.Src 			= shootOrigin
		bullet.Dir 			= shootAngles:Forward()
		bullet.Spread 		= self.spreadvector
		bullet.Tracer		= self.tracernum
		bullet.TracerName 	= self.tracer
		bullet.Force		= self.force
		bullet.Damage		= self.damage
		bullet.Attacker 	= self:GetPlayer()
	self:FireBullets( bullet )

	-- Make a muzzle flash
	local effectdata = EffectData()
		effectdata:SetOrigin( shootOrigin )
		effectdata:SetAngles( shootAngles )
		effectdata:SetScale( 1 )
	util.Effect( "MuzzleEffect", effectdata )

end

function ENT:OnTakeDamage( dmginfo )
	self:TakePhysicsDamage( dmginfo )
end

function ENT:Think()
	self.BaseClass.Think(self)

	if( self.Firing ) then
		self:FireShot()
	end

	self:NextThink(CurTime())
	return true
end

function ENT:TriggerInput(iname, value)
	if (iname == "Fire") then
		self.Firing = value > 0
	end
end

local ValidTracers = {
	["Tracer"]=true,
	["AR2Tracer"]=true,
	["AirboatGunHeavyTracer"]=true,
	["LaserTracer"]=true,
	[""]=true,
}

function ENT:Setup(delay, damage, force, sound, numbullets, spread, tracer, tracernum)
	if not game.SinglePlayer() then
		self.delay = math.max(delay,0.05) -- clamp delay if it's not single player
	end
	
	self.damage = damage
	self.force = force
	-- Preventing client crashes
	if string.find(sound, '["?]') then
		self.sound = ""
	else
		self.sound = sound
	end
	
	if not game.SinglePlayer() then
		self.numbullets = math.Clamp( numbullets, 1, 10 ) -- clamp num bullets if it's not single player
	end

	self.spread = spread -- for duplication
	self.spreadvector = Vector(spread,spread,0)

	self.tracer = ValidTracers[string.Trim(tracer)] and string.Trim(tracer) or ""
	self.tracernum = tracernum or 1
end

duplicator.RegisterEntityClass( "gmod_wire_turret", WireLib.MakeWireEnt, "Data", "delay", "damage", "force", "sound", "numbullets", "spread", "tracer", "tracernum" )
{'fraction_non_alphanumeric': 0.11904336962341602, 'fraction_numerical': 0.003926467963590933, 'mean_word_length': 4.404050144648023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2626933', 'n_tokens_mistral': 2213, 'n_tokens_neox': 2066, 'n_words': 487}