From 8e1e8f6d8fe2fb705d11d4d74648c9c2e9bf5606 Mon Sep 17 00:00:00 2001 From: JetBoom Date: Sun, 9 Nov 2014 18:28:31 -0500 Subject: [PATCH] Added point floaters to healing other players. Added point floaters to healing other players. Fixed medic aura interfering with transparency radius. --- .../entities/effects/floatingscore_heal.lua | 37 +++++++++++++++++++ .../entities/weapons/weapon_zs_medicalkit.lua | 8 +--- .../entities/weapons/weapon_zs_medicgun.lua | 8 +--- .../gamemode/cl_floatingscore.lua | 12 ++++-- gamemodes/zombiesurvival/gamemode/cl_init.lua | 4 +- 5 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 gamemodes/zombiesurvival/entities/effects/floatingscore_heal.lua diff --git a/gamemodes/zombiesurvival/entities/effects/floatingscore_heal.lua b/gamemodes/zombiesurvival/entities/effects/floatingscore_heal.lua new file mode 100644 index 0000000..596a7a4 --- /dev/null +++ b/gamemodes/zombiesurvival/entities/effects/floatingscore_heal.lua @@ -0,0 +1,37 @@ +EFFECT.LifeTime = 3 + +function EFFECT:Init(data) + self:SetRenderBounds(Vector(-64, -64, -64), Vector(64, 64, 64)) + + self.Seed = math.Rand(0, 10) + + local pos = data:GetOrigin() + local amount = math.Round(data:GetMagnitude()) + + self.Pos = pos + self.Amount = amount + + self.DeathTime = CurTime() + self.LifeTime +end + +function EFFECT:Think() + self.Pos.z = self.Pos.z + FrameTime() * 32 + return CurTime() < self.DeathTime +end + +local col = Color(30, 255, 30, 255) +local col2 = Color(0, 0, 0, 255) +function EFFECT:Render() + local delta = math.Clamp(self.DeathTime - CurTime(), 0, self.LifeTime) / self.LifeTime + col.a = delta * 240 + col2.a = col.a + local ang = EyeAngles() + local right = ang:Right() + ang:RotateAroundAxis(ang:Up(), -90) + ang:RotateAroundAxis(ang:Forward(), 90) + cam.IgnoreZ(true) + cam.Start3D2D(self.Pos + math.sin(CurTime() + self.Seed) * 30 * delta * right, ang, (delta * 0.12 + 0.045) / 2) + draw.SimpleText(self.Amount, "ZS3D2DFont2Big", 0, -21, col, TEXT_ALIGN_CENTER) + cam.End3D2D() + cam.IgnoreZ(false) +end diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicalkit.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicalkit.lua index fe9492a..bb11d4c 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicalkit.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicalkit.lua @@ -108,12 +108,6 @@ function SWEP:SecondaryAttack() end end ---[[function SWEP:Initialize() - if CLIENT and self:GetOwner() == LocalPlayer() and LocalPlayer():GetActiveWeapon() == self then - hook.Add("PostPlayerDraw", "PostPlayerDrawMedical", GAMEMODE.PostPlayerDrawMedical) - end -end]] - function SWEP:Deploy() gamemode.Call("WeaponDeployed", self.Owner, self) @@ -121,6 +115,7 @@ function SWEP:Deploy() if CLIENT then hook.Add("PostPlayerDraw", "PostPlayerDrawMedical", GAMEMODE.PostPlayerDrawMedical) + GAMEMODE.MedicalAura = true end return true @@ -129,6 +124,7 @@ end function SWEP:Holster() if CLIENT then hook.Remove("PostPlayerDraw", "PostPlayerDrawMedical") + GAMEMODE.MedicalAura = false end return true diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicgun.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicgun.lua index a60ec96..96c1f35 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicgun.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_medicgun.lua @@ -80,12 +80,6 @@ function SWEP:ShootBullets(dmg, numbul, cone) end end ---[[function SWEP:Initialize() - if CLIENT and self:GetOwner() == LocalPlayer() and LocalPlayer():GetActiveWeapon() == self then - hook.Add("PostPlayerDraw", "PostPlayerDrawMedical", GAMEMODE.PostPlayerDrawMedical) - end -end]] - function SWEP:Deploy() gamemode.Call("WeaponDeployed", self.Owner, self) @@ -93,6 +87,7 @@ function SWEP:Deploy() if CLIENT then hook.Add("PostPlayerDraw", "PostPlayerDrawMedical", GAMEMODE.PostPlayerDrawMedical) + GAMEMODE.MedicalAura = true end return true @@ -101,6 +96,7 @@ end function SWEP:Holster() if CLIENT then hook.Remove("PostPlayerDraw", "PostPlayerDrawMedical") + GAMEMODE.MedicalAura = false end return true diff --git a/gamemodes/zombiesurvival/gamemode/cl_floatingscore.lua b/gamemodes/zombiesurvival/gamemode/cl_floatingscore.lua index 81fd591..bbc3303 100644 --- a/gamemodes/zombiesurvival/gamemode/cl_floatingscore.lua +++ b/gamemodes/zombiesurvival/gamemode/cl_floatingscore.lua @@ -15,7 +15,7 @@ function GM:ReceivedCommission(crate, buyer, points) end function GM:HealedOtherPlayer(other, points) - gamemode.Call("FloatingScore", other, "floatingscore", points) + gamemode.Call("FloatingScore", other, "floatingscore_heal", points, nil, true) end function GM:RepairedObject(other, points) @@ -23,10 +23,16 @@ function GM:RepairedObject(other, points) end local cvarNoFloatingScore = CreateClientConVar("zs_nofloatingscore", 0, true, false) -function GM:FloatingScore(victim, effectname, frags, flags) +function GM:FloatingScore(victim, effectname, frags, flags, override_allow) + if cvarNoFloatingScore:GetBool() then return end + local isvec = type(victim) == "Vector" - if cvarNoFloatingScore:GetBool() or not isvec and (not victim:IsValid() or victim:IsPlayer() and victim:Team() == MySelf:Team()) then return end + if not isvec then + if not victim:IsValid() or victim:IsPlayer() and victim:Team() == MySelf:Team() and not override_allow then + return + end + end effectname = effectname or "floatingscore" diff --git a/gamemodes/zombiesurvival/gamemode/cl_init.lua b/gamemodes/zombiesurvival/gamemode/cl_init.lua index 20f11ad..d7ec577 100644 --- a/gamemodes/zombiesurvival/gamemode/cl_init.lua +++ b/gamemodes/zombiesurvival/gamemode/cl_init.lua @@ -127,7 +127,7 @@ local draw_SimpleTextBlurry = draw.SimpleTextBlurry local draw_SimpleTextBlur = draw.SimpleTextBlur local draw_GetFontHeight = draw.GetFontHeight -local MedicalAuraDistance = 400 +local MedicalAuraDistance = 300 GM.LifeStatsBrainsEaten = 0 GM.LifeStatsHumanDamage = 0 @@ -1337,7 +1337,7 @@ function GM:_PrePlayerDraw(pl) if pl.status_overridemodel and pl.status_overridemodel:IsValid() and self:ShouldDrawLocalPlayer(MySelf) then -- We need to do this otherwise the player's real model shows up for some reason. undomodelblend = true render.SetBlend(0) - elseif MySelf:Team() == TEAM_HUMAN and pl ~= MySelf and pl:Team() == TEAM_HUMAN then + elseif MySelf:Team() == TEAM_HUMAN and pl ~= MySelf and pl:Team() == TEAM_HUMAN and not self.MedicalAura then local radius = self.TransparencyRadius if radius > 0 then local eyepos = EyePos()