Advertisement
wifiboost

teemo dart shooter

Mar 11th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile()
  3. end
  4.  
  5. SWEP.PrintName = "Teemo's Poison Dart Shooter"
  6. SWEP.Author = "Your Name Here"
  7. SWEP.Instructions = "Left click to shoot a poison dart that deals damage over time."
  8.  
  9. SWEP.Spawnable = true
  10. SWEP.AdminOnly = false
  11. SWEP.Category = "Teemo's Weapons"
  12.  
  13. SWEP.Primary.ClipSize = -1
  14. SWEP.Primary.DefaultClip = -1
  15. SWEP.Primary.Automatic = true
  16. SWEP.Primary.Ammo = "none"
  17.  
  18. SWEP.Secondary.ClipSize = -1
  19. SWEP.Secondary.DefaultClip = -1
  20. SWEP.Secondary.Automatic = true
  21. SWEP.Secondary.Ammo = "none"
  22. SWEP.IsPoisoned = false
  23. SWEP.Weight = 5
  24. SWEP.AutoSwitchTo = false
  25. SWEP.AutoSwitchFrom = false
  26.  
  27. SWEP.Slot = 1
  28. SWEP.SlotPos = 2
  29.  
  30. SWEP.DrawAmmo = false
  31. SWEP.DrawCrosshair = false
  32.  
  33. SWEP.PoisonDamage = 5 -- Damage per tick of poison
  34. SWEP.PoisonInterval = 1 -- Time between poison ticks in seconds
  35. SWEP.PoisonDuration = 5 -- Duration of poison in seconds
  36.  
  37. local ShootSound = Sound("weapons/pistol/pistol_fire3.wav")
  38. local TeemoIcon = Material("vgui/hud/teemo_icon")
  39.  
  40. function SWEP:PrimaryAttack()
  41. self:SetNextPrimaryFire(CurTime() + 0.5)
  42.  
  43. local bullet = {}
  44. bullet.Num = 1
  45. bullet.Src = self.Owner:GetShootPos()
  46. bullet.Dir = self.Owner:GetAimVector()
  47. bullet.Spread = Vector(0, 0, 0)
  48. bullet.Tracer = 1
  49. bullet.TracerName = "Tracer"
  50. bullet.Force = 1
  51. bullet.Damage = 0
  52. self.Owner:FireBullets(bullet)
  53.  
  54. self:EmitSound(ShootSound)
  55. self:ShootEffects()
  56. self:TakePrimaryAmmo(1)
  57.  
  58. if SERVER then
  59. local pos = self.Owner:GetShootPos()
  60. local ang = self.Owner:GetAimVector()
  61.  
  62. local ent = ents.Create("teemo_poison_dart")
  63. ent:SetPos(pos + ang * 20)
  64. ent:SetAngles(ang:Angle())
  65. ent:SetOwner(self.Owner)
  66. ent:Spawn()
  67. ent:Activate()
  68.  
  69. timer.Simple(self.PoisonDuration, function()
  70. if IsValid(ent) then
  71. ent:Remove()
  72. end
  73. end)
  74. end
  75. end
  76.  
  77. function SWEP:Think()
  78. if SERVER then
  79. for _, ply in pairs(player.GetAll()) do
  80. if ply:IsPoisoned() then
  81. local timeLeft = ply:GetPoisoned() - CurTime()
  82. if timeLeft <= 0 then
  83. ply:SetPoisoned(false)
  84. else
  85. local damageTaken = self.PoisonDamage * FrameTime()
  86. ply:TakeDamage(damageTaken, self.Owner, self)
  87. end
  88. end
  89. end
  90. end
  91. end
  92.  
  93. if CLIENT then
  94. function SWEP:DrawHUD()
  95. surface.SetDrawColor(255, 255, 255, 255)
  96. surface.SetMaterial(TeemoIcon)
  97. surface.DrawTexturedRect(20, ScrH() - 80, 64, 64)
  98.  
  99. local totalDamage = self.PoisonDamage * (self.PoisonDuration / self.PoisonInterval)
  100. local timeLeft = 0
  101.  
  102. if LocalPlayer():GetPoisoned() then
  103. timeLeft = LocalPlayer():GetPoisoned()
  104. end
  105.  
  106. if timeLeft > 0 then
  107. local text = string.format("Poisoned: %d damage over %d seconds", totalDamage, math.ceil(timeLeft))
  108. draw.DrawText(text, "DermaDefaultBold", ScrW() * 0.5, ScrH() * 0.9, Color(255, 255, 255), TEXT_ALIGN_CENTER)
  109. end
  110. end
  111. end
  112.  
  113. if SERVER then
  114. function SWEP:PrimaryAttack()
  115. if self:GetNextPrimaryFire() > CurTime() then return end
  116.  
  117. local tr = self.Owner:GetEyeTrace()
  118.  
  119. local ent = tr.Entity
  120.  
  121. if not IsValid(ent) or not ent:IsNPC() and not ent:IsPlayer() then return end
  122.  
  123. local dmg = DamageInfo()
  124. dmg:SetDamage(self.Primary.Damage)
  125. dmg:SetDamageType(self.Primary.DamageType)
  126. dmg:SetAttacker(self.Owner)
  127. dmg:SetInflictor(self)
  128.  
  129. ent:TakeDamageInfo(dmg)
  130.  
  131. if ent:IsNPC() then
  132. ent:SetHealth(ent:Health() - self.Primary.Damage)
  133. end
  134.  
  135. if ent:IsPlayer() then
  136. ent:ViewPunch(Angle(-10, math.random(-5, 5), 0))
  137. end
  138.  
  139. self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
  140.  
  141. if ent:IsPlayer() then
  142. self:SetPoisoned(CurTime() + self.PoisonDuration)
  143. end
  144. end
  145.  
  146. function SWEP:Think()
  147. if self:IsPoisoned() then
  148. local totalDamage = self.PoisonDamage * self.PoisonDuration
  149. local timeLeft = self:GetPoisoned() - CurTime()
  150.  
  151. if timeLeft > 0 then
  152. local dmg = DamageInfo()
  153. dmg:SetDamage(self.PoisonDamage)
  154. dmg:SetDamageType(DMG_GENERIC)
  155. dmg:SetAttacker(self.Owner)
  156. dmg:SetInflictor(self)
  157.  
  158. self.Owner:TakeDamageInfo(dmg)
  159.  
  160. self.PoisonDuration = self.PoisonDuration - self.PoisonInterval
  161. self:SetPoisoned(CurTime() + self.PoisonInterval)
  162. else
  163. self:SetPoisoned(0)
  164. self.PoisonDuration = 0
  165. end
  166. end
  167. end
  168. end
  169.  
  170. if CLIENT then
  171. local TeemoIcon = Material("vgui/hud/teemo_icon")
  172.  
  173. function SWEP:DrawHUD()
  174. surface.SetDrawColor(255, 255, 255, 255)
  175. surface.SetMaterial(TeemoIcon)
  176. surface.DrawTexturedRect(20, ScrH() - 80, 64, 64)
  177.  
  178. if self:GetPoisoned() > CurTime() then
  179. local totalDamage = self.PoisonDamage * self.PoisonDuration
  180. local timeLeft = self:GetPoisoned() - CurTime()
  181. local text = string.format("Poisoned: %d damage over %d seconds", totalDamage, math.ceil(timeLeft))
  182. draw.DrawText(text, "DermaDefaultBold", ScrW() * 0.5, ScrH() * 0.9, Color(255, 255, 255), TEXT_ALIGN_CENTER)
  183. end
  184. end
  185. end
  186.  
  187.  
  188.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement