zombiesurvival-evolved/gamemodes/zombiesurvival/gamemode/zombieclasses/freshdead.lua

149 lines
3.6 KiB
Lua
Raw Normal View History

2014-10-02 08:49:54 +08:00
CLASS.Name = "Fresh Dead"
CLASS.TranslationName = "class_fresh_dead"
CLASS.Description = ""
CLASS.Help = ""
CLASS.Wave = 0
CLASS.Unlocked = true
CLASS.Hidden = true
CLASS.Health = 125
CLASS.Speed = 200
CLASS.Points = 3
CLASS.CanTaunt = true
CLASS.UsePreviousModel = true
CLASS.SWEP = "weapon_zs_freshdead"
CLASS.PainSounds = {"npc/zombie/zombie_pain1.wav", "npc/zombie/zombie_pain2.wav", "npc/zombie/zombie_pain3.wav", "npc/zombie/zombie_pain4.wav", "npc/zombie/zombie_pain5.wav", "npc/zombie/zombie_pain6.wav"}
CLASS.DeathSounds = {"npc/zombie/zombie_die1.wav", "npc/zombie/zombie_die2.wav", "npc/zombie/zombie_die3.wav"}
CLASS.VoicePitch = 0.65
CLASS.CanFeignDeath = true
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(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("Zombie.FootstepLeft")
else
pl:EmitSound("Zombie.FootstepRight")
end
return true
end]]
function CLASS:CalcMainActivity(pl, velocity)
local revive = pl.Revive
if revive and revive:IsValid() then
pl.CalcIdeal = ACT_HL2MP_ZOMBIE_SLUMP_RISE
return true
end
local feign = pl.FeignDeath
if feign and feign:IsValid() then
if feign:GetDirection() == DIR_BACK then
pl.CalcSeqOverride = pl:LookupSequence("zombie_slump_rise_02_fast")
else
pl.CalcIdeal = ACT_HL2MP_ZOMBIE_SLUMP_RISE
end
return true
end
if pl:WaterLevel() >= 3 then
pl.CalcIdeal = ACT_HL2MP_SWIM_PISTOL
elseif pl:Crouching() then
if velocity:Length2D() <= 0.5 then
pl.CalcIdeal = ACT_HL2MP_IDLE_CROUCH_ZOMBIE
else
pl.CalcIdeal = ACT_HL2MP_WALK_CROUCH_ZOMBIE_01 - 1 + math.ceil((CurTime() / 4 + pl:EntIndex()) % 3)
end
else
pl.CalcIdeal = ACT_HL2MP_RUN_ZOMBIE
end
return true
end
function CLASS:UpdateAnimation(pl, velocity, maxseqgroundspeed)
local revive = pl.Revive
if revive and revive:IsValid() then
pl:SetCycle(0.4 + (1 - math.Clamp((revive:GetReviveTime() - CurTime()) / revive.AnimTime, 0, 1)) * 0.6)
pl:SetPlaybackRate(0)
return true
end
local feign = pl.FeignDeath
if feign and feign:IsValid() then
if feign:GetState() == 1 then
pl:SetCycle(1 - math.max(feign:GetStateEndTime() - CurTime(), 0) * 0.666)
else
pl:SetCycle(math.max(feign:GetStateEndTime() - CurTime(), 0) * 0.666)
end
pl:SetPlaybackRate(0)
return true
end
local len2d = velocity:Length2D()
if len2d > 0.5 then
pl:SetPlaybackRate(math.min(len2d / maxseqgroundspeed, 3))
else
pl:SetPlaybackRate(1)
end
return true
end
function CLASS:DoAnimationEvent(pl, event, data)
if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
pl:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_RANGE_ZOMBIE, true)
return ACT_INVALID
end
end
function CLASS:DoesntGiveFear(pl)
return pl.FeignDeath and pl.FeignDeath:IsValid()
end
if SERVER then
function CLASS:OnKilled(pl, attacker, inflictor, suicide, headshot, dmginfo)
pl:SetZombieClass(GAMEMODE.DefaultZombieClass)
end
function CLASS:AltUse(pl)
pl:StartFeignDeath()
end
end
if not CLIENT then return end
CLASS.Icon = "zombiesurvival/killicons/zombie"
function CLASS:PrePlayerDraw(pl)
render.SetColorModulation(0.5, 0.9, 0.5)
end
function CLASS:PostPlayerDraw(pl)
render.SetColorModulation(1, 1, 1)
end