From c7ca128f3f93cd66def368f2db9ea912d3c44a04 Mon Sep 17 00:00:00 2001 From: JetBoom Date: Fri, 19 Dec 2014 00:52:24 -0500 Subject: [PATCH] Gun turret ammo fix. Gun turrets no longer store their ammo in a separate table. Instead, the user gets 250 SMG ammo when they buy it. The turret then removed 250 (or less) from the player when it is placed. --- .../entities/entities/prop_gunturret/init.lua | 5 ++- .../entities/prop_gunturret/shared.lua | 2 +- .../weapons/weapon_zs_gunturret/init.lua | 5 ++- gamemodes/zombiesurvival/gamemode/cl_init.lua | 4 +- gamemodes/zombiesurvival/gamemode/init.lua | 26 ++++++----- .../gamemode/obj_player_extend.lua | 26 ++++++++--- .../zombiesurvival/gamemode/sh_options.lua | 15 +++++-- gamemodes/zombiesurvival/gamemode/shared.lua | 24 +++++----- .../gamemode/vgui/dmodelkillicon.lua | 44 +++++++++++++++++++ 9 files changed, 116 insertions(+), 35 deletions(-) create mode 100644 gamemodes/zombiesurvival/gamemode/vgui/dmodelkillicon.lua diff --git a/gamemodes/zombiesurvival/entities/entities/prop_gunturret/init.lua b/gamemodes/zombiesurvival/entities/entities/prop_gunturret/init.lua index ef752cd..6accf59 100644 --- a/gamemodes/zombiesurvival/entities/entities/prop_gunturret/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/prop_gunturret/init.lua @@ -114,7 +114,7 @@ function ENT:FireTurret(src, dir) self:StartBulletKnockback() self:FireBullets({Num = 1, Src = src, Dir = dir, Spread = Vector(0.05, 0.05, 0), Tracer = 1, Force = 1, Damage = 12, Callback = BulletCallback}) - self:DoBulletKnockback(0.05) + self:DoBulletKnockback(0.04) self:EndBulletKnockback() else self:SetNextFire(CurTime() + 2) @@ -202,7 +202,8 @@ function ENT:OnPackedUp(pl) pl:GiveEmptyWeapon("weapon_zs_gunturret") pl:GiveAmmo(1, "thumper") - pl:PushPackedItem(self:GetClass(), self:GetObjectHealth(), self:GetAmmo()) + pl:PushPackedItem(self:GetClass(), self:GetObjectHealth()) + pl:GiveAmmo(self:GetAmmo(), "smg1") self:Remove() end diff --git a/gamemodes/zombiesurvival/entities/entities/prop_gunturret/shared.lua b/gamemodes/zombiesurvival/entities/entities/prop_gunturret/shared.lua index 4105da6..0bbf977 100644 --- a/gamemodes/zombiesurvival/entities/entities/prop_gunturret/shared.lua +++ b/gamemodes/zombiesurvival/entities/entities/prop_gunturret/shared.lua @@ -3,7 +3,7 @@ ENT.RenderGroup = RENDERGROUP_BOTH ENT.SearchDistance = 768 ENT.MinimumAimDot = 0.5 -ENT.DefaultAmmo = 250 +ENT.DefaultAmmo = 0 --250 ENT.MaxAmmo = 1000 ENT.NoReviveFromKills = true diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gunturret/init.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gunturret/init.lua index 4a20eb4..1e9169e 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gunturret/init.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gunturret/init.lua @@ -68,9 +68,12 @@ function SWEP:PrimaryAttack() local stored = owner:PopPackedItem(ent:GetClass()) if stored then ent:SetObjectHealth(stored[1]) - ent:SetAmmo(stored[2]) end + local ammo = math.min(owner:GetAmmoCount("smg1"), 250) + ent:SetAmmo(ammo) + owner:RemoveAmmo(ammo, "smg1") + if not owner:HasWeapon("weapon_zs_gunturretcontrol") then owner:Give("weapon_zs_gunturretcontrol") end diff --git a/gamemodes/zombiesurvival/gamemode/cl_init.lua b/gamemodes/zombiesurvival/gamemode/cl_init.lua index 440d9ad..65365a0 100644 --- a/gamemodes/zombiesurvival/gamemode/cl_init.lua +++ b/gamemodes/zombiesurvival/gamemode/cl_init.lua @@ -380,6 +380,8 @@ function GM:LocalPlayerFound() self.GUIMousePressed = self._GUIMousePressed self.HUDWeaponPickedUp = self._HUDWeaponPickedUp + LocalPlayer().LegDamage = 0 + if render.GetDXLevel() >= 80 then self.RenderScreenspaceEffects = self._RenderScreenspaceEffects end @@ -1245,7 +1247,7 @@ function GM:_CreateMove(cmd) return end - if MySelf:GetLegDamage() >= 0.5 then + if MySelf:GetAntiBunnyHopTime() >= 2 or MySelf:GetLegDamage() >= 0.5 then local buttons = cmd:GetButtons() if bit.band(buttons, IN_JUMP) ~= 0 then cmd:SetButtons(buttons - IN_JUMP) diff --git a/gamemodes/zombiesurvival/gamemode/init.lua b/gamemodes/zombiesurvival/gamemode/init.lua index 68e15fb..e2c623c 100644 --- a/gamemodes/zombiesurvival/gamemode/init.lua +++ b/gamemodes/zombiesurvival/gamemode/init.lua @@ -1600,6 +1600,8 @@ function GM:PlayerInitialSpawnRound(pl) pl.BonusDamageCheck = 0 + pl.LegDamage = 0 + pl.DamageDealt = {} pl.DamageDealt[TEAM_UNDEAD] = 0 pl.DamageDealt[TEAM_HUMAN] = 0 @@ -3523,22 +3525,24 @@ function GM:PlayerSpawn(pl) pl:SetNoTarget(false) pl:SetMaxHealth(100) - pl:Give("weapon_zs_fists") - if self.ZombieEscape then pl:Give("weapon_zs_zeknife") pl:Give("weapon_zs_zegrenade") pl:Give(table.Random(self.ZombieEscapeWeapons)) - elseif self.StartingLoadout then - self:GiveStartingLoadout(pl) - elseif pl.m_PreRedeem then - if self.RedeemLoadout then - for _, class in pairs(self.RedeemLoadout) do - pl:Give(class) + else + pl:Give("weapon_zs_fists") + + if self.StartingLoadout then + self:GiveStartingLoadout(pl) + elseif pl.m_PreRedeem then + if self.RedeemLoadout then + for _, class in pairs(self.RedeemLoadout) do + pl:Give(class) + end + else + pl:Give("weapon_zs_redeemers") + pl:Give("weapon_zs_swissarmyknife") end - else - pl:Give("weapon_zs_redeemers") - pl:Give("weapon_zs_swissarmyknife") end end diff --git a/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua b/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua index 9317654..8fbbd59 100644 --- a/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua +++ b/gamemodes/zombiesurvival/gamemode/obj_player_extend.lua @@ -141,10 +141,6 @@ function meta:SetZombieClassName(classname) end end -function meta:AddLegDamage(damage) - self:SetLegDamage(self:GetLegDamage() + damage) -end - function meta:SetPoints(points) self:SetDTInt(1, points) end @@ -183,6 +179,10 @@ function meta:GetUnlucky() return self.m_Unlucky end +function meta:AddLegDamage(damage) + self:SetLegDamage(self:GetLegDamage() + damage) +end + function meta:SetLegDamage(damage) self.LegDamage = CurTime() + math.min(GAMEMODE.MaxLegDamage, damage * 0.125) if SERVER then @@ -202,8 +202,22 @@ function meta:RawCapLegDamage(time) end function meta:GetLegDamage() - local base = self.LegDamage or 0 - return math.max(0, base - CurTime()) + return math.max(0, self.LegDamage - CurTime()) +end + +function meta:AddAntiBunnyHopTime(time) + self:SetAntiBunnyHopTime(math.max(CurTime(), self.ABHT) + time) +end + +function meta:SetAntiBunnyHopTime(time) + self.ABHT = math.min(CurTime() + 4.5, time) + --[[if SERVER then + self:UpdateAntiBunnyHopTime() + end]] +end + +function meta:GetAntiBunnyHopTime() + return math.max(0, self.ABHT - CurTime()) end function meta:WouldDieFrom(damage, hitpos) diff --git a/gamemodes/zombiesurvival/gamemode/sh_options.lua b/gamemodes/zombiesurvival/gamemode/sh_options.lua index d6ba59d..dab35b6 100644 --- a/gamemodes/zombiesurvival/gamemode/sh_options.lua +++ b/gamemodes/zombiesurvival/gamemode/sh_options.lua @@ -149,8 +149,12 @@ GM:AddStartingItem("medgun", "Medic Gun", nil, ITEMCAT_TOOLS, 45, "weapon_zs_med GM:AddStartingItem("150mkit", "150 Medical Kit power", "150 extra power for the Medical Kit.", ITEMCAT_TOOLS, 30, nil, function(pl) pl:GiveAmmo(150, "Battery", true) end, "models/healthvial.mdl") GM:AddStartingItem("arscrate", "Arsenal Crate", nil, ITEMCAT_TOOLS, 50, "weapon_zs_arsenalcrate").Countables = "prop_arsenalcrate" GM:AddStartingItem("resupplybox", "Resupply Box", nil, ITEMCAT_TOOLS, 70, "weapon_zs_resupplybox").Countables = "prop_resupplybox" -local item = GM:AddStartingItem("infturret", "Infrared Gun Turret", nil, ITEMCAT_TOOLS, 75, "weapon_zs_gunturret") -item.Countables = "prop_gunturret" +local item = GM:AddStartingItem("infturret", "Infrared Gun Turret", nil, ITEMCAT_TOOLS, 75, nil, function(pl) + pl:GiveEmptyWeapon("weapon_zs_gunturret") + pl:GiveAmmo(1, "thumper") + pl:GiveAmmo(250, "smg1") +end) +item.Countables = {"weapon_zs_gunturret", "prop_gunturret"} item.NoClassicMode = true local item = GM:AddStartingItem("manhack", "Manhack", nil, ITEMCAT_TOOLS, 60, "weapon_zs_manhack") item.Countables = "prop_manhack" @@ -239,7 +243,12 @@ GM:AddPointShopItem("crphmr", "Carpenter's Hammer", nil, ITEMCAT_TOOLS, 50, "wea GM:AddPointShopItem("wrench", "Mechanic's Wrench", nil, ITEMCAT_TOOLS, 25, "weapon_zs_wrench").NoClassicMode = true GM:AddPointShopItem("arsenalcrate", "Arsenal Crate", nil, ITEMCAT_TOOLS, 50, "weapon_zs_arsenalcrate") GM:AddPointShopItem("resupplybox", "Resupply Box", nil, ITEMCAT_TOOLS, 200, "weapon_zs_resupplybox") -GM:AddPointShopItem("infturret", "Infrared Gun Turret", nil, ITEMCAT_TOOLS, 50, "weapon_zs_gunturret").NoClassicMode = true +local item = GM:AddPointShopItem("infturret", "Infrared Gun Turret", nil, ITEMCAT_TOOLS, 50, nil, function(pl) + pl:GiveEmptyWeapon("weapon_zs_gunturret") + pl:GiveAmmo(1, "thumper") + pl:GiveAmmo(250, "smg1") +end) +item.NoClassicMode = true GM:AddPointShopItem("manhack", "Manhack", nil, ITEMCAT_TOOLS, 45, "weapon_zs_manhack") GM:AddPointShopItem("barricadekit", "'Aegis' Barricade Kit", nil, ITEMCAT_TOOLS, 125, "weapon_zs_barricadekit") GM:AddPointShopItem("nail", "Nail", "It's just one nail.", ITEMCAT_TOOLS, 5, nil, function(pl) pl:GiveAmmo(1, "GaussEnergy", true) end, "models/crossbow_bolt.mdl").NoClassicMode = true diff --git a/gamemodes/zombiesurvival/gamemode/shared.lua b/gamemodes/zombiesurvival/gamemode/shared.lua index c145928..379473f 100644 --- a/gamemodes/zombiesurvival/gamemode/shared.lua +++ b/gamemodes/zombiesurvival/gamemode/shared.lua @@ -395,20 +395,24 @@ function GM:OnPlayerHitGround(pl, inwater, hitfloater, speed) pl:PreventSkyCade() end - if not isundead or not pl:GetZombieClassTable().NoFallSlowdown then - pl:RawCapLegDamage(CurTime() + math.min(2, speed * 0.0035)) + if speed > 100 then + pl:AddAntiBunnyHopTime(1) end - if SERVER then - if isundead then - speed = math.max(0, speed - 200) + if isundead then + speed = math.max(0, speed - 200) + end + + local damage = (0.1 * (speed - 525)) ^ 1.45 + if hitfloater then damage = damage / 2 end + + if math.floor(damage) > 0 then + if damage >= 5 and (not isundead or not pl:GetZombieClassTable().NoFallSlowdown) then + pl:RawCapLegDamage(CurTime() + math.min(2, damage * 0.038)) end - local damage = (0.1 * (speed - 525)) ^ 1.45 - if hitfloater then damage = damage / 2 end - - if math.floor(damage) > 0 then - if 20 <= damage and damage < pl:Health() then + if SERVER then + if damage >= 30 and damage < pl:Health() then pl:KnockDown(damage * 0.05) end pl:TakeSpecialDamage(damage, DMG_FALL, game.GetWorld(), game.GetWorld(), pl:GetPos()) diff --git a/gamemodes/zombiesurvival/gamemode/vgui/dmodelkillicon.lua b/gamemodes/zombiesurvival/gamemode/vgui/dmodelkillicon.lua new file mode 100644 index 0000000..af9ef98 --- /dev/null +++ b/gamemodes/zombiesurvival/gamemode/vgui/dmodelkillicon.lua @@ -0,0 +1,44 @@ +local PANEL = {} + +function PANEL:SetModel(strModelName) + self.BaseClass.SetModel(self, strModelName) + + self:AutoCam() +end + +local matWhite = Material("models/debug/debugwhite") +function PANEL:Paint(w, h) + if !IsValid( self.Entity ) then return end + + self:LayoutEntity( self.Entity ) + + local ang = self.aLookAngle + local x, y = self:LocalToScreen( 0, 0 ) + local col = self.colColor + + if not ang then + ang = (self.vLookatPos - self.vCamPos):Angle() + end + + cam.Start3D(self.vCamPos, ang, self.fFOV, x, y, w, h, 5, self.FarZ) + cam.IgnoreZ(true) + + render.SuppressEngineLighting(true) + render.SetColorModulation(col.r / 255, col.g / 255, col.b / 255) + render.SetBlend(col.a / 255) + render.ModelMaterialOverride(matWhite) + + self:DrawModel() + + render.ModelMaterialOverride() + render.SetBlend(1) + render.SetColorModulation(1, 1, 1) + render.SuppressEngineLighting(false) + + cam.IgnoreZ(false) + cam.End3D() + + self.LastPaint = RealTime() +end + +vgui.Register("DModelKillIcon", PANEL, "DModelPanelEx")