-- AI : Melee Behavior for classic zombies -- mods by J_C -- --///////////////////////////////////////////////////////////////////////////////// -- -- To use this script... -- These settings must be setup in the zombie FPE file -- Fat Zombie , Zombie Nurse -- animmax = 7 -- anim0 = 211,232 ; idle0 -- anim1 = 2499,2525 ; zombie walk -- anim2 = 2528,2581 ; attack1 -- anim3 = 41,60 ; fake death -- anim4 = 211,232 ; idle0 -- anim5 = 913,936 ; rise from death -- anim6 = 913,913 ; idle-death -- Zombie Doctor , Zombie Surgeon , Zombie Cop -- animmax = 7 -- anim0 = 210,235 ; idle -- anim1 = 235,259 ; zombie walk -- anim2 = 319,355 ; attack1 -- anim3 = 64,79 ; fake death -- anim4 = 211,232 ; idle0 -- anim5 = 494,522 ; rise from death -- anim6 = 494,494 ; idle-death --///////////////////////////////////////////////////////////////////////////////// module_combatmelee = require "scriptbank\\ai\\module_combatmelee" local zombie_wait = 1 local zombie_startmove = 2 local zombie_moved = 3 local num = 0 local AIObjNo = 0 local zhealth = 0 local zombie_wtTm = {} local zombie_state = {} local zombie_startIdle = {} local zombie_oldHealth = {} function ai_classic_zombie_init(e) -- try to get zombies to start fake death zombie_state[e] = 0 num = math.random(1,2) if num == 1 then -- fake death zombie_startIdle[e] = 6 StartTimer(e) else -- normal idle zombie_startIdle[e] = 0 end -- play dead time zombie_wtTm[e] = math.random(3, 7) * 1000 module_combatmelee.init(e,ai_combattype_patrol) zombie_oldHealth[e] = g_Entity[e]['health'] end function ai_classic_zombie_main(e) zhealth = g_Entity[e]['health'] if zhealth > 0.0 and zhealth < zombie_oldHealth[e] then -- we are still alive -- but we are hurt - lets fake death zombie_startIdle[e] = 6 -- keep old health value zombie_oldHealth[e] = g_Entity[e]['health'] end if zombie_startIdle[e] == 0 then module_combatmelee.main(e,ai_combattype_patrol) else ai_classic_zombie_fakeDeath(e) end end function ai_classic_zombie_fakeDeath(e) AIObjNo = g_Entity[e]['obj'] PlayerDist = GetPlayerDistance(e) CharacterControlManual(e) AISetEntityControl(AIObjNo,AI_MANUAL) if zombie_state[e] == 0 then SetAnimation(zombie_startIdle[e]) LoopAnimation(e) SetAnimationSpeedModulation(e,1.0) zombie_state[e] = zombie_wait StartTimer(e) elseif zombie_state[e] == zombie_wait then -- zombie in idle-death ai_classic_zombie_waitToRise(e, AIObjNo, PlayerDist) elseif zombie_state[e] == zombie_startmove then -- zombie is rising to feet - wait here for rise anim to finish if GetTimer(e) > 2500 then --zombie_state[e] = zombie_moved zombie_state[e] = 0 -- now do normal combatmelee main code zombie_startIdle[e] = 0 end end end -- get zombies to rise from fake death function ai_classic_zombie_waitToRise(e, AIObjNo, PlayerDist) zombie_state[e] = zombie_wait if GetTimer(e) > zombie_wtTm[e] then -- only move when player is near and can see if PlayerDist < AIGetEntityViewRange(AIObjNo) and g_Entity[e]['plrvisible'] == 1 then zombie_state[e] = zombie_startmove SetAnimation(5) PlayAnimation(e) SetAnimationSpeedModulation(e,0.2) StartTimer(e) end end end