-- $Id: bot_ButBatle.lua,v 1.14 2009-04-15 08:22:23 vadim_b Exp $ --[[ AKEB (c) 11.08.2008 12:46 Маг Бутбатл Каждый ход Если на ком-то в своей команде нет ни абилки (А1), ни абилки (А2), наложить на себя абилку (А1). Если на текущем противнике нет абилки (B), наложить на него абилку (B) ВМЕСТО удара разыгрывется событие: - с вероятностью 40% делается рандомный удар - с вероятностью 60% и при наличии 50 маны применяется абилка (С) на текущего противника, иначе делается рандомный удар Для теста А1 = 167 А2 = 167 B = 161 C = 169 Скрипт: bot_ButBatle.lua Управляющая функция: bot_ButBatle bot_ButBatle_t --]] function bot_ButBatle_r(artikulId1,artikulId2,artikulId3,artikulId4,mana,artifacts,P_cast) if my.status ~= FS_PS_ACTIVE then -- если наш статус неактивный, ничего не делаем return end local bot = PERS(my.persPtr) local G = bot.hp/bot.hpMax bot_ButBatleInitArtikulUsed(bot.id) bot_ButBatleInitRandom(bot.id) local bots = {} local bot_count = 0 local persList = PERS_LIST(my.teamNum,nil,nil) for _,persPtr in pairs(persList) do if persPtr.status ~= FS_PS_DEAD then if #aux.activeEffects(persPtr,{artId = artikulId1}) < 1 and #aux.activeEffects(persPtr,{artId = artikulId2}) < 1 then aux.useEffect({artId = artikulId1},persPtr) break end end end if #aux.activeEffects(my.oppPtr,{artId = artikulId3}) < 1 then aux.useEffect({artId = artikulId3},my.oppPtr) end for _,persPtr in pairs(persList) do local pers = PERS(persPtr) if pers.artId then bots[pers.artId] = pers bot_count = bot_count+1 end end if bot_ButBatleArtikulUsed[bot.id] < 1 and G <= bot_ButBatleRandom[bot.id] then if bot_count > 1 then local check = 0 for artifact,botId in pairs(artifacts) do if (bots[botId]) then local status,_ = aux.useEffect({artId = artifact}) if status == 0 then check = 1 bot_ButBatleArtikulUsed[bot.id]=1 end break end end if (check == 0) then local status,_ = aux.useEffect({artId = aux.getRandKey(artifacts)}) if status == 0 then bot_ButBatleArtikulUsed[bot.id]=1 end end else local status,_ = aux.useEffect({artId = aux.getRandKey(artifacts)}) if status == 0 then bot_ButBatleArtikulUsed[bot.id]=1 end end end if aux.randRoll(P_cast) and bot.mp >= mana then aux.useEffect({artId = artikulId4},my.oppPtr) else ATTACK(math.random(3)) end end function bot_ButBatleInitArtikulUsed(botId) if bot_ButBatleArtikulUsed == nil then bot_ButBatleArtikulUsed={} end -- Если глобальная переменная не существует создаем ее if botId == nil then return; end -- если не задан ID бота, ничего не делаем if bot_ButBatleArtikulUsed[botId] == nil then bot_ButBatleArtikulUsed[botId]=0 end -- Если нет глобальной переменной с Этим ботом создаем ее со значением 0 end function bot_ButBatleInitRandom(botId) if bot_ButBatleRandom == nil then bot_ButBatleRandom={} end -- Если глобальная переменная не существует создаем ее if botId == nil then return; end -- если не задан ID бота, ничего не делаем if bot_ButBatleRandom[botId] == nil then bot_ButBatleRandom[botId]=math.random(65,90)/100 end -- Если нет глобальной переменной с Этим ботом создаем ее со значением 0 end function bot_ButBatle_fire() local artifacts = {[2840]=607} return bot_ButBatle_r(2814,2815,2633,2400,39,artifacts,0.9) end function bot_ButBatle_shadow() local artifacts = {[2842]=609} return bot_ButBatle_r(2817,2816,2821,2404,55,artifacts,0.9) end function bot_ButBatle_ground() local artifacts = {[2845]=606} return bot_ButBatle_r(2818,2819,2823,2402,34,artifacts,0.9) end function bot_ButBatle_air() local artifacts = {[2841]=605} return bot_ButBatle_r(2815,2814,2607,2399,39,artifacts,0.9) end function bot_ButBatle_light() local artifacts = {[2843]=610} return bot_ButBatle_r(2816,2817,2820,2403,55,artifacts,0.9) end function bot_ButBatle_water() local artifacts = {[2844]=608} return bot_ButBatle_r(2819,2818,2822,2401,34,artifacts,0.9) end function bot_ButBatle_fire_ph() local artifacts = {[2840]=607} return bot_ButBatle_r(2814,2815,2633,2400,39,artifacts,0.25) end function bot_ButBatle_shadow_ph() local artifacts = {[2842]=609} return bot_ButBatle_r(2817,2816,2821,2404,55,artifacts,0.25) end function bot_ButBatle_ground_ph() local artifacts = {[2845]=606} return bot_ButBatle_r(2818,2819,2823,2402,34,artifacts,0.25) end function bot_ButBatle_air_ph() local artifacts = {[2841]=605} return bot_ButBatle_r(2815,2814,2607,2399,39,artifacts,0.25) end function bot_ButBatle_light_ph() local artifacts = {[2843]=610} return bot_ButBatle_r(2816,2817,2820,2403,55,artifacts,0.25) end function bot_ButBatle_water_ph() local artifacts = {[2844]=608} return bot_ButBatle_r(2819,2818,2822,2401,34,artifacts,0.25) end function bot_ButBatle_t() local artifacts = {[161]=641,[167]=642} return bot_ButBatle_r(167,167,161,169,50,artifacts,0.5) end