HELP NEEDED WITH CUSTOM ZOMBIE


CLASS.Name = "Predator Zombie"
CLASS.TranslationName = "class_prdator"
CLASS.Description = "description_predator"
CLASS.Help = "controls_predator_zombie"

CLASS.Model = Model("models/player/nethead/warrior_new.mdl") --Model("models/Zombie/Fast.mdl") --models/player/zombie_fast.mdl

CLASS.Wave = 1/2
CLASS.Revives = true
CLASS.Infliction = 0.5 -- We auto-unlock this class if 50% of humans are dead regardless of what wave it is.

CLASS.Health = 100
CLASS.Speed = 280
CLASS.JumpPower = 120
CLASS.SWEP = "weapon_zs_predator"

CLASS.Points = 4

CLASS.ModelScale = 0.8

CLASS.Hull = {Vector(-16, -16, 0), Vector(16, 16, 58)}
CLASS.HullDuck = {Vector(-16, -16, 0), Vector(16, 16, 32)}
CLASS.ViewOffset = Vector(0, 0, 50)
CLASS.ViewOffsetDucked = Vector(0, 0, 24)

CLASS.PainSounds = {"NPC_FastZombie.Pain"}
CLASS.DeathSounds = {"NPC_FastZombie.Die"}

CLASS.VoicePitch = 0.55

CLASS.NoFallDamage = true
CLASS.NoFallSlowdown = true

hook.Add( "SetupMove", "Cloak Crouch", function( ply, mv, cmd )
if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) then
if ( bit.band( cmd:GetButtons(), IN_DUCK ) == IN_DUCK ) then
ply:SetMaterial( "Models/effects/vol_light001" ) 
else
ply:SetMaterial( "" ) 
end
end
end )

hook.Add( "PlayerDeath", "Tougher_per_kill", function( victim, inflictor, attacker )

	if !( IsValid( victim ) or IsValid( attacker ) ) then return end
	if !( victim:IsPlayer() or attacker:IsPlayer() ) then return end
	
	if victim == attacker then return end
	
	if attacker:Team() == TEAM_HUMAN and victim:Team() == TEAM_UNDEAD then
		SetMaxHealth(attacker, 0)
		SetMaxArmor(attacker, 0)
	end
		
	if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) == attacker:Team() == TEAM_UNDEAD and victim:Team() == TEAM_HUMAN then
		SetMaxHealth(attacker, 100)
		SetMaxArmor(attacker, 50)
	end
end )


function CLASS:Move(pl, mv)
	local wep = pl:GetActiveWeapon()
	if wep.Move and wep:Move(mv) then
		return true
	end

	if mv:GetForwardSpeed() <= 0 then
		mv:SetMaxSpeed(math.min(mv:GetMaxSpeed(), 90))
		mv:SetMaxClientSpeed(math.min(mv:GetMaxClientSpeed(), 90))
	end
end

