Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. SWEP.PrintName = "Fists"
  5. SWEP.Author = "Kilburn, robotboy655, MaxOfS2D & Tenrys"
  6. SWEP.Purpose = "Well we sure as hell didn't use guns! We would just wrestle Hunters to the ground with our bare hands! I used to kill ten, twenty a day, just using my fists."
  7.  
  8. SWEP.Slot = 0
  9. SWEP.SlotPos = 4
  10.  
  11. SWEP.Spawnable = true
  12.  
  13. SWEP.ViewModel = Model( "models/weapons/c_arms.mdl" )
  14. SWEP.WorldModel = ""
  15. SWEP.ViewModelFOV = 54
  16. SWEP.UseHands = true
  17.  
  18. SWEP.Primary.ClipSize = -1
  19. SWEP.Primary.DefaultClip = -1
  20. SWEP.Primary.Automatic = true
  21. SWEP.Primary.Ammo = "none"
  22.  
  23. SWEP.Secondary.ClipSize = -1
  24. SWEP.Secondary.DefaultClip = -1
  25. SWEP.Secondary.Automatic = true
  26. SWEP.Secondary.Ammo = "none"
  27.  
  28. SWEP.DrawAmmo = false
  29.  
  30. SWEP.HitDistance = 48
  31.  
  32. local SwingSound = Sound( "WeaponFrag.Throw" )
  33. local HitSound = Sound( "Flesh.ImpactHard" )
  34.  
  35. function SWEP:Initialize()
  36.  
  37. self:SetHoldType( "fist" )
  38.  
  39. end
  40.  
  41. function SWEP:SetupDataTables()
  42.  
  43. self:NetworkVar( "Float", 0, "NextMeleeAttack" )
  44. self:NetworkVar( "Float", 1, "NextIdle" )
  45. self:NetworkVar( "Int", 2, "Combo" )
  46.  
  47. end
  48.  
  49. function SWEP:UpdateNextIdle()
  50.  
  51. local vm = self.Owner:GetViewModel()
  52. self:SetNextIdle( CurTime() + vm:SequenceDuration() / vm:GetPlaybackRate() )
  53.  
  54. end
  55.  
  56. local _list = {};
  57.  
  58. function printProp(_e)
  59. //local _e = LocalPlayer():GetEyeTrace().Entity;
  60. if !IsValid(_e) then return end
  61. table.insert(_list, "{ Vector(" .. _e:GetPos().x .. "," .._e:GetPos().y .. "," .. _e:GetPos().z.."), Angle(" .. _e:GetAngles().p .. "," .. _e:GetAngles().y .. "," .. _e:GetAngles().r .. "), " .. _e:GetModel() .. " }");
  62.  
  63.  
  64. end
  65.  
  66. function SWEP:PrimaryAttack( right )
  67.  
  68. if self.Owner:GetEyeTrace().Entity then
  69. printProp(self.Owner:GetEyeTrace().Entity )
  70. end
  71.  
  72. self.Owner:ChatPrint("Added prop (#" .. #_list .. ")" )
  73.  
  74. self:SetNextPrimaryFire( CurTime() + 0.5)
  75. end
  76. local lastList = 0;
  77. function SWEP:Reload()
  78.  
  79. if CurTime() < lastList then return end
  80. _list = {};
  81. _count = 1;
  82. self.Owner:ChatPrint("Reset List")
  83. lastList = CurTime() + 0.5
  84. end
  85.  
  86. function SWEP:SecondaryAttack()
  87.  
  88. self.Owner:ChatPrint("Printing List Check Console")
  89.  
  90. for k , v in pairs( _list ) do
  91. print(v)
  92. end
  93. self:SetNextSecondaryFire( CurTime() + 0.5)
  94.  
  95. end
  96.  
  97. function SWEP:DealDamage()
  98.  
  99. local anim = self:GetSequenceName(self.Owner:GetViewModel():GetSequence())
  100.  
  101. self.Owner:LagCompensation( true )
  102.  
  103. local tr = util.TraceLine( {
  104. start = self.Owner:GetShootPos(),
  105. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
  106. filter = self.Owner,
  107. mask = MASK_SHOT_HULL
  108. } )
  109.  
  110. if ( !IsValid( tr.Entity ) ) then
  111. tr = util.TraceHull( {
  112. start = self.Owner:GetShootPos(),
  113. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * self.HitDistance,
  114. filter = self.Owner,
  115. mins = Vector( -10, -10, -8 ),
  116. maxs = Vector( 10, 10, 8 ),
  117. mask = MASK_SHOT_HULL
  118. } )
  119. end
  120.  
  121. -- We need the second part for single player because SWEP:Think is ran shared in SP
  122. if ( tr.Hit && !( game.SinglePlayer() && CLIENT ) ) then
  123. self:EmitSound( HitSound )
  124. end
  125.  
  126. local hit = false
  127.  
  128. if ( SERVER && IsValid( tr.Entity ) && ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) ) then
  129. local dmginfo = DamageInfo()
  130.  
  131. local attacker = self.Owner
  132. if ( !IsValid( attacker ) ) then attacker = self end
  133. dmginfo:SetAttacker( attacker )
  134.  
  135. dmginfo:SetInflictor( self )
  136. dmginfo:SetDamage( math.random( 8, 12 ) )
  137.  
  138. if ( anim == "fists_left" ) then
  139. dmginfo:SetDamageForce( self.Owner:GetRight() * 4912 + self.Owner:GetForward() * 9998 ) -- Yes we need those specific numbers
  140. elseif ( anim == "fists_right" ) then
  141. dmginfo:SetDamageForce( self.Owner:GetRight() * -4912 + self.Owner:GetForward() * 9989 )
  142. elseif ( anim == "fists_uppercut" ) then
  143. dmginfo:SetDamageForce( self.Owner:GetUp() * 5158 + self.Owner:GetForward() * 10012 )
  144. dmginfo:SetDamage( math.random( 12, 24 ) )
  145. end
  146.  
  147. tr.Entity:TakeDamageInfo( dmginfo )
  148. hit = true
  149.  
  150. end
  151.  
  152. if ( SERVER && IsValid( tr.Entity ) ) then
  153. local phys = tr.Entity:GetPhysicsObject()
  154. if ( IsValid( phys ) ) then
  155. phys:ApplyForceOffset( self.Owner:GetAimVector() * 80 * phys:GetMass(), tr.HitPos )
  156. end
  157. end
  158.  
  159. if ( SERVER ) then
  160. if ( hit && anim != "fists_uppercut" ) then
  161. self:SetCombo( self:GetCombo() + 1 )
  162. else
  163. self:SetCombo( 0 )
  164. end
  165. end
  166.  
  167. self.Owner:LagCompensation( false )
  168.  
  169. end
  170.  
  171. function SWEP:OnDrop()
  172.  
  173. self:Remove() -- You can't drop fists
  174.  
  175. end
  176.  
  177. function SWEP:Deploy()
  178.  
  179. local speed = GetConVarNumber( "sv_defaultdeployspeed" )
  180.  
  181. local vm = self.Owner:GetViewModel()
  182. vm:SendViewModelMatchingSequence( vm:LookupSequence( "fists_draw" ) )
  183. vm:SetPlaybackRate( speed )
  184.  
  185. self:SetNextPrimaryFire( CurTime() + vm:SequenceDuration() / speed )
  186. self:SetNextSecondaryFire( CurTime() + vm:SequenceDuration() / speed )
  187. self:UpdateNextIdle()
  188.  
  189. if ( SERVER ) then
  190. self:SetCombo( 0 )
  191. end
  192.  
  193. return true
  194.  
  195. end
  196.  
  197. function SWEP:Think()
  198.  
  199. local vm = self.Owner:GetViewModel()
  200. local curtime = CurTime()
  201. local idletime = self:GetNextIdle()
  202.  
  203. if ( idletime > 0 && CurTime() > idletime ) then
  204.  
  205. vm:SendViewModelMatchingSequence( vm:LookupSequence( "fists_idle_0" .. math.random( 1, 2 ) ) )
  206.  
  207. self:UpdateNextIdle()
  208.  
  209. end
  210.  
  211. local meleetime = self:GetNextMeleeAttack()
  212.  
  213. if ( meleetime > 0 && CurTime() > meleetime ) then
  214.  
  215. //self:DealDamage()
  216.  
  217. self:SetNextMeleeAttack( 0 )
  218.  
  219. end
  220.  
  221. if ( SERVER && CurTime() > self:GetNextPrimaryFire() + 0.1 ) then
  222.  
  223. self:SetCombo( 0 )
  224.  
  225. end
  226.  
  227. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement