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.
This commit is contained in:
JetBoom 2014-12-19 00:52:24 -05:00
parent 6ebf7ab049
commit c7ca128f3f
9 changed files with 116 additions and 35 deletions

View file

@ -114,7 +114,7 @@ function ENT:FireTurret(src, dir)
self:StartBulletKnockback() 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: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() self:EndBulletKnockback()
else else
self:SetNextFire(CurTime() + 2) self:SetNextFire(CurTime() + 2)
@ -202,7 +202,8 @@ function ENT:OnPackedUp(pl)
pl:GiveEmptyWeapon("weapon_zs_gunturret") pl:GiveEmptyWeapon("weapon_zs_gunturret")
pl:GiveAmmo(1, "thumper") 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() self:Remove()
end end

View file

@ -3,7 +3,7 @@ ENT.RenderGroup = RENDERGROUP_BOTH
ENT.SearchDistance = 768 ENT.SearchDistance = 768
ENT.MinimumAimDot = 0.5 ENT.MinimumAimDot = 0.5
ENT.DefaultAmmo = 250 ENT.DefaultAmmo = 0 --250
ENT.MaxAmmo = 1000 ENT.MaxAmmo = 1000
ENT.NoReviveFromKills = true ENT.NoReviveFromKills = true

View file

@ -68,9 +68,12 @@ function SWEP:PrimaryAttack()
local stored = owner:PopPackedItem(ent:GetClass()) local stored = owner:PopPackedItem(ent:GetClass())
if stored then if stored then
ent:SetObjectHealth(stored[1]) ent:SetObjectHealth(stored[1])
ent:SetAmmo(stored[2])
end end
local ammo = math.min(owner:GetAmmoCount("smg1"), 250)
ent:SetAmmo(ammo)
owner:RemoveAmmo(ammo, "smg1")
if not owner:HasWeapon("weapon_zs_gunturretcontrol") then if not owner:HasWeapon("weapon_zs_gunturretcontrol") then
owner:Give("weapon_zs_gunturretcontrol") owner:Give("weapon_zs_gunturretcontrol")
end end

View file

@ -380,6 +380,8 @@ function GM:LocalPlayerFound()
self.GUIMousePressed = self._GUIMousePressed self.GUIMousePressed = self._GUIMousePressed
self.HUDWeaponPickedUp = self._HUDWeaponPickedUp self.HUDWeaponPickedUp = self._HUDWeaponPickedUp
LocalPlayer().LegDamage = 0
if render.GetDXLevel() >= 80 then if render.GetDXLevel() >= 80 then
self.RenderScreenspaceEffects = self._RenderScreenspaceEffects self.RenderScreenspaceEffects = self._RenderScreenspaceEffects
end end
@ -1245,7 +1247,7 @@ function GM:_CreateMove(cmd)
return return
end end
if MySelf:GetLegDamage() >= 0.5 then if MySelf:GetAntiBunnyHopTime() >= 2 or MySelf:GetLegDamage() >= 0.5 then
local buttons = cmd:GetButtons() local buttons = cmd:GetButtons()
if bit.band(buttons, IN_JUMP) ~= 0 then if bit.band(buttons, IN_JUMP) ~= 0 then
cmd:SetButtons(buttons - IN_JUMP) cmd:SetButtons(buttons - IN_JUMP)

View file

@ -1600,6 +1600,8 @@ function GM:PlayerInitialSpawnRound(pl)
pl.BonusDamageCheck = 0 pl.BonusDamageCheck = 0
pl.LegDamage = 0
pl.DamageDealt = {} pl.DamageDealt = {}
pl.DamageDealt[TEAM_UNDEAD] = 0 pl.DamageDealt[TEAM_UNDEAD] = 0
pl.DamageDealt[TEAM_HUMAN] = 0 pl.DamageDealt[TEAM_HUMAN] = 0
@ -3523,13 +3525,14 @@ function GM:PlayerSpawn(pl)
pl:SetNoTarget(false) pl:SetNoTarget(false)
pl:SetMaxHealth(100) pl:SetMaxHealth(100)
pl:Give("weapon_zs_fists")
if self.ZombieEscape then if self.ZombieEscape then
pl:Give("weapon_zs_zeknife") pl:Give("weapon_zs_zeknife")
pl:Give("weapon_zs_zegrenade") pl:Give("weapon_zs_zegrenade")
pl:Give(table.Random(self.ZombieEscapeWeapons)) pl:Give(table.Random(self.ZombieEscapeWeapons))
elseif self.StartingLoadout then else
pl:Give("weapon_zs_fists")
if self.StartingLoadout then
self:GiveStartingLoadout(pl) self:GiveStartingLoadout(pl)
elseif pl.m_PreRedeem then elseif pl.m_PreRedeem then
if self.RedeemLoadout then if self.RedeemLoadout then
@ -3541,6 +3544,7 @@ function GM:PlayerSpawn(pl)
pl:Give("weapon_zs_swissarmyknife") pl:Give("weapon_zs_swissarmyknife")
end end
end end
end
local oldhands = pl:GetHands() local oldhands = pl:GetHands()
if IsValid(oldhands) then if IsValid(oldhands) then

