diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-30 15:09:24 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-30 15:09:24 -0400 |
| commit | fa0cf14f38c06cc6965b7297c333f2dd11f71ec7 (patch) | |
| tree | 44a138d28ed66e13e7075dd7081db05ddc7c5190 /entities/weapons/rad_crowbar/shared.lua | |
| parent | 2736f498f30220b858fc6fac23e7ddc4a597df6d (diff) | |
| download | redead-fa0cf14f38c06cc6965b7297c333f2dd11f71ec7.tar.gz redead-fa0cf14f38c06cc6965b7297c333f2dd11f71ec7.tar.bz2 redead-fa0cf14f38c06cc6965b7297c333f2dd11f71ec7.zip | |
Changed mele weapons to break wooden items more consistently
Diffstat (limited to 'entities/weapons/rad_crowbar/shared.lua')
| -rw-r--r-- | entities/weapons/rad_crowbar/shared.lua | 146 |
1 files changed, 73 insertions, 73 deletions
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 |
