Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- SWEP.PrintName = "Ork Claws"
- SWEP.Author = "TylerB, robotboy655, MaxOfS2D & Tenrys"
- SWEP.Purpose = "Gnaw stuff. Rip stuff. Kill stuff."
- SWEP.Spawnable = true
- SWEP.UseHands = true
- SWEP.DrawAmmo = false
- SWEP.ViewModel = "models/weapons/c_arms_citizen.mdl"
- SWEP.WorldModel = ""
- SWEP.ViewModelFOV = 52
- SWEP.Slot = 0
- SWEP.SlotPos = 5
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "none"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = true
- SWEP.Secondary.Ammo = "none"
- function SWEP:Initialize()
- self:SetWeaponHoldType( "fist" )
- end
- function SWEP:PreDrawViewModel( vm, wep, ply )
- vm:SetMaterial( "engine/occlusionproxy" ) -- Hide that view model with hacky material
- end
- SWEP.HitDistance = 48
- function SWEP:PrimaryAttack( right )
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- if ( !IsFirstTimePredicted() ) then return end
- -- We need this because attack sequences won't work otherwise in multiplayer
- local vm = self.Owner:GetViewModel()
- vm:ResetSequence( vm:LookupSequence( "fists_idle_01" ) )
- local anim = "fists_left"
- if ( right ) then anim = "fists_right" end
- if ( math.random( 1, 10 ) == 1 ) then anim = "fists_uppercut" end
- timer.Simple( 0, function()
- if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
- local vm = self.Owner:GetViewModel()
- vm:ResetSequence( vm:LookupSequence( anim ) )
- self:Idle()
- end )
- timer.Simple( 0.05, function()
- if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
- if ( anim == "fists_left" ) then
- self.Owner:ViewPunch( Angle( 0, 16, 0 ) )
- elseif ( anim == "fists_right" ) then
- self.Owner:ViewPunch( Angle( 0, -16, 0 ) )
- elseif ( anim == "fists_uppercut" ) then
- self.Owner:ViewPunch( Angle( 16, -8, 0 ) )
- end
- end )
- timer.Simple( 0.2, function()
- if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
- if ( anim == "fists_left" ) then
- self.Owner:ViewPunch( Angle( 4, -16, 0 ) )
- elseif ( anim == "fists_right" ) then
- self.Owner:ViewPunch( Angle( 4, 16, 0 ) )
- elseif ( anim == "fists_uppercut" ) then
- self.Owner:ViewPunch( Angle( -32, 0, 0 ) )
- end
- self.Owner:EmitSound( "npc/fast_zombie/claw_miss"..(math.random(1,2))..".wav" )
- end )
- timer.Simple( 0.2, function()
- if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self || CLIENT ) then return end
- self:DealDamage( anim )
- end )
- self:SetNextPrimaryFire( CurTime() + 0.5 )
- self:SetNextSecondaryFire( CurTime() + 0.5 )
- end
- function SWEP:SecondaryAttack()
- if CLIENT then return end
- if not self.Owner.orkcooldown then self.Owner.orkcooldown = 0 end
- if CurTime() - self.Owner.orkcooldown >= 10 then
- self.Owner.orkcooldown = CurTime()
- local sounds = {
- "npc/fast_zombie/fz_frenzy1.wav",
- "npc/fast_zombie/fz_scream1.wav",
- "npc/fast_zombie/leap1.wav"
- }
- self.Owner:EmitSound(table.Random(sounds),80,100)
- end
- end
- function SWEP:DealDamage( anim )
- local tr = util.TraceLine( {
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
- filter = self.Owner
- } )
- if ( !IsValid( tr.Entity ) ) then
- tr = util.TraceHull( {
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
- filter = self.Owner,
- mins = Vector( -15, -15, -20 ),
- maxs = Vector( 15, 15, 20 )
- } )
- end
- if tr.Hit then
- if ( IsValid( tr.Entity ) && ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) ) then
- local dmginfo = DamageInfo()
- dmginfo:SetDamage( math.random( 15, 20 ) )
- if ( anim == "fists_left" ) then
- dmginfo:SetDamageForce( self.Owner:GetRight() * 49125 + self.Owner:GetForward() * 99984 ) -- Yes we need those specific numbers
- elseif ( anim == "fists_right" ) then
- dmginfo:SetDamageForce( self.Owner:GetRight() * -49124 + self.Owner:GetForward() * 99899 )
- elseif ( anim == "fists_uppercut" ) then
- dmginfo:SetDamageForce( self.Owner:GetUp() * 51589 + self.Owner:GetForward() * 100128 )
- dmginfo:SetDamage( math.random( 15, 25 ) )
- end
- dmginfo:SetInflictor( self )
- local attacker = self.Owner
- if ( !IsValid( attacker ) ) then attacker = self end
- dmginfo:SetAttacker( attacker )
- local vPoint = Vector(0,0,0)
- local effectdata = EffectData()
- effectdata:SetStart( tr.HitPos ) // not sure if we need a start and origin (endpoint) for this effect, but whatever
- effectdata:SetOrigin( tr.HitPos )
- util.Effect( "BloodImpact", effectdata )
- tr.Entity:TakeDamageInfo( dmginfo )
- self.Owner:EmitSound( "npc/fast_zombie/claw_strike"..(math.random(1,3))..".wav" )
- else
- self.Owner:EmitSound( "Flesh.ImpactHard" )
- end
- end
- end
- function SWEP:Idle()
- local vm = self.Owner:GetViewModel()
- timer.Create( "fists_idle" .. self:EntIndex(), vm:SequenceDuration(), 1, function()
- vm:ResetSequence( vm:LookupSequence( "fists_idle_0" .. math.random( 1, 2 ) ) )
- end )
- end
- function SWEP:OnRemove()
- if ( IsValid( self.Owner ) ) then
- local vm = self.Owner:GetViewModel()
- if ( IsValid( vm ) ) then vm:SetMaterial( "" ) end
- end
- timer.Stop( "fists_idle" .. self:EntIndex() )
- end
- function SWEP:Holster( wep )
- self:OnRemove()
- return true
- end
- function SWEP:Deploy()
- local vm = self.Owner:GetViewModel()
- vm:ResetSequence( vm:LookupSequence( "fists_draw" ) )
- self:Idle()
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement