Fix errors from last commit. Better anti bhop.

Players no longer get leg damage unless they take damage from the fall.
Anti bunny hopping script remade and now applies to all players
regardless of leg damage, team, or zombie class.
This commit is contained in:
JetBoom 2014-12-19 01:50:23 -05:00
parent c7ca128f3f
commit 8cbfdaf59f
3 changed files with 31 additions and 40 deletions

View file

@ -1021,22 +1021,6 @@ end
function GM:PlayerDeath(pl, attacker) function GM:PlayerDeath(pl, attacker)
end end
function GM:OnPlayerHitGround(pl, inwater, hitfloater, speed)
if inwater then return true end
if pl:Team() == TEAM_UNDEAD then
if pl:GetZombieClassTable().NoFallDamage then return true end
speed = math.max(0, speed - 200)
end
if pl:Team() ~= TEAM_UNDEAD or not pl:GetZombieClassTable().NoFallSlowdown then
pl:RawCapLegDamage(CurTime() + math.min(2, speed * 0.0035))
end
return true
end
function GM:LastHuman(pl) function GM:LastHuman(pl)
if not IsValid(pl) then pl = nil end if not IsValid(pl) then pl = nil end
@ -1241,17 +1225,43 @@ function GM:CalcViewTaunt(pl, origin, angles, fov, zclose, zfar)
end end
local staggerdir = VectorRand():GetNormalized() local staggerdir = VectorRand():GetNormalized()
local BHopTime = 0
local WasPressingJump = false
local function PressingJump(cmd)
return bit.band(cmd:GetButtons(), IN_JUMP) ~= 0
end
local function DontPressJump(cmd)
cmd:SetButtons(cmd:GetButtons() - IN_JUMP)
end
function GM:_CreateMove(cmd) function GM:_CreateMove(cmd)
if MySelf:IsPlayingTaunt() and MySelf:Alive() then if MySelf:IsPlayingTaunt() and MySelf:Alive() then
self:CreateMoveTaunt(cmd) self:CreateMoveTaunt(cmd)
return return
end end
if MySelf:GetAntiBunnyHopTime() >= 2 or MySelf:GetLegDamage() >= 0.5 then -- Disables bunny hopping to an extent.
local buttons = cmd:GetButtons() if MySelf:GetLegDamage() >= 0.5 then
if bit.band(buttons, IN_JUMP) ~= 0 then if PressingJump(cmd) then
cmd:SetButtons(buttons - IN_JUMP) DontPressJump(cmd)
end end
elseif MySelf:OnGround() then
if CurTime() < BHopTime then
if PressingJump(cmd) then
DontPressJump(cmd)
WasPressingJump = true
end
elseif WasPressingJump then
if PressingJump(cmd) then
DontPressJump(cmd)
else
WasPressingJump = false
end
end
else
BHopTime = CurTime() + 0.065
end end
if MySelf:Team() == TEAM_HUMAN then if MySelf:Team() == TEAM_HUMAN then

View file

@ -205,21 +205,6 @@ function meta:GetLegDamage()
return math.max(0, self.LegDamage - CurTime()) return math.max(0, self.LegDamage - CurTime())
end 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) function meta:WouldDieFrom(damage, hitpos)
return self:Health() <= damage * GAMEMODE:GetZombieDamageScale(hitpos, self) return self:Health() <= damage * GAMEMODE:GetZombieDamageScale(hitpos, self)
end end

View file

@ -391,14 +391,10 @@ function GM:OnPlayerHitGround(pl, inwater, hitfloater, speed)
if isundead then if isundead then
if pl:GetZombieClassTable().NoFallDamage then return true end if pl:GetZombieClassTable().NoFallDamage then return true end
else elseif SERVER then
pl:PreventSkyCade() pl:PreventSkyCade()
end end
if speed > 100 then
pl:AddAntiBunnyHopTime(1)
end
if isundead then if isundead then
speed = math.max(0, speed - 200) speed = math.max(0, speed - 200)
end end