Advertisement
TylerB

weapon_orkclaws

Jan 25th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.03 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3. SWEP.PrintName                        = "Ork Claws"
  4.  
  5. SWEP.Author                        = "TylerB, robotboy655, MaxOfS2D & Tenrys"
  6. SWEP.Purpose                = "Gnaw stuff. Rip stuff. Kill stuff."
  7.  
  8. SWEP.Spawnable                        = true
  9. SWEP.UseHands                        = true
  10. SWEP.DrawAmmo                        = false
  11.  
  12. SWEP.ViewModel                        = "models/weapons/c_arms_citizen.mdl"
  13. SWEP.WorldModel                        = ""
  14.  
  15. SWEP.ViewModelFOV                = 52
  16. SWEP.Slot                                = 0
  17. SWEP.SlotPos                        = 5
  18.  
  19. SWEP.Primary.ClipSize                = -1
  20. SWEP.Primary.DefaultClip        = -1
  21. SWEP.Primary.Automatic                = true
  22. SWEP.Primary.Ammo                        = "none"
  23.  
  24. SWEP.Secondary.ClipSize                = -1
  25. SWEP.Secondary.DefaultClip        = -1
  26. SWEP.Secondary.Automatic        = true
  27. SWEP.Secondary.Ammo                        = "none"
  28.  
  29. function SWEP:Initialize()
  30.  
  31.         self:SetWeaponHoldType( "fist" )
  32.  
  33. end
  34.  
  35. function SWEP:PreDrawViewModel( vm, wep, ply )
  36.  
  37.         vm:SetMaterial( "engine/occlusionproxy" ) -- Hide that view model with hacky material
  38.  
  39. end
  40.  
  41. SWEP.HitDistance = 48
  42. function SWEP:PrimaryAttack( right )
  43.  
  44.         self.Owner:SetAnimation( PLAYER_ATTACK1 )
  45.  
  46.         if ( !IsFirstTimePredicted() ) then return end
  47.  
  48.         -- We need this because attack sequences won't work otherwise in multiplayer
  49.         local vm = self.Owner:GetViewModel()
  50.         vm:ResetSequence( vm:LookupSequence( "fists_idle_01" ) )
  51.  
  52.         local anim = "fists_left"
  53.         if ( right ) then anim = "fists_right" end
  54.         if ( math.random( 1, 10 ) == 1 ) then anim = "fists_uppercut" end
  55.  
  56.         timer.Simple( 0, function()
  57.                 if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
  58.        
  59.                 local vm = self.Owner:GetViewModel()
  60.                 vm:ResetSequence( vm:LookupSequence( anim ) )
  61.  
  62.                 self:Idle()
  63.         end )
  64.  
  65.         timer.Simple( 0.05, function()
  66.                 if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
  67.                 if ( anim == "fists_left" ) then
  68.                         self.Owner:ViewPunch( Angle( 0, 16, 0 ) )
  69.                 elseif ( anim == "fists_right" ) then
  70.                         self.Owner:ViewPunch( Angle( 0, -16, 0 ) )
  71.                 elseif ( anim == "fists_uppercut" ) then
  72.                         self.Owner:ViewPunch( Angle( 16, -8, 0 ) )
  73.                 end
  74.         end )
  75.  
  76.         timer.Simple( 0.2, function()
  77.                 if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self ) then return end
  78.                 if ( anim == "fists_left" ) then
  79.                         self.Owner:ViewPunch( Angle( 4, -16, 0 ) )
  80.                 elseif ( anim == "fists_right" ) then
  81.                         self.Owner:ViewPunch( Angle( 4, 16, 0 ) )
  82.                 elseif ( anim == "fists_uppercut" ) then
  83.                         self.Owner:ViewPunch( Angle( -32, 0, 0 ) )
  84.                 end
  85.                 self.Owner:EmitSound( "npc/fast_zombie/claw_miss"..(math.random(1,2))..".wav" )
  86.                
  87.         end )
  88.  
  89.         timer.Simple( 0.2, function()
  90.                 if ( !IsValid( self ) || !IsValid( self.Owner ) || !self.Owner:GetActiveWeapon() || self.Owner:GetActiveWeapon() != self || CLIENT ) then return end
  91.                 self:DealDamage( anim )
  92.         end )
  93.  
  94.         self:SetNextPrimaryFire( CurTime() + 0.5 )
  95.         self:SetNextSecondaryFire( CurTime() + 0.5 )
  96.  
  97. end
  98.  
  99. function SWEP:SecondaryAttack()
  100.     if CLIENT then return end
  101.    
  102.     if not self.Owner.orkcooldown then self.Owner.orkcooldown = 0 end
  103.    
  104.     if CurTime() - self.Owner.orkcooldown >= 10 then
  105.         self.Owner.orkcooldown = CurTime()
  106.        
  107.         local sounds = {
  108.             "npc/fast_zombie/fz_frenzy1.wav",
  109.             "npc/fast_zombie/fz_scream1.wav",
  110.             "npc/fast_zombie/leap1.wav"
  111.         }
  112.        
  113.         self.Owner:EmitSound(table.Random(sounds),80,100)
  114.     end
  115. end
  116.  
  117. function SWEP:DealDamage( anim )
  118.         local tr = util.TraceLine( {
  119.                 start = self.Owner:GetShootPos(),
  120.                 endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
  121.                 filter = self.Owner
  122.         } )
  123.  
  124.         if ( !IsValid( tr.Entity ) ) then
  125.                 tr = util.TraceHull( {
  126.                         start = self.Owner:GetShootPos(),
  127.                         endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
  128.                         filter = self.Owner,
  129.                         mins = Vector( -15, -15, -20 ),
  130.                         maxs = Vector( 15, 15, 20 )
  131.                 } )
  132.         end
  133.        
  134.         if tr.Hit then
  135.             if ( IsValid( tr.Entity ) && ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) ) then
  136.                     local dmginfo = DamageInfo()
  137.                     dmginfo:SetDamage( math.random( 15, 20 ) )
  138.                     if ( anim == "fists_left" ) then
  139.                             dmginfo:SetDamageForce( self.Owner:GetRight() * 49125 + self.Owner:GetForward() * 99984 ) -- Yes we need those specific numbers
  140.                     elseif ( anim == "fists_right" ) then
  141.                             dmginfo:SetDamageForce( self.Owner:GetRight() * -49124 + self.Owner:GetForward() * 99899 )
  142.                     elseif ( anim == "fists_uppercut" ) then
  143.                             dmginfo:SetDamageForce( self.Owner:GetUp() * 51589 + self.Owner:GetForward() * 100128 )
  144.                             dmginfo:SetDamage( math.random( 15, 25 ) )
  145.                     end
  146.                     dmginfo:SetInflictor( self )
  147.                     local attacker = self.Owner
  148.                     if ( !IsValid( attacker ) ) then attacker = self end
  149.                     dmginfo:SetAttacker( attacker )
  150.  
  151.                     local vPoint = Vector(0,0,0)
  152.                     local effectdata = EffectData()
  153.                     effectdata:SetStart( tr.HitPos ) // not sure if we need a start and origin (endpoint) for this effect, but whatever
  154.                     effectdata:SetOrigin( tr.HitPos )
  155.                
  156.                     util.Effect( "BloodImpact", effectdata )
  157.                
  158.                     tr.Entity:TakeDamageInfo( dmginfo )
  159.                    
  160.                     self.Owner:EmitSound( "npc/fast_zombie/claw_strike"..(math.random(1,3))..".wav" )
  161.             else
  162.                 self.Owner:EmitSound( "Flesh.ImpactHard" )
  163.             end
  164.         end
  165. end
  166.  
  167. function SWEP:Idle()
  168.  
  169.         local vm = self.Owner:GetViewModel()
  170.         timer.Create( "fists_idle" .. self:EntIndex(), vm:SequenceDuration(), 1, function()
  171.                 vm:ResetSequence( vm:LookupSequence( "fists_idle_0" .. math.random( 1, 2 ) ) )
  172.         end )
  173.  
  174. end
  175.  
  176. function SWEP:OnRemove()
  177.  
  178.         if ( IsValid( self.Owner ) ) then
  179.                 local vm = self.Owner:GetViewModel()
  180.                 if ( IsValid( vm ) ) then vm:SetMaterial( "" ) end
  181.         end
  182.  
  183.         timer.Stop( "fists_idle" .. self:EntIndex() )
  184.  
  185. end
  186.  
  187. function SWEP:Holster( wep )
  188.  
  189.         self:OnRemove()
  190.  
  191.         return true
  192. end
  193.  
  194. function SWEP:Deploy()
  195.  
  196.         local vm = self.Owner:GetViewModel()
  197.         vm:ResetSequence( vm:LookupSequence( "fists_draw" ) )
  198.  
  199.         self:Idle()
  200.  
  201.         return true
  202.  
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement