-- Tazer
-- By JetBoom

	function onInit( )
		_SWEPSetSound( MyIndex, "single_shot", "Weapon_AR2.Reload_Push" )
	end

	function onThink( )
	end

	function onPrimaryAttack( )
		if not _PlayerInfo( Owner, "alive" ) then return end

		_TraceLine(_PlayerGetShootPos(Owner), _PlayerGetShootAng(Owner), 400, Owner)
		_EntEmitSound(Owner, "ambient/levels/labs/electric_explosion"..math.random(1,5)..".wav")
		local tempent = _EntCreate("info_target")
		if tempent > 0 then
			_EntSetPos(tempent, _TraceEndPos())
			_EntSetName(tempent, _PlayerInfo(userid, "name").."temptarget")
			_EntSpawn(tempent)
			_EntFire(tempent, "kill", "", 0.55)
		end

		if _TraceHitNonWorld() then
			local target = _TraceGetEnt()
			_EntEmitSound(target, "weapons/physcannon/energy_disintegrate5.wav")
			_TraceAttack(target, Owner, Owner, math.random(15,20))
			_MakeDecal(77)
			if target <= _MaxPlayers() then
				_PlayerEnableSprint(target, false)
				_RunString("AddTimer(10, 1, _PlayerEnableSprint, "..target..", true)")
				_PlayerSetMaxSpeed(target, 50)
				_RunString("AddTimer(10, 1, _PlayerSetMaxSpeed, "..target..", 200)")
				_GModRect_Start( "gmod/white" )
				_GModRect_SetPos( 0.0, 0.0, 1.0, 1.0 )
				_GModRect_SetColor( 255, 255, 255, 235 )
				_GModRect_SetTime( 10, 0.2, 0.2 )
				_GModRect_Send( target, 1515 )
			end
		else
			_EntEmitSound(target, "weapons/physcannon/energy_disintegrate5.wav")
		end

		local laser = _EntCreate("env_laser")
		if laser > 0 then
			_EntSetPos(laser, _PlayerGetShootPos(Owner))
			_EntSetKeyValue(laser, "renderamt", "170")
			_EntSetKeyValue(laser, "rendercolor", "255 255 255")
			_EntSetKeyValue(laser, "width", "2")
			_EntSetKeyValue(laser, "texture", "sprites/laserbeam.spr")
			_EntSetKeyValue(laser, "TextureScroll", "35")
			_EntSetKeyValue(laser, "damage", "0")
			_EntSetKeyValue(laser, "renderfx", "0")
			_EntSetKeyValue(laser, "TextureScroll", "35")
			_EntSetKeyValue(laser, "LaserTarget", _PlayerInfo(Owner, "name").."temptarget")
			_EntSetKeyValue(laser, "NoiseAmplitude", "2")
			_EntSetKeyValue(laser, "spawnflags", "33")
			_EntSpawn(laser)
			_EntFire(laser, "kill", "", 0.5)
		end
	end
	
	function onSecondaryAttack( )
	end
	
	
	function onReload( )
		return false
	end

	function getWeaponSwapHands()
		return false	
	end
	
	function getWeaponFOV()
		return 60	
	end
	
	function getWeaponSlot()
		return 1	
	end
	
	function getWeaponSlotPos()
		return 4	
	end
	
	function getFiresUnderwater()
		return false
	end
	
	function getReloadsSingly()
		return false
	end
	
	function getDamage()
		return 5
	end
	
	function getPrimaryShotDelay()
		return 3.0
	end
	
	function getSecondaryShotDelay()
		return 0.2
	end
	
	function getPrimaryIsAutomatic()
		return false
	end
	
	function getSecondaryIsAutomatic()
		return false
	end
	
	function getBulletSpread()
		return vector3( 0.00, 0.00, 0.00 )
	end
	
	function getViewKick()
		return vector3( 0.0, 0.0, 0.0)
	end
	
	function getViewKickRandom()
		return vector3( 0.0, 0.0, 0.0 )
	end

	function getViewModel( )
		return "models/weapons/v_Pistol.mdl"
	end
	
	function getWorldModel( )
		return "models/weapons/w_Pistol.mdl"
	end
	
	function getClassName()
		return "weapon_propmaker"
	end

	function getPrimaryAmmoType()
		return
	end
		
	function getSecondaryAmmoType()
		return
	end
	
	-- return -1 if it doesn't use clips
	function getMaxClipPrimary()
		return 1
	end
	
	function getMaxClipSecondary()
		return -1
	end
	
	-- ammo in gun by default
	function getDefClipPrimary()
		return 1
	end
	
	function getDefClipSecondary()
		return 1
	end

	-- pistol, smg, ar2, shotgun, rpg, phys, crossbow, melee, slam, grenade
	function getAnimPrefix()
		return "pistol"
	end

	function getPrintName()
		return "Tazer\n  by JetBoom"
	end
	
	
	-- 0 = Don't override, shoot bullets, make sound and flash
	-- 1 = Don't shoot bullets but do make flash/sounds
	-- 2 = Only play animations
	-- 3 = Don't do anything
	
	function getPrimaryScriptOverride()
		return 1
	end

	function getSecondaryScriptOverride()
		return 3
	end

	function getBulletSpreadSecondary()
		return vector3( 0.0, 0.0, 0.0 )
	end
	
	function getViewKickSecondary()
		return vector3( 0.0, 0.0, 0.0)
	end
	
	function getViewKickRandomSecondary()
		return vector3( 0.0, 0.0, 0.0 )
	end