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)
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)
if not IsValid(pl) then pl = nil end
@ -1241,17 +1225,43 @@ function GM:CalcViewTaunt(pl, origin, angles, fov, zclose, zfar)
end
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)
if MySelf:IsPlayingTaunt() and MySelf:Alive() then
self:CreateMoveTaunt(cmd)
return
end
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)
-- Disables bunny hopping to an extent.
if MySelf:GetLegDamage() >= 0.5 then
if PressingJump(cmd) then
DontPressJump(cmd)
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
if MySelf:Team() == TEAM_HUMAN then

View file

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

View file

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