zombiesurvival-evolved/gamemodes/zombiesurvival/entities/entities/status_drown/init.lua
JetBoom bd937c290e Large backend update
Players are no longer implicitly zombies if they're not humans. Players
are no longer implicitly humans if they're not zombies. This is
preparation for a third, optional spectator team.
A few small optimizations and fixes.
2015-03-09 13:45:47 -04:00

27 lines
722 B
Lua

AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Think()
local owner = self:GetOwner()
if not owner:IsValid() or not owner:Alive() then return end
if owner:Team() ~= TEAM_HUMAN then self:Remove() return end
if self:IsUnderwater() then
if owner:WaterLevel() < 3 and not (owner.NoAirBrush and owner.NoAirBrush:IsValid()) then
self:SetUnderwater(false)
end
elseif owner:WaterLevel() >= 3 or owner.NoAirBrush and owner.NoAirBrush:IsValid() then
self:SetUnderwater(true)
end
if self:IsDrowning() then
owner:TakeSpecialDamage(10, DMG_DROWN, game.GetWorld())
self:NextThink(CurTime() + 1)
return true
elseif not self:IsUnderwater() and self:GetDrown() == 0 then
self:Remove()
end
end