Zombie Class Custom Sequence Animation



  • Hello there Noxious net I have another question for ya. How would I go about setting a sequence for a zombie classes attack animation. By this I mean the classes model not the viewmodel of the weapon the class is holding thanks in advance. Braintwistah



  • Hello there Noxious net I have another question for ya. How would I go about setting a sequence for a zombie classes attack animation. By this I mean the classes model not the viewmodel of the weapon the class is holding thanks in advance. Braintwistah



  • To add on to the subject just incase some poeple arent understanding the problem Im having is a class I made and I coded a weapon to fit the class but the attack sequence for it is attack_1 so it wont play the sequence so it just does nothing  when I attack with the weapon so Im trying to find out how I can have it play a sequence when you attack instead of a ACT animation



  • Bump


  • Administrators

    Some of the classes use sequences and cycles to fake this. I think the flesh creeper does this. Anyway you want to look in to controlling SetCycle, SetSequence, and SetPlaybackRate in the gamemode animation hook (or in this case, the class-specific functionss).



  • @JetBoom:

    Some of the classes use sequences and cycles to fake this. I think the flesh creeper does this. Anyway you want to look in to controlling SetCycle, SetSequence, and SetPlaybackRate in the gamemode animation hook (or in this case, the class-specific functionss).

    CLASS.Name = "Tank"
    CLASS.TranslationName = "class_tank"
    CLASS.Description = "description_tank"
    CLASS.Help = "controls_tank"
    
    CLASS.Wave = 0
    CLASS.Threshold = 0
    CLASS.Unlocked = true
    CLASS.Hidden = true
    CLASS.Boss = true
    
    CLASS.Health = 3000
    CLASS.SWEP = "weapon_zs_tank"
    CLASS.Model = Model("models/enhanced_infected/hulk_1.mdl")
    
    CLASS.Speed = 220
    
    CLASS.Points = 60
    
    CLASS.VoicePitch = 0.55
    CLASS.Mass = 500
    CLASS.PainSounds = {Sound("tank/voice/pain/tank_pain_01.wav"), Sound("tank/voice/pain/tank_pain_02.wav"), Sound("tank/voice/pain/tank_pain_03.wav"), Sound("tank/voice/pain/tank_pain_04.wav"), Sound("tank/voice/pain/tank_pain_05.wav")}
    CLASS.DeathSounds = {Sound("tank/voice/die/tank_death_01.wav"), Sound("tank/voice/die/tank_death_02.wav"), Sound("tank/voice/die/tank_death_03.wav"), Sound("tank/voice/die/tank_death_04.wav"), Sound("tank/voice/die/tank_death_05.wav"), Sound("tank/voice/die/tank_death_06.wav"), Sound("tank/voice/die/tank_death_07.wav")}
    
    CLASS.JumpPower = 180
    CLASS.Hull = {Vector(-22, -22, 0), Vector(22, 22, 96)}
    CLASS.HullDuck = {Vector(-22, -22, 0), Vector(22, 22, 58)}
    CLASS.ViewOffset = Vector(0, 0, 75)
    CLASS.ViewOffsetDucked = Vector(0, 0, 48)
    
    function CLASS:CanUse(pl)
    	return GAMEMODE:GetDynamicSpawning() and not GAMEMODE.ZombieEscape
    end
    
    function CLASS:CalcMainActivity(pl, velocity)
    	local wep = pl:GetActiveWeapon()
    	if wep:IsValid() and wep.GetBurrowTime then
    		local time = wep:GetBurrowTime()
    		if time > 0 then
    			pl.CalcSeqOverride = 11
    			return true
    		elseif time < 0 then
    			pl.CalcSeqOverride = 10
    			return true
    		end
    	end
    
    	if pl:OnGround() then
    		if velocity:Length2D() > 0.5 then
    			pl.CalcSeqOverride = pl:LookupSequence("Run_4")
    		else
    			pl.CalcSeqOverride = 1
    		end
    	elseif pl:WaterLevel() >= 3 then
    		pl.CalcSeqOverride = 4
    	else
    		pl.CalcSeqOverride = 3
    	end
    
    	return true
    end
    
    function CLASS:UpdateAnimation(pl, velocity, maxseqgroundspeed)
    	pl:FixModelAngles(velocity)
    
    	local seq = pl:GetSequence()
    	if seq == 5 then
    		if not pl.m_PrevFrameCycle then
    			pl.m_PrevFrameCycle = true
    			pl:SetCycle(0)
    		end
    
    		pl:SetPlaybackRate(0.9)
    
    		return true
    	elseif pl.m_PrevFrameCycle then
    		pl.m_PrevFrameCycle = nil
    	end
    
    	local len2d = velocity:Length2D()
    	if len2d > 0.5 then
    		pl:SetPlaybackRate(0.9)
    
    	return true
    	end
    end
    function CLASS:DoAnimationEvent(pl, event, data)
    	if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
    		return ACT_INVALID
    	end
    end
    
    local mathrandom = math.random
    local StepLeftSounds = {
    	"npc/zombie/foot1.wav",
    	"npc/zombie/foot2.wav"
    }
    local StepRightSounds = {
    	"npc/zombie/foot2.wav",
    	"npc/zombie/foot3.wav"
    }
    function CLASS:PlayerFootstep(pl, vFootPos, iFoot, strSoundName, fVolume, pFilter)
    	if iFoot == 0 then
    
    		pl:EmitSound("footsteps/tank/walk/tank_walk0"..math.random(6)..".wav", 70)
    	end
    
    	if EyePos():Distance(vFootPos) <= 300 then
    		util.ScreenShake(vFootPos, 5, 5, 1, 300)
    	end
    
    	return true
    end
    
    if not CLIENT then return end
    
    --CLASS.Icon = "zombiesurvival/killicons/flesh_creeper"
    
    function CLASS:PostPlayerDraw(pl)
    	render.ModelMaterialOverride()
    end
    
    function CLASS:ShouldDrawLocalPlayer()
    	return true
    end
    
    

    This is the code for the class Im trying to have run the attack sequence “attack_moving” I dont really understand what your saying above as I am not that experienced in lua. Can you perhaps highlight the function that defines the classes attack animation and how to go about editing it?


  • Administrators

    function CLASS:CalcMainActivity(pl, velocity)
    You define the ACT or sequence ID in here. LookupSequence translates a string sequence in to a number. I just put the numbers there because it saves resources and the IDs never change.

    function CLASS:UpdateAnimation(pl, velocity, maxseqgroundspeed)
    You can control the cycle and playback rate here.



  • Thank you very much Jetboom!

    EDIT: This is what I did and it didnt work I feel I did something wrong.

    function CLASS:CalcMainActivity(pl, velocity)
    	local wep = pl:GetActiveWeapon()
    	if wep:IsValid() and wep.GetBurrowTime then
    		local time = wep:GetBurrowTime()
    		if time > 0 then
    			pl.CalcSeqOverride = pl:LookupSequence("attack_moving")
    			return true
    		elseif time < 0 then
    			pl.CalcSeqOverride = pl:LookupSequence("attack_moving")
    			return true
    		end
    	end
    


  • Was I supposed to put in the number or could I have done it that way?


  • Administrators

    Sequence lookups take resources so better to just figure out the number once and put that in the code. At least for NPC models because they never change.

    And obviously that’s not going to work since you just copy+pasted rather than understanding what it does. Burrow time? Does your class burrow?


Log in to reply
 

7
Online

10973
Users

15257
Topics

297298
Posts

Looks like your connection to NoXiousNet was lost, please wait while we try to reconnect.