local mathrandom = math.random
local StepLeftSounds = {
	"npc/fast_zombie/foot1.wav",
	"npc/fast_zombie/foot2.wav"
}
local StepRightSounds = {
	"npc/fast_zombie/foot3.wav",
	"npc/fast_zombie/foot4.wav"
}
function CLASS:PlayerFootstep(pl, vFootPos, iFoot, strSoundName, fVolume, pFilter)
	if iFoot == 0 then
		pl:EmitSound(StepLeftSounds[mathrandom(#StepLeftSounds)], 70)
	else
		pl:EmitSound(StepRightSounds[mathrandom(#StepRightSounds)], 70)
	end

	return true
end
--[[function CLASS:PlayerFootstep(pl, vFootPos, iFoot, strSoundName, fVolume, pFilter)
	if iFoot == 0 then
		pl:EmitSound("NPC_FastZombie.GallopLeft")
	else
		pl:EmitSound("NPC_FastZombie.GallopRight")
	end

	return true
end]]

function CLASS:PlayerStepSoundTime(pl, iType, bWalking)
	if iType == STEPSOUNDTIME_NORMAL or iType == STEPSOUNDTIME_WATER_FOOT then
		return 450 - pl:GetVelocity():Length()
	elseif iType == STEPSOUNDTIME_ON_LADDER then
		return 400
	elseif iType == STEPSOUNDTIME_WATER_KNEE then
		return 550
	end

	return 250
end

function CLASS:CalcMainActivity(pl, velocity)
	local wep = pl:GetActiveWeapon()
	if not wep:IsValid() or not wep.GetClimbing then return end

	if wep:GetClimbing() then
		pl.CalcIdeal = ACT_ZOMBIE_CLIMB_UP
		return true
	elseif wep:GetPounceTime() > 0 then
		pl.CalcIdeal = ACT_ZOMBIE_LEAP_START
		return true
	end

	local speed = velocity:Length2D()
	if not pl:OnGround() or pl:WaterLevel() >= 3 then
		pl.CalcIdeal = ACT_ZOMBIE_LEAPING
	elseif speed <= 0.5 and wep:IsRoaring() then
		pl.CalcSeqOverride = pl:LookupSequence("menu_zombie_01")
	else
		pl.CalcIdeal = ACT_HL2MP_RUN_ZOMBIE_FAST
	end

	return true
end

function CLASS:UpdateAnimation(pl, velocity, maxseqgroundspeed)
	local wep = pl:GetActiveWeapon()
	if not wep:IsValid() or not wep.GetClimbing then return end

	if wep:GetSwinging() then
		if not pl.PlayingFZSwing then
			pl.PlayingFZSwing = true
			pl:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_RANGE_FRENZY)
		end
	elseif pl.PlayingFZSwing then
		pl.PlayingFZSwing = false
		pl:AnimResetGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD) --pl:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_RANGE_FRENZY, true)
	end

	if wep:GetClimbing() then
		local vel = pl:GetVelocity()
		local speed = vel:Length()
		if speed > 8 then
			pl:SetPlaybackRate(math.Clamp(speed / 160, 0, 1) * (vel.z < 0 and -1 or 1))
		else
			pl:SetPlaybackRate(0)
		end

		return true
	end

	if wep:GetPounceTime() > 0 then
		pl:SetPlaybackRate(0.25)

		if not pl.m_PrevFrameCycle then
			pl.m_PrevFrameCycle = true
			pl:SetCycle(0)
		end

		return true
	elseif pl.m_PrevFrameCycle then
		pl.m_PrevFrameCycle = nil
	end

	local speed = velocity:Length2D()
	if not pl:OnGround() or pl:WaterLevel() >= 3 then
		pl:SetPlaybackRate(1)

		if pl:GetCycle() >= 1 then
			pl:SetCycle(pl:GetCycle() - 1)
		end

		return true
	end
	if speed <= 0.5 and wep:IsRoaring() then
		pl:SetPlaybackRate(0)
		pl:SetCycle(math.Clamp(1 - (wep:GetRoarEndTime() - CurTime()) / wep.RoarTime, 0, 1) * 0.9)

		return true
	end
end

function CLASS:DoAnimationEvent(pl, event, data)
	if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
		return ACT_INVALID
	end
end

if SERVER then
	function CLASS:ReviveCallback(pl, attacker, dmginfo)
		if not pl.Revive and not dmginfo:GetInflictor().IsMelee and dmginfo:GetDamageType() ~= DMG_BLAST and dmginfo:GetDamageType() ~= DMG_BURN and (pl:LastHitGroup() == HITGROUP_LEFTLEG or pl:LastHitGroup() == HITGROUP_RIGHTLEG) and math.random(3) == 1 then
			local classtable = GAMEMODE.ZombieClasses["Fast Zombie Legs"]
			if classtable then
				pl:RemoveStatus("overridemodel", false, true)
				local deathclass = pl.DeathClass or pl:GetZombieClass()
				pl:SetZombieClass(classtable.Index)
				pl:DoHulls(classtable.Index, TEAM_UNDEAD)
				pl.DeathClass = deathclass

				pl:EmitSound("physics/flesh/flesh_bloody_break.wav", 100, 75)

				pl:Gib()
				pl.Gibbed = nil

				timer.Simple(0, function()
					if IsValid(pl) then
						pl:SecondWind()
					end
				end)

				return true
			end
		end

		return false
	end
end

if SERVER then return end

CLASS.Icon = "zombiesurvival/killicons/fastzombie_hd"

function CLASS:CreateMove(pl, cmd)
	local wep = pl:GetActiveWeapon()
	if wep:IsValid() and wep.IsPouncing then
		if wep.m_ViewAngles and wep:IsPouncing() then
			local maxdiff = FrameTime() * 20
			local mindiff = -maxdiff
			local originalangles = wep.m_ViewAngles
			local viewangles = cmd:GetViewAngles()

			local diff = math.AngleDifference(viewangles.yaw, originalangles.yaw)
			if diff > maxdiff or diff < mindiff then
				viewangles.yaw = math.NormalizeAngle(originalangles.yaw + math.Clamp(diff, mindiff, maxdiff))
			end

			wep.m_ViewAngles = viewangles

			cmd:SetViewAngles(viewangles)
		--[[elseif wep:IsClimbing() then
			local buttons = cmd:GetButtons()
			if bit.band(buttons, IN_DUCK) ~= 0 then
				cmd:SetButtons(buttons - IN_DUCK)
			end]]
		end
	end
end


[editline]13th September 2015[/editline]
Could someone please help me make these two hooks work?



hook.Add( "SetupMove", "Cloak Crouch", function( ply, mv, cmd )
if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) then
if ( bit.band( cmd:GetButtons(), IN_DUCK ) == IN_DUCK ) then
ply:SetMaterial( "Models/effects/vol_light001" ) 
else
ply:SetMaterial( "" ) 
end
end
end )



hook.Add( "PlayerDeath", "Tougher_per_kill", function( victim, inflictor, attacker )

	if !( IsValid( victim ) or IsValid( attacker ) ) then return end
	if !( victim:IsPlayer() or attacker:IsPlayer() ) then return end
	
	if victim == attacker then return end
	
	if attacker:Team() == TEAM_HUMAN and victim:Team() == TEAM_UNDEAD then
		SetMaxHealth(attacker, 0)
		SetMaxArmor(attacker, 0)
	end
		
	if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) == attacker:Team() == TEAM_UNDEAD and victim:Team() == TEAM_HUMAN then
		SetMaxHealth(attacker, 100)
		SetMaxArmor(attacker, 50)
	end
end )

What are you trying to achieve? What errors are you getting?

No errors I want to make it so when I crouch with that class of zombie that it will turn to that material.

And then the other hook i’m trying to make it so it gains health and armor per kill but both hooks aren’t doing anything.

Both hooks aren’t working for some reason.

[editline]13th September 2015[/editline]

I also need to make it so when it turns to that material that it will go slower.

I’m also willing to pay someone for this.

:excited:

Well no one helped but I coded it


hook.Add( "SetupMove", "Cloak Crouch", function( ply, mv, cmd )
                  print("it works")

                if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) then
                  ply:SetCrouchedWalkSpeed( 0.3 )  --CROUCHLINE CROUCHLINE CROUCHLINE CROUCHLINE CROUCHLINE
                        if ( bit.band( cmd:GetButtons(), IN_DUCK ) == IN_DUCK ) then
                                ply:SetMaterial( "Models/effects/vol_light001" )
                               
                        else    
                                ply:SetMaterial( "" )
                        end
                end
        end )

 
        hook.Add( "PlayerDeath", "Tougher_per_kill", function( victim, inflictor, attacker )
                        if !( IsValid( victim ) or IsValid( attacker ) ) then return end
                        if !( victim:IsPlayer() or attacker:IsPlayer() ) then return end
                        if victim == attacker then return end
       
                        if attacker:Team() == TEAM_HUMAN and victim:Team() == TEAM_UNDEAD then
                                        attacker:SetMaxHealth(0)
                        end
               
                        if ( player_manager.GetPlayerClass( ply ) == "class_predator" ) == attacker:Team() and victim:Team() == TEAM_HUMAN then
                                        attacker:SetHealth(attacker:Health() + 100)
                                        attacker:SetArmor(50)
                                        attacker:SetWalkSpeed(attacker:GetWalkSpeed() + 25)
                        end
        end )