Advertisement
Guest User

Untitled

a guest
May 3rd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.64 KB | None | 0 0
  1. --[[
  2.     © 2020 The Empire Limited,  re-use or modify
  3.    
  4.     without permission of its author (chris@theempire.com).
  5. ]]
  6. SWEP.Base = "gs_baseweapon"
  7.  
  8. SWEP.PrintName = "Fists"
  9. SWEP.Author = "Chris"
  10. SWEP.Category = "Empire"
  11. SWEP.Spawnable = true
  12. SWEP.Slot = 1
  13. SWEP.SlotPos = 4
  14.  
  15. SWEP.ViewModel = "models/weapons/c_arms.mdl"
  16. SWEP.UseHands = true
  17. SWEP.WorldModel = ""
  18. SWEP.HoldType = "fist"
  19.  
  20. SWEP.Activities = {
  21.     draw = "fists_draw",
  22.     holster = "fists_holster",
  23.     idle = {{"fists_idle_01", "fists_idle_02"}},
  24.     hit = "fists_left",
  25.     miss = "fists_left",
  26.     hit_alt = "fists_right",
  27.     miss_alt = "fists_right",
  28.     critical = "fists_uppercut",
  29.     admire = "seq_admire"
  30. }
  31.  
  32. SWEP.Sounds = {
  33.     hit = "Flesh.ImpactHard",
  34.     hitworld = "Flesh.ImpactHard",
  35.     miss = "WeaponFrag.Throw"
  36. }
  37.  
  38. SWEP.Primary.Damage = function() return code_gs.random:RandomInt(8, 12) end
  39. SWEP.Primary.Force = 80
  40. SWEP.Primary.Range = 48
  41. SWEP.Primary.Cooldown = 0.9
  42. SWEP.Primary.Delay = 0.2
  43. SWEP.Primary.ComboDamage = function() return code_gs.random:RandomInt(12, 24) end
  44.  
  45. SWEP.Secondary.MaxDamage = -1
  46. SWEP.Secondary.ComboDamage = -1
  47.  
  48. SWEP.Melee = {
  49.     AlwaysPlaySwing = true,
  50.     TestHull = Vector(10, 10, 8),
  51.     ComboCount = 2
  52. }
  53.  
  54. if (CLIENT) then
  55.     SWEP.Category = "Empire"
  56.     SWEP.ViewModelFOV = 54
  57. end
  58.  
  59. local BaseClass = baseclass.Get(SWEP.Base)
  60. local bRun = SERVER or not game.SinglePlayer()
  61.  
  62. if (SERVER or not game.SinglePlayer()) then
  63.     function SWEP:Initialize()
  64.         BaseClass.Initialize(self)
  65.  
  66.         self:SetupPredictedVar("m_iCombo", 0)
  67.     end
  68.  
  69.     function SWEP:ItemFrame()
  70.         if (self:GetOwner():MouseLifted() and self:GetNextPrimaryFire() < CurTime()) then
  71.             self:SetPredictedVar("m_iCombo", 0)
  72.         end
  73.     end
  74. end
  75.  
  76. function SWEP:PrimaryAttack()
  77.     if (self:CanPrimaryAttack(0)) then
  78.         self:Swing(false, 0)
  79.         self:SetNextSecondaryFire(CurTime() + self:GetSpecialKey("Cooldown", false))
  80.  
  81.         return true
  82.     end
  83.  
  84.     return false
  85. end
  86.  
  87. function SWEP:SecondaryAttack()
  88.     if (self:CanSecondaryAttack(0)) then
  89.         self:Swing(true, 0)
  90.         self:SetNextSecondaryFire(CurTime() + self:GetSpecialKey("Cooldown", true))
  91.  
  92.         return true
  93.     end
  94.  
  95.     return false
  96. end
  97.  
  98.  
  99. function SWEP:CanReload(iIndex)
  100.     local flNextReload = self:GetNextReload()
  101.  
  102.     if (flNextReload == -1) then
  103.         if (self:GetPredictedVar("m_bLowered") and not self:EventActive("lower")) then
  104.             self:ToggleFullyLowered(iIndex)
  105.         end
  106.  
  107.         return false
  108.     end
  109.  
  110.     if (flNextReload > CurTime()) then
  111.         return false
  112.     end
  113.  
  114.     local pPlayer = self:GetOwner()
  115.  
  116.     if (pPlayer == NULL) then
  117.         return false
  118.     end
  119.  
  120.     return true
  121. end
  122.  
  123. function SWEP:Reload()
  124.     if (self:CanReload(0)) then
  125.         self:ToggleFullyLowered(0)
  126.  
  127.         return true
  128.     end
  129.  
  130.     return false
  131. end
  132.  
  133. function SWEP:Smack(tr, vForward, bSecondary, iIndex)
  134.     BaseClass.Smack(self, tr, vForward, bSecondary, iIndex)
  135.  
  136.     if (tr.Fraction == 1) then
  137.         self:SetPredictedVar("m_iCombo", 0)
  138.     else
  139.         local iCombo = self:GetPredictedVar("m_iCombo")
  140.         self:SetPredictedVar("m_iCombo", iCombo == self.Melee.ComboCount and 0 or iCombo + 1)
  141.     end
  142. end
  143.  
  144. local phys_pushscale = GetConVar("phys_pushscale")
  145.  
  146. function SWEP:SmackDamage(tr, vForward, bSecondary)
  147.     local pPlayer = self:GetOwner()
  148.     local pEntity = tr.Entity
  149.  
  150.     local info = DamageInfo()
  151.         code_gs.random:SetSeed(self:GetOwner():GetMD5Seed() % 0x100)
  152.  
  153.         if (self:GetPredictedVar("m_iCombo") == self.Melee.ComboCount) then
  154.             info:SetDamage(self:GetSpecialKey("ComboDamage", bSecondary))
  155.             info:SetDamageForce(vForward:Up() * 5158 + vForward * 10012)
  156.         else
  157.             info:SetDamage(self:GetSpecialKey("Damage", bSecondary))
  158.  
  159.             if (bSecondary) then
  160.                 info:SetDamageForce(vForward:Right() * -4912 + vForward * 9989)
  161.             else
  162.                 info:SetDamageForce(vForward:Right() * 4912 + vForward * 9998)
  163.             end
  164.         end
  165.  
  166.         info:SetAttacker(pPlayer)
  167.         info:SetInflictor(self)
  168.         info:SetDamageType(self.Melee.DamageType)
  169.         info:SetDamagePosition(tr.HitPos)
  170.         info:SetReportedPosition(tr.StartPos)
  171.     pEntity:DispatchTraceAttack(info, tr, vForward)
  172.  
  173.     local pPhysObj = pEntity:GetPhysicsObject()
  174.  
  175.     if (pPhysObj:IsValid()) then
  176.         pPhysObj:ApplyForceOffset(vForward * pPhysObj:GetMass() * self:GetSpecialKey("Force", bSecondary) * phys_pushscale:GetFloat(), tr.HitPos)
  177.     end
  178. end
  179.  
  180. local tCriticalActs = {
  181.     hit = true,
  182.     miss = true,
  183.     hit_alt = true,
  184.     miss_alt = true
  185. }
  186.  
  187. function SWEP:PlayActivity(Activity, iIndex --[[= 0]], flRate --[[= 1]], bStrictPrefix --[[= false]], bStrictSuffix --[[= false]])
  188.     return BaseClass.PlayActivity(self, isstring(Activity) and tCriticalActs[Activity:lower()] and self:GetPredictedVar("m_iCombo") == 2 and "critical" or Activity, iIndex, flRate, bStrictPrefix, bStrictSuffix)
  189. end
  190.  
  191. function SWEP:DoImpactEffect()
  192.     return true
  193. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement