Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile()
- end
- SWEP.PrintName = "Teemo's Poison Dart Shooter"
- SWEP.Author = "Your Name Here"
- SWEP.Instructions = "Left click to shoot a poison dart that deals damage over time."
- SWEP.Spawnable = true
- SWEP.AdminOnly = false
- SWEP.Category = "Teemo's Weapons"
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "none"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = true
- SWEP.Secondary.Ammo = "none"
- SWEP.IsPoisoned = false
- SWEP.Weight = 5
- SWEP.AutoSwitchTo = false
- SWEP.AutoSwitchFrom = false
- SWEP.Slot = 1
- SWEP.SlotPos = 2
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = false
- SWEP.PoisonDamage = 5 -- Damage per tick of poison
- SWEP.PoisonInterval = 1 -- Time between poison ticks in seconds
- SWEP.PoisonDuration = 5 -- Duration of poison in seconds
- local ShootSound = Sound("weapons/pistol/pistol_fire3.wav")
- local TeemoIcon = Material("vgui/hud/teemo_icon")
- function SWEP:PrimaryAttack()
- self:SetNextPrimaryFire(CurTime() + 0.5)
- local bullet = {}
- bullet.Num = 1
- bullet.Src = self.Owner:GetShootPos()
- bullet.Dir = self.Owner:GetAimVector()
- bullet.Spread = Vector(0, 0, 0)
- bullet.Tracer = 1
- bullet.TracerName = "Tracer"
- bullet.Force = 1
- bullet.Damage = 0
- self.Owner:FireBullets(bullet)
- self:EmitSound(ShootSound)
- self:ShootEffects()
- self:TakePrimaryAmmo(1)
- if SERVER then
- local pos = self.Owner:GetShootPos()
- local ang = self.Owner:GetAimVector()
- local ent = ents.Create("teemo_poison_dart")
- ent:SetPos(pos + ang * 20)
- ent:SetAngles(ang:Angle())
- ent:SetOwner(self.Owner)
- ent:Spawn()
- ent:Activate()
- timer.Simple(self.PoisonDuration, function()
- if IsValid(ent) then
- ent:Remove()
- end
- end)
- end
- end
- function SWEP:Think()
- if SERVER then
- for _, ply in pairs(player.GetAll()) do
- if ply:IsPoisoned() then
- local timeLeft = ply:GetPoisoned() - CurTime()
- if timeLeft <= 0 then
- ply:SetPoisoned(false)
- else
- local damageTaken = self.PoisonDamage * FrameTime()
- ply:TakeDamage(damageTaken, self.Owner, self)
- end
- end
- end
- end
- end
- if CLIENT then
- function SWEP:DrawHUD()
- surface.SetDrawColor(255, 255, 255, 255)
- surface.SetMaterial(TeemoIcon)
- surface.DrawTexturedRect(20, ScrH() - 80, 64, 64)
- local totalDamage = self.PoisonDamage * (self.PoisonDuration / self.PoisonInterval)
- local timeLeft = 0
- if LocalPlayer():GetPoisoned() then
- timeLeft = LocalPlayer():GetPoisoned()
- end
- if timeLeft > 0 then
- local text = string.format("Poisoned: %d damage over %d seconds", totalDamage, math.ceil(timeLeft))
- draw.DrawText(text, "DermaDefaultBold", ScrW() * 0.5, ScrH() * 0.9, Color(255, 255, 255), TEXT_ALIGN_CENTER)
- end
- end
- end
- if SERVER then
- function SWEP:PrimaryAttack()
- if self:GetNextPrimaryFire() > CurTime() then return end
- local tr = self.Owner:GetEyeTrace()
- local ent = tr.Entity
- if not IsValid(ent) or not ent:IsNPC() and not ent:IsPlayer() then return end
- local dmg = DamageInfo()
- dmg:SetDamage(self.Primary.Damage)
- dmg:SetDamageType(self.Primary.DamageType)
- dmg:SetAttacker(self.Owner)
- dmg:SetInflictor(self)
- ent:TakeDamageInfo(dmg)
- if ent:IsNPC() then
- ent:SetHealth(ent:Health() - self.Primary.Damage)
- end
- if ent:IsPlayer() then
- ent:ViewPunch(Angle(-10, math.random(-5, 5), 0))
- end
- self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
- if ent:IsPlayer() then
- self:SetPoisoned(CurTime() + self.PoisonDuration)
- end
- end
- function SWEP:Think()
- if self:IsPoisoned() then
- local totalDamage = self.PoisonDamage * self.PoisonDuration
- local timeLeft = self:GetPoisoned() - CurTime()
- if timeLeft > 0 then
- local dmg = DamageInfo()
- dmg:SetDamage(self.PoisonDamage)
- dmg:SetDamageType(DMG_GENERIC)
- dmg:SetAttacker(self.Owner)
- dmg:SetInflictor(self)
- self.Owner:TakeDamageInfo(dmg)
- self.PoisonDuration = self.PoisonDuration - self.PoisonInterval
- self:SetPoisoned(CurTime() + self.PoisonInterval)
- else
- self:SetPoisoned(0)
- self.PoisonDuration = 0
- end
- end
- end
- end
- if CLIENT then
- local TeemoIcon = Material("vgui/hud/teemo_icon")
- function SWEP:DrawHUD()
- surface.SetDrawColor(255, 255, 255, 255)
- surface.SetMaterial(TeemoIcon)
- surface.DrawTexturedRect(20, ScrH() - 80, 64, 64)
- if self:GetPoisoned() > CurTime() then
- local totalDamage = self.PoisonDamage * self.PoisonDuration
- local timeLeft = self:GetPoisoned() - CurTime()
- local text = string.format("Poisoned: %d damage over %d seconds", totalDamage, math.ceil(timeLeft))
- draw.DrawText(text, "DermaDefaultBold", ScrW() * 0.5, ScrH() * 0.9, Color(255, 255, 255), TEXT_ALIGN_CENTER)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement