Advertisement
jordan3012000

Untitled

Apr 12th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. if ( SERVER ) then
  2. AddCSLuaFile( "shared.lua" )
  3.  
  4. end
  5.  
  6. if ( CLIENT ) then
  7. SWEP.PrintName = "Shadow Virus Grenade"
  8. SWEP.Purpose = "Harm players that stand inside the virus cloud."
  9. SWEP.Instructions = "Left click to throw the grenade."
  10. SWEP.Category = "Star Wars (Updated)"
  11. SWEP.Slot = 4
  12. SWEP.SlotPos = 0
  13. SWEP.ViewModelFlip = false
  14. SWEP.UseHands = true
  15.  
  16. SWEP.WepSelectIcon = surface.GetTextureID("HUD/killicons/shadowvirus_grenade")
  17.  
  18. killicon.Add( "weapon_shadowvirus_grenade", "HUD/killicons/shadowvirus_grenade", Color( 255, 80, 0, 255 ) )
  19.  
  20. end
  21.  
  22. SWEP.Icon = "VGUI/ttt/icon_nades"
  23. SWEP.Base = "weapon_base"
  24. SWEP.Kind = WEAPON_NADE
  25. SWEP.HoldType = "grenade"
  26.  
  27. SWEP.Spawnable = true
  28. SWEP.AdminSpawnable = true
  29.  
  30. SWEP.ViewModel = "models/weapons/cstrike/c_eq_flashbang.mdl"
  31. SWEP.WorldModel = "models/weapons/w_eq_flashbang.mdl"
  32.  
  33. SWEP.Primary.Sound = Sound("Default.PullPin_Grenade")
  34. SWEP.Primary.Recoil = 0
  35. SWEP.Primary.Unrecoil = 0
  36. SWEP.Primary.Damage = 0
  37. SWEP.Primary.NumShots = 1
  38. SWEP.Primary.Cone = 0
  39. SWEP.Primary.Delay = 1
  40. SWEP.Primary.Ammo = "SLAM"
  41. SWEP.Primary.ClipSize = -1
  42. SWEP.Primary.DefaultClip = 1
  43. SWEP.Primary.Automatic = false
  44.  
  45. SWEP.Secondary.ClipSize = -1
  46. SWEP.Secondary.DefaultClip = 1
  47. SWEP.Secondary.Automatic = false
  48. SWEP.Secondary.Ammo = "none"
  49.  
  50. SWEP.Next = CurTime()
  51. SWEP.Primed = 0
  52.  
  53. function SWEP:Reload()
  54. return false
  55. end
  56.  
  57. function SWEP:Deploy()
  58. return true
  59. end
  60.  
  61. function SWEP:Holster()
  62. self.Next = CurTime()
  63. self.Primed = 0
  64. return true
  65. end
  66.  
  67. function SWEP:ShootEffects()
  68. self.Weapon:SendWeaponAnim( ACT_VM_THROW ) // View model animation
  69. //self.Owner:MuzzleFlash() // Crappy muzzle light
  70. self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation
  71. end
  72.  
  73.  
  74. function SWEP:PrimaryAttack()
  75. if self.Next < CurTime() and self.Primed == 0 and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  76. self.Next = CurTime() + self.Primary.Delay
  77.  
  78. self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN)
  79. self.Primed = 1
  80. //self.Weapon:EmitSound(self.Primary.Sound)
  81. end
  82. end
  83.  
  84. function SWEP:SecondaryAttack()
  85. return false
  86. end
  87.  
  88. function SWEP:Think()
  89. if self.Next < CurTime() then
  90. if self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK) then
  91. self.Weapon:SendWeaponAnim(ACT_VM_THROW)
  92. self.Primed = 2
  93. self.Next = CurTime() + .3
  94. elseif self.Primed == 2 then
  95. self.Primed = 0
  96. self.Next = CurTime() + self.Primary.Delay
  97.  
  98. if SERVER then
  99. local ent = ents.Create("cse_ent_shortgasgrenade")
  100. ent:SetOwner(self.Owner)
  101. ent.Owner = self.Owner
  102. ent:SetPos(self.Owner:GetShootPos())
  103. ent:SetAngles(Angle(1,0,0))
  104. if (self.Weapon:GetNWBool("upgraded") && SERVER) then
  105. ent:Upgrade()
  106. ent:SetNWBool("upgraded", true)
  107. end
  108. ent:Spawn()
  109.  
  110. local phys = ent:GetPhysicsObject()
  111. phys:SetVelocity(self.Owner:GetAimVector() * 1000)
  112. phys:AddAngleVelocity(Vector(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000)))
  113.  
  114. self.Owner:RemoveAmmo(1,self.Primary.Ammo)
  115.  
  116. if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  117. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  118. else
  119. timer.Simple(1, function() self.Owner:StripWeapon(self:GetClass()) end) -- Delay so anim is displayed, tends to look better
  120. end
  121. end
  122. end
  123. end
  124. end
  125.  
  126. function SWEP:PreDrawViewModel( vm )
  127. vm:SetMaterial("models/weapons/v_models/grenades/virus_grenade")
  128. end
  129.  
  130. function SWEP:PostDrawViewModel( vm ) -- Paint it back
  131. vm:SetMaterial("")
  132. end
  133.  
  134. function SWEP:DrawWorldModel()
  135. self:DrawModel()
  136. self:SetMaterial("models/weapons/v_models/grenades/virus_grenade")
  137. end
  138.  
  139. function SWEP:GetGrenadeName()
  140. return "ttt_smokegrenade_proj"
  141. end
  142.  
  143. function SWEP:ShouldDropOnDie()
  144. return true
  145. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement