local U = require "scriptbank\\utillib" local creature_name = {} g_ai_botList = g_ai_botList or {} ai_bot_state = ai_bot_state or {} g_bearskilled = g_bearskilled or 0 g_deerk = g_deerk or 0 g_boark = g_boark or 0 require "scriptbank\\ai_elk" require "scriptbank\\boar" require "scriptbank\\bear" function ai_respawn_init_name( e, name ) Include("utillib.lua") Include("ai_elk.lua") Include("boar.lua") Include("bear.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 = { elk = { init = ai_elk_init, main = ai_elk_main }, boar = { init = boar_init, main = boar_main }, bear = { init = bear_init, main = bear_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 local bot = botList[ e ] local tname = GetEntityName(e) if tname =="boar" then g_exp = g_exp + 5 g_hidecollected = g_hidecollected + 1 g_meatcollected = g_meatcollected + math.random(2 , 8) g_boark = g_boark + 1 elseif tname == "elk" then g_exp = g_exp + 5 g_hidecollected = g_hidecollected + 1 g_meatcollected = g_meatcollected + math.random(2 , 8) g_deerk = g_deerk + 1 elseif tname == "bear" then g_exp = g_exp + 5 g_hidecollected = g_hidecollected + 1 g_meatcollected = g_meatcollected + math.random(2 , 8) g_bearskilled = g_bearskilled + 1 end end