local U = require "scriptbank\\utillib" g_ai_botList = g_ai_botList or {} ai_bot_state = ai_bot_state or {} require "scriptbank\\cowboy" require "scriptbank\\deer" require "scriptbank\\ai_soldier" function ai_respawn_init_name( e, name ) Include("utillib.lua") Include("cowboy.lua") Include("deer.lua") if g_ai_botList[ e ] == nil then g_ai_botList[ e ] = { state = 'prenate', name = name } end Hide( e ) CollisionOff( e ) ai_bot_state[ e ] = 1 end local aiList = nil local aiListInitialised = false function initAIlist() aiList = { cowboy = { init = cowboy_init, main = cowboy_main }, deer = { init = deer_init, main = deer_main }, Soldier = { init = ai_soldier_init, main = ai_soldier_main } } end local botList = g_ai_botList --script to be used in conjunction with ai_respawner.lua function ai_respawn_main( e ) if not aiListInitialised then initAIlist() for _,v in pairs( aiList ) do if v.init == nil or v.main == nil then return end end aiListInitialised = true end local bot = botList[ e ] if bot == nil or bot.state == nil or bot.name == nil then return elseif bot.state == 'prenate' then aiList[ bot.name ].init( e ) botList[ e ].state = 'alive' Show( e ) CollisionOn( e ) elseif bot.state == 'alive' then aiList[ bot.name ].main( e ) elseif bot.state == 'respawn' and not U.PlayerCloserThan ( e, 1200 ) and not U.PlayerLookingNear( e, 3000, 180 ) then aiList[ bot.name ].init( e ) botList[ e ].state = 'alive' Show( e ) CollisionOn( e ) end --Prompt( bot.state .. "," .. ai_bot_state[ e ] ) end local hurt = ai_state_hurt function ai_respawn_exit(e) botList[ e ].state = 'dead' ai_bot_state[ e ] = hurt end