summaryrefslogtreecommitdiff
path: root/entities/weapons
diff options
context:
space:
mode:
Diffstat (limited to 'entities/weapons')
-rw-r--r--entities/weapons/rad_axe/shared.lua140
-rw-r--r--entities/weapons/rad_crowbar/shared.lua146
-rw-r--r--entities/weapons/rad_hammer/shared.lua316
-rw-r--r--entities/weapons/rad_knife/shared.lua128
4 files changed, 365 insertions, 365 deletions
diff --git a/entities/weapons/rad_axe/shared.lua b/entities/weapons/rad_axe/shared.lua
index 2411957..c8848e7 100644
--- a/entities/weapons/rad_axe/shared.lua
+++ b/entities/weapons/rad_axe/shared.lua
@@ -1,19 +1,19 @@
if SERVER then
AddCSLuaFile("shared.lua")
-
+
end
if CLIENT then
SWEP.ViewModelFOV = 80
SWEP.ViewModelFlip = false
-
+
SWEP.PrintName = "Axe"
SWEP.IconLetter = "j"
SWEP.Slot = 1
SWEP.Slotpos = 0
-
+
end
SWEP.HoldType = "melee2"
@@ -42,7 +42,7 @@ SWEP.Primary.Automatic = true
function SWEP:GetViewModelPosition( pos, ang )
return self.Weapon:MoveViewModelTo( self.HoldPos, self.HoldAng, pos, ang, 1 )
-
+
end
function SWEP:SecondaryAttack()
@@ -52,62 +52,62 @@ end
function SWEP:PrimaryAttack()
if SERVER then
-
+
self.Owner:AddStamina( -4 )
-
+
end
-
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
+
+ self.Owner:SetAnimation( PLAYER_ATTACK1 )
+
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:MeleeTrace( self.Primary.Damage )
-
+
end
-function SWEP:Think()
+function SWEP:Think()
if self.Owner:GetVelocity():Length() > 0 then
-
+
if self.Owner:KeyDown( IN_SPEED ) then
-
+
self.LastRunFrame = CurTime() + 0.3
-
+
end
-
+
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
+
end
-
+
end
-
+
if self.MoveTime and self.MoveTime < CurTime() and SERVER then
-
+
self.MoveTime = nil
self.Weapon:SetZoomMode( self.Weapon:GetZoomMode() + 1 )
self.Owner:DrawViewModel( false )
-
+
end
end
function SWEP:MeleeTrace( dmg )
-
+
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
-
+
if CLIENT then return end
-
+
local pos = self.Owner:GetShootPos()
local aim = self.Owner:GetAimVector() * 64
-
+
local line = {}
line.start = pos
line.endpos = pos + aim
line.filter = self.Owner
-
+
local linetr = util.TraceLine( line )
-
+
local tr = {}
tr.start = pos + self.Owner:GetAimVector() * -5
tr.endpos = pos + aim
@@ -119,95 +119,95 @@ function SWEP:MeleeTrace( dmg )
local trace = util.TraceHull( tr )
local ent = trace.Entity
local ent2 = linetr.Entity
-
+
if not IsValid( ent ) and IsValid( ent2 ) then
-
+
ent = ent2
-
+
end
- if not IsValid( ent ) then
-
+ if not IsValid( ent ) then
+
self.Owner:EmitSound( self.Primary.Sound, 100, math.random(60,80) )
- return
-
+ return
+
elseif not ent:IsWorld() then
-
+
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
-
- if ent:IsPlayer() then
-
+
+ if ent:IsPlayer() then
+
local snd = table.Random( GAMEMODE.AxeHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
if ent:Team() != self.Owner:Team() then
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
+
end
-
+
elseif string.find( ent:GetClass(), "npc" ) then
-
+
ent:SetHeadshotter( self.Owner, true )
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
local snd = table.Random( GAMEMODE.AxeHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
- elseif !ent:IsPlayer() then
-
+
+ elseif !ent:IsPlayer() then
+
if string.find( ent:GetClass(), "breakable" ) then
-
+
ent:TakeDamage( 50, self.Owner, self.Weapon )
-
+
if ent:GetClass() == "func_breakable_surf" then
-
+
ent:Fire( "shatter", "1 1 1", 0 )
-
+
end
-
+
end
-
+
ent:EmitSound( self.Primary.Hit, 100, math.random(90,110) )
-
+
local phys = ent:GetPhysicsObject()
-
+
if IsValid( phys ) then
-
- if ent.IsWooden then
-
+
+ if ent.IsWooden or (ent:GetMaterialType() == MAT_WOOD) then
+
ent:Fire( "break", 0, 0 )
-
+
else
-
+
ent:SetPhysicsAttacker( self.Owner )
ent:TakeDamage( 10, self.Owner, self.Weapon )
-
+
phys:Wake()
phys:ApplyForceCenter( self.Owner:GetAimVector() * phys:GetMass() * 200 )
-
+
end
-
+
end
-
+
end
-
+
end
end
function SWEP:DrawHUD()
-
+
end
diff --git a/entities/weapons/rad_crowbar/shared.lua b/entities/weapons/rad_crowbar/shared.lua
index 54134ac..37b93b0 100644
--- a/entities/weapons/rad_crowbar/shared.lua
+++ b/entities/weapons/rad_crowbar/shared.lua
@@ -1,19 +1,19 @@
if SERVER then
AddCSLuaFile("shared.lua")
-
+
end
if CLIENT then
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = false
-
+
SWEP.PrintName = "Crowbar"
SWEP.IconLetter = "j"
SWEP.Slot = 1
SWEP.Slotpos = 0
-
+
end
SWEP.HoldType = "melee2"
@@ -44,7 +44,7 @@ SWEP.Primary.Automatic = true
function SWEP:GetViewModelPosition( pos, ang )
return pos, ang //self.Weapon:MoveViewModelTo( self.HoldPos, self.HoldAng, pos, ang, 1 )
-
+
end
function SWEP:SecondaryAttack()
@@ -54,62 +54,62 @@ end
function SWEP:PrimaryAttack()
if SERVER then
-
+
self.Owner:AddStamina( -3 )
-
+
end
-
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
+
+ self.Owner:SetAnimation( PLAYER_ATTACK1 )
+
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:MeleeTrace( self.Primary.Damage )
-
+
end
-function SWEP:Think()
+function SWEP:Think()
if self.Owner:GetVelocity():Length() > 0 then
-
+
if self.Owner:KeyDown( IN_SPEED ) then
-
+
self.LastRunFrame = CurTime() + 0.3
-
+
end
-
+
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
+
end
-
+
end
-
+
if self.MoveTime and self.MoveTime < CurTime() and SERVER then
-
+
self.MoveTime = nil
self.Weapon:SetZoomMode( self.Weapon:GetZoomMode() + 1 )
self.Owner:DrawViewModel( false )
-
+
end
end
function SWEP:MeleeTrace( dmg )
-
+
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
-
+
if CLIENT then return end
-
+
local pos = self.Owner:GetShootPos()
local aim = self.Owner:GetAimVector() * 64
-
+
local line = {}
line.start = pos
line.endpos = pos + aim
line.filter = self.Owner
-
+
local linetr = util.TraceLine( line )
-
+
local tr = {}
tr.start = pos + self.Owner:GetAimVector() * -5
tr.endpos = pos + aim
@@ -121,100 +121,100 @@ function SWEP:MeleeTrace( dmg )
local trace = util.TraceHull( tr )
local ent = trace.Entity
local ent2 = linetr.Entity
-
+
if not IsValid( ent ) and IsValid( ent2 ) then
-
+
ent = ent2
-
+
end
- if not IsValid( ent ) then
-
+ if not IsValid( ent ) then
+
self.Owner:EmitSound( self.Primary.Sound, 100, math.random(60,80) )
- return
-
+ return
+
elseif not ent:IsWorld() then
-
+
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
-
- if ent:IsPlayer() then
-
+
+ if ent:IsPlayer() then
+
local snd = table.Random( GAMEMODE.BluntHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
if ent:Team() != self.Owner:Team() then
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
+
end
-
+
elseif string.find( ent:GetClass(), "npc" ) then
-
+
if math.random(1,3) == 1 then
-
+
ent:SetHeadshotter( self.Owner, true )
-
+
end
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
local snd = table.Random( GAMEMODE.BluntHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
- elseif !ent:IsPlayer() then
-
+
+ elseif !ent:IsPlayer() then
+
if string.find( ent:GetClass(), "breakable" ) then
-
+
ent:TakeDamage( 50, self.Owner, self.Weapon )
-
+
if ent:GetClass() == "func_breakable_surf" then
-
+
ent:Fire( "shatter", "1 1 1", 0 )
-
+
end
-
+
end
-
+
ent:EmitSound( self.Primary.Hit, 100, math.random(90,110) )
-
+
local phys = ent:GetPhysicsObject()
-
+
if IsValid( phys ) then
-
- if ent.IsWooden then
-
+
+ if ent.IsWooden or (ent:GetMaterialType() == MAT_WOOD) then
+
ent:Fire( "break", 0, 0 )
-
+
else
-
+
ent:SetPhysicsAttacker( self.Owner )
ent:TakeDamage( 10, self.Owner, self.Weapon )
-
+
phys:Wake()
phys:ApplyForceCenter( self.Owner:GetAimVector() * phys:GetMass() * 200 )
-
+
end
-
+
end
-
+
end
-
+
end
end
function SWEP:DrawHUD()
-
+
end
diff --git a/entities/weapons/rad_hammer/shared.lua b/entities/weapons/rad_hammer/shared.lua
index 5bf20ee..6a7999f 100644
--- a/entities/weapons/rad_hammer/shared.lua
+++ b/entities/weapons/rad_hammer/shared.lua
@@ -1,19 +1,19 @@
if SERVER then
AddCSLuaFile("shared.lua")
-
+
end
if CLIENT then
SWEP.ViewModelFOV = 80
SWEP.ViewModelFlip = false
-
+
SWEP.PrintName = "Hammer"
SWEP.IconLetter = "j"
SWEP.Slot = 1
SWEP.Slotpos = 0
-
+
end
SWEP.HoldType = "melee"
@@ -50,7 +50,7 @@ SWEP.BuildAng = 0
function SWEP:GetViewModelPosition( pos, ang )
return self.Weapon:MoveViewModelTo( self.HoldPos, self.HoldAng, pos, ang, 1 )
-
+
end
function SWEP:ReleaseGhost()
@@ -59,9 +59,9 @@ function SWEP:ReleaseGhost()
self.GhostEntity:Remove()
self.GhostEntity = nil
-
+
end
-
+
end
function SWEP:MakeGhost( model, pos, angle )
@@ -71,82 +71,82 @@ function SWEP:MakeGhost( model, pos, angle )
self.GhostEntity:SetPos( pos )
self.GhostEntity:SetAngles( angle )
self.GhostEntity:Spawn()
-
+
self.GhostEntity:SetSolid( SOLID_VPHYSICS )
self.GhostEntity:SetMoveType( MOVETYPE_NONE )
self.GhostEntity:SetNotSolid( true )
self.GhostEntity:SetRenderMode( RENDERMODE_TRANSALPHA )
self.GhostEntity:SetColor( Color( 255, 255, 255, 200 ) )
-
+
end
function SWEP:UpdateGhost()
if not IsValid( self.GhostEntity ) then return end
-
+
local tr = util.GetPlayerTrace( self.Owner )
local trace = util.TraceLine( tr )
-
+
if not trace.Hit then return end
-
+
local ang = ( trace.HitNormal * -1 ):Angle() + Angle( 0, 0, math.NormalizeAngle( 90 + self.Weapon:GetNWInt( "BuildAng", 0 ) ) )
- local pos = trace.HitPos
-
+ local pos = trace.HitPos
+
local trlength = self.Weapon:GetOwner():GetPos() - trace.HitPos
- trlength = trlength:Length()
-
+ trlength = trlength:Length()
+
if trlength < 150 and ( trace.HitWorld or trace.Entity:GetClass() == "prop_door_rotating" ) then
-
+
self.GhostEntity:SetColor( Color( 50, 255, 50, 200 ) )
-
+
else
-
+
self.GhostEntity:SetColor( Color( 255, 50, 50, 200 ) )
-
+
end
-
+
if not trace.HitWorld and not trace.Entity:GetClass() == "prop_door_rotating" then
-
+
self.GhostEntity:SetColor( Color( 255, 50, 50, 200 ) )
self.GhostEntity:SetModel( self.Barricade )
self.GhostEntity:SetPos( pos + ( self.GhostEntity:GetUp() * self.Position ) )
self.GhostEntity:SetAngles( ang )
-
+
elseif string.find( trace.Entity:GetClass(), "prop_door" ) then
-
+
self.GhostEntity:SetModel( "models/props_c17/tools_wrench01a.mdl" )
self.GhostEntity:SetPos( trace.HitPos + trace.HitNormal * 5 )
self.GhostEntity:SetAngles( ( trace.HitNormal * -1 ):Angle() + Angle(0,90,90) )
-
+
else
-
+
self.GhostEntity:SetModel( self.Barricade )
self.GhostEntity:SetPos( pos + ( self.GhostEntity:GetUp() * self.Position ) )
self.GhostEntity:SetAngles( ang )
-
+
end
-
+
end
function SWEP:SetPlacePosition( ent )
local tr = util.GetPlayerTrace( self:GetOwner() )
local trace = util.TraceLine( tr )
-
+
if not trace.Hit then return end
-
+
local ang = ( trace.HitNormal * -1 ):Angle() + Angle( 0, 0, math.NormalizeAngle( 90 + self.Weapon:GetNWInt( "BuildAng", 0 ) ) )
ent:SetAngles( ang )
-
- local pos = trace.HitPos
+
+ local pos = trace.HitPos
ent:SetPos( pos + ( ent:GetUp() * self.Position ) )
-
+
local phys = ent:GetPhysicsObject()
-
+
if IsValid( phys ) then
-
+
phys:EnableMotion( false )
-
+
end
end
@@ -154,32 +154,32 @@ end
function SWEP:Deploy()
if SERVER then
-
+
self.Owner:DrawViewModel( true )
self.Owner:NoticeOnce( "Toggle build mode with your reload key", GAMEMODE.Colors.Blue, 5, 2 )
-
+
else
-
+
self.Weapon:ReleaseGhost()
-
+
end
-
+
self.InIron = false
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
-
+
return true
-
-end
+
+end
function SWEP:Holster()
if CLIENT then
-
+
self.Weapon:ReleaseGhost()
-
+
end
-
+
return true
end
@@ -187,16 +187,16 @@ end
function SWEP:Reload()
if CLIENT then return end
-
+
if ( self.ReloadTime or 0 ) < CurTime() then
-
+
self.ReloadTime = CurTime() + 0.75
-
+
self.Weapon:SetNWBool( "BuildMode", !self.Weapon:GetNWBool( "BuildMode", false ) )
-
+
self.Owner:EmitSound( self.Click, 50, 120 )
self.Owner:NoticeOnce( "Rotate your barricade by right clicking", GAMEMODE.Colors.Blue, 5, 2 )
-
+
end
end
@@ -204,23 +204,23 @@ end
function SWEP:SecondaryAttack()
if CLIENT then return end
-
+
if ( self.SecondDelay or 0 ) < CurTime() and self.Weapon:GetNWBool( "BuildMode", false ) then
-
+
self.SecondDelay = CurTime() + 0.25
self.BuildAng = self.BuildAng + 45
-
+
if self.BuildAng == 360 then
-
+
self.BuildAng = 0
-
+
end
-
+
self.Weapon:SetNWInt( "BuildAng", self.BuildAng )
self.Owner:EmitSound( self.Click )
-
+
end
-
+
end
function SWEP:PrimaryAttack()
@@ -228,23 +228,23 @@ function SWEP:PrimaryAttack()
if not self.Weapon:GetNWBool( "BuildMode", false ) then
if SERVER then
-
+
self.Owner:AddStamina( -2 )
-
+
end
self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
+
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:MeleeTrace( self.Primary.Damage )
-
+
else
-
+
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:BarricadeTrace()
-
+
end
-
+
end
function SWEP:BarricadeTrace()
@@ -254,75 +254,75 @@ function SWEP:BarricadeTrace()
local trace = util.GetPlayerTrace( self.Owner )
local tr = util.TraceLine( trace )
local trlength = self.Weapon:GetOwner():GetPos() - tr.HitPos
- trlength = trlength:Length()
-
+ trlength = trlength:Length()
+
local has, id = self.Owner:GetWood()
-
+
if not has then
-
+
self.Owner:Notice( "You don't have enough wood", GAMEMODE.Colors.Red )
self.Owner:EmitSound( self.Deny, 50, 100 )
-
+
return
-
+
end
-
+
if tr.HitWorld and trlength < 150 then
-
+
self.Owner:Notice( "Built a barricade using 1 piece of wood", GAMEMODE.Colors.Green )
self.Owner:NoticeOnce( "You can also repair doors", GAMEMODE.Colors.Blue, 5, 2 )
-
+
local prop = ents.Create( "prop_physics" )
prop:SetModel( self.Barricade )
prop:Spawn()
prop:SetHealth( 350 )
prop:SetCustomCollisionCheck()
prop.IsWood = true
-
+
self.Weapon:SetPlacePosition( prop )
-
+
elseif string.find( tr.Entity:GetClass(), "prop_door" ) and trlength < 150 then
-
+
self.Owner:Notice( "Fortified a door using 1 piece of wood", GAMEMODE.Colors.Green )
-
+
tr.Entity.MaxHits = 30
tr.Entity.Hits = 0
-
+
else
-
+
self.Owner:Notice( "You can't build a barricade here", GAMEMODE.Colors.Red )
self.Owner:EmitSound( self.Deny, 50, 100 )
-
+
return
-
+
end
-
+
self.Owner:AddStamina( -15 )
self.Owner:RemoveFromInventory( id )
self.Owner:AddStat( "Wood" )
self.Owner:AddCash( 1 )
-
+
self.Owner:EmitSound( table.Random( GAMEMODE.Drill ), 100, math.random(90,110) )
self.Owner:EmitSound( table.Random( GAMEMODE.WoodHammer ), 100, math.random(90,110) )
end
function SWEP:MeleeTrace( dmg )
-
+
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
-
+
if CLIENT then return end
-
+
local pos = self.Owner:GetShootPos()
local aim = self.Owner:GetAimVector() * 64
-
+
local line = {}
line.start = pos
line.endpos = pos + aim
line.filter = self.Owner
-
+
local linetr = util.TraceLine( line )
-
+
local tr = {}
tr.start = pos + self.Owner:GetAimVector() * -5
tr.endpos = pos + aim
@@ -334,150 +334,150 @@ function SWEP:MeleeTrace( dmg )
local trace = util.TraceHull( tr )
local ent = trace.Entity
local ent2 = linetr.Entity
-
+
if not IsValid( ent ) and IsValid( ent2 ) then
-
+
ent = ent2
-
+
end
- if not IsValid( ent ) then
-
+ if not IsValid( ent ) then
+
self.Owner:EmitSound( self.Primary.Sound, 100, math.random(60,80) )
- return
-
+ return
+
elseif not ent:IsWorld() then
-
+
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
-
- if ent:IsPlayer() then
-
+
+ if ent:IsPlayer() then
+
local snd = table.Random( GAMEMODE.BluntHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
if ent:Team() != self.Owner:Team() then
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
+
end
-
+
elseif string.find( ent:GetClass(), "npc" ) then
-
+
local snd = table.Random( GAMEMODE.BluntHit )
ent:EmitSound( snd, 100, math.random(90,110) )
-
+
if math.random(1,3) == 1 then
-
+
ent:SetHeadshotter( self.Owner, true )
-
+
end
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
- elseif !ent:IsPlayer() then
-
+
+ elseif !ent:IsPlayer() then
+
if string.find( ent:GetClass(), "breakable" ) then
-
+
ent:TakeDamage( 50, self.Owner, self.Weapon )
-
+
if ent:GetClass() == "func_breakable_surf" then
-
+
ent:Fire( "shatter", "1 1 1", 0 )
-
+
end
-
+
end
-
+
ent:EmitSound( self.Primary.Hit, 100, math.random(90,110) )
-
+
local phys = ent:GetPhysicsObject()
-
+
if IsValid( phys ) then
-
- if ent.IsWooden then
-
+
+ if ent.IsWooden or (ent:GetMaterialType() == MAT_WOOD) then
+
ent:Fire( "break", 0, 0 )
-
+
else
-
+
ent:SetPhysicsAttacker( self.Owner )
ent:TakeDamage( 10, self.Owner, self.Weapon )
-
+
phys:Wake()
phys:ApplyForceCenter( self.Owner:GetAimVector() * phys:GetMass() * 200 )
-
+
end
-
+
end
-
+
end
-
+
end
end
-function SWEP:Think()
+function SWEP:Think()
if CLIENT then
-
+
if self.Weapon:GetNWBool( "BuildMode", false ) then
-
+
if not self.GhostEntity then
-
+
self.Weapon:MakeGhost( self.Barricade, self.Owner:GetPos() + Vector(0,0,100), Angle(0,0,0))
-
+
else
-
+
self.Weapon:UpdateGhost()
-
+
end
-
+
elseif IsValid( self.GhostEntity ) then
-
+
self.Weapon:ReleaseGhost()
-
+
end
-
+
end
if self.Owner:GetVelocity():Length() > 0 then
-
+
if self.Owner:KeyDown( IN_SPEED ) then
-
+
self.LastRunFrame = CurTime() + 0.3
-
+
end
-
+
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
+
end
-
+
end
-
+
if self.MoveTime and self.MoveTime < CurTime() and SERVER then
-
+
self.MoveTime = nil
self.Weapon:SetZoomMode( self.Weapon:GetZoomMode() + 1 )
self.Owner:DrawViewModel( false )
-
+
end
end
function SWEP:DrawHUD()
-
+
end
diff --git a/entities/weapons/rad_knife/shared.lua b/entities/weapons/rad_knife/shared.lua
index 8b06c17..66d4b3a 100644
--- a/entities/weapons/rad_knife/shared.lua
+++ b/entities/weapons/rad_knife/shared.lua
@@ -1,18 +1,18 @@
if SERVER then
AddCSLuaFile( "shared.lua" )
-
+
end
if CLIENT then
SWEP.ViewModelFlip = false
-
+
SWEP.PrintName = "Knife"
SWEP.IconLetter = "j"
SWEP.Slot = 1
SWEP.Slotpos = 0
-
+
end
SWEP.HoldType = "knife"
@@ -40,7 +40,7 @@ SWEP.Primary.Automatic = true
function SWEP:GetViewModelPosition( pos, ang )
return pos, ang
-
+
end
function SWEP:SecondaryAttack()
@@ -48,40 +48,40 @@ function SWEP:SecondaryAttack()
end
function SWEP:PrimaryAttack()
-
+
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:MeleeTrace( self.Primary.Damage )
-
+
if SERVER then
-
+
self.Owner:AddStamina( -1 )
-
+
end
-
+
end
-function SWEP:Think()
+function SWEP:Think()
end
function SWEP:MeleeTrace( dmg )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
+
self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER )
-
+
if CLIENT then return end
-
+
local pos = self.Owner:GetShootPos()
local aim = self.Owner:GetAimVector() * 64
-
+
local line = {}
line.start = pos
line.endpos = pos + aim
line.filter = self.Owner
-
+
local linetr = util.TraceLine( line )
-
+
local tr = {}
tr.start = pos + self.Owner:GetAimVector() * -5
tr.endpos = pos + aim
@@ -93,107 +93,107 @@ function SWEP:MeleeTrace( dmg )
local trace = util.TraceHull( tr )
local ent = trace.Entity
local ent2 = linetr.Entity
-
+
if not IsValid( ent ) and IsValid( ent2 ) then
-
+
ent = ent2
-
+
end
- if not IsValid( ent ) then
-
+ if not IsValid( ent ) then
+
self.Owner:EmitSound( self.Primary.Sound, 100, math.random(90,110) )
- return
-
+ return
+
elseif not ent:IsWorld() then
-
+
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
self.Owner:AddStamina( -2 )
-
- if ent:IsPlayer() then
-
+
+ if ent:IsPlayer() then
+
ent:EmitSound( self.Primary.HitFlesh, 100, math.random(90,110) )
-
+
if ent:Team() != self.Owner:Team() then
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
+
end
-
+
elseif string.find( ent:GetClass(), "npc" ) then
-
+
ent:TakeDamage( dmg, self.Owner, self.Weapon )
ent:EmitSound( self.Primary.HitFlesh, 100, math.random(90,110) )
-
+
self.Owner:DrawBlood()
-
+
local ed = EffectData()
ed:SetOrigin( trace.HitPos )
util.Effect( "BloodImpact", ed, true, true )
-
- elseif !ent:IsPlayer() then
-
+
+ elseif !ent:IsPlayer() then
+
if string.find( ent:GetClass(), "breakable" ) then
-
+
ent:TakeDamage( 50, self.Owner, self.Weapon )
-
+
if ent:GetClass() == "func_breakable_surf" then
-
+
ent:Fire( "shatter", "1 1 1", 0 )
-
+
end
-
+
end
-
+
ent:EmitSound( self.Primary.Hit, 100, math.random(90,110) )
-
+
local phys = ent:GetPhysicsObject()
-
+
if IsValid( phys ) then
-
- if ent.IsWooden then
-
+
+ if ent.IsWooden or (ent:GetMaterialType() == MAT_WOOD) then
+
ent:Fire( "break", 0, 0 )
-
+
else
-
+
ent:SetPhysicsAttacker( self.Owner )
ent:TakeDamage( 10, self.Owner, self.Weapon )
-
+
phys:Wake()
phys:ApplyForceCenter( self.Owner:GetAimVector() * phys:GetMass() * 200 )
-
+
end
-
+
end
-
+
end
-
+
end
end
function SWEP:DrawHUD()
-
+
end
function SWEP:Deploy()
if SERVER then
-
+
self.Owner:DrawViewModel( true )
self.Owner:EmitSound( self.Primary.Deploy, 100, math.random(90,110) )
-
- end
+
+ end
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
-
+
return true
-
-end
+
+end