Advertisement
Guest User

qazxcvbnmmbvcx

a guest
Sep 22nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. --[[
  2. Created by Chessnut for the Chessnut's Corner community.
  3. http://chessnut.info
  4. --]]
  5.  
  6. AddCSLuaFile();
  7.  
  8. if (CLIENT) then
  9. SWEP.PrintName = "Fists"
  10. SWEP.Slot = 1;
  11. SWEP.SlotPos = 1;
  12. SWEP.DrawAmmo = false;
  13. SWEP.DrawCrosshair = false;
  14. end;
  15.  
  16. SWEP.Author = "\67\104\101\115\115\110\117\116"
  17. SWEP.Instructions = "Primary Fire: Punch,\nSecondary Fire: Knock";
  18. SWEP.Purpose = "Hitting things and knocking on doors."
  19. SWEP.Drop = false;
  20.  
  21. SWEP.ViewModelFOV = 48;
  22. SWEP.ViewModelFlip = false;
  23. SWEP.AnimPrefix = "rpg";
  24.  
  25. SWEP.ViewTranslation = 4;
  26.  
  27. SWEP.Primary.ClipSize = -1;
  28. SWEP.Primary.DefaultClip = -1;
  29. SWEP.Primary.Automatic = false;
  30. SWEP.Primary.Ammo = "";
  31. SWEP.Primary.Damage = 20;
  32. SWEP.Primary.Delay = 0.75;
  33.  
  34. SWEP.Secondary.ClipSize = -1;
  35. SWEP.Secondary.DefaultClip = 0;
  36. SWEP.Secondary.Automatic = false;
  37. SWEP.Secondary.Ammo = "";
  38.  
  39. SWEP.ViewModel = Model("models/weapons/v_fists.mdl");
  40. SWEP.WorldModel = ""
  41.  
  42. SWEP.UseHands = true;
  43.  
  44. function SWEP:PreDrawViewModel(viewModel, weapon, client)
  45. local hands = player_manager.RunClass(client, "GetHandsModel");
  46.  
  47. if (hands and hands.model) then
  48. viewModel:SetModel(hands.model);
  49. end;
  50. end;
  51.  
  52. ACT_VM_FISTS_DRAW = 3;
  53. ACT_VM_FISTS_HOLSTER = 2;
  54.  
  55. function SWEP:Deploy()
  56. if ( !IsValid(self.Owner) ) then
  57. return;
  58. end;
  59.  
  60. local viewModel = self.Owner:GetViewModel();
  61.  
  62. if ( IsValid(viewModel) ) then
  63. viewModel:SetPlaybackRate(0.5);
  64. viewModel:ResetSequence(ACT_VM_FISTS_DRAW);
  65. end;
  66.  
  67. return true;
  68. end;
  69.  
  70. function SWEP:Holster()
  71. if ( !IsValid(self.Owner) ) then
  72. return;
  73. end;
  74.  
  75. local viewModel = self.Owner:GetViewModel();
  76.  
  77. if ( IsValid(viewModel) ) then
  78. viewModel:SetPlaybackRate(0.5);
  79. viewModel:ResetSequence(ACT_VM_FISTS_HOLSTER);
  80. end;
  81.  
  82. return true;
  83. end;
  84.  
  85. function SWEP:Precache()
  86. util.PrecacheSound("npc/vort/claw_swing1.wav");
  87. util.PrecacheSound("npc/vort/claw_swing2.wav");
  88. util.PrecacheSound("physics/plastic/plastic_box_impact_hard1.wav");
  89. util.PrecacheSound("physics/plastic/plastic_box_impact_hard2.wav");
  90. util.PrecacheSound("physics/plastic/plastic_box_impact_hard3.wav");
  91. util.PrecacheSound("physics/plastic/plastic_box_impact_hard4.wav");
  92. end;
  93.  
  94. function SWEP:Initialize()
  95. self:SetWeaponHoldType("fist");
  96. self.LastHand = 0;
  97. end;
  98.  
  99. function SWEP:DoPunchAnimation()
  100. self.LastHand = math.abs(1 - self.LastHand);
  101.  
  102. local sequence = 4 + self.LastHand;
  103. local viewModel = self.Owner:GetViewModel();
  104.  
  105. if ( IsValid(viewModel) ) then
  106. viewModel:SetPlaybackRate(0.525);
  107. viewModel:SetSequence(sequence);
  108. end;
  109. end;
  110.  
  111. function SWEP:PrimaryAttack()
  112. if ( !IsFirstTimePredicted() ) then
  113. return
  114. end
  115.  
  116. self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
  117. self:EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav")
  118.  
  119. local damage = self.Primary.Damage
  120.  
  121. self:DoPunchAnimation()
  122. self.Owner:SetAnimation(PLAYER_ATTACK1)
  123. self.Owner:ViewPunch( Angle(self.LastHand + 2, self.LastHand + 5, 0.125) )
  124.  
  125. timer.Simple(0.055, function()
  126. if (IsValid(self) and IsValid(self.Owner)) then
  127. local damage = self.Primary.Damage
  128. local data = {}
  129. data.start = self.Owner:GetShootPos()
  130. data.endpos = data.start + self.Owner:GetAimVector()*108
  131. data.filter = self.Owner
  132. local trace = util.TraceLine(data)
  133.  
  134. if (SERVER and trace.Hit) then
  135. local entity = trace.Entity
  136.  
  137. if (IsValid(entity)) then
  138. local damageInfo = DamageInfo()
  139. damageInfo:SetAttacker(self.Owner)
  140. damageInfo:SetInflictor(self)
  141. damageInfo:SetDamage(damage)
  142. damageInfo:SetDamageType(DMG_SLASH)
  143. damageInfo:SetDamagePosition(trace.HitPos)
  144. damageInfo:SetDamageForce(self.Owner:GetAimVector()*10000)
  145. entity:DispatchTraceAttack(damageInfo, data.start, data.endpos)
  146.  
  147. self.Owner:EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80)
  148. end
  149. end
  150. end
  151. end)
  152. end;
  153.  
  154. function SWEP:SecondaryAttack()
  155. local trace = self.Owner:GetEyeTraceNoCursor();
  156. local entity = trace.Entity;
  157.  
  158. if ( SERVER and IsValid(entity) and string.find(entity:GetClass(), "door") ) then
  159. local distance = self.Owner:EyePos():Distance(trace.HitPos);
  160.  
  161. if (distance > 72) then
  162. return;
  163. end;
  164.  
  165. self.Owner:ViewPunch( Angle(-1.3, 1.8, 0) );
  166. self.Owner:EmitSound("physics/plastic/plastic_box_impact_hard"..math.random(1, 4)..".wav");
  167. self.Owner:SetAnimation(PLAYER_ATTACK1);
  168.  
  169. self:DoPunchAnimation();
  170. self:SetNextSecondaryFire(CurTime() + 0.4);
  171. self:SetNextPrimaryFire(CurTime() + 1);
  172. end;
  173. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement