CLASS.Name = "Puke Pus"

CLASS.TranslationName = "class_pukepus"

CLASS.Description = "description_pukepus"

CLASS.Help = "controls_pukepus"



CLASS.Wave = 0

CLASS.Threshold = 0

CLASS.Unlocked = true

CLASS.Hidden = true

CLASS.Boss = true



CLASS.FearPerInstance = 1



CLASS.Health = 2750

CLASS.SWEP = "weapon_zs_pukepus"



CLASS.Model = Model("models/Zombie/Poison.mdl")



CLASS.Speed = 120

CLASS.Points = 30



CLASS.PainSounds = {"NPC_PoisonZombie.Pain"}

CLASS.DeathSounds = {Sound("npc/zombie_poison/pz_call1.wav")}



CLASS.VoicePitch = 0.5



CLASS.ModelScale = 1.5

CLASS.Mass = 200

CLASS.ViewOffset = Vector(0, 0, 75)

CLASS.ViewOffsetDucked = Vector(0, 0, 48)

CLASS.StepSize = 25

--[[CLASS.Hull = {Vector(-22, -22, 0), Vector(22, 22, 96)}

CLASS.HullDuck = {Vector(-22, -22, 0), Vector(22, 22, 58)}]]



CLASS.JumpPower = 225



local ACT_IDLE = ACT_IDLE

local STEPSOUNDTIME_NORMAL = STEPSOUNDTIME_NORMAL

local STEPSOUNDTIME_WATER_FOOT = STEPSOUNDTIME_WATER_FOOT

local STEPSOUNDTIME_ON_LADDER = STEPSOUNDTIME_ON_LADDER

local STEPSOUNDTIME_WATER_KNEE = STEPSOUNDTIME_WATER_KNEE



function CLASS:CalcMainActivity(pl, velocity)

	if velocity:Length2D() <= 0.5 then

		pl.CalcIdeal = ACT_IDLE

	else

		pl.CalcSeqOverride = 2

	end



	return true

end



local mathrandom = math.random

local StepSounds = {

	"npc/zombie_poison/pz_left_foot1.wav"

}

local ScuffSounds = {

	"npc/zombie_poison/pz_right_foot1.wav"

}

function CLASS:PlayerFootstep(pl, vFootPos, iFoot, strSoundName, fVolume, pFilter)

	if iFoot == 0 and mathrandom() < 0.333 then

		pl:EmitSound(ScuffSounds[mathrandom(#ScuffSounds)], 80, 90)

	else

		pl:EmitSound(StepSounds[mathrandom(#StepSounds)], 80, 90)

	end



	return true

end



function CLASS:PlayerStepSoundTime(pl, iType, bWalking)

	if iType == STEPSOUNDTIME_NORMAL or iType == STEPSOUNDTIME_WATER_FOOT then

		return (365 - pl:GetVelocity():Length()) * 1.5

	elseif iType == STEPSOUNDTIME_ON_LADDER then

		return 450

	elseif iType == STEPSOUNDTIME_WATER_KNEE then

		return 600

	end



	return 200

end



function CLASS:UpdateAnimation(pl, velocity, maxseqgroundspeed)

	pl:FixModelAngles(velocity)



	local len2d = velocity:Length2D()

	if len2d > 0.5 then

		pl:SetPlaybackRate(math.min(len2d / maxseqgroundspeed * 0.5, 3))

	else

		pl:SetPlaybackRate(0.5)

	end



	return true

end



if SERVER then

	function CLASS:OnSpawned(pl)

		pl:CreateAmbience("pukepusambience")

	end

end



local BonesToZero = {

	"ValveBiped.Bip01_L_UpperArm",

	"ValveBiped.Bip01_L_Forearm",

	"ValveBiped.Bip01_L_Hand",

	"ValveBiped.Bip01_L_Finger1",

	"ValveBiped.Bip01_L_Finger11",

	"ValveBiped.Bip01_L_Finger12",

	"ValveBiped.Bip01_L_Finger2",

	"ValveBiped.Bip01_L_Finger21",

	"ValveBiped.Bip01_L_Finger22",

	"ValveBiped.Bip01_L_Finger3",

	"ValveBiped.Bip01_L_Finger31",

	"ValveBiped.Bip01_L_Finger32",

	"ValveBiped.Bip01_R_UpperArm",

	"ValveBiped.Bip01_R_Forearm",

	"ValveBiped.Bip01_R_Hand",

	"ValveBiped.Bip01_R_Finger1",

	"ValveBiped.Bip01_R_Finger11",

	"ValveBiped.Bip01_R_Finger12",

	"ValveBiped.Bip01_R_Finger2",

	"ValveBiped.Bip01_R_Finger21",

	"ValveBiped.Bip01_R_Finger22",

	"ValveBiped.Bip01_R_Finger3",

	"ValveBiped.Bip01_R_Finger31",

	"ValveBiped.Bip01_R_Finger32"

}

function CLASS:BuildBonePositions(pl)

	for _, bone in pairs(BonesToZero) do

		local boneid = pl:LookupBone(bone)

		if boneid and boneid > 0 then

			pl:ManipulateBoneScale(boneid, vector_tiny)

		end

	end

end



if not CLIENT then return end



CLASS.Icon = "zombiesurvival/killicons/pukepus"



local matSkin = Material("Models/Barnacle/barnacle_sheet")

function CLASS:PrePlayerDraw(pl)

	render.ModelMaterialOverride(matSkin)

end



function CLASS:PostPlayerDraw(pl)

	render.ModelMaterialOverride()

end