View file

@ -141,10 +141,6 @@ function meta:SetZombieClassName(classname)
end end
end end
function meta:AddLegDamage(damage)
self:SetLegDamage(self:GetLegDamage() + damage)
end
function meta:SetPoints(points) function meta:SetPoints(points)
self:SetDTInt(1, points) self:SetDTInt(1, points)
end end
@ -183,6 +179,10 @@ function meta:GetUnlucky()
return self.m_Unlucky return self.m_Unlucky
end end
function meta:AddLegDamage(damage)
self:SetLegDamage(self:GetLegDamage() + damage)
end
function meta:SetLegDamage(damage) function meta:SetLegDamage(damage)
self.LegDamage = CurTime() + math.min(GAMEMODE.MaxLegDamage, damage * 0.125) self.LegDamage = CurTime() + math.min(GAMEMODE.MaxLegDamage, damage * 0.125)
if SERVER then if SERVER then
@ -202,8 +202,22 @@ function meta:RawCapLegDamage(time)
end end
function meta:GetLegDamage() function meta:GetLegDamage()
local base = self.LegDamage or 0 return math.max(0, self.LegDamage - CurTime())
return math.max(0, base - 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 end
function meta:WouldDieFrom(damage, hitpos) function meta:WouldDieFrom(damage, hitpos)

View file

@ -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("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("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" 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") local item = GM:AddStartingItem("infturret", "Infrared Gun Turret", nil, ITEMCAT_TOOLS, 75, nil, function(pl)
item.Countables = "prop_gunturret" pl:GiveEmptyWeapon("weapon_zs_gunturret")
pl:GiveAmmo(1, "thumper")
pl:GiveAmmo(250, "smg1")
end)
item.Countables = {"weapon_zs_gunturret", "prop_gunturret"}
item.NoClassicMode = true item.NoClassicMode = true
local item = GM:AddStartingItem("manhack", "Manhack", nil, ITEMCAT_TOOLS, 60, "weapon_zs_manhack") local item = GM:AddStartingItem("manhack", "Manhack", nil, ITEMCAT_TOOLS, 60, "weapon_zs_manhack")
item.Countables = "prop_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("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("arsenalcrate", "Arsenal Crate", nil, ITEMCAT_TOOLS, 50, "weapon_zs_arsenalcrate")
GM:AddPointShopItem("resupplybox", "Resupply Box", nil, ITEMCAT_TOOLS, 200, "weapon_zs_resupplybox") 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("manhack", "Manhack", nil, ITEMCAT_TOOLS, 45, "weapon_zs_manhack")
GM:AddPointShopItem("barricadekit", "'Aegis' Barricade Kit", nil, ITEMCAT_TOOLS, 125, "weapon_zs_barricadekit") 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 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

View file

@ -395,11 +395,10 @@ function GM:OnPlayerHitGround(pl, inwater, hitfloater, speed)
pl:PreventSkyCade() pl:PreventSkyCade()
end end
if not isundead or not pl:GetZombieClassTable().NoFallSlowdown then if speed > 100 then
pl:RawCapLegDamage(CurTime() + math.min(2, speed * 0.0035)) pl:AddAntiBunnyHopTime(1)
end end
if SERVER then
if isundead then if isundead then
speed = math.max(0, speed - 200) speed = math.max(0, speed - 200)
end end
@ -408,7 +407,12 @@ function GM:OnPlayerHitGround(pl, inwater, hitfloater, speed)
if hitfloater then damage = damage / 2 end if hitfloater then damage = damage / 2 end
if math.floor(damage) > 0 then if math.floor(damage) > 0 then
if 20 <= damage and damage < pl:Health() then if damage >= 5 and (not isundead or not pl:GetZombieClassTable().NoFallSlowdown) then
pl:RawCapLegDamage(CurTime() + math.min(2, damage * 0.038))
end
if SERVER then
if damage >= 30 and damage < pl:Health() then
pl:KnockDown(damage * 0.05) pl:KnockDown(damage * 0.05)
end end
pl:TakeSpecialDamage(damage, DMG_FALL, game.GetWorld(), game.GetWorld(), pl:GetPos()) pl:TakeSpecialDamage(damage, DMG_FALL, game.GetWorld(), game.GetWorld(), pl:GetPos())

View file

@ -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")