local U = require "scriptbank\\utillib" function ai_dead2_init( e ) Include( "utillib.lua" ) LoadGlobalSound( "audiobank\\music\\theescape\\default.ogg", 2) LoadGlobalSound( "audiobank\\music\\theescape\\battle.ogg", 1) end local state = 'idle' local timer = 0 local triggerDistance = 2000 local enemyDistance = 3000 function ai_dead2_main( e ) if state == 'done' then return end if g_Time > timer then timer = g_Time + 1000 if state == 'idle' and U.PlayerCloserThan( e, triggerDistance ) then state = 'play' LoopGlobalSound( 1 ) ` elseif state == 'play' then local aiAllDead = true local Ent = g_Entity[ e ] for _, v in pairs( U.ClosestEntities( enemyDistance, math.huge, Ent.x, Ent.z ) ) do if ai_bot_state[ v ] ~= nil then if g_Entity[ v ].health > 0 then aiAllDead = false break end end end if aiAllDead then StopGlobalSound( 1 ) LoopGlobalSound( 2 ) state = 'done' end end end end