Hello.
I have just one request/question.
Is it possible to find the nail gun’s files anywhere in the GMod folder?
If no, is there any other way to get it’s code?
Thank you.
- Dugehong
Hello.
I have just one request/question.
Is it possible to find the nail gun’s files anywhere in the GMod folder?
If no, is there any other way to get it’s code?
Thank you.
[lua]
SWEP.PrintName = “nailgun”
SWEP.Slot = 2
SWEP.SlotPos = 0
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Author = “”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Instructions = “figure it out if you haven’t already”
SWEP.ViewModel = “models/advancedweaponiser/nailgun/v_nailgun.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”
SWEP.Primary.ClipSize = 20
SWEP.Primary.DefaultClip = 40
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = “pistol”
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”
SWEP.ShootSound = “weapons/nailgun_shoot.wav”
SWEP.DELAY = .12
function SWEP:Deploy()
return true
end
/attack/
function SWEP:PrimaryAttack()
if self.Weapon:Clip1() <= 0 then
self:Reload()
return
end
if self.DELAY > CurTime(.14) then return end
self.DELAY = CurTime(.14)
self:TakePrimaryAmmo(1)
self:EmitSound( self.ShootSound )
local needle = ents.Create("scout_nail")
local pos = self:GetAttachment(self:LookupAttachment("muzzle"))["Pos"]
pos.z = pos.z +self.Owner:WorldToLocal(self.Owner:GetEyeTrace( ).StartPos).z
needle:SetPos( self:GetOwner():GetShootPos() )
needle:SetAngles(self.Owner:EyeAngles())
needle.owner = self
needle:Spawn()
needle:Activate()
needle:SetOwner(self.Owner)
local phys = needle:GetPhysicsObject()
if phys:IsValid() then
phys:SetVelocity( (self.Owner:GetForward() +Vector(0, math.Rand(-0.009,0.009), math.Rand(-0.009,0.009))) *1900 )
end
self.Weapon:SetNextSecondaryFire(CurTime() + .14)
self.Weapon:SetNextPrimaryFire(CurTime() + .14)
end
/nothing/
function SWEP:SecondaryAttack()
end
/drop on die?/
function SWEP:ShouldDropOnDie()
return true
end
/entity/
local NAIL = {}
NAIL.Type = “anim”
NAIL.Base = “base_anim”
if SERVER then
function NAIL:Initialize()
self:SetModel("models/weapons/w_models/w_nail.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_CUSTOM )
self:SetHealth(1)
self:PhysicsInitSphere( 0.1 )
self:SetMoveCollide( 3 )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
phys:SetMass( 0.1 )
phys:EnableDrag(false)
phys:SetBuoyancyRatio( 0.1 )
end
end
function NAIL:PhysicsSimulate( phys, deltatime )
return angle_zero, vector_origin, SIM_LOCAL_ACCELERATION
end
function NAIL:PhysicsCollide(data, physobj)
if !self.Hit then
if data.HitEntity == self.OWNER then return end
if data.HitEntity:GetClass() == "scout_nail" then self:Remove() return end
self:EmitSound("nailimpact.wav")
self.Hit = true
if data.HitEntity:GetClass() != "worldspawn" then
self:SetPos( data.HitPos )
data.HitEntity:TakeDamage(math.random(10,30))
self:SetParent( data.HitEntity )
else
timer.Simple(0, function() self:SetMoveType( MOVETYPE_NOCLIP ) self:SetPos( self:GetPos() - self:GetAngles():Forward()*10 ) end)
end
if data.HitEntity:IsNPC() or data.HitEntity:IsPlayer() then
timer.Simple(.2, function() if data.HitEntity:Health() <= 0 then self:Remove() end end)
end
timer.Simple(20, function() if self and self:IsValid() then self:Remove() end end)
end
end
end
scripted_ents.Register( NAIL, “scout_nail”, true )
[/lua]