g_new_ai_zombie_state = {} function new_ai_zombie_init( e ) g_new_ai_zombie_state[ e ] = 0 CharacterControlLimbo( e ) SetAnimationFrames( 493, 494 ) PlayAnimation( e ) end function new_ai_zombie_main( e ) local Ent = g_Entity[ e ] local playerDist = GetPlayerDistance( e ) if playerDist < 75 and g_new_ai_zombie_state[ e ] == 0 then -- Starting Animation (Zombie rises) SetAnimationFrames( 495, 522) SetAnimationSpeed( e, 0.2 ) PlayAnimation( e ) g_new_ai_zombie_state[ e ] = 'rising' elseif g_new_ai_zombie_state[ e ] == 'rising' and GetAnimationFrame( e ) >= 520 then -- Preparing Second Animation (Run To Player) SetAnimationSpeed( e, 1 ) g_new_ai_zombie_state[ e ] = 'runtoplayer' elseif g_new_ai_zombie_state[ e ] == 'runtoplayer' and playerDist < 85 then -- Preparing Attack g_new_ai_zombie_state[ e ] = 'attack' elseif g_new_ai_zombie_state[ e ] == 'runtoplayer' then -- Zombie runs to Player CharacterControlUnarmed( e ) SetCharacterToRun( e ) AIEntityGoToPosition( Ent.obj, g_PlayerPosX, g_PlayerPosZ ) elseif g_new_ai_zombie_state[ e ] == 'attack' then -- Zombie Attack Player CharacterControlLimbo( e ) SetAnimationSpeed( e, 1 ) SetAnimationFrames( 2981, 3034 ) PlayAnimation( e ) g_Entity[e]['animating'] = 1 g_new_ai_zombie_state[ e ] = 'attacking' elseif g_new_ai_zombie_state[ e ] == 'attacking' and playerDist >= 85 and g_Entity[e]['animating'] == 0 then -- If player get out of range, zombie chases again g_new_ai_zombie_state[ e ] = 'runtoplayer' elseif g_new_ai_zombie_state[e] == 'attacking' then if GetAnimationFrame( e ) == 3010 and playerDist <= 100 then -- If player is in range while Zombie is at specific frame animation (Claws near), player got damaged HurtPlayer( e, 40 ) end if g_Entity[e]['animating'] == 0 then g_new_ai_zombie_state[e] = 'attack' end end Prompt( "State= " .. g_new_ai_zombie_state[ e ] .. "frame= " .. GetAnimationFrame( e ) ) end function new_ai_zombie_preexit(e) end function new_ai_zombie_exit(e) end