diff --git a/BotNameUtility.lua b/BotNameUtility.lua new file mode 100644 index 00000000..36abb60f --- /dev/null +++ b/BotNameUtility.lua @@ -0,0 +1,201 @@ +local U = {} + +local dota2team = { + + [1] = { + ['name'] = "Navi TI1"; + ['alias'] = "Na'Vi"; + ['players'] = { + 'Artstyle.Darer', + 'Puppeh', + 'Dendi', + 'LightToHeaveN', + 'XBOCT' + }; + ['sponsorship'] = ''; + }, + [2] = { + ['name'] = "Ehome TI1"; + ['alias'] = "EH.GIGABYTE"; + ['players'] = { + '820', + '357', + 'FCB', + 'PLT', + 'X!!' + }; + ['sponsorship'] = 'CN'; + }, + [3] = { + ['name'] = "IG TI2"; + ['alias'] = "iG"; + ['players'] = { + 'Zhou', + 'Ferrari_430', + 'YYF', + 'ChuaN', + 'Faith' + }; + ['sponsorship'] = ''; + }, + [4] = { + ['name'] = "Navi TI2"; + ['alias'] = "Na'Vi"; + ['players'] = { + 'XBOCT', + 'Dendi', + 'LightToHeaveN', + 'Puppey', + 'ARS-ART' + }; + ['sponsorship'] = ''; + }, + [5] = { + ['name'] = "Alliance TI3"; + ['alias'] = ""; + ['players'] = { + 'Lod[A]', + '[A]s4', + '[A]dmiralBulldog', + '[A]EGM', + '[A]kke' + }; + ['sponsorship'] = ''; + }, + [6] = { + ['name'] = "Navi TI3"; + ['alias'] = "Na'Vi"; + ['players'] = { + 'XBOCT', + 'Dendi', + 'Funn1k', + 'Puppey', + 'KuroKy' + }; + ['sponsorship'] = ''; + }, + [7] = { + ['name'] = "Newbee TI4"; + ['alias'] = "Newbee"; + ['players'] = { + 'Hao', + 'Mu', + 'xiao8', + 'Banana', + 'SanSheng' + }; + ['sponsorship'] = ''; + }, + [8] = { + ['name'] = "VG TI4"; + ['alias'] = "VG"; + ['players'] = { + 'Sylar', + 'Super', + 'rOtk', + 'fy', + 'Fenrir' + }; + ['sponsorship'] = '天喔'; + }, + [9] = { + ['name'] = "Evil Geniuses TI5"; + ['alias'] = "EG"; + ['players'] = { + 'Fear', + 'SumaiL.Coffin', + 'UNiVeRsE', + 'Aui_2000', + 'ppd' + }; + ['sponsorship'] = ''; + }, + [10] = { + ['name'] = "CDEC Gaming TI5"; + ['alias'] = "CDEC"; + ['players'] = { + 'Q', + 'Xz', + 'garder', + 'Shiki', + 'Agressif' + }; + ['sponsorship'] = 'DouYuTV'; + }, + [11] = { + ['name'] = "Wings Gaming TI6"; + ['alias'] = "Wings"; + ['players'] = { + 'shadow', + '跳刀跳刀丶.bLink', + 'Faith_bian.Vicky', + 'y`.innocence', + 'iceice' + }; + ['sponsorship'] = ''; + }, + [12] = { + ['name'] = "Digital Chaos TI6"; + ['alias'] = "DC"; + ['players'] = { + 'Resolut1on', + 'w33', + 'Moo.hotaW', + 'MiSeRy', + 'Saksa' + }; + ['sponsorship'] = ''; + }, + [13] = { + ['name'] = "Team Liquid TI7"; + ['alias'] = "Liquid"; + ['players'] = { + 'MATUMBAMAN', + 'Miracle-', + 'MinD_ContRoL', + 'GH', + 'KuroKy' + }; + ['sponsorship'] = ''; + }, + [14] = { + ['name'] = "Newbee TI7"; + ['alias'] = "Newbee"; + ['players'] = { + 'Moogy', + 'Sccc', + 'kpii', + 'Kaka', + 'Faith' + }; + ['sponsorship'] = ''; + }, +} + +local sponsorship = {"GG.bet", "gg.bet", "VPGAME", "LOOT.bet", "loot.bet", "", "Esports.bet", "G2A", "Dota2.net"}; + +function U.GetDota2Team() + local bot_names = {}; + local rand = RandomInt(1, #dota2team); + local srand = RandomInt(1, #sponsorship); + if GetTeam() == TEAM_RADIANT then + while rand%2 ~= 0 do + rand = RandomInt(1, #dota2team); + end + else + while rand%2 ~= 1 do + rand = RandomInt(1, #dota2team); + end + end + local team = dota2team[rand]; + for _,player in pairs(team.players) do + if team.sponsorship == "" then + table.insert(bot_names, team.alias.."."..player); + else + table.insert(bot_names, team.alias.."."..player.."."..team.sponsorship); + end + end + return bot_names; +end + +return U \ No newline at end of file diff --git a/DEV_ability_item_usage_kunkka.lua b/DEV_ability_item_usage_kunkka.lua index 2f0a19fb..8d7faca0 100644 --- a/DEV_ability_item_usage_kunkka.lua +++ b/DEV_ability_item_usage_kunkka.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/DEV_ability_item_usage_batrider.lua b/DEV_ability_item_usage_morphling.lua similarity index 74% rename from DEV_ability_item_usage_batrider.lua rename to DEV_ability_item_usage_morphling.lua index bac02d3b..646ff1e5 100644 --- a/DEV_ability_item_usage_batrider.lua +++ b/DEV_ability_item_usage_morphling.lua @@ -1,11 +1,11 @@ ---------------------------------------------------------------------------- --- Ranked Matchmaking AI v1.2 New Structure +-- Ranked Matchmaking AI v1.3 New Structure -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,24 +18,24 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { + Abilities[4], Abilities[1], - Abilities[3], Abilities[1], - Abilities[3], + Abilities[4], Abilities[1], Abilities[4], Abilities[1], + Abilities[4], Abilities[2], - Abilities[3], "talent", - Abilities[3], - Abilities[4], + Abilities[8], + Abilities[8], Abilities[2], Abilities[2], "talent", Abilities[2], "nil", - Abilities[4], + Abilities[8], "nil", "talent", "nil", @@ -50,10 +50,10 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[7] @@ -83,7 +83,7 @@ function GetComboMana() return ability_item_usage_generic.GetComboMana(AbilitiesReal) end -Consider[1]=function() --Target Ability Example +Consider[1]=function() local abilityNumber=1 -------------------------------------- -- Generic Variable Setting @@ -104,13 +104,104 @@ Consider[1]=function() --Target Ability Example local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- -- Mode based usage -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 500, true, BOT_MODE_NONE ); + if(npcBot:WasRecentlyDamagedByAnyHero(5)) + then + for _,npcEnemy in pairs( enemys2 ) + do + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy + end + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + end + --protect myself local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) then + --[[ + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE, utility.Fountain(GetTeam()); + end + end]]-- + for _,npcEnemy in pairs( enemys ) do if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) @@ -217,149 +308,7 @@ Consider[1]=function() --Target Ability Example end -Consider[2]=function() --Target AOE Ability Example - local abilityNumber=2 - -------------------------------------- - -- Generic Variable Setting - -------------------------------------- - local ability=AbilitiesReal[abilityNumber]; - - if not ability:IsFullyCastable() then - return BOT_ACTION_DESIRE_NONE, 0; - end - - local CastRange = ability:GetCastRange(); - local Damage = ability:GetAbilityDamage(); - local CastPoint = ability:GetCastPoint(); - - local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); - local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) - local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) - local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) - local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) - - --try to kill enemy hero - if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end - end - end - -------------------------------------- - -- Mode based usage - -------------------------------------- - - --teamfightUsing - if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) - then - if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (#enemys+#creeps>2) - then - if(WeakestCreep~=nil) - then - return BOT_ACTION_DESIRE_HIGH,WeakestCreep; - end - if(WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end - end - end - end - - --Last hit - --if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) - --then - if(WeakestCreep~=nil) - then - if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) - then - return BOT_ACTION_DESIRE_LOW,WeakestCreep; - end - end - end - --end - - -- If we're farming and can hit 2+ creeps and kill 1+ - if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) - then - if ( #creeps >= 2 ) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - - -- If we're pushing or defending a lane and can hit 3+ creeps, go for it - if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) - then - if ( #enemys+#creeps >= 3 ) - then - if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestEnemy; - end - end - if (WeakestCreep~=nil) - then - if ( CanCast[abilityNumber]( WeakestCreep )and GetUnitToUnitDistance(npcBot,WeakestCreep)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - end - end - - -- If we're going after someone - if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or - npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or - npcBot:GetActiveMode() == BOT_MODE_ATTACK ) - then - local npcEnemy = npcBot:GetTarget(); - - if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) - then - if ( npcEnemy ~= nil ) - then - if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) - then - return BOT_ACTION_DESIRE_MODERATE, npcEnemy; - end - end - end - end - - return BOT_ACTION_DESIRE_NONE, 0; - -end - -Consider[3]=function() --Location AOE Example +Consider[3]=function() local abilityNumber=3 -------------------------------------- diff --git a/DEV_ability_item_usage_normal.lua b/DEV_ability_item_usage_normal.lua index 41c4d798..9ecfc4f2 100644 --- a/DEV_ability_item_usage_normal.lua +++ b/DEV_ability_item_usage_normal.lua @@ -1,11 +1,11 @@ ---------------------------------------------------------------------------- --- Ranked Matchmaking AI v1.2 New Structure +-- Ranked Matchmaking AI v1.3 New Structure -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -192,6 +192,16 @@ Consider[1]=function() --Target Ability Example -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) then + --[[ + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE, utility.Fountain(GetTeam()); + end + end]]-- + for _,npcEnemy in pairs( enemys ) do if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) diff --git a/DEV_ability_item_usage_normal2.lua b/DEV_ability_item_usage_normal2.lua index 3194d56d..92e83d7c 100644 --- a/DEV_ability_item_usage_normal2.lua +++ b/DEV_ability_item_usage_normal2.lua @@ -5,7 +5,7 @@ -------------------------------------- -- Load Utility Function Library -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") -------------------------------------- -- Hero Area Local Variable Setting diff --git a/DEV_ability_item_usage_pudge.lua b/DEV_ability_item_usage_pudge.lua index 2f0a19fb..8d7faca0 100644 --- a/DEV_ability_item_usage_pudge.lua +++ b/DEV_ability_item_usage_pudge.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/DEV_item_purchase_normal.lua b/DEV_item_purchase_normal.lua index 11e100d4..dbce7372 100644 --- a/DEV_item_purchase_normal.lua +++ b/DEV_item_purchase_normal.lua @@ -1,8 +1,8 @@ ---------------------------------------------------------------------------- --- Ranked Matchmaking AI v1.0a +-- Ranked Matchmaking AI v1.3 -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 local ItemsToBuy = { @@ -45,10 +45,10 @@ local ItemsToBuy = } -utility.checkItemBuild(ItemsToBuy) +utility.checkItemBuild(ItemsToBuy) --检查装备列表 function ItemPurchaseThink() - utility.BuySupportItem() - utility.BuyCourier() - utility.ItemPurchase(ItemsToBuy) + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.BuyCourier() --购买信使 对于5号位保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 end \ No newline at end of file diff --git a/MinionUtility.lua b/MinionUtility.lua new file mode 100644 index 00000000..4133a743 --- /dev/null +++ b/MinionUtility.lua @@ -0,0 +1,997 @@ +local BotsInit = require( "game/botsinit" ); +local MyModule = BotsInit.CreateGeneric(); +local npcBot = nil; +local MoveDesire = 0; +local AttackDesire = 0; +local RetreatDesire = 0; +local npcBotAR = 0; +local ProxRange = 1300; +local castWSDesire = 0; +local castTCDesire = 0; +local castSWDesire = 0; +local castMBDesire = 0; +local castPGDesire = 0; +local castESDesire = 0; +local castHBDesire = 0; +local castHB2Desire = 0; +local castCLDesire = 0; +local castFADesire = 0; + + +function MinionThink( hMinionUnit ) + + if npcBot == nil then npcBot = GetBot(); end + + if not hMinionUnit:IsNull() and hMinionUnit ~= nil and hMinionUnit:IsAlive() then + if hMinionUnit:IsIllusion() then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_centaur_khan" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + abilityWS = hMinionUnit:GetAbilityByName( "centaur_khan_war_stomp" ); + + castWSDesire = ConsiderWarStomp(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castWSDesire > 0 then + hMinionUnit:Action_UseAbility(abilityWS); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_polar_furbolg_ursa_warrior" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityTC = hMinionUnit:GetAbilityByName( "polar_furbolg_ursa_warrior_thunder_clap" ); + + castTCDesire = ConsiderThunderClap(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castTCDesire > 0 then + hMinionUnit:Action_UseAbility(abilityTC); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + ----------------SATYR + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_satyr_hellcaller" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilitySW = hMinionUnit:GetAbilityByName( "satyr_hellcaller_shockwave" ); + + castSWDesire, castSWLocation = ConsiderShockWave(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castSWDesire > 0 then + hMinionUnit:Action_UseAbilityOnLocation(abilitySW, castSWLocation); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_satyr_soulstealer" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityMB = hMinionUnit:GetAbilityByName( "satyr_soulstealer_mana_burn" ); + + castMBDesire, castMBTarget = ConsiderManaBurn(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castMBDesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityMB, castMBTarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_satyr_trickster" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityPG = hMinionUnit:GetAbilityByName( "satyr_trickster_purge" ); + + castPGDesire, castPGTarget = ConsiderPurge(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castPGDesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityPG, castPGTarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + ---------------TROLL + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_dark_troll_warlord" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityES = hMinionUnit:GetAbilityByName( "dark_troll_warlord_ensnare" ); + + castESDesire, castESTarget = ConsiderEnsnare(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castESDesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityES, castESTarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + ---------------MUD GOLEM + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_mud_golem" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityHB = hMinionUnit:GetAbilityByName( "mud_golem_hurl_boulder" ); + + castHBDesire, castHBTarget = ConsiderBoulder(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castHBDesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityHB, castHBTarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_mud_golem_split" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityHB2 = hMinionUnit:GetAbilityByName( "mud_golem_hurl_boulder" ); + + castHB2Desire, castHB2Target = ConsiderBoulder2(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castHB2Desire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityHB2, castHB2Target); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + ---------------Harpy + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_harpy_storm" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityCL = hMinionUnit:GetAbilityByName( "harpy_storm_chain_lightning" ); + + castCLDesire, castCLTarget = ConsiderChainLighting(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castCLDesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityCL, castCLTarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + elseif hMinionUnit:GetUnitName() == "npc_dota_neutral_ogre_magi" then + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + + abilityFA = hMinionUnit:GetAbilityByName( "ogre_magi_frost_armor" ); + + castFADesire, castFATarget = ConsiderFrostArmor(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if castFADesire > 0 then + hMinionUnit:Action_UseAbilityOnEntity(abilityFA, castFATarget); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + else + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() ) then return end + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + end + end + +end + +function CanBeAttacked( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsInvulnerable(); +end + +function CanCastOnMagicImmuneTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsInvulnerable(); +end +function CanCastOnNonMagicImmuneTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable(); +end + +function ConsiderAttacking(hMinionUnit) + + if hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.9 + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + if hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.25 then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local npcBot = GetBot(); + local target = npcBot:GetTarget(); + local AR = hMinionUnit:GetAttackRange(); + local OAR = npcBot:GetAttackRange(); + local AD = hMinionUnit:GetAttackDamage(); + + if target == nil or target:IsTower() or target:IsBuilding() then + target = npcBot:GetAttackTarget(); + end + + if target ~= nil and GetUnitToUnitDistance(hMinionUnit, npcBot) <= ProxRange then + return BOT_ACTION_DESIRE_MODERATE, target; + end + + local enemies = npcBot:GetNearbyHeroes(1300, true, BOT_MODE_NONE); + if not npcBot:IsAlive() or ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and #enemies == 0 ) then + local followTarget = nil; + local closest = nil; + local closestDist = 100000; + for i,id in pairs(GetTeamPlayers(GetTeam())) do + local member = GetTeamMember(i); + if member ~= nil and member:IsAlive() then + local target = member:GetTarget(); + if target == nil or target:IsTower() or target:IsBuilding() then + target = member:GetAttackTarget(); + end + local distance = GetUnitToUnitDistance(member, hMinionUnit); + if target ~= nil and GetUnitToUnitDistance(member, target) <= ProxRange and distance < closestDist then + closest = member; + closestDist = distance; + followTarget = target; + end + end + end + if closest ~= nil and followTarget ~= nil then + return BOT_ACTION_DESIRE_MODERATE, followTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function ConsiderMove(hMinionUnit) + + if hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.9 + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + if hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.25 then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local target = npcBot:GetTarget() + + if AttackDesire > 0 or not npcBot:IsAlive() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + if target == nil or ( target ~= nil and not CanBeAttacked(target) ) or (target ~= nil and GetUnitToUnitDistance(target, npcBot) > ProxRange and GetUnitToUnitDistance(target, npcBot) > 300) then + --return BOT_ACTION_DESIRE_MODERATE, npcBot:GetLocation(); + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetXUnitsTowardsLocation(GetAncient(GetOpposingTeam()):GetLocation(), 250); + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderRetreat(hMinionUnit) + + if hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() > 0.9 + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + local RB = Vector(-7200,-6666) + local DB = Vector(7137,6548) + + if ( hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.9 ) + or hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.25 + then + local location = DB; + if GetTeam( ) == TEAM_RADIANT then + location = RB; + end + return BOT_ACTION_DESIRE_LOW, location; + end + + if not npcBot:IsAlive() then + local enemies = hMinionUnit:GetNearbyHeroes(1300, true, BOT_MODE_NONE); + local allies = hMinionUnit:GetNearbyHeroes(1300, false, BOT_MODE_NONE); + if #allies == 0 or #enemies == 0 then + local location = DB; + if GetTeam( ) == TEAM_RADIANT then + location = RB; + end + return BOT_ACTION_DESIRE_LOW, location; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +--------THUNDER CLAP +function ConsiderThunderClap(hMinionUnit) + + -- Make sure it's castable + if ( abilityTC:IsNull() or not abilityTC:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE; + end + + -- Get some of its values + local nRadius = abilityTC:GetSpecialValueInt( "radius" ); + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 1.0 ) and CanCastOnNonMagicImmuneTarget( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() ) + then + if ( CanCastOnNonMagicImmuneTarget( npcTarget ) and GetUnitToUnitDistance( hMinionUnit, npcTarget ) < nRadius ) + then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +--------WAR STOMP +function ConsiderWarStomp(hMinionUnit) + + -- Make sure it's castable + if ( abilityWS:IsNull() or not abilityWS:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE; + end + + -- Get some of its values + local nRadius = abilityWS:GetSpecialValueInt( "radius" ); + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 1.0 ) and CanCastOnNonMagicImmuneTarget( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() ) + then + if ( CanCastOnNonMagicImmuneTarget( npcTarget ) and GetUnitToUnitDistance( hMinionUnit, npcTarget ) < nRadius ) + then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + + +----------------SHOCK WAVE +function ConsiderShockWave(hMinionUnit) + + -- Make sure it's castable + if ( abilitySW:IsNull() or not abilitySW:IsFullyCastable() ) + then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nRadius = abilitySW:GetSpecialValueInt( "radius_end" ); + local nCastRange = abilitySW:GetCastRange(); + local nCastPoint = abilitySW:GetCastPoint( ); + local nDamage = abilitySW:GetAbilityDamage(); + + -------------------------------------- + -- Mode based usage + -------------------------------------- + + -- If a mode has set a target, and we can kill them, do it + local npcTargetToKill = npcBot:GetTarget(); + if ( npcTargetToKill ~= nil and npcTargetToKill:IsHero() and CanCastOnNonMagicImmuneTarget( npcTargetToKill ) ) + then + if ( npcTargetToKill:GetActualIncomingDamage( nDamage, DAMAGE_TYPE_MAGICAL ) > npcTargetToKill:GetHealth() and GetUnitToUnitDistance( npcTargetToKill, hMinionUnit ) < nCastRange ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTargetToKill:GetExtrapolatedLocation(nCastPoint); + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetLocation(); + end + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, hMinionUnit:GetLocation(), nCastRange, nRadius, 0, 0 ); + if ( locationAoE.count >= 3 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcTarget ~= nil and npcTarget:IsHero() and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < nCastRange and CanCastOnNonMagicImmuneTarget( npcTarget ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation(nCastPoint); + end + end +-- + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------MANA BURN +function ConsiderManaBurn(hMinionUnit) + + -- Make sure it's castable + if ( abilityMB:IsNull() or not abilityMB:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityMB:GetCastRange(); + local nCastPoint = abilityMB:GetCastPoint(); + local nDamage = abilityMB:GetSpecialValueInt("burn_amount"); + + + -- If a mode has set a target, and we can kill them, do it + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget( npcTarget ) ) + then + if ( npcTarget:GetActualIncomingDamage( nDamage, DAMAGE_TYPE_MAGICAL ) > npcTarget:GetHealth() and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < ( nCastRange + 200 ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcTarget; + end + end + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange + 200 ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------PURGE +function ConsiderPurge(hMinionUnit) + + -- Make sure it's castable + if ( abilityPG:IsNull() or not abilityPG:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityPG:GetCastRange(); + local nCastPoint = abilityPG:GetCastPoint(); + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange + 200 ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------Ensnare +function ConsiderEnsnare(hMinionUnit) + + -- Make sure it's castable + if ( abilityES:IsNull() or not abilityES:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityES:GetCastRange(); + local nCastPoint = abilityES:GetCastPoint(); + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange + 200 ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------BOULDER +function ConsiderBoulder(hMinionUnit) + + -- Make sure it's castable + if ( abilityHB:IsNull() or not abilityHB:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityHB:GetCastRange(); + local nCastPoint = abilityHB:GetCastPoint(); + local nDamage = abilityHB:GetSpecialValueInt("damage"); + + + -- If a mode has set a target, and we can kill them, do it + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget( npcTarget ) ) + then + if ( npcTarget:GetActualIncomingDamage( nDamage, DAMAGE_TYPE_MAGICAL ) > npcTarget:GetHealth() and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < nCastRange ) + then + return BOT_ACTION_DESIRE_HIGH, npcTarget; + end + end + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------BOULDER 2 +function ConsiderBoulder2(hMinionUnit) + + -- Make sure it's castable + if ( abilityHB2:IsNull() or not abilityHB2:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityHB2:GetCastRange(); + local nCastPoint = abilityHB2:GetCastPoint(); + local nDamage = abilityHB2:GetSpecialValueInt("damage"); + + + -- If a mode has set a target, and we can kill them, do it + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget( npcTarget ) ) + then + if ( npcTarget:GetActualIncomingDamage( nDamage, DAMAGE_TYPE_MAGICAL ) > npcTarget:GetHealth() and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < nCastRange ) + then + return BOT_ACTION_DESIRE_HIGH, npcTarget; + end + end + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +------------CHAIN LIGHTNING +function ConsiderChainLighting(hMinionUnit) + + -- Make sure it's castable + if ( abilityCL:IsNull() or not abilityCL:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nCastRange = abilityCL:GetCastRange(); + local nCastPoint = abilityCL:GetCastPoint(); + local nDamage = abilityCL:GetSpecialValueInt("initial_damage"); + + + -- If a mode has set a target, and we can kill them, do it + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget( npcTarget ) ) + then + if ( npcTarget:GetActualIncomingDamage( nDamage, DAMAGE_TYPE_MAGICAL ) > npcTarget:GetHealth() and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < nCastRange ) + then + return BOT_ACTION_DESIRE_HIGH, npcTarget; + end + end + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCastOnNonMagicImmuneTarget(npcEnemy) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and CanCastOnNonMagicImmuneTarget(npcTarget) and GetUnitToUnitDistance(npcTarget, hMinionUnit) < nCastRange ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function ConsiderFrostArmor(hMinionUnit) + + -- Make sure it's castable + if ( abilityFA:IsNull() or not abilityFA:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = abilityFA:GetCastRange(); + + if not npcBot:HasModifier("modifier_ogre_magi_frost_armor") then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + end + + local tableNearbyFriendlyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange+200, false, BOT_MODE_NONE ); + for _,myFriend in pairs(tableNearbyFriendlyHeroes) do + if ( not myFriend:HasModifier("modifier_ogre_magi_frost_armor") ) + then + return BOT_ACTION_DESIRE_MODERATE, myFriend; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end +return MyModule; \ No newline at end of file diff --git a/NewMinionUtil.lua b/NewMinionUtil.lua new file mode 100644 index 00000000..32511b1d --- /dev/null +++ b/NewMinionUtil.lua @@ -0,0 +1,530 @@ +local BotsInit = require( "game/botsinit" ); +local MyModule = BotsInit.CreateGeneric(); + +--local utils = require(GetScriptDirectory() .. "/util") + +local bot = GetBot(); +--print("Minion"..bot:GetUnitName()); +local TeamAncient = GetAncient(GetTeam()); +local TeamAncientLoc = TeamAncient:GetLocation(); +local EnemyAncient = GetAncient(GetOpposingTeam()); +local EnemyAncientLoc = EnemyAncient:GetLocation(); +local centre = Vector(0, 0, 0); + +--print(tostring(EnemyBaseLoc)); + +local attackDesire = 0; +local moveDesire = 0; +local retreatDesire = 0; + +local castQDesire = 0; +local castWDesire = 0; +local castEDesire = 0; + +function IsFrozeSigil(unit_name) + return unit_name == "npc_dota_tusk_frozen_sigil1" + or unit_name == "npc_dota_tusk_frozen_sigil2" + or unit_name == "npc_dota_tusk_frozen_sigil3" + or unit_name == "npc_dota_tusk_frozen_sigil4"; +end + +------------BEASTMASTER'S HAWK +function IsHawk(unit_name) + return unit_name == "npc_dota_scout_hawk" + or unit_name == "npc_dota_greater_hawk" + or unit_name == "npc_dota_beastmaster_hawk" + or unit_name == "npc_dota_beastmaster_hawk_1" + or unit_name == "npc_dota_beastmaster_hawk_2" + or unit_name == "npc_dota_beastmaster_hawk_3" + or unit_name == "npc_dota_beastmaster_hawk_4"; +end + +function HawkThink(minion) + if CantMove(minion) then return end + minion:Action_MoveToLocation(bot:GetLocation()); + return +end + +function IsTornado(unit_name) + return unit_name == "npc_dota_enraged_wildkin_tornado"; +end + +function IsHealingWard(unit_name) + return unit_name == "npc_dota_juggernaut_healing_ward"; +end + +function IsBear(unit_name) + return unit_name == "npc_dota_lone_druid_bear1" + or unit_name == "npc_dota_lone_druid_bear2" + or unit_name == "npc_dota_lone_druid_bear3" + or unit_name == "npc_dota_lone_druid_bear4"; +end + +function IsFamiliar(unit_name) + return unit_name == "npc_dota_visage_familiar1" + or unit_name == "npc_dota_visage_familiar2" + or unit_name == "npc_dota_visage_familiar3"; +end + +function IsMinionWithNoSkill(unit_name) + return unit_name == "npc_dota_lesser_eidolon" + or unit_name == "npc_dota_eidolon" + or unit_name == "npc_dota_greater_eidolon" + or unit_name == "npc_dota_dire_eidolon" + or unit_name == "npc_dota_furion_treant" + or unit_name == "npc_dota_furion_treant_large" + or unit_name == "npc_dota_invoker_forged_spirit" + or unit_name == "npc_dota_broodmother_spiderling" + or unit_name == "npc_dota_broodmother_spiderite" + or unit_name == "npc_dota_wraith_king_skeleton_warrior" + or unit_name == "npc_dota_warlock_golem_1" + or unit_name == "npc_dota_warlock_golem_2" + or unit_name == "npc_dota_warlock_golem_3" + or unit_name == "npc_dota_warlock_golem_scepter_1" + or unit_name == "npc_dota_warlock_golem_scepter_2" + or unit_name == "npc_dota_warlock_golem_scepter_3" + or unit_name == "npc_dota_beastmaster_boar" + or unit_name == "npc_dota_beastmaster_greater_boar" + or unit_name == "npc_dota_beastmaster_boar_1" + or unit_name == "npc_dota_beastmaster_boar_2" + or unit_name == "npc_dota_beastmaster_boar_3" + or unit_name == "npc_dota_beastmaster_boar_4" + or unit_name == "npc_dota_lycan_wolf1" + or unit_name == "npc_dota_lycan_wolf2" + or unit_name == "npc_dota_lycan_wolf3" + or unit_name == "npc_dota_lycan_wolf4" + or unit_name == "npc_dota_neutral_kobold" + or unit_name == "npc_dota_neutral_kobold_tunneler" + or unit_name == "npc_dota_neutral_kobold_taskmaster" + or unit_name == "npc_dota_neutral_centaur_outrunner" + or unit_name == "npc_dota_neutral_fel_beast" + or unit_name == "npc_dota_neutral_polar_furbolg_champion" + or unit_name == "npc_dota_neutral_ogre_mauler" + or unit_name == "npc_dota_neutral_giant_wolf" + or unit_name == "npc_dota_neutral_alpha_wolf" + or unit_name == "npc_dota_neutral_wildkin" + or unit_name == "npc_dota_neutral_jungle_stalker" + or unit_name == "npc_dota_neutral_elder_jungle_stalker" + or unit_name == "npc_dota_neutral_prowler_acolyte" + or unit_name == "npc_dota_neutral_rock_golem" + or unit_name == "npc_dota_neutral_granite_golem" + or unit_name == "npc_dota_neutral_small_thunder_lizard" + or unit_name == "npc_dota_neutral_gnoll_assassin" + or unit_name == "npc_dota_neutral_ghost" + or unit_name == "npc_dota_wraith_ghost" + or unit_name == "npc_dota_neutral_dark_troll" + or unit_name == "npc_dota_neutral_forest_troll_berserker" + or unit_name == "npc_dota_neutral_harpy_scout" + or unit_name == "npc_dota_neutral_black_drake" + or unit_name == "npc_dota_dark_troll_warlord_skeleton_warrior" + or unit_name == "npc_dota_necronomicon_warrior_1" + or unit_name == "npc_dota_necronomicon_warrior_2" + or unit_name == "npc_dota_necronomicon_warrior_3"; +end + +local remnant = { + "npc_dota_stormspirit_remnant", + "npc_dota_ember_spirit_remnant", + "npc_dota_earth_spirit_stone" +} + +local trap = { + "npc_dota_templar_assassin_psionic_trap", + "npc_dota_techies_remote_mine", + "npc_dota_techies_land_mine", + "npc_dota_techies_stasis_trap" +} + +local independent = { + "npc_dota_brewmaster_earth_1", + "npc_dota_brewmaster_earth_2", + "npc_dota_brewmaster_earth_3", + "npc_dota_brewmaster_storm_1", + "npc_dota_brewmaster_storm_2", + "npc_dota_brewmaster_storm_3", + "npc_dota_brewmaster_fire_1", + "npc_dota_brewmaster_fire_2", + "npc_dota_brewmaster_fire_3" +} + +function IsValidUnit(unit) + return unit ~= nil + and unit:IsNull() == false + and unit:IsAlive(); +end + +function IsValidTarget(target) + return target ~= nil + and target:IsNull() == false + and target:CanBeSeen() + and target:IsInvulnerable() == false + and target:IsAlive(); +end + +function IsInRange(unit, target, range) + return GetUnitToUnitDistance(unit, target) <= range; +end + +function CanCastOnTarget(target, ability) + if CheckFlag(ability:GetTargetFlags(), ABILITY_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES) then + return target:IsHero() and target:IsIllusion() == false; + else + return target:IsHero() and target:IsIllusion() == false and target:IsMagicImmune() == false; + end +end + +local globRadius = 1200; + +function GetWeakest(units) + local target = nil; + local minHP = 10000; + if #units > 0 then + for i=1, #units do + if IsValidTarget(units[i]) then + local hp = units[i]:GetHealth(); + if hp <= minHP then + target = units[i]; + minHP = hp; + end + end + end + end + return target; +end + +function GetWeakestHero(radius, minion) + local enemies = minion:GetNearbyHeroes(radius, true, BOT_MODE_NONE); + return GetWeakest(enemies); +end + +function GetWeakestCreep(radius, minion) + local creeps = minion:GetNearbyLaneCreeps(radius, true); + return GetWeakest(creeps); +end + +function GetWeakestTower(radius, minion) + local towers = minion:GetNearbyTowers(radius, true); + return GetWeakest(towers); +end + +function GetWeakestBarracks(radius, minion) + local barracks = minion:GetNearbyBarracks(radius, true); + return GetWeakest(barracks); +end + +function GetIllusionAttackTarget(minion) + local target = bot:GetAttackTarget(); + if target == nil and bot:GetActiveMode() == BOT_MODE_RETREAT then + target = GetWeakestHero(globRadius, minion); + if target == nil then target = GetWeakestCreep(globRadius, minion); end + if target == nil then target = GetWeakestTower(globRadius, minion); end + if target == nil then target = GetWeakestBarracks(globRadius, minion); end + end + return target; +end + + +function IsBusy(unit) + return unit:IsUsingAbility() or unit:IsCastingAbility() or unit:IsChanneling(); +end + +function CantMove(unit) + return unit:IsStunned() or unit:IsRooted() or unit:IsNightmared() or unit:IsInvulnerable(); +end + +function CantAttack(unit) + return unit:IsStunned() or unit:IsRooted() or unit:IsNightmared() or unit:IsDisarmed() or unit:IsInvulnerable(); +end + +------------ILLUSION ACT +function ConsiderIllusionAttack(minion) + if CantAttack(minion) then return BOT_MODE_DESIRE_NONE, nil; end + local target = GetIllusionAttackTarget(minion); + if target ~= nil then + return BOT_MODE_DESIRE_HIGH, target; + end + return BOT_MODE_DESIRE_NONE, nil; +end + +function ConsiderIllusionMove(minion) + if CantMove(minion) then return BOT_MODE_DESIRE_NONE, nil; end + if bot:GetActiveMode() ~= BOT_MODE_RETREAT then + return BOT_MODE_DESIRE_HIGH, bot:GetXUnitsTowardsLocation(TeamAncientLoc, 300); + end + return BOT_MODE_DESIRE_NONE, nil; +end + +function IllusionThink(minion) + minion.attackDesire, minion.target = ConsiderIllusionAttack(minion); + minion.moveDesire, minion.loc = ConsiderIllusionMove(minion); + if minion.attackDesire > 0 then + minion:Action_AttackUnit(minion.target, true); + return + end + if minion.moveDesire > 0 then + minion:Action_MoveToLocation(minion.loc); + return + end +end + +-----------ATTACKING WARD LIKE UNIT +function IsAttackingWard(unit_name) + return unit_name == "npc_dota_shadow_shaman_ward_1" + or unit_name == "npc_dota_shadow_shaman_ward_2" + or unit_name == "npc_dota_shadow_shaman_ward_3" + or unit_name == "npc_dota_venomancer_plague_ward_1" + or unit_name == "npc_dota_venomancer_plague_ward_2" + or unit_name == "npc_dota_venomancer_plague_ward_3" + or unit_name == "npc_dota_venomancer_plague_ward_4" + or unit_name == "npc_dota_witch_doctor_death_ward"; +end + +function GetWardAttackTarget(minion) + local range = minion:GetAttackRange(); + local target = bot:GetAttackTarget(); + if IsValidTarget(target) == false or (IsValidTarget(target) and GetUnitToUnitDistance(minion, target) > range) then + target = GetWeakestHero(range, minion); + if target == nil then target = GetWeakestCreep(range, minion); end + if target == nil then target = GetWeakestTower(range, minion); end + if target == nil then target = GetWeakestBarracks(range, minion); end + end + return target; +end + +function ConsiderWardAttack(minion) + local target = GetWardAttackTarget(minion); + if target ~= nil then + return BOT_MODE_DESIRE_HIGH, target; + end + return BOT_MODE_DESIRE_NONE, nil; +end + +function AttackingWardThink(minion) + minion.attackDesire, minion.target = ConsiderWardAttack(minion); + if minion.attackDesire > 0 then + minion:Action_AttackUnit(minion.target, true); + return + end +end + +----------CAN'T BE CONTROLLED UNIT +function CantBeControlled(unit_name) + return unit_name == "npc_dota_zeus_cloud" + or unit_name == "npc_dota_unit_tombstone1" + or unit_name == "npc_dota_unit_tombstone2" + or unit_name == "npc_dota_unit_tombstone3" + or unit_name == "npc_dota_unit_tombstone4" + or unit_name == "npc_dota_pugna_nether_ward_1" + or unit_name == "npc_dota_pugna_nether_ward_2" + or unit_name == "npc_dota_pugna_nether_ward_3" + or unit_name == "npc_dota_pugna_nether_ward_4" + or unit_name == "npc_dota_rattletrap_cog" + or unit_name == "npc_dota_rattletrap_rocket" + or unit_name == "npc_dota_broodmother_web" + or unit_name == "npc_dota_unit_undying_zombie" + or unit_name == "npc_dota_unit_undying_zombie_torso" + or unit_name == "npc_dota_weaver_swarm" + or unit_name == "npc_dota_death_prophet_torment" + or unit_name == "npc_dota_gyrocopter_homing_missile" + or unit_name == "npc_dota_plasma_field" + or unit_name == "npc_dota_wisp_spirit" + or unit_name == "npc_dota_beastmaster_axe" + or unit_name == "npc_dota_troll_warlord_axe" + or unit_name == "npc_dota_phoenix_sun" + or unit_name == "npc_dota_techies_minefield_sign" + or unit_name == "npc_dota_treant_eyes" + or unit_name == "dota_death_prophet_exorcism_spirit" + or unit_name == "npc_dota_dark_willow_creature"; +end + +function CantBeControlledThink(minion) + return +end + +-----------MINION WITH SKILLS +function IsMinionWithSkill(unit_name) + return unit_name == "npc_dota_neutral_centaur_khan" + or unit_name == "npc_dota_neutral_polar_furbolg_ursa_warrior" + or unit_name == "npc_dota_neutral_mud_golem" + or unit_name == "npc_dota_neutral_mud_golem_split" + or unit_name == "npc_dota_neutral_mud_golem_split_doom" + or unit_name == "npc_dota_neutral_ogre_magi" + or unit_name == "npc_dota_neutral_enraged_wildkin" + or unit_name == "npc_dota_neutral_satyr_soulstealer" + or unit_name == "npc_dota_neutral_satyr_hellcaller" + or unit_name == "npc_dota_neutral_prowler_shaman" + or unit_name == "npc_dota_neutral_big_thunder_lizard" + or unit_name == "npc_dota_neutral_dark_troll_warlord" + or unit_name == "npc_dota_neutral_satyr_trickster" + or unit_name == "npc_dota_neutral_forest_troll_high_priest" + or unit_name == "npc_dota_neutral_harpy_storm" + or unit_name == "npc_dota_neutral_black_dragon" + or unit_name == "npc_dota_necronomicon_archer_1" + or unit_name == "npc_dota_necronomicon_archer_2" + or unit_name == "npc_dota_necronomicon_archer_3"; +end + +function InitiateAbility(minion) + minion.abilities = {}; + for i=0, 3 do + minion.abilities [i+1] = minion:GetAbilityInSlot(i); + end +end + +function CheckFlag(bitfield, flag) + return ((bitfield/flag) % 2) >= 1 +end + +function CanCastAbility(ability) + return ability ~= nil and ability:IsFullyCastable() and ability:IsPassive() == false; +end + +function ConsiderUnitTarget(minion, ability) + local castRange = ability:GetCastRange()+200; + if bot:GetActiveMode() == BOT_MODE_RETREAT and bot:WasRecentlyDamagedByAnyHero(2.0) then + local enemies = minion:GetNearbyHeroes(castRange, true, BOT_MODE_NONE); + if #enemies > 0 then + for i=1, #enemies do + if IsValidTarget(enemies[i]) and CanCastOnTarget(enemies[i], ability) then + return BOT_ACTION_DESIRE_HIGH, enemies[i]; + end + end + end + else + local target = bot:GetAttackTarget(); + if IsValidTarget(target) and CanCastOnTarget(target, ability) and IsInRange(minion, target, castRange) then + return BOT_ACTION_DESIRE_HIGH, target; + end + end + return BOT_ACTION_DESIRE_NONE, nil; +end + +function ConsiderPointTarget(minion, ability) + local castRange = ability:GetCastRange()+200; + if bot:GetActiveMode() == BOT_MODE_RETREAT and bot:WasRecentlyDamagedByAnyHero(2.0) then + local enemies = minion:GetNearbyHeroes(castRange, true, BOT_MODE_NONE); + if #enemies > 0 then + for i=1, #enemies do + if IsValidTarget(enemies[i]) and CanCastOnTarget(enemies[i], ability) then + return BOT_ACTION_DESIRE_HIGH, enemies[i]:GetLocation(); + end + end + end + elseif bot:GetActiveMode() == BOT_MODE_ATTACK or bot:GetActiveMode() == BOT_MODE_DEFEND_ALLY then + local target = bot:GetAttackTarget(); + if IsValidTarget(target) and CanCastOnTarget(target, ability) and IsInRange(minion, target, castRange) then + return BOT_ACTION_DESIRE_HIGH, target:GetLocation(); + end + end + return BOT_ACTION_DESIRE_NONE, nil; +end + + +function ConsiderNoTarget(minion, ability) + local nRadius = ability:GetSpecialValueInt("radius"); + if bot:GetActiveMode() == BOT_MODE_RETREAT and bot:WasRecentlyDamagedByAnyHero(2.0) then + local enemies = minion:GetNearbyHeroes(nRadius, true, BOT_MODE_NONE); + if #enemies > 0 then + for i=1, #enemies do + if IsValidTarget(enemies[i]) and CanCastOnTarget(enemies[i], ability) then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + elseif bot:GetActiveMode() == BOT_MODE_ATTACK or bot:GetActiveMode() == BOT_MODE_DEFEND_ALLY then + local target = bot:GetAttackTarget(); + --print(tostring(target)) + if IsValidTarget(target) and CanCastOnTarget(target, ability) and IsInRange(minion, target, nRadius) then + return BOT_ACTION_DESIRE_HIGH; + end + end + return BOT_ACTION_DESIRE_HIGH; +end + +function CastThink(minion, ability) + if CheckFlag(ability:GetBehavior(), ABILITY_BEHAVIOR_UNIT_TARGET) then + if ability:GetName() == "ogre_magi_frost_armor" then + local castRange = ability:GetCastRange(); + local allies = GetNearbyHeroes(castRange+200, false, BOT_MODE_NONE); + if #allies > 0 then + for i=1, #allies do + if IsValidTarget(allies[i]) and CanCastOnTarget(allies[i], ability) + and allies[i]:HasModifier("ogre_magi_frost_armor") == false + then + minion:Action_UseAbilityOnEntity(ability, allies[i]); + return + end + end + end + else + minion.castDesire, target = ConsiderUnitTarget(minion, ability); + if minion.castDesire > 0 then + --print(minion:GetUnitName()..tostring(minion.castDesire).." Use Ability "..ability:GetName()) + minion:Action_UseAbilityOnEntity(ability, target); + return + end + end + elseif CheckFlag(ability:GetBehavior(), ABILITY_BEHAVIOR_POINT) then + minion.castDesire, loc = ConsiderPointTarget(minion, ability); + if minion.castDesire > 0 then + --print(minion:GetUnitName()..tostring(minion.castDesire).." Use Ability "..ability:GetName()) + minion:Action_UseAbilityOnLocation(ability, loc); + return + end + elseif CheckFlag(ability:GetBehavior(), ABILITY_BEHAVIOR_NO_TARGET) then + minion.castDesire = ConsiderNoTarget(minion, ability); + if minion.castDesire > 0 then + --print(minion:GetUnitName()..tostring(minion.castDesire).." Use Ability "..ability:GetName()) + minion:Action_UseAbility(ability); + return + end + end +end + +function CastAbilityThink(minion) + if CanCastAbility(minion.abilities[1]) then + CastThink(minion, minion.abilities[1]); + end + if CanCastAbility(minion.abilities[2]) then + CastThink(minion, minion.abilities[2]); + end + if CanCastAbility(minion.abilities[3]) then + CastThink(minion, minion.abilities[3]); + end + if CanCastAbility(minion.abilities[4]) then + CastThink(minion, minion.abilities[4]); + end +end + +function MinionWithSkillThink(minion) + if IsBusy(minion) then return; end + if minion.abilities == nil then InitiateAbility(minion); end + CastAbilityThink(minion); + minion.attackDesire, minion.target = ConsiderIllusionAttack(minion); + minion.moveDesire, minion.loc = ConsiderIllusionMove(minion); + if minion.attackDesire > 0 then + minion:Action_AttackUnit(minion.target, true); + return + end + if minion.moveDesire > 0 then + minion:Action_MoveToLocation(minion.loc); + return + end +end + +function MinionThink( hMinionUnit ) + if bot == nil then bot = GetBot(); end + if IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + IllusionThink(hMinionUnit); + elseif IsAttackingWard(hMinionUnit:GetUnitName()) then + return; + --AttackingWardThink(hMinionUnit); + elseif CantBeControlled(hMinionUnit:GetUnitName()) then + CantBeControlledThink(hMinionUnit); + end + end +end + + +return MyModule; \ No newline at end of file diff --git a/PushUtility.lua b/PushUtility.lua index f13897cb..9d25d1bd 100644 --- a/PushUtility.lua +++ b/PushUtility.lua @@ -487,7 +487,7 @@ end function GetWeakestCreep(r) local npcBot = GetBot(); - + r=math.min(1600,r) local EnemyCreeps = npcBot:GetNearbyLaneCreeps(r,true); if EnemyCreeps==nil or #EnemyCreeps==0 then @@ -597,13 +597,28 @@ function IsEnemyTooMany() if(EnemyCount>AllyCount) then - print(npcBot:GetName().." enemy is too much") + print(getCurrentFileName().." "..npcBot:GetUnitName().."'s enemy is too much, fall back") return true else return false end end +function getCurrentFileName() + return strippath(debug.getinfo(1,'S').source:sub(2)) +end + +function strippath(filename) + if filename:match(".-/.-") then + return string.match(filename, ".+/([^/]*%.%w+)$") + elseif filename:match(".-\\.-") then + return string.match(filename, ".+\\([^\\]*%.%w+)$") + else + return '' + end + +end + EnemyHeroListTimer=-1000; EnemyHeroList=nil; diff --git a/RChangeLOG_EN.txt b/RChangeLOG_EN.txt index bc297133..0f289399 100644 --- a/RChangeLOG_EN.txt +++ b/RChangeLOG_EN.txt @@ -161,4 +161,9 @@ v1.3b (2017.11.3) v1.3c (2017.11.7) 1. Fixed a lot of bugs made by the Valve updated the internal structure of the game API. Now the hero can correctly upgrade abilities. 2. Fixed a few items building bugs. -3. Optimize the script program structure. \ No newline at end of file +3. Optimize the script program structure. +v1.4 (2018.1.1) +1. Added 20 new heroes: batrider, beastmaster, bounty hunter, brewmaster, broodmother, chen, dark seer, disruptor, earth spirit, elder titan, enchantress, enigma, keeper of the light, lycan, magnataur, medusa, mirana, monkey king, pudge, sand king. +2. Update all heroes talents and abilities building to fit the latest version. +3. To commemorate the famous professional player, the AI will now use professional player name of TI's history. +4. Several bug fixes. \ No newline at end of file diff --git a/RChangeLOG_ZH_CN.txt b/RChangeLOG_ZH_CN.txt index afb814cf..bc2be59b 100644 --- a/RChangeLOG_ZH_CN.txt +++ b/RChangeLOG_ZH_CN.txt @@ -161,4 +161,9 @@ v1.3b(2017.11.3) v1.3c(2017.11.7) 1.޸VϷײɵĴӢȷ 2.޸һЩƷװĴ -3.ŻӢۼʹõijṹ \ No newline at end of file +3.ŻӢۼʹõijṹ +v1.4(2018.1.1) +1.20Ӣʿͽˣɣĸ֩룬£ڰߣߣ֮飬ϹžȻħŮţ֮ˣɯȣʥɳ +2.ȫӢ۵츳ͼܼӵ㣬Ӧ°汾 +3.Ϊ˼ְҵѡ֣AIʹTIʷϵְҵѡơ +4.ɴ \ No newline at end of file diff --git a/ability_item_usage_abaddon.lua b/ability_item_usage_abaddon.lua index 643f38db..90d68a32 100644 --- a/ability_item_usage_abaddon.lua +++ b/ability_item_usage_abaddon.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -52,7 +52,7 @@ local TalentTree={ return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_abyssal_underlord.lua b/ability_item_usage_abyssal_underlord.lua index 509a2019..bba7e37a 100644 --- a/ability_item_usage_abyssal_underlord.lua +++ b/ability_item_usage_abyssal_underlord.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -21,12 +21,12 @@ local AbilityToLevelUp= Abilities[1], Abilities[3], Abilities[1], - Abilities[2], - Abilities[1], Abilities[3], Abilities[1], - Abilities[4], Abilities[2], + Abilities[1], + Abilities[2], + Abilities[4], "talent", Abilities[2], Abilities[4], @@ -47,16 +47,16 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_alchemist.lua b/ability_item_usage_alchemist.lua index 08cfd36e..f3e39d0e 100644 --- a/ability_item_usage_alchemist.lua +++ b/ability_item_usage_alchemist.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,7 +47,7 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[4] @@ -56,7 +56,7 @@ local TalentTree={ return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_ancient_apparition.lua b/ability_item_usage_ancient_apparition.lua index 8d9d52b7..c282b993 100644 --- a/ability_item_usage_ancient_apparition.lua +++ b/ability_item_usage_ancient_apparition.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -56,7 +56,7 @@ local TalentTree={ return Talents[5] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_antimage.lua b/ability_item_usage_antimage.lua index 53f19332..6880d5b1 100644 --- a/ability_item_usage_antimage.lua +++ b/ability_item_usage_antimage.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,13 +47,13 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() return Talents[7] diff --git a/ability_item_usage_arc_warden.lua b/ability_item_usage_arc_warden.lua index 2ae4826b..4cf4afa6 100644 --- a/ability_item_usage_arc_warden.lua +++ b/ability_item_usage_arc_warden.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/ability_item_usage_axe.lua b/ability_item_usage_axe.lua index 85f1058c..e22fda92 100644 --- a/ability_item_usage_axe.lua +++ b/ability_item_usage_axe.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=utility.debug_mode @@ -47,7 +47,7 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] @@ -56,7 +56,7 @@ local TalentTree={ return Talents[5] end, function() - return Talents[8] + return Talents[7] end } @@ -83,7 +83,7 @@ function GetComboMana() return ability_item_usage_generic.GetComboMana(AbilitiesReal) end -Consider[1]=function() --Target Ability Example +Consider[1]=function() local abilityNumber=1 -------------------------------------- -- Generic Variable Setting diff --git a/ability_item_usage_bane.lua b/ability_item_usage_bane.lua index eba89422..57bda46f 100644 --- a/ability_item_usage_bane.lua +++ b/ability_item_usage_bane.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local role = require(GetScriptDirectory() .. "/RoleUtility") @@ -51,7 +51,7 @@ local TalentTree={ return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[6] diff --git a/DEV_ability_item_usage_keeper_of_the_light.lua b/ability_item_usage_batrider.lua similarity index 52% rename from DEV_ability_item_usage_keeper_of_the_light.lua rename to ability_item_usage_batrider.lua index 88863576..de86e9d4 100644 --- a/DEV_ability_item_usage_keeper_of_the_light.lua +++ b/ability_item_usage_batrider.lua @@ -1,734 +1,572 @@ ----------------------------------------------------------------------------- --- Ranked Matchmaking AI v1.0 --- Author: adamqqq Email:adamqqq@163.com ----------------------------------------------------------------------------- --------------------------------------- --- Load Utility Function Library --------------------------------------- -require(GetScriptDirectory() .. "/utility") -require(GetScriptDirectory() .. "/ability_item_usage_generic") --------------------------------------- --- Hero Area Local Variable Setting --------------------------------------- -local npcBot = GetBot() -local ComboMana = 0 -local debugmode=false - -local Talents = -{ - "keeper_of_the_light_illuminate", - "keeper_of_the_light_mana_leak", - "keeper_of_the_light_chakra_magic", - "keeper_of_the_light_spirit_form", - "keeper_of_the_light_recall", - "keeper_of_the_light_blinding_light", - "keeper_of_the_light_illuminate_end", - "keeper_of_the_light_spirit_form_illuminate", - "keeper_of_the_light_spirit_form_illuminate_end" -} - -local Abilities = -{ - "special_bonus_strength_7", - "special_bonus_movement_speed_20", - "special_bonus_exp_boost_20", - "special_bonus_respawn_reduction_25", - "special_bonus_magic_resistance_10", - "special_bonus_armor_7", - "special_bonus_cast_range_400", - "special_bonus_unique_keeper_of_the_light" -} - -local AbilitiesReal = -{ - npcBot:GetAbilityByName(Abilities[1]), - npcBot:GetAbilityByName(Abilities[2]), - npcBot:GetAbilityByName(Abilities[3]), - npcBot:GetAbilityByName(Abilities[4]) -} - -local AbilityToLevelUp= -{ - Abilities[1], - Abilities[3], - Abilities[2], - Abilities[2], - Abilities[2], - Abilities[4], - Abilities[2], - Abilities[1], - Abilities[1], - "talent", - Abilities[1], - Abilities[4], - Abilities[3], - Abilities[3], - "talent", - Abilities[3], - "nil", - Abilities[4], - "nil", - "talent", - "nil", - "nil", - "nil", - "nil", - "talent", -} -local TalentTree={ - function() - return Talents[1] - end, - function() - return Talents[3] - end, - function() - return Talents[5] - end, - function() - return Talents[7] - end -} --------------------------------------- --- Level Ability and Talent --------------------------------------- - --- check skill build vs current level -utility.CheckAbilityBuild(AbilityToLevelUp) - -function AbilityLevelUpThink() - ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) -end - --------------------------------------- --- Ability Usage Thinking --------------------------------------- -local castDesire = {} -local castTarget = {} -local castLocation = {} -local castType = {} - ---Target Judement -function CanCast1( npcEnemy ) - return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable(); -end - -function CanCast2( npcEnemy ) - return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable(); -end - -function CanCast3( npcEnemy ) - return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable(); -end - -function CanCast4( npcEnemy ) - return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable(); -end - -local CanCast={CanCast1,CanCast2,CanCast3,CanCast4} - -function enemyDisabled(npcEnemy) - if npcEnemy:IsRooted( ) or npcEnemy:IsStunned( ) or npcEnemy:IsHexed( ) then - return true; - end - return false; -end ---Combo Variable Getting -local function GetComboDamage() - - local sum=0 - - if AbilitiesReal[1]:IsFullyCastable() - then - sum=sum+AbilitiesReal[1]:GetAbilityDamage(); - end - if AbilitiesReal[2]:IsFullyCastable() - then - sum=sum+AbilitiesReal[2]:GetAbilityDamage(); - end - if AbilitiesReal[3]:IsFullyCastable() - then - sum=sum+AbilitiesReal[3]:GetAbilityDamage(); - end - if AbilitiesReal[4]:IsFullyCastable() - then - sum=sum+AbilitiesReal[4]:GetAbilityDamage(); - end - - return sum - - return npcBot:GetOffensivePower() -end - -local function GetComboMana() - - local tempComboMana=0 - if AbilitiesReal[1]:IsFullyCastable() - then - tempComboMana=tempComboMana+AbilitiesReal[1]:GetManaCost() - end - if AbilitiesReal[2]:IsFullyCastable() - then - tempComboMana=tempComboMana+AbilitiesReal[2]:GetManaCost() - end - if AbilitiesReal[3]:IsFullyCastable() - then - tempComboMana=tempComboMana+AbilitiesReal[3]:GetManaCost() - end - if AbilitiesReal[4]:IsFullyCastable() or AbilitiesReal[4]:GetCooldownTimeRemaining()<=30 - then - tempComboMana=tempComboMana+AbilitiesReal[4]:GetManaCost() - end - - if AbilitiesReal[1]:GetLevel()<1 or AbilitiesReal[2]:GetLevel()<1 or AbilitiesReal[3]:GetLevel()<1 or AbilitiesReal[4]:GetLevel()<1 - then - tempComboMana=300; - end - - ComboMana=tempComboMana - return -end - -function AbilityUsageThink() - - -- Check if we're already using an ability - if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) - then - return - end - - GetComboMana() - AttackRange=npcBot:GetAttackRange() - ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() - HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() - - -- Consider using each ability - castDesire[1], castTarget[1] = Consider1(); - castDesire[2], castTarget[2] = Consider2(); - castDesire[3], castTarget[3] = Consider3(); - castDesire[4], castTarget[4] = Consider4(); - ---------------------------------debug-------------------------------------------- - if(debugmode==true) then - if(npcBot.LastSpeaktime==nil) - then - npcBot.LastSpeaktime=0 - end - if(GameTime()-npcBot.LastSpeaktime>1) - then - for i=1,4,1 - do - if ( castDesire[i] > 0 ) - then - if (castType[i]==nil or castType[i]=="target") and castTarget[i]~=nil - then - npcBot:ActionImmediate_Chat("try to use skill "..i.." at "..castTarget[i]:GetUnitName().." Desire= "..castDesire[i],true) - else - npcBot:ActionImmediate_Chat("try to use skill "..i.." Desire= "..castDesire[i],true) - end - npcBot.LastSpeaktime=GameTime() - end - end - end - end - ---------------------------------debug-------------------------------------------- - if ( castDesire[4] > 0 ) - then - npcBot:Action_UseAbility( AbilitiesReal[4] ); - return - end - - if ( castDesire[3] > 0 ) - then - npcBot:Action_UseAbilityOnEntity( AbilitiesReal[3], castTarget[3] ); - return - end - - if ( castDesire[2] > 0 ) - then - npcBot:Action_UseAbilityOnLocation( AbilitiesReal[2], castLocation[2] ); - return - end - - if ( castDesire[1] > 0 ) - then - npcBot:Action_UseAbilityOnEntity( AbilitiesReal[1], castTarget[1] ); - return - end - -end - -function Consider1() --Target Ability Example - local abilityNumber=1 - -------------------------------------- - -- Generic Variable Setting - -------------------------------------- - local ability=AbilitiesReal[abilityNumber]; - - if not ability:IsFullyCastable() then - return BOT_ACTION_DESIRE_NONE, 0; - end - - local CastRange = ability:GetCastRange(); - local Damage = ability:GetAbilityDamage(); - - local HeroHealth=10000 - local CreepHealth=10000 - local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); - local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) - local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) - local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) - local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) - -------------------------------------- - -- Global high-priorty usage - -------------------------------------- - -- Check for a channeling enemy - for _,npcEnemy in pairs( enemys ) - do - if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy - end - end - - --Try to kill enemy hero - if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end - end - end - - -- If we're in a teamfight, use it on the scariest enemy - local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); - if ( #tableNearbyAttackingAlliedHeroes >= 2 ) - then - - local npcMostDangerousEnemy = nil; - local nMostDangerousDamage = 0; - - for _,npcEnemy in pairs( enemys ) - do - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) - then - local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); - if ( Damage2 > nMostDangerousDamage ) - then - nMostDangerousDamage = Damage2; - npcMostDangerousEnemy = npcEnemy; - end - end - end - - if ( npcMostDangerousEnemy ~= nil ) - then - return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; - end - end - -------------------------------------- - -- Mode based usage - -------------------------------------- - --protect myself - local enemys2 = npcBot:GetNearbyHeroes( 500, true, BOT_MODE_NONE ); - if(npcBot:WasRecentlyDamagedByAnyHero(5)) - then - for _,npcEnemy in pairs( enemys2 ) - do - if ( CanCast[abilityNumber]( npcEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy - end - end - end - - -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently - if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) - then - for _,npcEnemy in pairs( enemys ) - do - if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) - then - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy; - end - end - end - end - - -- If my mana is enough,use it at enemy - if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) - then - if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - return BOT_ACTION_DESIRE_LOW,WeakestEnemy; - end - end - end - end - - --Last hit - if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) - then - if(WeakestCreep~=nil) - then - if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) - then - return BOT_ACTION_DESIRE_LOW,WeakestCreep; - end - end - end - end - - -- If we're farming and can hit 2+ creeps and kill 1+ - if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) - then - if ( #creeps >= 2 ) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - - -- If we're pushing or defending a lane - if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) - then - if ( #enemys>=1) - then - if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana and AbilitiesReal[abilityNumber]:GetLevel()>=1) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestEnemy; - end - end - end - end - - if (#creeps >= 3 ) - then - if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana and AbilitiesReal[abilityNumber]:GetLevel()>=1) - then - if ( CanCast[abilityNumber]( creeps[1] )and GetUnitToUnitDistance(npcBot,creeps[1])< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, creeps[1]; - end - end - end - end - - -- If we're going after someone - if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or - npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or - npcBot:GetActiveMode() == BOT_MODE_ATTACK ) - then - local npcEnemy = npcBot:GetTarget(); - - if ( npcEnemy ~= nil ) - then - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) - then - return BOT_ACTION_DESIRE_MODERATE, npcEnemy - end - end - end - - return BOT_ACTION_DESIRE_NONE, 0; - -end - -function Consider2() --Target AOE Ability Example - local abilityNumber=2 - -------------------------------------- - -- Generic Variable Setting - -------------------------------------- - local ability=AbilitiesReal[abilityNumber]; - - if not ability:IsFullyCastable() then - return BOT_ACTION_DESIRE_NONE, 0; - end - - local CastRange = ability:GetCastRange(); - local Damage = ability:GetAbilityDamage(); - - local HeroHealth=10000 - local CreepHealth=10000 - local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); - local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) - local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) - local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) - local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) - - --try to kill enemy hero - if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end - end - end - -------------------------------------- - -- Mode based usage - -------------------------------------- - - --teamfightUsing - if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) - then - if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (#enemys+#creeps>2) - then - if(WeakestCreep~=nil) - then - return BOT_ACTION_DESIRE_HIGH,WeakestCreep; - end - if(WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end - end - end - end - - --Last hit - --if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) - --then - if(WeakestCreep~=nil) - then - if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) - then - return BOT_ACTION_DESIRE_LOW,WeakestCreep; - end - end - end - --end - - -- If we're farming and can hit 2+ creeps and kill 1+ - if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) - then - if ( #creeps >= 2 ) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - - -- If we're pushing or defending a lane and can hit 3+ creeps, go for it - if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) - then - if ( #enemys+#creeps >= 3 ) - then - if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestEnemy; - end - end - if (WeakestCreep~=nil) - then - if ( CanCast[abilityNumber]( WeakestCreep )and GetUnitToUnitDistance(npcBot,WeakestCreep)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - end - end - - -- If we're going after someone - if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or - npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or - npcBot:GetActiveMode() == BOT_MODE_ATTACK ) - then - local npcEnemy = npcBot:GetTarget(); - - if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) - then - if ( npcEnemy ~= nil ) - then - if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) - then - return BOT_ACTION_DESIRE_MODERATE, npcEnemy; - end - end - end - end - - return BOT_ACTION_DESIRE_NONE, 0; - -end - -function Consider3() --Location AOE Example - - local abilityNumber=3 - -------------------------------------- - -- Generic Variable Setting - -------------------------------------- - local ability=AbilitiesReal[abilityNumber]; - - if not ability:IsFullyCastable() then - return BOT_ACTION_DESIRE_NONE, 0; - end - - local CastRange = ability:GetCastRange(); - local Damage = ability:GetAbilityDamage(); - local Radius = ability:GetAOERadius() - - local HeroHealth=10000 - local CreepHealth=10000 - local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); - local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) - local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) - local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) - local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) - - -------------------------------------- - -- Global high-priorty usage - -------------------------------------- - - -- Check for a channeling enemy - for _,npcEnemy in pairs( enemys ) - do - if ( npcEnemy:IsChanneling() ) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); - end - end - - --try to kill enemy hero - if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(0.5); - end - end - end - end - -------------------------------------- - -- Mode based usage - -------------------------------------- - if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=1 ) - then - local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); - if ( locationAoE.count >= 2 ) then - return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; - end - end - - -- If we're farming and can kill 3+ creeps with LSA - if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then - local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); - - if ( locationAoE.count >= 3 ) then - return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; - end - end - - -- If we're pushing or defending a lane and can hit 4+ creeps, go for it - if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) - then - local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); - - if ( locationAoE.count >= 4 ) - then - return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; - end - end - - -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently - if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) - then - for _,npcEnemy in pairs( enemys ) - do - if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) - then - if ( CanCast[abilityNumber]( npcEnemy ) ) - then - return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(0.5); - end - end - end - end - - -- If we're going after someone - if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or - npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or - npcBot:GetActiveMode() == BOT_MODE_GANK or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) - then - local npcEnemy = npcBot:GetTarget(); - - if ( npcEnemy ~= nil ) - then - if ( CanCast[abilityNumber]( npcEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(0.5); - end - end - end - - return BOT_ACTION_DESIRE_NONE, 0; - -end - -function Consider4() - -end - -function CourierUsageThink() - ability_item_usage_generic.CourierUsageThink() +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.2 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[4] + end, + function() + return Talents[6] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 2 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.5) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy:GetLocation(); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function GetStickyNapalmCount(npcTarget) + local modifier=npcTarget:GetModifierByName("modifier_batrider_sticky_napalm") + if(modifier~=nil) + then + return npcTarget:GetModifierStackCount(modifier) + else + return 0 + end +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetStickyNapalmCount(npcEnemy)>=3 ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH + end + end + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy )and GetStickyNapalmCount(WeakestEnemy)>=3 ) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + end + + -- If we're farming and can hit 2+ creeps and kill 1+ + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + then + if ( #creeps >= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys and GetStickyNapalmCount(npcEnemy)>=3) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() end \ No newline at end of file diff --git a/ability_item_usage_beastmaster.lua b/ability_item_usage_beastmaster.lua new file mode 100644 index 00000000..5c3fcf5c --- /dev/null +++ b/ability_item_usage_beastmaster.lua @@ -0,0 +1,438 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.2 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[1], + Abilities[1], + "talent", + Abilities[3], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[4] + end, + function() + return Talents[6] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() --Location AOE Example + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + -- LANING last hit + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana)) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 1 and GetUnitToLocationDistance(npcBot,locationAoE.targetloc)<=CastRange) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 and GetUnitToLocationDistance(npcBot,locationAoE.targetloc)<=CastRange) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0; + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) + then + for _,npcEnemy in pairs( enemys ) + do + if (npcBot:WasRecentlyDamagedByAnyHero(2.0)) + then + return BOT_ACTION_DESIRE_HIGH + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + + -- If we're farming and can hit 2+ creeps and kill 1+ + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + then + if ( #creeps >= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + + +Consider[4]=function() --Target Ability Example + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_bloodseeker.lua b/ability_item_usage_bloodseeker.lua index c8cec4cb..45ae58bc 100644 --- a/ability_item_usage_bloodseeker.lua +++ b/ability_item_usage_bloodseeker.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,7 +47,7 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] diff --git a/ability_item_usage_bounty_hunter.lua b/ability_item_usage_bounty_hunter.lua new file mode 100644 index 00000000..162aaf85 --- /dev/null +++ b/ability_item_usage_bounty_hunter.lua @@ -0,0 +1,379 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[3], + Abilities[2], + Abilities[1], + Abilities[1], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[4], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[4] + end, + function() + return Talents[5] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() --Target Ability Example + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local Radius = ability:GetSpecialValueInt( "bounce_aoe" ); + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + if(GetUnitToUnitDistance(npcBot,npcEnemy)ComboMana)) + then + if(GetUnitToUnitDistance(npcBot,WeakestEnemy)= 2 ) + then + local trackedEnemy=0; + for k,npcEnemy in pairs(enemys) do + if npcEnemy:HasModifier("modifier_bounty_hunter_track") then + trackedEnemy=trackedEnemy+1; + end + end + + if(trackedEnemy>=2) + then + if(creeps[1]~=nil) + then + return BOT_ACTION_DESIRE_HIGH, creeps[1]; + elseif(enemys[1]~=nil) + then + return BOT_ACTION_DESIRE_HIGH, enemys[1]; + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + if(GetUnitToUnitDistance(npcBot,npcEnemy)= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW, WeakestCreep; + end + end + end + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + if ( #enemys>=1) + then + if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(GetUnitToUnitDistance(npcBot,WeakestEnemy)= BOT_MODE_DESIRE_MODERATE ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_HIGH + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + if ( npcEnemy ~= nil ) + then + if (GetUnitToUnitDistance(npcBot,npcEnemy)<=2000) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + + return BOT_ACTION_DESIRE_NONE + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT and ManaPercentage>=0.2) + then + for _,npcEnemy in pairs( enemys ) + do + local count=100; + local modifier=npcEnemy:GetModifierByName("modifier_bounty_hunter_track") + if(modifier~=nil) + then + count=npcEnemy:GetModifierRemainingDuration(modifier) + end + + if(npcEnemy:HasModifier("modifier_bounty_hunter_track")==false or count<=5) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_brewmaster.lua b/ability_item_usage_brewmaster.lua new file mode 100644 index 00000000..2c625f38 --- /dev/null +++ b/ability_item_usage_brewmaster.lua @@ -0,0 +1,442 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[3], + Abilities[1], + Abilities[1], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[4], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[3] + end, + function() + return Talents[5] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange() + local Damage = ability:GetAbilityDamage() + local Radius = ability:GetAOERadius()-50 + local CastPoint = ability:GetCastPoint() + + local i=npcBot:FindItemSlot("item_blink") + if(i>=0 and i<=5) + then + blink=npcBot:GetItemInSlot(i) + i=nil + end + if(blink~=nil and blink:IsFullyCastable()) + then + CastRange=CastRange+1200 + if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) + then + npcBot:Action_UseAbilityOnLocation( blink, locationAoE.targetloc ); + return 0 + end + end + end + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH,npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + if((npcBot:WasRecentlyDamagedByAnyHero(2) and #enemys>=1) or #enemys >=2) + then + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH,"immediately" + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(GetUnitToUnitDistance(npcBot,WeakestEnemy)= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW,WeakestCreep + end + end + end + + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)<=Radius) + then + return BOT_ACTION_DESIRE_MODERATE,npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_PHYSICAL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.7 or npcBot:GetMana()>ComboMana ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy; + end + end + end + end + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + if ( #enemys>=1) + then + if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) + then + return BOT_ACTION_DESIRE_LOW, WeakestEnemy; + end + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + return BOT_ACTION_DESIRE_LOW + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + return BOT_ACTION_DESIRE_LOW + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and #enemys>=2 and #allys>=2 and GetUnitToUnitDistance(npcBot,npcEnemy)<=1000) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_bristleback.lua b/ability_item_usage_bristleback.lua index 8c76ce39..dfd16f29 100644 --- a/ability_item_usage_bristleback.lua +++ b/ability_item_usage_bristleback.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/ability_item_usage_broodmother.lua b/ability_item_usage_broodmother.lua new file mode 100644 index 00000000..0a7dc49d --- /dev/null +++ b/ability_item_usage_broodmother.lua @@ -0,0 +1,430 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode = false +local npcBot = GetBot() +local Talents = {} +local Abilities = {} +local AbilitiesReal = {} + +ability_item_usage_generic.InitAbility(Abilities, AbilitiesReal, Talents) + +local AbilityToLevelUp = +{ + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[1], + Abilities[1], + "talent", + Abilities[3], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree = { + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[5] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp, TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast = {}cast.Desire = {}cast.Target = {}cast.Type = {} +local Consider = {} +local CanCast = {utility.NCanCast, utility.NCanCast, utility.NCanCast, utility.UCanCast} +local enemyDisabled = utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1] = function() + local abilityNumber = 1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability = AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() + then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes(1200, false, BOT_MODE_NONE); + local enemys = npcBot:GetNearbyHeroes(math.min(1600,CastRange + 300), true, BOT_MODE_NONE) + local WeakestEnemy, HeroHealth = utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(math.min(1600,CastRange + 300), true) + local WeakestCreep, CreepHealth = utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if (npcBot:GetActiveMode() ~= BOT_MODE_RETREAT) + then + if (WeakestEnemy ~= nil) + then + if (CanCast[abilityNumber](WeakestEnemy)) + then + if (HeroHealth <= WeakestEnemy:GetActualIncomingDamage(Damage, DAMAGE_TYPE_MAGICAL) or (HeroHealth <= WeakestEnemy:GetActualIncomingDamage(GetComboDamage(), DAMAGE_TYPE_MAGICAL) and npcBot:GetMana() > ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH, WeakestEnemy; + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) + then + for _, npcEnemy in pairs(enemys) + do + if (npcBot:WasRecentlyDamagedByHero(npcEnemy, 2.0)) + then + if (CanCast[abilityNumber](npcEnemy)) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + end + + -- If my mana is enough,use it at enemy + if (npcBot:GetActiveMode() == BOT_MODE_LANING) + then + if ((ManaPercentage > 0.6 or npcBot:GetMana() > ComboMana) and ability:GetLevel() >= 2) + then + if (WeakestEnemy ~= nil) + then + if (CanCast[abilityNumber](WeakestEnemy)) + then + return BOT_ACTION_DESIRE_LOW, WeakestEnemy; + end + end + end + end + + --Last hit + if (npcBot:GetActiveMode() == BOT_MODE_LANING) + then + if (WeakestCreep ~= nil) + then + if ((ManaPercentage > 0.6 or npcBot:GetMana() > ComboMana) and GetUnitToUnitDistance(npcBot, WeakestCreep) >= AttackRange + 100) + then + if (CreepHealth <= WeakestCreep:GetActualIncomingDamage(Damage, DAMAGE_TYPE_MAGICAL)) + then + return BOT_ACTION_DESIRE_LOW, WeakestCreep; + end + end + end + end + + -- If we're farming and can hit 2+ creeps and kill 1+ + if (npcBot:GetActiveMode() == BOT_MODE_FARM) + then + if (#creeps >= 2) + then + if (CreepHealth <= WeakestCreep:GetActualIncomingDamage(Damage, DAMAGE_TYPE_MAGICAL) and npcBot:GetMana() > ComboMana) + then + return BOT_ACTION_DESIRE_LOW, WeakestCreep; + end + end + end + + -- If we're pushing or defending a lane + if (npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT) + then + if (#creeps >= 3) + then + if (ManaPercentage > 0.6 or npcBot:GetMana() > ComboMana) + then + if (CanCast[abilityNumber](creeps[1]) and GetUnitToUnitDistance(npcBot, creeps[1]) < CastRange + 75 * #allys) + then + return BOT_ACTION_DESIRE_LOW, creeps[1]; + end + end + end + end + + -- If we're going after someone + if (npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local npcEnemy = npcBot:GetTarget(); + + if (npcEnemy ~= nil) + then + if (CanCast[abilityNumber](npcEnemy) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot, npcEnemy) < CastRange + 75 * #allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function IsLocationOverlapWeb(location, Radius) + local unit = GetUnitList(UNIT_LIST_ALLIES); + for _, u in pairs(unit) + do + if u:GetUnitName() == "npc_dota_broodmother_web" + then + local flag = (2 * Radius) - 100; + if GetUnitToLocationDistance(u, location) <= flag then + return true + end + end + end + return false; +end + +function GetTowardsFountainLocation(unitLoc, distance) + local destination = {}; + if (GetTeam() == TEAM_RADIANT) then + destination[1] = unitLoc[1] - distance / math.sqrt(2); + destination[2] = unitLoc[2] - distance / math.sqrt(2); + end + + if (GetTeam() == TEAM_DIRE) then + destination[1] = unitLoc[1] + distance / math.sqrt(2); + destination[2] = unitLoc[2] + distance / math.sqrt(2); + end + return Vector(destination[1], destination[2]); +end + +Consider[2] = function() + local abilityNumber = 2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability = AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local Radius = ability:GetAOERadius() + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes(1200, false, BOT_MODE_NONE); + local enemys = npcBot:GetNearbyHeroes(1600, true, BOT_MODE_NONE) + local WeakestEnemy, HeroHealth = utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600, true) + local WeakestCreep, CreepHealth = utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) + then + if (npcBot:WasRecentlyDamagedByAnyHero(2.0)) + then + if (not IsLocationOverlapWeb(GetTowardsFountainLocation(npcBot:GetLocation(), CastRange), Radius)) + then + return BOT_ACTION_DESIRE_MODERATE, GetTowardsFountainLocation(npcBot:GetLocation(), CastRange); + end + end + end + + -- If my mana is enough,use it at enemy + if (npcBot:GetActiveMode() == BOT_MODE_LANING) + then + if creeps ~= nil and #creeps >= 4 and not IsLocationOverlapWeb(npcBot:GetLocation(), Radius) then + return BOT_MODE_DESIRE_MODERATE, npcBot:GetLocation(); + end + end + + -- If we're pushing or defending a lane + if (npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT) + then + local lanecreeps = npcBot:GetNearbyLaneCreeps(1600, true); + local NearbyTower = npcBot:GetNearbyTowers(Radius, true); + local locationAoE = npcBot:FindAoELocation(true, false, npcBot:GetLocation(), CastRange, Radius / 3, 0, 0); + if locationAoE.count >= 3 and #lanecreeps >= 3 and not IsLocationOverlapWeb(locationAoE.targetloc, Radius) then + return BOT_ACTION_DESIRE_MODERATE, locationAoE.targetloc; + end + if NearbyTower[1] ~= nil and not NearbyTower[1]:IsInvulnerable() and + not IsLocationOverlapWeb(NearbyTower[1]:GetLocation(), Radius) + then + return BOT_ACTION_DESIRE_MODERATE, NearbyTower[1]:GetLocation(); + end + end + + if (npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT) + then + local NearbyTower = npcBot:GetNearbyTowers(Radius, false); + if NearbyTower[1] ~= nil and not NearbyTower[1]:IsInvulnerable() and + not IsLocationOverlapWeb(NearbyTower[1]:GetLocation(), Radius) + then + return BOT_ACTION_DESIRE_MODERATE, NearbyTower[1]:GetLocation(); + end + end + + -- If we're going after someone + if (npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local npcEnemy = npcBot:GetTarget(); + + if (npcEnemy ~= nil) + then + if (not IsLocationOverlapWeb(npcEnemy:GetExtrapolatedLocation(CastPoint), Radius) and GetUnitToUnitDistance(npcBot, npcEnemy) < CastRange + 75 * #allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4] = function() + local abilityNumber = 4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability = AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes(1200, false, BOT_MODE_NONE); + local enemys = npcBot:GetNearbyHeroes(1600, true, BOT_MODE_NONE) + local WeakestEnemy, HeroHealth = utility.GetWeakestUnit(enemys) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if (npcBot:GetActiveMode() ~= BOT_MODE_RETREAT) + then + if (WeakestEnemy ~= nil) + then + if (CanCast[abilityNumber](WeakestEnemy)) + then + if (HeroHealth <= WeakestEnemy:GetActualIncomingDamage(GetComboDamage(), DAMAGE_TYPE_MAGICAL) and npcBot:GetMana() > ComboMana) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're going after someone + if (npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local npcEnemy = npcBot:GetTarget(); + + if (npcEnemy ~= nil) + then + if (CanCast[abilityNumber](npcEnemy) and GetUnitToUnitDistance(npcBot, npcEnemy) <= 400) + then + return BOT_ACTION_DESIRE_LOW + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if (npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced()) + then + return + end + + ComboMana = GetComboMana() + AttackRange = npcBot:GetAttackRange() + ManaPercentage = npcBot:GetMana() / npcBot:GetMaxMana() + HealthPercentage = npcBot:GetHealth() / npcBot:GetMaxHealth() + + cast = ability_item_usage_generic.ConsiderAbility(AbilitiesReal, Consider) + ---------------------------------debug-------------------------------------------- + if (debugmode == true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal, cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal, cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end diff --git a/ability_item_usage_centaur.lua b/ability_item_usage_centaur.lua index cc5059d2..5c8d65f2 100644 --- a/ability_item_usage_centaur.lua +++ b/ability_item_usage_centaur.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -49,7 +49,7 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] diff --git a/ability_item_usage_chaos_knight.lua b/ability_item_usage_chaos_knight.lua index 1599bbe6..9df4724b 100644 --- a/ability_item_usage_chaos_knight.lua +++ b/ability_item_usage_chaos_knight.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,16 +46,16 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] end, function() - return Talents[8] + return Talents[7] end } -------------------------------------- diff --git a/ability_item_usage_chen.lua b/ability_item_usage_chen.lua new file mode 100644 index 00000000..3c0a98b9 --- /dev/null +++ b/ability_item_usage_chen.lua @@ -0,0 +1,476 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[3], + Abilities[1], + Abilities[3], + Abilities[2], + Abilities[3], + Abilities[4], + Abilities[3], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + Abilities[4], + Abilities[1], + Abilities[1], + "talent", + Abilities[1], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[4] + end, + function() + return Talents[6] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0; + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = (ability:GetSpecialValueInt("damage_max")+ability:GetSpecialValueInt("damage_min"))*0.5 + local Heal = (ability:GetSpecialValueInt("heal_max")+ability:GetSpecialValueInt("heal_min"))*0.5 + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( CastRange+300, false, BOT_MODE_NONE ); + local WeakestAlly,AllyHealth=utility.GetWeakestUnit(allys) + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy + end + end + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( HealthPercentage<=0.5 and npcBot:WasRecentlyDamagedByAnyHero(2.0)) + then + if ( CanCast[abilityNumber]( npcBot )) + then + return BOT_ACTION_DESIRE_HIGH, npcBot + end + end + end + + --teamfightUsing + if( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + if (WeakestAlly~=nil) + then + if(AllyHealth/WeakestAlly:GetMaxHealth()<0.3+0.2*ManaPercentage) + then + return BOT_ACTION_DESIRE_MODERATE,WeakestAlly + end + end + + for _,npcTarget in pairs( allys ) + do + local enemys2 = npcTarget:GetNearbyHeroes(600,true,BOT_MODE_NONE) + local healingFactor=0.2+#enemys2*0.05+0.2*ManaPercentage + if(enemyDisabled(npcTarget)) + then + healingFactor=healingFactor+0.1 + end + + if(npcTarget:GetHealth()/npcTarget:GetMaxHealth()=1 and #creeps <= 3 ) + then + if(ManaPercentage>0.5) + then + return BOT_ACTION_DESIRE_LOW,WeakestCreep + end + end + end + + -- If our mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.6 and ability:GetLevel()>=2 ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +local goodNeutral= +{ + npc_dota_neutral_alpha_wolf ,-- 头狼 + npc_dota_neutral_centaur_khan ,-- 半人马征服者 + npc_dota_neutral_dark_troll_warlord ,-- 黑暗巨魔召唤法师 + npc_dota_neutral_polar_furbolg_ursa_warrior ,-- 地狱熊怪粉碎者 + npc_dota_neutral_forest_troll_high_priest ,-- 丘陵巨魔牧师 + npc_dota_neutral_mud_golem ,-- 泥土傀儡 + npc_dota_neutral_ogre_magi ,-- 食人魔冰霜法师 + npc_dota_neutral_satyr_hellcaller ,-- 萨特苦难使者 + npc_dota_neutral_enraged_wildkin ,-- 枭兽撕裂者 +} + +function IsGoodNeutralCreeps(npcCreep) + local name=npcCreep:GetUnitName(); + for k,creepName in pairs(goodNeutral) do + if(name==creepName) + then + return true; + end + end + return false; +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0; + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + local creepsNeutral = npcBot:GetNearbyNeutralCreeps(1600) + local StrongestCreep,CreepHealth2=utility.GetStrongestUnit(creepsNeutral) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- Find neural creeps + if(ManaPercentage>=0.4) + then + for k,creep in pairs(creepsNeutral) do + if(IsGoodNeutralCreeps(creep) or (creep:IsAncientCreep() and npcBot:HasScepter())) + then + return BOT_ACTION_DESIRE_MODERATE, creep; + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local lowHpAlly = nil; + local nLowestHealth = 10000; + + for _,npcAlly in pairs( allys ) + do + if ( CanCast[abilityNumber]( npcAlly ) and npcAlly:GetUnitName() ~= npcBot:GetUnitName() ) + then + local nAllyHP = npcAlly:GetHealth(); + if nAllyHP < nLowestHealth and npcAlly:GetHealth() / npcAlly:GetMaxHealth() < 0.25 and npcAlly:WasRecentlyDamagedByAnyHero(3.0) + then + nLowestHealth = nAllyHP; + lowHpAlly = npcAlly; + end + end + end + if ( lowHpAlly ~= nil ) + then + return BOT_ACTION_DESIRE_MODERATE, lowHpAlly; + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 1000; + local Damage = 0; + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 1.0 ) ) + then + return BOT_ACTION_DESIRE_HIGH; + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + for _,Ally in pairs(allys) do + if Ally:GetHealth()/Ally:GetMaxHealth() < 0.35 and enemys~=nil and #enemys > 0 + then + return BOT_ACTION_DESIRE_HIGH; + end + end + end + + local numPlayer = GetTeamPlayers(GetTeam()); + local maxDist = 0; + local target = nil; + for i = 1, #numPlayer + do + local Ally = GetTeamMember(i); + if Ally:IsAlive() and + Ally:GetActiveMode() == BOT_MODE_RETREAT and Ally:GetActiveModeDesire() >= BOT_ACTION_DESIRE_HIGH and + Ally:GetHealth() /Ally:GetMaxHealth() < 0.45 and Ally:WasRecentlyDamagedByAnyHero(2.0) + then + target = GetTeamMember(i); + break; + end + end + if target ~= nil then + return BOT_ACTION_DESIRE_MODERATE; + end + + return BOT_ACTION_DESIRE_NONE; +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_clinkz.lua b/ability_item_usage_clinkz.lua index 163e4e29..566ebd13 100644 --- a/ability_item_usage_clinkz.lua +++ b/ability_item_usage_clinkz.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,7 +46,7 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[4] diff --git a/ability_item_usage_crystal_maiden.lua b/ability_item_usage_crystal_maiden.lua index 48e3a080..77c8731f 100644 --- a/ability_item_usage_crystal_maiden.lua +++ b/ability_item_usage_crystal_maiden.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,7 +46,7 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[3] diff --git a/ability_item_usage_dark_seer.lua b/ability_item_usage_dark_seer.lua new file mode 100644 index 00000000..bdfd0453 --- /dev/null +++ b/ability_item_usage_dark_seer.lua @@ -0,0 +1,496 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[3], + Abilities[2], + Abilities[3], + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[3], + Abilities[4], + "talent", + Abilities[3], + Abilities[4], + Abilities[1], + Abilities[1], + "talent", + Abilities[1], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + local Radius = ability:GetAOERadius(); + + local allys = npcBot:GetNearbyHeroes( CastRange+300, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + local creeps2 = npcBot:GetNearbyCreeps(CastRange+300,false) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( Radius, true, BOT_MODE_NONE ); + if(npcBot:WasRecentlyDamagedByAnyHero(5) and #enemys2~=nil and #enemys2>0) + then + if ( CanCast[abilityNumber]( npcBot ) and not npcBot:HasModifier("modifier_dark_seer_ion_shell") ) + then + return BOT_ACTION_DESIRE_HIGH, npcBot + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( CanCast[abilityNumber]( npcBot ) and not npcBot:HasModifier("modifier_dark_seer_ion_shell") ) + then + return BOT_ACTION_DESIRE_HIGH, npcBot + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + for k,creep in pairs(creeps2) do + if(creep:GetAttackRange()<=300 and CanCast[abilityNumber]( creep ) + and not creep:HasModifier("modifier_dark_seer_ion_shell") and creep:GetHealth()/creep:GetMaxHealth()>0.8) + then + return BOT_ACTION_DESIRE_LOW,creep; + end + end + end + end + + -- If we're farming and can hit 2+ creeps and kill 1+ + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + then + if ( #creeps >= 2 ) + then + if ( CanCast[abilityNumber]( npcBot ) and not npcBot:HasModifier("modifier_dark_seer_ion_shell") ) + then + return BOT_ACTION_DESIRE_HIGH, npcBot + end + end + end + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + for k,creep in pairs(creeps2) do + if(creep:GetAttackRange()<=300 and CanCast[abilityNumber]( creep ) + and not creep:HasModifier("modifier_dark_seer_ion_shell") and creep:GetHealth()/creep:GetMaxHealth()>0.8) + then + return BOT_ACTION_DESIRE_LOW,creep; + end + end + + if ( GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + for _,myFriend in pairs(allys) do + if ( not myFriend:HasModifier("modifier_dark_seer_ion_shell") and myFriend:GetAttackRange() < 300 ) + then + return BOT_ACTION_DESIRE_MODERATE, myFriend; + end + end + if not npcBot:HasModifier("modifier_dark_seer_ion_shell") then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + for _,myFriend in pairs(allys) do + if ( not myFriend:HasModifier("modifier_dark_seer_ion_shell") and myFriend:GetAttackRange() < 300 ) + then + return BOT_ACTION_DESIRE_MODERATE, myFriend; + end + end + if not npcBot:HasModifier("modifier_dark_seer_ion_shell") then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + local AOESurge=npcBot:GetAbilityByName( "special_bonus_unique_dark_seer_3" ); + local Radius=300; + + local locationAoE = npcBot:FindAoELocation( false, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 and AOESurge:IsTrained()==true ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + if(AOESurge:IsTrained()==true) then + return BOT_ACTION_DESIRE_HIGH, locationAoE.targetloc; + else + return BOT_ACTION_DESIRE_HIGH, npcBot; + end + end + end + + -- Help our ally + local allysRetreat = npcBot:GetNearbyHeroes( CastRange+300, false, BOT_MODE_RETREAT ); + for k,ally in pairs(allys) do + if(CanCast[abilityNumber]( ally ) and ally:WasRecentlyDamagedByAnyHero(2.0)) + then + if(AOESurge:IsTrained()==true) then + local locationAoE = npcBot:FindAoELocation( false, true, ally:GetLocation(), CastRange, Radius, 0, 0 ); + return BOT_ACTION_DESIRE_HIGH, locationAoE.targetloc; + else + return BOT_ACTION_DESIRE_HIGH, ally; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( GetUnitToUnitDistance(npcBot,npcEnemy)< 1600) + then + local ClosestDist = GetUnitToUnitDistance(npcTarget, npcBot); + local ClosestBot = npcBot; + for _,myFriend in pairs(allys) do + local dist = GetUnitToUnitDistance(npcTarget, myFriend); + if dist < ClosestDist and dist < CastRange then + ClosestDist = dist; + ClosestBot = myFriend; + end + end + if(AOESurge:IsTrained()==true) then + local locationAoE = npcBot:FindAoELocation( false, true, ClosestBot:GetLocation(), CastRange, Radius, 0, 0 ); + return BOT_ACTION_DESIRE_MODERATE, locationAoE.targetloc; + else + return BOT_ACTION_DESIRE_MODERATE, ClosestBot; + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_dazzle.lua b/ability_item_usage_dazzle.lua index c9f30daf..03192a2e 100644 --- a/ability_item_usage_dazzle.lua +++ b/ability_item_usage_dazzle.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,17 +18,17 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { - Abilities[3], - Abilities[1], Abilities[1], + Abilities[3], Abilities[2], - Abilities[1], - Abilities[4], - Abilities[1], Abilities[3], Abilities[3], - "talent", + Abilities[4], Abilities[3], + Abilities[1], + Abilities[1], + "talent", + Abilities[1], Abilities[4], Abilities[2], Abilities[2], @@ -50,13 +50,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_death_prophet.lua b/ability_item_usage_death_prophet.lua index 5a32c255..9bc168a5 100644 --- a/ability_item_usage_death_prophet.lua +++ b/ability_item_usage_death_prophet.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -53,10 +53,10 @@ local TalentTree={ return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/DEV_ability_item_usage_bounty_hunter.lua b/ability_item_usage_disruptor.lua similarity index 72% rename from DEV_ability_item_usage_bounty_hunter.lua rename to ability_item_usage_disruptor.lua index 2f0a19fb..91e931ba 100644 --- a/DEV_ability_item_usage_bounty_hunter.lua +++ b/ability_item_usage_disruptor.lua @@ -1,11 +1,11 @@ ---------------------------------------------------------------------------- --- Ranked Matchmaking AI v1.1 NewStructure +-- Ranked Matchmaking AI v1.3 New Structure -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -20,15 +20,15 @@ local AbilityToLevelUp= { Abilities[1], Abilities[3], - Abilities[2], - Abilities[2], - Abilities[2], - Abilities[4], + Abilities[1], Abilities[2], Abilities[1], + Abilities[4], Abilities[1], + Abilities[2], + Abilities[2], "talent", - Abilities[1], + Abilities[2], Abilities[4], Abilities[3], Abilities[3], @@ -47,16 +47,16 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } @@ -83,7 +83,7 @@ function GetComboMana() return ability_item_usage_generic.GetComboMana(AbilitiesReal) end -Consider[1]=function() --Target Ability Example +Consider[1]=function() local abilityNumber=1 -------------------------------------- -- Generic Variable Setting @@ -95,7 +95,8 @@ Consider[1]=function() --Target Ability Example end local CastRange = ability:GetCastRange(); - local Damage = ability:GetAbilityDamage(); + local perDamage=ability:GetSpecialValueInt("strike_damage") + local Damage = perDamage*ability:GetSpecialValueInt("strikes") local CastPoint = ability:GetCastPoint(); local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); @@ -106,15 +107,6 @@ Consider[1]=function() --Target Ability Example -------------------------------------- -- Global high-priorty usage -------------------------------------- - -- Check for a channeling enemy - for _,npcEnemy in pairs( enemys ) - do - if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy - end - end - --Try to kill enemy hero if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) then @@ -130,59 +122,19 @@ Consider[1]=function() --Target Ability Example end end - -- If we're in a teamfight, use it on the scariest enemy - local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); - if ( #tableNearbyAttackingAlliedHeroes >= 2 ) - then - - local npcMostDangerousEnemy = nil; - local nMostDangerousDamage = 0; - - for _,npcEnemy in pairs( enemys ) - do - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) - then - local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); - if ( Damage2 > nMostDangerousDamage ) - then - nMostDangerousDamage = Damage2; - npcMostDangerousEnemy = npcEnemy; - end - end - end - - if ( npcMostDangerousEnemy ~= nil ) - then - return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; - end - end -------------------------------------- -- Mode based usage -------------------------------------- --protect myself - local enemys2 = npcBot:GetNearbyHeroes( 500, true, BOT_MODE_NONE ); - if(npcBot:WasRecentlyDamagedByAnyHero(5)) - then - for _,npcEnemy in pairs( enemys2 ) - do - if ( CanCast[abilityNumber]( npcEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy - end - end - end - + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently - if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) then for _,npcEnemy in pairs( enemys ) do - if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) then - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) - then - return BOT_ACTION_DESIRE_HIGH, npcEnemy; - end + return BOT_ACTION_DESIRE_HIGH, npcEnemy; end end end @@ -190,7 +142,7 @@ Consider[1]=function() --Target Ability Example -- If my mana is enough,use it at enemy if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) then - if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) then if (WeakestEnemy~=nil) then @@ -209,7 +161,7 @@ Consider[1]=function() --Target Ability Example then if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(perDamage,DAMAGE_TYPE_MAGICAL)) then return BOT_ACTION_DESIRE_LOW,WeakestCreep; end @@ -284,7 +236,40 @@ Consider[1]=function() --Target Ability Example end -Consider[2]=function() --Target AOE Ability Example +function GetEarlyLocation(npcEnemy) + local nPlayerID=npcEnemy:GetPlayerID() + local infoTable=GetHeroLastSeenInfo(nPlayerID) + local mostNearlySecond=4 + local mostNearlyLocation=utility.Fountain(npcEnemy) + local delta=mostNearlySecond + for k,t in pairs(infoTable) do + local time1=t.time_since_seen + local location=t.location + + local tempDelta=math.abs( mostNearlySecond-time1 ) + if( tempDelta=3.9 and time1<=4.1) + then + return location + end + + if(time1>5) + then + return mostNearlyLocation + end + end + + return mostNearlyLocation +end + + +Consider[2]=function() local abilityNumber=2 -------------------------------------- -- Generic Variable Setting @@ -300,79 +285,40 @@ Consider[2]=function() --Target AOE Ability Example local CastPoint = ability:GetCastPoint(); local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); - local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) - local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local creeps = npcBot:GetNearbyCreeps(1600,true) local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) - - --try to kill enemy hero - if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) - then - if (WeakestEnemy~=nil) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end - end + return BOT_ACTION_DESIRE_HIGH, npcEnemy end end -------------------------------------- -- Mode based usage -------------------------------------- - - --teamfightUsing - if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) then - if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (#enemys+#creeps>2) + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) then - if(WeakestCreep~=nil) - then - return BOT_ACTION_DESIRE_HIGH,WeakestCreep; - end - if(WeakestEnemy~=nil) + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToLocationDistance(npcBot,GetEarlyLocation(npcEnemy))>=600 ) then - if ( CanCast[abilityNumber]( WeakestEnemy ) ) - then - return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; - end + return BOT_ACTION_DESIRE_HIGH, npcEnemy; end end end end - - --Last hit - --if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) - --then - if(WeakestCreep~=nil) - then - if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL)) - then - return BOT_ACTION_DESIRE_LOW,WeakestCreep; - end - end - end - --end - - -- If we're farming and can hit 2+ creeps and kill 1+ - if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) - then - if ( #creeps >= 2 ) - then - if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end - end - end - -- If we're pushing or defending a lane and can hit 3+ creeps, go for it + -- If we're pushing or defending a lane if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or @@ -380,28 +326,17 @@ Consider[2]=function() --Target AOE Ability Example npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) then - if ( #enemys+#creeps >= 3 ) + if ( #enemys>=1) then - if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) - then - if (WeakestEnemy~=nil) - then - if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestEnemy; - end - end - if (WeakestCreep~=nil) + for k,npcEnemy in pairs(enemys) do + if(GetUnitToLocationDistance(npcBot,GetEarlyLocation(npcEnemy))>=3000) then - if ( CanCast[abilityNumber]( WeakestCreep )and GetUnitToUnitDistance(npcBot,WeakestCreep)< CastRange + 75*#allys ) - then - return BOT_ACTION_DESIRE_LOW, WeakestCreep; - end + return BOT_ACTION_DESIRE_HIGH, npcEnemy; end end end end - + -- If we're going after someone if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or @@ -409,15 +344,12 @@ Consider[2]=function() --Target AOE Ability Example npcBot:GetActiveMode() == BOT_MODE_ATTACK ) then local npcEnemy = npcBot:GetTarget(); - - if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) + + if ( npcEnemy ~= nil ) then - if ( npcEnemy ~= nil ) + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)> CastRange/2 and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange) then - if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) - then - return BOT_ACTION_DESIRE_MODERATE, npcEnemy; - end + return BOT_ACTION_DESIRE_MODERATE, npcEnemy end end end @@ -426,7 +358,8 @@ Consider[2]=function() --Target AOE Ability Example end -Consider[3]=function() --Location AOE Example + +Consider[3]=function() local abilityNumber=3 -------------------------------------- @@ -442,6 +375,7 @@ Consider[3]=function() --Location AOE Example local Damage = ability:GetAbilityDamage(); local Radius = ability:GetAOERadius() local CastPoint = ability:GetCastPoint(); + local Delay = ability:GetSpecialValueInt("formation_time"); local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) @@ -452,15 +386,87 @@ Consider[3]=function() --Location AOE Example -------------------------------------- -- Global high-priorty usage -------------------------------------- - -- Check for a channeling enemy - for _,npcEnemy in pairs( enemys ) - do - if ( npcEnemy:IsChanneling() ) + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(Delay); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetLocation(); + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, Delay, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) then - return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(Delay); + end end end + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetSpecialValueInt("damage_max")*ability:GetSpecialValueInt("duration")*0.5; + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- --try to kill enemy hero if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) then @@ -482,27 +488,26 @@ Consider[3]=function() --Location AOE Example if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); - if ( locationAoE.count >= 3 ) then + if ( locationAoE.count >= 8 ) then return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; end end -- If we're pushing or defending a lane and can hit 4+ creeps, go for it if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or - npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) then - local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); - - if ( locationAoE.count >= 4 ) + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 3 ) then return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; end end - + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) then @@ -544,9 +549,6 @@ Consider[3]=function() --Location AOE Example end -Consider[4]=function() - -end function AbilityUsageThink() diff --git a/ability_item_usage_doom_bringer.lua b/ability_item_usage_doom_bringer.lua index 9f48ee5b..30f99ca2 100644 --- a/ability_item_usage_doom_bringer.lua +++ b/ability_item_usage_doom_bringer.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,16 +46,16 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_dragon_knight.lua b/ability_item_usage_dragon_knight.lua index 0aad9543..c2bdf11a 100644 --- a/ability_item_usage_dragon_knight.lua +++ b/ability_item_usage_dragon_knight.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,7 +50,7 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] diff --git a/ability_item_usage_drow_ranger.lua b/ability_item_usage_drow_ranger.lua index cf12832d..5063abb8 100644 --- a/ability_item_usage_drow_ranger.lua +++ b/ability_item_usage_drow_ranger.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,13 +50,13 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_earth_spirit.lua b/ability_item_usage_earth_spirit.lua new file mode 100644 index 00000000..ec0116ee --- /dev/null +++ b/ability_item_usage_earth_spirit.lua @@ -0,0 +1,768 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[1], + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[6], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[6], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[6], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[4] + end, + function() + return Talents[5] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.NCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + + +local nStone = 0; + +local remnantLoc = {}; +local remnantCastTime = -100; +local remnantCastGap = 0.1; +local stoneCast = -100; +local stoneCastGap = 1.0; + +function IsStoneNearby(location, radius) + local units = GetUnitList(UNIT_LIST_ALLIED_OTHER); + for _,u in pairs(units) do + if u ~= nil and u:GetUnitName() == "npc_dota_earth_spirit_stone" and GetUnitToLocationDistance(u, location) < radius then + return true; + end + end + return false; +end + +function IsStoneInPath(location, dist) + if npcBot:IsFacingLocation(location, 5) then + local units = GetUnitList(UNIT_LIST_ALLIED_OTHER); + for _,u in pairs(units) do + if u ~= nil and u:GetUnitName() == "npc_dota_earth_spirit_stone" + and npcBot:IsFacingLocation(u:GetLocation(), 5) and GetUnitToUnitDistance(u, npcBot) < dist + then + return true; + end + end + end + return false; +end + +function CanChainMag(target, radius) + local enemies = target:GetNearbyHeroes(radius, false, BOT_MODE_NONE); + for _,enemy in pairs(enemies) + do + if not enemy:HasModifier('modifier_earth_spirit_magnetize') then + return true + end + end + return false; +end + +function GetCorrectLoc(target, delay) + if target:GetMovementDirectionStability() < 0.9 then + return target:GetLocation(); + else + return target:GetExtrapolatedLocation(delay); + end +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local nRadius = ability:GetSpecialValueInt('radius'); + local nSearchRad = ability:GetSpecialValueInt('rock_search_aoe'); + local nUnitCR = 150; + local nStoneCR = ability:GetSpecialValueInt('rock_distance'); + local nCastPoint = ability:GetCastPoint( ); + local nManaCost = ability:GetManaCost( ); + local nSpeed = ability:GetSpecialValueInt('speed'); + local nDamage = ability:GetSpecialValueInt('rock_damage'); + local stoneNearby = IsStoneNearby(npcBot:GetLocation(), nSearchRad); + + if nStoneCR > 1600 then nStoneCR = 1600 end + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + local target=npcEnemy; + local loc = GetCorrectLoc(target, GetUnitToUnitDistance(npcBot, target)/nSpeed) + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + elseif nStone < 1 then + --do nothing + end + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + local target=WeakestEnemy; + local loc = GetCorrectLoc(target, GetUnitToUnitDistance(npcBot, target)/nSpeed) + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + elseif nStone < 1 and GetUnitToUnitDistance(npcBot,target)<=nUnitCR+200 then + return BOT_ACTION_DESIRE_HIGH, target, false, false; + end + end + end + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local target=npcEnemy; + local loc = GetCorrectLoc(target, GetUnitToUnitDistance(npcBot, target)/nSpeed) + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + elseif nStone < 1 and GetUnitToUnitDistance(npcBot,target)<=nUnitCR+200 then + return BOT_ACTION_DESIRE_HIGH, target, false, false; + end + end + end + end + end + + -- -- If my mana is enough,use it at enemy + -- if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + -- then + -- if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + -- then + -- if (WeakestEnemy~=nil) + -- then + -- if ( CanCast[abilityNumber]( WeakestEnemy ) ) + -- then + -- return BOT_ACTION_DESIRE_LOW,WeakestEnemy; + -- end + -- end + -- end + -- end + + -- -- If we're farming and can hit 2+ creeps and kill 1+ + -- if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + -- then + -- if ( #creeps >= 2 ) + -- then + -- if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + -- then + -- return BOT_ACTION_DESIRE_LOW, WeakestCreep; + -- end + -- end + -- end + + -- -- If we're pushing or defending a lane + -- if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + -- npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + -- npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + -- npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + -- npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + -- npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + -- then + -- if ( #enemys>=1) + -- then + -- if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana and AbilitiesReal[abilityNumber]:GetLevel()>=1) + -- then + -- if (WeakestEnemy~=nil) + -- then + -- if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) + -- then + -- return BOT_ACTION_DESIRE_LOW, WeakestEnemy; + -- end + -- end + -- end + -- end + + -- if (#creeps >= 3 ) + -- then + -- if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana and AbilitiesReal[abilityNumber]:GetLevel()>=1) + -- then + -- if ( CanCast[abilityNumber]( creeps[1] )and GetUnitToUnitDistance(npcBot,creeps[1])< CastRange + 75*#allys ) + -- then + -- return BOT_ACTION_DESIRE_LOW, creeps[1]; + -- end + -- end + -- end + -- end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), nStoneCR, nRadius, nCastPoint, 0 ); + if ( locationAoE.count >= 2 ) + then + if stoneNearby then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc, true, false; + end + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + local target=npcEnemy; + local loc = GetCorrectLoc(target, GetUnitToUnitDistance(npcBot, target)/nSpeed) + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0, false, false; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local nRadius = ability:GetSpecialValueInt('radius'); + local nUnitCR = ability:GetSpecialValueInt('distance'); + local nStoneCR = ability:GetSpecialValueInt('rock_distance'); + local nCastPoint = ability:GetCastPoint( ); + local nDelay = ability:GetSpecialValueFloat('delay'); + local nManaCost = ability:GetManaCost( ); + local nSpeed = ability:GetSpecialValueInt('speed'); + local nRSpeed = ability:GetSpecialValueInt('rock_speed'); + local nDamage = ability:GetSpecialValueInt('damage'); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + local target=WeakestEnemy; + local loc = GetCorrectLoc(target, (GetUnitToUnitDistance(npcBot, target)/nRSpeed)+nDelay) + if IsStoneInPath(loc, (nUnitCR/2)+200) then + return BOT_ACTION_DESIRE_HIGH, loc, false; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true; + elseif nStone < 1 and GetUnitToUnitDistance(npcBot,target)<=nUnitCR+200 then + return BOT_ACTION_DESIRE_HIGH, target:GetLocation(), false; + end + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local location = utility.Fountain(GetTeam()); + local loc = npcBot:GetXUnitsTowardsLocation( location, nUnitCR ); + if IsStoneInPath(loc, (nUnitCR/2)+200) then + return BOT_ACTION_DESIRE_MODERATE, loc, false; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_MODERATE, loc, true; + elseif nStone < 1 then + return BOT_ACTION_DESIRE_MODERATE, loc, false; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcTarget ~= nil ) + then + if(CanCast[abilityNumber]( npcTarget )) + then + if nStone >= 1 and (GetUnitToUnitDistance(npcTarget, npcBot) <= nStoneCR + 200) + then + local targetAlly = npcTarget:GetNearbyHeroes(1000, false, BOT_MODE_NONE); + local targetEnemy = npcTarget:GetNearbyHeroes(1000, true, BOT_MODE_NONE); + if targetEnemy ~= nil and targetAlly ~= nil and #targetEnemy >= #targetAlly then + local loc = GetCorrectLoc(npcTarget, GetUnitToUnitDistance(npcBot, target)/nRSpeed) + if IsStoneInPath(loc, (nUnitCR/2)+200) then + return BOT_ACTION_DESIRE_HIGH, loc, false; + else + return BOT_ACTION_DESIRE_HIGH, loc, true; + end + end + elseif nStone < 1 and (GetUnitToUnitDistance(npcTarget, npcBot) <= nUnitCR / 2) then + local loc = GetCorrectLoc(npcTarget, GetUnitToUnitDistance(npcBot, target)/nSpeed) + return BOT_ACTION_DESIRE_HIGH, loc, false; + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0, false; + +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local nRadius = ability:GetSpecialValueInt('radius'); + local nSearchRad = 175; + local nCastRange = ability:GetCastRange(); + local nCastPoint = ability:GetCastPoint( ); + local nManaCost = ability:GetManaCost( ); + local nDamage = ability:GetSpecialValueInt('rock_damage'); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + if gripAllies ~= nil and gripAllies:IsTrained() then + for _,ally in pairs(allys) + do + if ally:GetActiveMode() == BOT_MODE_RETREAT and ally:WasRecentlyDamagedByAnyHero(2.0) then + return BOT_ACTION_DESIRE_HIGH, ally:GetLocation(), false, true; + end + end + end + + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + local target=npcEnemy + local loc = GetCorrectLoc(target, 2*nCastPoint) + local stoneNearby = IsStoneNearby(loc, nSearchRad); + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + end + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + if stoneNearby then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(), false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(), true, false; + end + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), nCastRange, nRadius, nCastPoint, 0 ); + if ( locationAoE.count >= 2 ) + then + local stoneNearby = IsStoneNearby(locationAoE.targetloc, nSearchRad); + if stoneNearby and ( nStone >= 1 or nStone < 1 ) then + return BOT_ACTION_DESIRE_HIGH, locationAoE.targetloc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, locationAoE.targetloc, true, false; + end + end + + local npcTarget = npcBot:GetTarget(); + + if ( npcTarget ~= nil ) + then + if ( CanCast[abilityNumber]( npcTarget ) and not enemyDisabled(npcTarget) and GetUnitToUnitDistance(npcBot,npcTarget)< CastRange + 75*#allys) + then + local targetAlly = npcTarget:GetNearbyHeroes(1000, false, BOT_MODE_NONE); + local targetEnemy = npcTarget:GetNearbyHeroes(1000, true, BOT_MODE_NONE); + if targetEnemy ~= nil and targetAlly ~= nil and #targetEnemy >= #targetAlly then + local loc = GetCorrectLoc(npcTarget, 2*nCastPoint) + local stoneNearby = IsStoneNearby(loc, nSearchRad); + if stoneNearby and ( nStone >= 1 or nStone < 1 ) then + return BOT_ACTION_DESIRE_HIGH, loc, false, true; + elseif nStone >= 1 then + return BOT_ACTION_DESIRE_HIGH, loc, true, false; + end + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + if DotaTime() < stoneCast + stoneCastGap then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = ability:GetCastRange( ); + local nRadius = AbilitiesReal[6]:GetSpecialValueInt('rock_search_radius'); + + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange - 200, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if npcEnemy:HasModifier('modifier_earth_spirit_magnetize') + then + local duration = npcEnemy:GetModifierRemainingDuration(npcEnemy:GetModifierByName('modifier_earth_spirit_magnetize')); + if duration < 1.0 or CanChainMag(npcEnemy, nRadius) then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetLocation(); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0, false, false; +end + +Consider[5]=function() + local abilityNumber=5 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[6]=function() + local abilityNumber=6 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local nRadius = ability:GetSpecialValueInt( "cast_radius" ); + local nCastPoint = ability:GetCastPoint( ); + local nManaCost = ability:GetManaCost( ); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 1.0 ) and CanCast[abilityNumber](npcEnemy) ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + if ( tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 2 ) + then + return BOT_ACTION_DESIRE_HIGH; + end + + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil ) + then + if ( CanCast[abilityNumber]( npcTarget ) and not enemyDisabled(npcTarget) and GetUnitToUnitDistance(npcBot,npcTarget)< CastRange + 75*#allys) and GetUnitToUnitDistance(npcBot,npcTarget)< nRadius-100 + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + + return BOT_ACTION_DESIRE_NONE; +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() or npcBot:NumQueuedActions() > 0) + then + return + end + + nStone = npcBot:GetModifierStackCount(npcBot:GetModifierByName('modifier_earth_spirit_stone_caller_charge_counter')); + gripAllies = npcBot:GetAbilityByName( "special_bonus_unique_earth_spirit_2" ) + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast.Desire[1], castQLoc, castQStone, QStoneNear = Consider[1](); + cast.Desire[2], castWLoc, castWStone, WStoneNear = Consider[2](); + cast.Desire[3], castELoc, castEStone, EStoneNear = Consider[3](); + cast.Desire[4], castDLoc = Consider[4](); + cast.Desire[5], castFTarget = Consider[5](); + cast.Desire[6] = Consider[6](); + + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + + if ( cast.Desire[6] > 0 ) + then + npcBot:Action_UseAbility( AbilitiesReal[6] ); + return; + end + + if ( cast.Desire[5] > 0 ) + then + --npcBot:Action_UseAbilityOnEntity( abilityF, castFTarget ); + npcBot:ActionQueue_UseAbilityOnEntity(AbilitiesReal[5], castFTarget); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[1], npcBot:GetLocation()+RandomVector(800)); + return; + end + + if ( cast.Desire[1] > 0 ) + then + if castQStone then + npcBot:Action_ClearActions(false); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[4], npcBot:GetLocation()); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[1], castQLoc); + return; + else + if QStoneNear then + npcBot:Action_UseAbilityOnLocation( AbilitiesReal[1], castQLoc ); + return; + else + npcBot:Action_UseAbilityOnEntity( AbilitiesReal[1], castQLoc ); + return; + end + end + end + + if ( cast.Desire[2] > 0 ) + then + if castWStone then + npcBot:Action_ClearActions(false); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[2], castWLoc); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[4], npcBot:GetXUnitsTowardsLocation(castWLoc, 300)); + return; + else + npcBot:Action_UseAbilityOnLocation( AbilitiesReal[2], castWLoc ); + return; + end + end + + if ( cast.Desire[3] > 0 ) + then + if castEStone then + npcBot:Action_ClearActions(false); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[4], castELoc); + npcBot:ActionQueue_UseAbilityOnLocation(AbilitiesReal[3], castELoc); + return; + else + npcBot:Action_UseAbilityOnLocation( AbilitiesReal[3], castELoc ); + return; + end + end + + if ( cast.Desire[4] > 0 ) + then + npcBot:Action_UseAbilityOnLocation( AbilitiesReal[4], castDLoc ); + npcBot:ActionImmediate_Chat( "RESET BOYS", true ); + stoneCast = DotaTime(); + return; + end + +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_earthshaker.lua b/ability_item_usage_earthshaker.lua index b05bb78a..88d62afb 100644 --- a/ability_item_usage_earthshaker.lua +++ b/ability_item_usage_earthshaker.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -53,10 +53,10 @@ local TalentTree={ return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_elder_titan.lua b/ability_item_usage_elder_titan.lua new file mode 100644 index 00000000..394ff7bb --- /dev/null +++ b/ability_item_usage_elder_titan.lua @@ -0,0 +1,432 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +if GetBot():IsInvulnerable() or not GetBot():IsHero() or not string.find(GetBot():GetUnitName(), "hero") or GetBot():IsIllusion() then + return; +end + +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 0 + local Damage = ability:GetAbilityDamage() + local Radius = ability:GetAOERadius()-50 + local CastPoint = ability:GetCastPoint() + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH,npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + if((npcBot:WasRecentlyDamagedByAnyHero(2) and #enemys>=1) or #enemys >=2) + then + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH,"immediately" + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(GetUnitToUnitDistance(npcBot,WeakestEnemy)= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW,WeakestCreep + end + end + end + + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)<=Radius) + then + return BOT_ACTION_DESIRE_MODERATE,npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetSpecialValueInt("crack_width"); + local CastPoint = ability:GetCastPoint(); + local CrackTime = ability:GetSpecialValueInt("crack_time")-1.5; + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint+CrackTime); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint+CrackTime); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_ember_spirit.lua b/ability_item_usage_ember_spirit.lua index 4407519e..e1dc85dd 100644 --- a/ability_item_usage_ember_spirit.lua +++ b/ability_item_usage_ember_spirit.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/ability_item_usage_enchantress.lua b/ability_item_usage_enchantress.lua new file mode 100644 index 00000000..ac4bad8f --- /dev/null +++ b/ability_item_usage_enchantress.lua @@ -0,0 +1,377 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[1], + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[4], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +local goodNeutral= +{ + npc_dota_neutral_alpha_wolf ,-- 头狼 + npc_dota_neutral_centaur_khan ,-- 半人马征服者 + npc_dota_neutral_dark_troll_warlord ,-- 黑暗巨魔召唤法师 + npc_dota_neutral_polar_furbolg_ursa_warrior ,-- 地狱熊怪粉碎者 + npc_dota_neutral_forest_troll_high_priest ,-- 丘陵巨魔牧师 + npc_dota_neutral_mud_golem ,-- 泥土傀儡 + npc_dota_neutral_ogre_magi ,-- 食人魔冰霜法师 + npc_dota_neutral_satyr_hellcaller ,-- 萨特苦难使者 + npc_dota_neutral_enraged_wildkin ,-- 枭兽撕裂者 +} + +function IsGoodNeutralCreeps(npcCreep) + local name=npcCreep:GetUnitName(); + for k,creepName in pairs(goodNeutral) do + if(name==creepName) + then + return true; + end + end + return false; +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0; + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + local creepsNeutral = npcBot:GetNearbyNeutralCreeps(1600) + local StrongestCreep,CreepHealth2=utility.GetStrongestUnit(creepsNeutral) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- Find neural creeps + if(ManaPercentage>=0.4) + then + for k,creep in pairs(creepsNeutral) do + if(IsGoodNeutralCreeps(creep) or (creep:IsAncientCreep() and npcBot:HasScepter())) + then + return BOT_ACTION_DESIRE_MODERATE, creep; + end + end + end + + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local Radius = ability:GetAOERadius(); + local Damage = 0 + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( Radius+300, false, BOT_MODE_NONE ); + local WeakestAlly,AllyHealth=utility.GetWeakestUnit(allys) + local enemys = npcBot:GetNearbyHeroes(Radius+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( HealthPercentage<=0.5 and npcBot:WasRecentlyDamagedByAnyHero(2.0)) + then + return BOT_ACTION_DESIRE_HIGH + end + end + + --teamfightUsing + if( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + if (WeakestAlly~=nil) + then + if(AllyHealth/WeakestAlly:GetMaxHealth()<0.4+0.4*ManaPercentage) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + + local creeps2 = npcBot:GetNearbyCreeps(Radius+300,false) + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_LANING or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT) + then + if #creeps2<=2 then + for _,npcTarget in pairs( allys ) + do + if(npcTarget:GetHealth()/npcTarget:GetMaxHealth()<(0.4+0.4*ManaPercentage)) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0 + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+100,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+100,true) + local creeps2 = npcBot:GetNearbyCreeps(300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + if(ability:GetToggleState()==false) + then + local t=npcBot:GetAttackTarget() + if(t~=nil) + then + if (t:IsHero() or t:IsTower()) + then + ability:ToggleAutoCast() + return BOT_ACTION_DESIRE_NONE, 0; + end + end + else + local t=npcBot:GetAttackTarget() + if(t~=nil) + then + if (not(t:IsHero() or t:IsTower())) + then + ability:ToggleAutoCast() + return BOT_ACTION_DESIRE_NONE, 0; + end + end + end + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_ALL)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(CreepHealth>=250 and ManaPercentage>=0.5 and HealthPercentage>=0.6 and #creeps2<=1) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW-0.01,WeakestEnemy + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange+100) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_enigma.lua b/ability_item_usage_enigma.lua new file mode 100644 index 00000000..f2d61b28 --- /dev/null +++ b/ability_item_usage_enigma.lua @@ -0,0 +1,536 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[1], + Abilities[1], + "talent", + Abilities[3], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +function CanCast2(npcTarget) + if(utility.NCanCast(npcTarget) and npcTarget:GetLevel()<=5 ) + then + return true; + end + return false; +end + +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,CanCast2,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() and CanCast[abilityNumber]( npcEnemy )) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy + end + end + + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy; + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + local creeps2 = npcBot:GetNearbyCreeps(CastRange+300,false) + local WeakestCreep2,CreepHealth2=utility.GetWeakestUnit(creeps2) + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + for k,creep in pairs(creeps) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + for k,creep in pairs(creeps2) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + end + end + + -- If my mana is enough,use it at enemy + -- If we're farming and can hit 2+ creeps and kill 1+ + if ( npcBot:GetActiveMode() == BOT_MODE_FARM or npcBot:GetActiveMode() == BOT_MODE_LANING) + then + if ( #creeps >= 2 ) + then + for k,creep in pairs(creeps) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + for k,creep in pairs(creeps2) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + end + end + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + for k,creep in pairs(creeps) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + for k,creep in pairs(creeps2) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + for k,creep in pairs(creeps) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + for k,creep in pairs(creeps2) do + if(CanCast[abilityNumber](creep)) then + return BOT_ACTION_DESIRE_HIGH, creep; + end + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0 + local Radius = ability:GetAOERadius()-50; + local CastPoint = ability:GetCastPoint() + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + + local i=npcBot:FindItemSlot("item_blink") + if(i>=0 and i<=5) + then + blink=npcBot:GetItemInSlot(i) + i=nil + end + if(blink~=nil and blink:IsFullyCastable()) + then + CastRange=CastRange+1200 + if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) + then + npcBot:Action_UseAbilityOnLocation( blink, locationAoE.targetloc ); + return 0 + end + end + end + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation() + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 2 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 3 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_faceless_void.lua b/ability_item_usage_faceless_void.lua index 984f1c17..889bbf0d 100644 --- a/ability_item_usage_faceless_void.lua +++ b/ability_item_usage_faceless_void.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,10 +50,10 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_generic.lua b/ability_item_usage_generic.lua index 2f0c384a..a504ea2d 100644 --- a/ability_item_usage_generic.lua +++ b/ability_item_usage_generic.lua @@ -5,7 +5,7 @@ ------- _G._savedEnv = getfenv() module( "ability_item_usage_generic", package.seeall ) -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) ---------- function CourierUsageThink() @@ -356,6 +356,10 @@ function UseAbility(AbilitiesReal,cast) then npcBot:Action_UseAbilityOnLocation( ability , cast.Target[j]) return + elseif(utility.CheckFlag(ability:GetTargetType(),ABILITY_TARGET_TYPE_TREE)) + then + npcBot:Action_UseAbilityOnTree( ability , cast.Target[j]) + return else npcBot:Action_UseAbilityOnEntity( ability , cast.Target[j]) return diff --git a/ability_item_usage_gyrocopter.lua b/ability_item_usage_gyrocopter.lua index 4160f61d..f2133970 100644 --- a/ability_item_usage_gyrocopter.lua +++ b/ability_item_usage_gyrocopter.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,17 +18,17 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { - Abilities[2], + Abilities[3], Abilities[1], Abilities[2], Abilities[1], - Abilities[2], - Abilities[4], - Abilities[2], Abilities[1], + Abilities[4], Abilities[1], + Abilities[2], + Abilities[2], "talent", - Abilities[3], + Abilities[2], Abilities[4], Abilities[3], Abilities[3], @@ -50,13 +50,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_huskar.lua b/ability_item_usage_huskar.lua index 5684ba9a..b3c287e5 100644 --- a/ability_item_usage_huskar.lua +++ b/ability_item_usage_huskar.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -49,13 +49,13 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_jakiro.lua b/ability_item_usage_jakiro.lua index 0ec37e07..4f7e45d4 100644 --- a/ability_item_usage_jakiro.lua +++ b/ability_item_usage_jakiro.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,7 +50,7 @@ local TalentTree={ return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[5] diff --git a/ability_item_usage_juggernaut.lua b/ability_item_usage_juggernaut.lua index 2c84938d..b86d0daf 100644 --- a/ability_item_usage_juggernaut.lua +++ b/ability_item_usage_juggernaut.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,13 +50,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_keeper_of_the_light.lua b/ability_item_usage_keeper_of_the_light.lua new file mode 100644 index 00000000..6f598822 --- /dev/null +++ b/ability_item_usage_keeper_of_the_light.lua @@ -0,0 +1,650 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[1], + Abilities[3], + Abilities[3], + Abilities[1], + Abilities[1], + Abilities[3], + Abilities[2], + Abilities[1], + Abilities[3], + "talent", + Abilities[6], + Abilities[6], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[6], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[4] + end, + function() + return Talents[6] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if npcBot:HasScepter() or npcBot:HasModifier("modifier_keeper_of_the_light_spirit_form") or not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetSpecialValueFloat("damage_per_second")*ability:GetSpecialValueFloat("max_channel_time") + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + --Last hit + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(WeakestCreep~=nil) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=300) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + if ( locationAoE.count >= 1 ) then + return BOT_ACTION_DESIRE_LOW-0.02, locationAoE.targetloc; + end + end + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW-0.01, locationAoE.targetloc; + end + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +--keeper_of_the_light_spirit_form_illuminate +Consider[8]=Consider[1] + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + local Damage2 = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL ); + if ( Damage2 > nMostDangerousDamage ) + then + nMostDangerousDamage = Damage2; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( (npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH) or #enemys2>0) + then + for _,npcEnemy in pairs( enemys ) + do + if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) and CanCast[abilityNumber]( npcEnemy )) or GetUnitToUnitDistance(npcBot,npcEnemy)<400) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.4 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy; + end + end + end + end + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + if ( #enemys>=1) + then + if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) + then + return BOT_ACTION_DESIRE_LOW, WeakestEnemy; + end + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + + if npcBot:GetMana() / npcBot:GetMaxMana() < 0.75 then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + else + for _,myFriend in pairs(allys) do + if ( CanCast[abilityNumber](myFriend) and myFriend:GetMana() / myFriend:GetMaxMana() < 0.65 ) + then + return BOT_ACTION_DESIRE_MODERATE, myFriend; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + local numPlayer = GetTeamPlayers(GetTeam()); + for i = 1, #numPlayer + do + local player = GetTeamMember(i); + if player ~= nil and not IsPlayerBot(player:GetPlayerID()) and player:IsAlive() and GetUnitToUnitDistance(npcBot, player) > 1000 then + local p = player:GetMostRecentPing(); + if p ~= nil and GetUnitToLocationDistance(player, p.location) < 1000 and GameTime() - p.time < 10 then + --print("Human pinged to get recalled") + return BOT_ACTION_DESIRE_MODERATE, player; + end + end + end + + -- If we're defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local nearbyTower = npcBot:GetNearbyTowers(1000, false) + if nearbyTower[1] ~= nil then + local maxDist = 0; + local target = nil; + for i = 1, #numPlayer + do + local player = GetTeamMember(i); + if player ~= nil and player:IsAlive() and player:GetActiveMode() ~= BOT_MODE_RETREAT then + local dist = GetUnitToUnitDistance(nearbyTower[1], player); + local health = player:GetHealth()/player:GetMaxHealth(); + if IsPlayerBot(player:GetPlayerID()) and dist > maxDist and dist > 2500 and health >= 0.25 then + maxDist = dist; + target = GetTeamMember(i); + end + end + end + if target ~= nil then + return BOT_ACTION_DESIRE_MODERATE, target; + end + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT ) + then + local nearbyTower = npcBot:GetNearbyTowers(1000, true) + if nearbyTower[1] ~= nil then + local maxDist = 0; + local target = nil; + for i = 1, #numPlayer + do + local player = GetTeamMember(i); + if player ~= nil and player:IsAlive() and player:GetActiveMode() ~= BOT_MODE_RETREAT then + local dist = GetUnitToUnitDistance(nearbyTower[1], player); + local health = player:GetHealth()/player:GetMaxHealth(); + if IsPlayerBot(player:GetPlayerID()) and dist > maxDist and dist > 2500 and health >= 0.25 then + maxDist = dist; + target = GetTeamMember(i); + end + end + end + if target ~= nil then + return BOT_ACTION_DESIRE_MODERATE, target; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() and GetUnitToUnitDistance( npcTarget, npcBot ) < 1000 ) + then + local maxDist = 0; + local target = nil; + for i = 1, #numPlayer + do + local player = GetTeamMember(i); + if player ~= nil and player:IsAlive() and player:GetActiveMode() ~= BOT_MODE_RETREAT then + local dist = GetUnitToUnitDistance(player, npcBot); + local health = player:GetHealth()/player:GetMaxHealth(); + if IsPlayerBot(player:GetPlayerID()) and dist > maxDist and dist > 2500 and health >= 0.25 then + maxDist = dist; + target = GetTeamMember(i); + end + end + end + if target ~= nil then + return BOT_ACTION_DESIRE_MODERATE, target; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[5]=function() + + local abilityNumber=5 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + return BOT_ACTION_DESIRE_HIGH, npcBot:GetLocation(); + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[6]=function() + + local abilityNumber=6 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Radius = 1200 + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero(2) ) + then + return BOT_ACTION_DESIRE_MODERATE-0.05 + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) then + return BOT_ACTION_DESIRE_HIGH + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( npcEnemy:GetHealth()<=npcEnemy:GetActualIncomingDamage(npcBot:GetOffensivePower(),DAMAGE_TYPE_MAGICAL) and GetUnitToUnitDistance(npcEnemy,npcBot)<=Radius) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if npcBot:IsCastingAbility() or npcBot:IsUsingAbility() or npcBot:IsInvulnerable() or npcBot:IsChanneling() or npcBot:IsSilenced() or npcBot:HasModifier("modifier_doom_bringer_doom") or npcBot:NumQueuedActions() > 0 then return end + + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_legion_commander.lua b/ability_item_usage_legion_commander.lua index 7cd7ae09..e49a117b 100644 --- a/ability_item_usage_legion_commander.lua +++ b/ability_item_usage_legion_commander.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -49,7 +49,7 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] diff --git a/ability_item_usage_leshrac.lua b/ability_item_usage_leshrac.lua index 73ec267e..1059b65f 100644 --- a/ability_item_usage_leshrac.lua +++ b/ability_item_usage_leshrac.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,10 +50,10 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[7] diff --git a/ability_item_usage_lich.lua b/ability_item_usage_lich.lua index f36b6446..5ea314e1 100644 --- a/ability_item_usage_lich.lua +++ b/ability_item_usage_lich.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -56,7 +56,7 @@ local TalentTree={ return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_life_stealer.lua b/ability_item_usage_life_stealer.lua index d46513bf..efe34403 100644 --- a/ability_item_usage_life_stealer.lua +++ b/ability_item_usage_life_stealer.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,7 +47,7 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[4] @@ -56,7 +56,7 @@ local TalentTree={ return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_lina.lua b/ability_item_usage_lina.lua index c8773e87..cb096d65 100644 --- a/ability_item_usage_lina.lua +++ b/ability_item_usage_lina.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,16 +46,16 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_lion.lua b/ability_item_usage_lion.lua index ac810833..05ddda83 100644 --- a/ability_item_usage_lion.lua +++ b/ability_item_usage_lion.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,7 +50,7 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] diff --git a/ability_item_usage_luna.lua b/ability_item_usage_luna.lua index 22437be4..42b696e3 100644 --- a/ability_item_usage_luna.lua +++ b/ability_item_usage_luna.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -16,14 +16,6 @@ local AbilitiesReal ={} ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) -local AbilitiesReal = -{ - npcBot:GetAbilityByName(Abilities[1]), - npcBot:GetAbilityByName(Abilities[2]), - npcBot:GetAbilityByName(Abilities[3]), - npcBot:GetAbilityByName(Abilities[4]) -} - local AbilityToLevelUp= { Abilities[3], @@ -54,7 +46,7 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[4] @@ -63,7 +55,7 @@ local TalentTree={ return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_lycan.lua b/ability_item_usage_lycan.lua new file mode 100644 index 00000000..7f66393f --- /dev/null +++ b/ability_item_usage_lycan.lua @@ -0,0 +1,318 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[3], + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[4] + end, + function() + return Talents[5] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 300; + local CastPoint = ability:GetCastPoint(); + + local wolves = 0; + local units = GetUnitList(UNIT_LIST_ALLIES); + for _,unit in pairs(units) + do + if string.find(unit:GetUnitName(), "npc_dota_lycan_wolf") then + wolves = wolves + 1; + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.6 or npcBot:GetMana()>ComboMana and wolves < 1 ) then + return BOT_ACTION_DESIRE_LOW; + end + end + + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), 600, 300, 0, 0 ); + if ( locationAoE.count >= 3 and npcBot:GetMana()/npcBot:GetMaxMana() > 0.65 and wolves < 1 ) then + return BOT_ACTION_DESIRE_LOW; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) and wolves < 1 ) + then + return BOT_ACTION_DESIRE_HIGH + end + end + + if npcBot:GetActiveMode() == BOT_MODE_FARM + then + local npcTarget = npcBot:GetAttackTarget(); + if npcTarget ~= nil then + return BOT_ACTION_DESIRE_LOW; + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_ROSHAN ) + then + local npcTarget = npcBot:GetAttackTarget(); + if ( string.find(npcTarget:GetUnitName(), "roshan") and GetUnitToUnitDistance(npcBot,npcTarget)< 600 and wolves < 1) + then + return BOT_ACTION_DESIRE_LOW; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys and wolves < 1) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), 600, 300, 0, 0 ); + if ( locationAoE.count >= 3 and npcBot:GetMana()/npcBot:GetMaxMana() > 0.65 ) then + return BOT_ACTION_DESIRE_LOW; + end + end + + if npcBot:GetActiveMode() == BOT_MODE_FARM + then + local npcTarget = npcBot:GetAttackTarget(); + if npcTarget ~= nil then + return BOT_ACTION_DESIRE_LOW; + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_ROSHAN ) + then + local npcTarget = npcBot:GetAttackTarget(); + if ( string.find(npcTarget:GetUnitName(), "roshan") and GetUnitToUnitDistance(npcBot,npcTarget)< 600 ) + then + return BOT_ACTION_DESIRE_LOW; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< 300 + 75*#allys ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 )) + then + return BOT_ACTION_DESIRE_HIGH + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< 300 + 75*#allys ) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_magnataur.lua b/ability_item_usage_magnataur.lua new file mode 100644 index 00000000..eb829586 --- /dev/null +++ b/ability_item_usage_magnataur.lua @@ -0,0 +1,478 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[3], + Abilities[1], + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[5] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius(); + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+0,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+0,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetLocation(); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --Last hit + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(WeakestCreep~=nil) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=300) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + if ( locationAoE.count >= 1 ) then + return BOT_ACTION_DESIRE_LOW-0.02, locationAoE.targetloc; + end + end + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and ability:GetLevel()>=2 ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW-0.01, locationAoE.targetloc; + end + end + end + + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + + if ( locationAoE.count >= 4 ) + then + return BOT_ACTION_DESIRE_LOW+0.01, locationAoE.targetloc; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcTarget ~= nil ) + then + if ( CanCast[abilityNumber]( npcTarget ) ) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetLocation(); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local modifierName="modifier_magnataur_empower" + local CastRange = ability:GetCastRange(); + local Damage = 0 + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -- If we're pushing or defending a lane + if ( npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOTTOM or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOTTOM) + then + for _,myFriend in pairs(allys) do + if ( GetUnitToUnitDistance( myFriend, npcBot ) < CastRange and not myFriend:HasModifier(modifierName) ) + then + return BOT_ACTION_DESIRE_MODERATE, myFriend; + end + end + if not npcBot:HasModifier(modifierName) then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + end + end + + -- If my mana is enough,buff myfriend. + if(ManaPercentage>0.5 and npcBot:GetMana()>ComboMana) + then + for _,ally in pairs(allys) + do + if ( not ally:HasModifier(modifierName) ) + then + return BOT_ACTION_DESIRE_MODERATE,ally; + end + end + + if not npcBot:HasModifier(modifierName) then + return BOT_ACTION_DESIRE_MODERATE, npcBot; + end + + end + + return BOT_ACTION_DESIRE_NONE, 0 +end + +Consider[3]=function() + + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're farming and can kill 3+ creeps with LSA + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, 0, Damage ); + + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE, utility.Fountain(GetTeam()); + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 0 + local Damage = ability:GetAbilityDamage() + local Radius = ability:GetAOERadius()-50 + local CastPoint = ability:GetCastPoint() + + local i=npcBot:FindItemSlot("item_blink") + if(i>=0 and i<=5) + then + blink=npcBot:GetItemInSlot(i) + i=nil + end + if(blink~=nil and blink:IsFullyCastable()) + then + CastRange=CastRange+1200 + if(npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) + then + npcBot:Action_UseAbilityOnLocation( blink, locationAoE.targetloc ); + return 0 + end + end + end + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + if((npcBot:WasRecentlyDamagedByAnyHero(2) and #enemys>=1) or #enemys>=2) + then + for _,npcEnemy in pairs( enemys ) + do + return BOT_ACTION_DESIRE_HIGH + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana)) + then + if (WeakestEnemy~=nil) + then + if(GetUnitToUnitDistance(npcBot,WeakestEnemy)=300 ) + then + if( GetUnitToUnitDistance(npcBot,npcEnemy)<=1200+Radius and blink~=nil) + then + npcBot:Action_UseAbilityOnLocation( blink, npcEnemy:GetExtrapolatedLocation(CastPoint) ); + return 0 + end + else + return BOT_ACTION_DESIRE_MODERATE + end + + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_medusa.lua b/ability_item_usage_medusa.lua new file mode 100644 index 00000000..1c7f606c --- /dev/null +++ b/ability_item_usage_medusa.lua @@ -0,0 +1,321 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[3], + Abilities[2], + Abilities[1], + Abilities[2], + Abilities[4], + Abilities[2], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[4], + Abilities[1], + Abilities[1], + "talent", + Abilities[1], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[3] + end, + function() + return Talents[5] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[2]=function() + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetSpecialValueInt("snake_damage") + local CastPoint = ability:GetCastPoint(); + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(CastRange+300,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're in a teamfight + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + if (#enemys+#creeps>2) + then + if(WeakestCreep~=nil) + then + return BOT_ACTION_DESIRE_HIGH,WeakestCreep; + end + if(WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy; + end + end + end + end + end + + --Last hit + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(WeakestCreep~=nil) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) and GetUnitToUnitDistance(npcBot,WeakestCreep)>=AttackRange+100) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or #enemys>=1) + then + return BOT_ACTION_DESIRE_LOW,creeps[1]; + end + end + end + end + + -- If we're farming and can hit 2+ creeps and kill 1+ + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + then + if ( #creeps >= 2 ) + then + if(ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + return BOT_ACTION_DESIRE_LOW, creeps[1]; + end + end + end + + -- If we're pushing or defending a lane and can hit 3+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + if ( #enemys+#creeps >= 3 ) + then + if (ManaPercentage>0.5 or npcBot:GetMana()>ComboMana) + then + if (creeps[1]~=nil) + then + if ( CanCast[abilityNumber]( WeakestCreep )and GetUnitToUnitDistance(npcBot,WeakestCreep)< CastRange + 75*#allys ) + then + return BOT_ACTION_DESIRE_LOW, creeps[1]; + end + end + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy )and GetUnitToUnitDistance(npcBot,WeakestEnemy)< CastRange + 75*#allys ) + then + return BOT_ACTION_DESIRE_LOW, WeakestEnemy; + end + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< CastRange + 75*#allys) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[3]=function() + + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + if(ability:GetToggleState()==false) + then + return BOT_ACTION_DESIRE_HIGH + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local CastPoint = ability:GetCastPoint(); + + local enemys = npcBot:GetNearbyHeroes(CastRange-300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + local enemys2 = npcBot:GetNearbyHeroes( 400, true, BOT_MODE_NONE ); + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH or #enemys2>=2) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 )) + then + return BOT_ACTION_DESIRE_HIGH + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)< 300 + 75*#allys and #enemys>=2 ) + then + return BOT_ACTION_DESIRE_MODERATE + end + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_mirana.lua b/ability_item_usage_mirana.lua new file mode 100644 index 00000000..a3634621 --- /dev/null +++ b/ability_item_usage_mirana.lua @@ -0,0 +1,405 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[3], + Abilities[1], + Abilities[1], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + Abilities[4], + Abilities[1], + Abilities[1], + "talent", + Abilities[1], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +Consider[1]=function() + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 0 + local Damage = ability:GetAbilityDamage() + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint() + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + --Try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) ) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_PHYSICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + --protect myself + if((npcBot:WasRecentlyDamagedByAnyHero(2) and #enemys>=1) or #enemys >=2) + then + for _,npcEnemy in pairs( enemys ) + do + if ( CanCast[abilityNumber]( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_HIGH,"immediately" + end + end + end + + -- If my mana is enough,use it at enemy + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if((ManaPercentage>0.6 or npcBot:GetMana()>ComboMana)) + then + if ((WeakestEnemy~=nil and CanCast[abilityNumber]( WeakestEnemy ) and GetUnitToUnitDistance(npcBot,WeakestEnemy)= 2 ) + then + if(CreepHealth<=WeakestCreep:GetActualIncomingDamage(Damage,DAMAGE_TYPE_PHYSICAL) and (ManaPercentage>0.4 or npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_LOW,WeakestCreep + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)<=Radius) + then + return BOT_ACTION_DESIRE_MODERATE,npcEnemy + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function IsEnemyCreepBetweenMeAndTarget(hSource, hTarget, vLoc, nRadius) + local vStart = hSource:GetLocation(); + local vEnd = vLoc; + local creeps = hSource:GetNearbyLaneCreeps(1600, true); + for i,creep in pairs(creeps) do + local tResult = PointToLineDistance(vStart, vEnd, creep:GetLocation()); + if tResult ~= nil and tResult.within and tResult.distance <= nRadius + 50 then + return true; + end + end + creeps = hTarget:GetNearbyLaneCreeps(1600, false); + for i,creep in pairs(creeps) do + local tResult = PointToLineDistance(vStart, vEnd, creep:GetLocation()); + if tResult ~= nil and tResult.within and tResult.distance <= nRadius + 50 then + return true; + end + end + return false; +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local nRadius = ability:GetSpecialValueInt( "arrow_width" ); + local speed = ability:GetSpecialValueInt( "arrow_speed" ); + local nDamage = ability:GetAbilityDamage(); + local nCastRange = ability:GetSpecialValueInt("arrow_range") + local nCastPoint = ability:GetCastPoint(); + + -- Check for a channeling enemy + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1600, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcEnemy:IsChanneling() and not IsEnemyCreepBetweenMeAndTarget(npcBot, npcEnemy, npcEnemy:GetLocation(), nRadius) ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_ROSHAN ) + then + local npcTarget = npcBot:GetAttackTarget(); + if ( npcTarget:IsRoshan() and CanCast[abilityNumber](npcTarget) and GetUnitToUnitDistance(npcBot,npcTarget)= BOT_MODE_DESIRE_HIGH ) + then + local ancient = GetAncient(GetTeam()); + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) and npcBot:IsFacingLocation(ancient:GetLocation(),10)) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + local distance=GetUnitToUnitDistance(npcBot,npcEnemy) + if ( CanCast[abilityNumber]( npcEnemy ) and distance>CastRange and distance<1.5*CastRange and npcBot:IsFacingLocation(npcEnemy:GetLocation(),10)) + then + local tableNearbyEnemyHeroes = npcEnemy:GetNearbyHeroes( 1000, false, BOT_MODE_NONE ); + if ( tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes <= 2 ) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +Consider[4]=function() + local abilityNumber=4 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = 0 + local Damage = ability:GetAbilityDamage() + local Radius = 1000; + local CastPoint = ability:GetCastPoint() + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(Radius,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(Radius,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH and #enemys>=1) + then + if ( npcBot:WasRecentlyDamagedByAnyHero( 2.0 ) ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcEnemy = npcBot:GetTarget(); + + if ( npcEnemy ~= nil ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and GetUnitToUnitDistance(npcBot,npcEnemy)<=3000 and GetUnitToUnitDistance(npcBot,npcEnemy)>=1600) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_monkey_king.lua b/ability_item_usage_monkey_king.lua new file mode 100644 index 00000000..e3c7c9c9 --- /dev/null +++ b/ability_item_usage_monkey_king.lua @@ -0,0 +1,579 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +--require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[4], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[4], + Abilities[2], + Abilities[4], + Abilities[1], + Abilities[1], + "talent", + Abilities[6], + Abilities[6], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + "nil", + Abilities[6], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[4] + end, + function() + return Talents[5] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +function GetFurthestTree(trees) + if Ancient == nil then return nil end; + local furthest = nil; + local fDist = 10000; + for _,tree in pairs(trees) + do + local dist = GetUnitToLocationDistance(Ancient, GetTreeLocation(tree)); + if dist < fDist then + furthest = tree; + fDist = dist; + end + end + return furthest; +end + +function IsTargetDebuffStackEnough( npcTarget, sModifierName ,count ) + if(npcTarget~=nil and count~=nil) + then + local nModifier=npcTarget:GetModifierByName(sModifierName) + if(nModifier~=nil) + then + if(npcTarget:GetModifierStackCount(nModifier)>=count) + then + return true + end + end + end + return false; +end + +Consider[1]=function() + + local abilityNumber=1 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = ability:GetAbilityDamage(); + local Radius = ability:GetAOERadius() + local CastPoint = ability:GetCastPoint() + + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(1600,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + local creeps = npcBot:GetNearbyCreeps(1600,true) + local WeakestCreep,CreepHealth=utility.GetWeakestUnit(creeps) + + -------------------------------------- + -- Global high-priorty usage + -------------------------------------- + -- Check for a channeling enemy + for _,npcEnemy in pairs( enemys ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_HIGH, npcEnemy:GetLocation(); + end + end + + --try to kill enemy hero + if(npcBot:GetActiveMode() ~= BOT_MODE_RETREAT ) + then + if (WeakestEnemy~=nil) + then + if ( CanCast[abilityNumber]( WeakestEnemy ) and not enemyDisabled(WeakestEnemy) and (npcBot:HasModifier('modifier_monkey_king_quadruple_tap_bonuses') or IsTargetDebuffStackEnough(WeakestEnemy,"modifier_monkey_king_quadruple_tap_counter",3))) + then + if(HeroHealth<=WeakestEnemy:GetActualIncomingDamage(Damage,DAMAGE_TYPE_MAGICAL) or (HeroHealth<=WeakestEnemy:GetActualIncomingDamage(GetComboDamage(),DAMAGE_TYPE_MAGICAL) and npcBot:GetMana()>ComboMana)) + then + return BOT_ACTION_DESIRE_HIGH,WeakestEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + for _,npcEnemy in pairs( enemys ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy)) + then + return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + -- If we're farming and can kill 3+ creeps + if ( npcBot:GetActiveMode() == BOT_MODE_FARM ) + then + if((ManaPercentage>0.5 or npcBot:GetMana()>ComboMana)) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 3 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_LANING ) + then + if(ManaPercentage>0.7 or npcBot:GetMana()>ComboMana) + then + if(WeakestEnemy~=nil and CanCast[abilityNumber]( WeakestEnemy ) and not enemyDisabled(WeakestEnemy) and (npcBot:HasModifier('modifier_monkey_king_quadruple_tap_bonuses') or IsTargetDebuffStackEnough(WeakestEnemy,"modifier_monkey_king_quadruple_tap_counter",3))) + then + return BOT_ACTION_DESIRE_LOW,WeakestEnemy:GetExtrapolatedLocation(CastPoint) + end + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + if((ManaPercentage>0.4 or npcBot:GetMana()>ComboMana)) + then + local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 3 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_MODERATE, locationAoE.targetloc; + end + + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil ) + then + if(npcBot:HasModifier('modifier_monkey_king_quadruple_tap_bonuses') or IsTargetDebuffStackEnough(npcTarget,"modifier_monkey_king_quadruple_tap_counter",3)) + then + if ( CanCast[abilityNumber]( npcTarget ) and not enemyDisabled(npcTarget) and GetUnitToUnitDistance(npcBot,npcEnemy)<=CastRange) + then + return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation(CastPoint); + end + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[2]=function() + + local abilityNumber=2 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() or not AbilitiesReal[3]:IsFullyCastable() or npcBot:IsRooted() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( CastRange, true, BOT_MODE_NONE ); + if tableNearbyEnemyHeroes == nil then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH and npcBot:DistanceFromFountain() > 1000 and #tableNearbyEnemyHeroes >= 1 + then + local tableNearbyTrees = npcBot:GetNearbyTrees( CastRange ); + local furthest = GetFurthestTree(tableNearbyTrees); + if furthest ~= nil then + return BOT_ACTION_DESIRE_MODERATE, furthest; + end + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( CastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( GetUnitToUnitDistance(npcBot,npcEnemy)<=CastRange ) + then + local tableNearbyTrees = npcEnemy:GetNearbyTrees( CastRange ); + if tableNearbyTrees ~= nil and #tableNearbyTrees >= 1 then + return BOT_ACTION_DESIRE_MODERATE, tableNearbyTrees[1]; + end + end + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget~=nil and CanCast[abilityNumber]( npcTarget ) and GetUnitToUnitDistance(npcBot,npcTarget)<=CastRange ) + then + local tableNearbyTrees = npcTarget:GetNearbyTrees( CastRange ); + if tableNearbyTrees ~= nil and #tableNearbyTrees >= 1 then + return BOT_ACTION_DESIRE_MODERATE, tableNearbyTrees[1]; + end + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[3]=function() + + local abilityNumber=3 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() or ability:IsHidden() or ability:IsActivated() == false then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- Get some of its values + local CastRange = ability:GetSpecialValueInt("max_distance"); + local Radius = ability:GetSpecialValueInt("impact_radius"); + local nCastPoint = ability:GetChannelTime( ); + + local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE ); + if tableNearbyEnemyHeroes == nil then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH and #tableNearbyEnemyHeroes >= 1 + then + local location = npcBot:GetXUnitsTowardsLocation( GetAncient(GetTeam()):GetLocation(), CastRange ); + return BOT_ACTION_DESIRE_MODERATE, location; + end + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 2 ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, 0, 0 ); + if ( locationAoE.count >= 2 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + if npcTarget~=nil and CanCast[abilityNumber]( npcTarget ) and GetUnitToUnitDistance(npcBot,npcTarget)<=CastRange + then + if enemyDisabled(npcTarget) or npcTarget:GetMovementDirectionStability() < 1.0 then + return BOT_ACTION_DESIRE_HIGH, npcTarget:GetLocation( ); + else + return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation( nCastPoint ); + end + end + end +-- + return BOT_ACTION_DESIRE_NONE, 0; +end + +Consider[7]=function() + local abilityNumber=7 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() or ability:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local trees = npcBot:GetNearbyTrees(50); + if trees == nil or #trees == 0 then + return BOT_ACTION_DESIRE_NONE; + end + + local Radius = 375; + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + return BOT_ACTION_DESIRE_MODERATE + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + if npcTarget~=nil and CanCast[abilityNumber]( npcTarget ) and + ( GetUnitToLocationDistance(npcTarget, PSLoc) >= ( 375 - 125 ) or npcTarget:GetHealth() <= 175 ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +Consider[5]=function() + + local abilityNumber=5 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() or ability:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemy = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_NONE ); + if #tableNearbyEnemy >= 1 then + return BOT_ACTION_DESIRE_MODERATE + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local tableNearbyAlly = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_NONE ); + local tower = npcBot:GetNearbyTowers(1000, false); + if tower ~= nil and tableNearbyAlly ~= nil and #tower >= 1 and #tableNearbyAlly >= 2 then + return BOT_ACTION_DESIRE_MODERATE + end + end + + return BOT_ACTION_DESIRE_NONE; +end + +Consider[8]=function() + + local abilityNumber=8 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() or ability:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local npcTarget = npcBot:GetTarget(); + if npcTarget~=nil and GetUnitToUnitDistance(npcBot,npcTarget)>=1200 + then + return BOT_ACTION_DESIRE_MODERATE + end + end + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) and not npcBot:WasRecentlyDamagedByAnyHero(4.0) + then + return BOT_ACTION_DESIRE_MODERATE + end + + return BOT_ACTION_DESIRE_NONE; +end + +Consider[6]=function() + local abilityNumber=6 + -------------------------------------- + -- Generic Variable Setting + -------------------------------------- + local ability=AbilitiesReal[abilityNumber]; + + if not ability:IsFullyCastable() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local CastRange = ability:GetCastRange(); + local Damage = 0 + local Radius = ability:GetAOERadius()-50; + local CastPoint = ability:GetCastPoint() + + local HeroHealth=10000 + local CreepHealth=10000 + local allys = npcBot:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local enemys = npcBot:GetNearbyHeroes(CastRange+300,true,BOT_MODE_NONE) + local WeakestEnemy,HeroHealth=utility.GetWeakestUnit(enemys) + + -------------------------------------- + -- Mode based usage + -------------------------------------- + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 2 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + -- If we're pushing or defending a lane and can hit 4+ creeps, go for it + if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 3 ) + then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY or + npcBot:GetActiveMode() == BOT_MODE_ATTACK ) + then + local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), CastRange, Radius, CastPoint, 0 ); + if ( locationAoE.count >= 2 ) then + return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function AbilityUsageThink() + + -- Check if we're already using an ability + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced() ) + then + return + end + + ComboMana=GetComboMana() + AttackRange=npcBot:GetAttackRange() + ManaPercentage=npcBot:GetMana()/npcBot:GetMaxMana() + HealthPercentage=npcBot:GetHealth()/npcBot:GetMaxHealth() + + cast=ability_item_usage_generic.ConsiderAbility(AbilitiesReal,Consider) + ---------------------------------debug-------------------------------------------- + if(debugmode==true) + then + ability_item_usage_generic.PrintDebugInfo(AbilitiesReal,cast) + end + ability_item_usage_generic.UseAbility(AbilitiesReal,cast) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_necrolyte.lua b/ability_item_usage_necrolyte.lua index 2e5843fa..e8218be2 100644 --- a/ability_item_usage_necrolyte.lua +++ b/ability_item_usage_necrolyte.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -16,14 +16,6 @@ local AbilitiesReal ={} ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) -local AbilitiesReal = -{ - npcBot:GetAbilityByName(Abilities[1]), - npcBot:GetAbilityByName(Abilities[2]), - npcBot:GetAbilityByName(Abilities[3]), - npcBot:GetAbilityByName(Abilities[4]) -} - local AbilityToLevelUp= { Abilities[3], @@ -57,13 +49,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_nevermore.lua b/ability_item_usage_nevermore.lua index 38b2004b..a5b592d7 100644 --- a/ability_item_usage_nevermore.lua +++ b/ability_item_usage_nevermore.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,16 +47,16 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() - return Talents[4] + return Talents[5] end, function() return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_night_stalker.lua b/ability_item_usage_night_stalker.lua index a918a31f..dd234e72 100644 --- a/ability_item_usage_night_stalker.lua +++ b/ability_item_usage_night_stalker.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -53,7 +53,7 @@ local TalentTree={ return Talents[3] end, function() - return Talents[6] + return Talents[5] end, function() return Talents[7] diff --git a/ability_item_usage_ogre_magi.lua b/ability_item_usage_ogre_magi.lua index 654898fe..f9083f5f 100644 --- a/ability_item_usage_ogre_magi.lua +++ b/ability_item_usage_ogre_magi.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false diff --git a/ability_item_usage_omniknight.lua b/ability_item_usage_omniknight.lua index 97cbbb34..36345cdf 100644 --- a/ability_item_usage_omniknight.lua +++ b/ability_item_usage_omniknight.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,7 +50,7 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[6] diff --git a/ability_item_usage_oracle.lua b/ability_item_usage_oracle.lua index 69090799..8f89e013 100644 --- a/ability_item_usage_oracle.lua +++ b/ability_item_usage_oracle.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,13 +50,13 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_phantom_assassin.lua b/ability_item_usage_phantom_assassin.lua index 9f0571dd..7f9f08ec 100644 --- a/ability_item_usage_phantom_assassin.lua +++ b/ability_item_usage_phantom_assassin.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -55,7 +55,7 @@ local TalentTree={ return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_pudge.lua b/ability_item_usage_pudge.lua new file mode 100644 index 00000000..2670014a --- /dev/null +++ b/ability_item_usage_pudge.lua @@ -0,0 +1,88 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[2], + Abilities[1], + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[2], + Abilities[2], + "talent", + Abilities[3], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[2] + end, + function() + return Talents[3] + end, + function() + return Talents[6] + end, + function() + return Talents[8] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_pugna.lua b/ability_item_usage_pugna.lua index 9cd6aae9..0f5b4519 100644 --- a/ability_item_usage_pugna.lua +++ b/ability_item_usage_pugna.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,16 +47,16 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_queenofpain.lua b/ability_item_usage_queenofpain.lua index ef761c23..6d585485 100644 --- a/ability_item_usage_queenofpain.lua +++ b/ability_item_usage_queenofpain.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -47,16 +47,16 @@ local AbilityToLevelUp= local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_razor.lua b/ability_item_usage_razor.lua index 1b4a1fc2..34e7a630 100644 --- a/ability_item_usage_razor.lua +++ b/ability_item_usage_razor.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local npcBot = GetBot() @@ -49,13 +49,13 @@ local TalentTree={ return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[6] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_riki.lua b/ability_item_usage_riki.lua index 554ec3bf..a49527bb 100644 --- a/ability_item_usage_riki.lua +++ b/ability_item_usage_riki.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,7 +46,7 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] diff --git a/ability_item_usage_sand_king.lua b/ability_item_usage_sand_king.lua new file mode 100644 index 00000000..b4ee9ab5 --- /dev/null +++ b/ability_item_usage_sand_king.lua @@ -0,0 +1,88 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 New Structure +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +-------------------------------------- +-- General Initialization +-------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) +require(GetScriptDirectory() .. "/ability_item_usage_generic") + +local debugmode=false +local npcBot = GetBot() +local Talents ={} +local Abilities ={} +local AbilitiesReal ={} + +ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) + +local AbilityToLevelUp= +{ + Abilities[1], + Abilities[3], + Abilities[1], + Abilities[2], + Abilities[1], + Abilities[4], + Abilities[1], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + Abilities[4], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], + "nil", + Abilities[4], + "nil", + "talent", + "nil", + "nil", + "nil", + "nil", + "talent", +} + +local TalentTree={ + function() + return Talents[1] + end, + function() + return Talents[3] + end, + function() + return Talents[5] + end, + function() + return Talents[7] + end +} + +-- check skill build vs current level +utility.CheckAbilityBuild(AbilityToLevelUp) + +function AbilityLevelUpThink() + ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp,TalentTree) +end + +-------------------------------------- +-- Ability Usage Thinking +-------------------------------------- +local cast={} cast.Desire={} cast.Target={} cast.Type={} +local Consider ={} +local CanCast={utility.NCanCast,utility.NCanCast,utility.NCanCast,utility.UCanCast} +local enemyDisabled=utility.enemyDisabled + +function GetComboDamage() + return ability_item_usage_generic.GetComboDamage(AbilitiesReal) +end + +function GetComboMana() + return ability_item_usage_generic.GetComboMana(AbilitiesReal) +end + +function CourierUsageThink() + ability_item_usage_generic.CourierUsageThink() +end \ No newline at end of file diff --git a/ability_item_usage_shadow_shaman.lua b/ability_item_usage_shadow_shaman.lua index 99a137fe..4a3e65f2 100644 --- a/ability_item_usage_shadow_shaman.lua +++ b/ability_item_usage_shadow_shaman.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,7 +46,7 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] @@ -55,7 +55,7 @@ local TalentTree={ return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_silencer.lua b/ability_item_usage_silencer.lua index 1442a9b3..0d08fc11 100644 --- a/ability_item_usage_silencer.lua +++ b/ability_item_usage_silencer.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -27,16 +27,16 @@ local AbilitiesReal = local AbilityToLevelUp= { Abilities[1], + Abilities[3], Abilities[2], - Abilities[1], Abilities[3], - Abilities[1], - Abilities[4], - Abilities[1], Abilities[3], + Abilities[4], Abilities[3], + Abilities[1], + Abilities[1], "talent", - Abilities[3], + Abilities[1], Abilities[4], Abilities[2], Abilities[2], @@ -54,13 +54,13 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[7] diff --git a/ability_item_usage_skeleton_king.lua b/ability_item_usage_skeleton_king.lua index 0718d2f8..cd713646 100644 --- a/ability_item_usage_skeleton_king.lua +++ b/ability_item_usage_skeleton_king.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,10 +46,10 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] diff --git a/ability_item_usage_skywrath_mage.lua b/ability_item_usage_skywrath_mage.lua index 39df8ee0..dc09f391 100644 --- a/ability_item_usage_skywrath_mage.lua +++ b/ability_item_usage_skywrath_mage.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -52,10 +52,10 @@ local TalentTree={ return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_slardar.lua b/ability_item_usage_slardar.lua index 4fe28970..8c365af0 100644 --- a/ability_item_usage_slardar.lua +++ b/ability_item_usage_slardar.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -49,7 +49,7 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[6] diff --git a/ability_item_usage_slark.lua b/ability_item_usage_slark.lua index a0e99f86..bc3093de 100644 --- a/ability_item_usage_slark.lua +++ b/ability_item_usage_slark.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,18 +18,18 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { - Abilities[1], - Abilities[3], - Abilities[2], - Abilities[2], - Abilities[2], - Abilities[4], Abilities[2], + Abilities[3], Abilities[1], Abilities[1], - "talent", Abilities[1], Abilities[4], + Abilities[1], + Abilities[2], + Abilities[2], + "talent", + Abilities[2], + Abilities[4], Abilities[3], Abilities[3], "talent", @@ -52,10 +52,10 @@ local TalentTree={ return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_sniper.lua b/ability_item_usage_sniper.lua index 4e42f3d3..498095d4 100644 --- a/ability_item_usage_sniper.lua +++ b/ability_item_usage_sniper.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=utility.debug_mode @@ -50,10 +50,10 @@ local TalentTree={ return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[7] diff --git a/ability_item_usage_spectre.lua b/ability_item_usage_spectre.lua index f7a72723..dec79d2f 100644 --- a/ability_item_usage_spectre.lua +++ b/ability_item_usage_spectre.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -53,7 +53,7 @@ local TalentTree={ return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_spirit_breaker.lua b/ability_item_usage_spirit_breaker.lua index ba2941a9..43405700 100644 --- a/ability_item_usage_spirit_breaker.lua +++ b/ability_item_usage_spirit_breaker.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,17 +18,17 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { - Abilities[3], Abilities[1], - Abilities[2], - Abilities[3], - Abilities[3], - Abilities[4], Abilities[3], + Abilities[2], Abilities[1], Abilities[1], - "talent", + Abilities[4], Abilities[1], + Abilities[3], + Abilities[3], + "talent", + Abilities[3], Abilities[4], Abilities[2], Abilities[2], @@ -46,13 +46,13 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[7] diff --git a/ability_item_usage_sven.lua b/ability_item_usage_sven.lua index cb97cc1a..636ad433 100644 --- a/ability_item_usage_sven.lua +++ b/ability_item_usage_sven.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,7 +50,7 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] diff --git a/ability_item_usage_tidehunter.lua b/ability_item_usage_tidehunter.lua index 96936f94..fb8e694e 100644 --- a/ability_item_usage_tidehunter.lua +++ b/ability_item_usage_tidehunter.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,16 +46,16 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } -------------------------------------- diff --git a/ability_item_usage_tiny.lua b/ability_item_usage_tiny.lua index 2a6aafb1..7047982c 100644 --- a/ability_item_usage_tiny.lua +++ b/ability_item_usage_tiny.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,17 +18,17 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { + Abilities[3], Abilities[2], Abilities[1], - Abilities[2], Abilities[1], Abilities[1], - Abilities[2], + Abilities[4], Abilities[1], Abilities[2], - Abilities[4], + Abilities[2], "talent", - Abilities[3], + Abilities[2], Abilities[4], Abilities[3], Abilities[3], @@ -50,10 +50,10 @@ local TalentTree={ return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() return Talents[8] diff --git a/ability_item_usage_treant.lua b/ability_item_usage_treant.lua index 76fb684f..f9670fab 100644 --- a/ability_item_usage_treant.lua +++ b/ability_item_usage_treant.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -51,7 +51,7 @@ local TalentTree={ return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_undying.lua b/ability_item_usage_undying.lua index 4db56ba0..6f99f4cd 100644 --- a/ability_item_usage_undying.lua +++ b/ability_item_usage_undying.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,10 +46,10 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] diff --git a/ability_item_usage_ursa.lua b/ability_item_usage_ursa.lua index 2ad09358..e85164b7 100644 --- a/ability_item_usage_ursa.lua +++ b/ability_item_usage_ursa.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,10 +46,10 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() - return Talents[4] + return Talents[3] end, function() return Talents[5] diff --git a/ability_item_usage_vengefulspirit.lua b/ability_item_usage_vengefulspirit.lua index 59b0d4ec..7e695aa2 100644 --- a/ability_item_usage_vengefulspirit.lua +++ b/ability_item_usage_vengefulspirit.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -49,7 +49,7 @@ local TalentTree={ return Talents[2] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[6] diff --git a/ability_item_usage_venomancer.lua b/ability_item_usage_venomancer.lua index f5ba487e..e65ec9a4 100644 --- a/ability_item_usage_venomancer.lua +++ b/ability_item_usage_venomancer.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -18,22 +18,22 @@ ability_item_usage_generic.InitAbility(Abilities,AbilitiesReal,Talents) local AbilityToLevelUp= { - Abilities[2], Abilities[1], Abilities[2], Abilities[1], Abilities[2], - Abilities[4], - Abilities[2], Abilities[1], + Abilities[4], Abilities[1], + Abilities[3], + Abilities[3], "talent", Abilities[3], Abilities[4], Abilities[3], - Abilities[3], + Abilities[2], "talent", - Abilities[3], + Abilities[2], "nil", Abilities[4], "nil", @@ -46,13 +46,13 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[2] + return Talents[1] end, function() return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_viper.lua b/ability_item_usage_viper.lua index 977ef8d7..a4a2e3c9 100644 --- a/ability_item_usage_viper.lua +++ b/ability_item_usage_viper.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -46,16 +46,16 @@ local AbilityToLevelUp= } local TalentTree={ function() - return Talents[1] + return Talents[2] end, function() return Talents[4] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } -------------------------------------- diff --git a/ability_item_usage_warlock.lua b/ability_item_usage_warlock.lua index 46498c9f..dd2edf4b 100644 --- a/ability_item_usage_warlock.lua +++ b/ability_item_usage_warlock.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -53,10 +53,10 @@ local TalentTree={ return Talents[4] end, function() - return Talents[6] + return Talents[5] end, function() - return Talents[7] + return Talents[8] end } diff --git a/ability_item_usage_windrunner.lua b/ability_item_usage_windrunner.lua index d2efde2d..f471c213 100644 --- a/ability_item_usage_windrunner.lua +++ b/ability_item_usage_windrunner.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -23,12 +23,12 @@ local AbilityToLevelUp= Abilities[2], Abilities[3], Abilities[2], - Abilities[3], + Abilities[1], Abilities[2], Abilities[3], Abilities[4], "talent", - Abilities[1], + Abilities[3], Abilities[4], Abilities[1], Abilities[1], @@ -50,10 +50,10 @@ local TalentTree={ return Talents[1] end, function() - return Talents[4] + return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() return Talents[8] diff --git a/ability_item_usage_winter_wyvern.lua b/ability_item_usage_winter_wyvern.lua index f10897c9..14f3fcee 100644 --- a/ability_item_usage_winter_wyvern.lua +++ b/ability_item_usage_winter_wyvern.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,13 +50,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[6] end, function() - return Talents[7] + return Talents[8] end } @@ -524,7 +524,7 @@ Consider[4]=function() do if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) then - if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and #allys<#enemys) + if ( CanCast[abilityNumber]( npcEnemy ) and not enemyDisabled(npcEnemy) and #allys<=1) then return BOT_ACTION_DESIRE_HIGH, npcEnemy; end diff --git a/ability_item_usage_witch_doctor.lua b/ability_item_usage_witch_doctor.lua index 0b06012a..11b76757 100644 --- a/ability_item_usage_witch_doctor.lua +++ b/ability_item_usage_witch_doctor.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -50,13 +50,13 @@ local TalentTree={ return Talents[1] end, function() - return Talents[3] + return Talents[4] end, function() return Talents[5] end, function() - return Talents[8] + return Talents[7] end } diff --git a/ability_item_usage_zuus.lua b/ability_item_usage_zuus.lua index 97c6ae59..267f48c1 100644 --- a/ability_item_usage_zuus.lua +++ b/ability_item_usage_zuus.lua @@ -5,7 +5,7 @@ -------------------------------------- -- General Initialization -------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) require(GetScriptDirectory() .. "/ability_item_usage_generic") local debugmode=false @@ -52,10 +52,10 @@ local TalentTree={ return Talents[3] end, function() - return Talents[5] + return Talents[6] end, function() - return Talents[7] + return Talents[8] end } diff --git a/bot_beastmaster.lua b/bot_beastmaster.lua new file mode 100644 index 00000000..57b7d556 --- /dev/null +++ b/bot_beastmaster.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if minionutils.IsHawk(hMinionUnit:GetUnitName()) then + minionutils.HawkThink(hMinionUnit); + elseif minionutils.IsMinionWithSkill(hMinionUnit:GetUnitName()) then + minionutils.MinionWithSkillThink(hMinionUnit); + else + minionutils.IllusionThink(hMinionUnit); + end + end +end \ No newline at end of file diff --git a/bot_brewmaster.lua b/bot_brewmaster.lua new file mode 100644 index 00000000..94a79d6c --- /dev/null +++ b/bot_brewmaster.lua @@ -0,0 +1,446 @@ +local bot = GetBot(); + +local RB = Vector(-7200,-6666) +local DB = Vector(7137,6548) + +local CastDMDesire = 0 +local CastCYDesire = 0 +local CastWWDesire = 0 +local CastHBDesire = 0 +local AttackDesire = 0 +local MoveDesire = 0 +local RetreatDesire = 0 +local castSCDesire = 0; +local castCHDesire = 0; +local radius = 1000; + +function MinionThink( hMinionUnit ) + +if not hMinionUnit:IsNull() and hMinionUnit ~= nil then + + if string.find(hMinionUnit:GetUnitName(), "npc_dota_brewmaster_storm") then + + if ( hMinionUnit:IsUsingAbility() ) then return end + + abilityDM = hMinionUnit:GetAbilityByName( "brewmaster_storm_dispel_magic" ); + abilityCY = hMinionUnit:GetAbilityByName( "brewmaster_storm_cyclone" ); + abilityWW = hMinionUnit:GetAbilityByName( "brewmaster_storm_wind_walk" ); + abilityCH = hMinionUnit:GetAbilityByName( "brewmaster_drunken_haze" ); + CastDMDesire, DMLocation = ConsiderDM(hMinionUnit); + CastCYDesire, CYTarget = ConsiderCY(hMinionUnit); + castCHDesire, castCHTarget = ConsiderCorrosiveHaze(hMinionUnit); + CastWWDesire = ConsiderWW(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + + if ( CastDMDesire > 0 ) + then + hMinionUnit:Action_UseAbilityOnLocation( abilityDM, DMLocation ); + return; + end + + if ( CastCYDesire > 0 ) + then + hMinionUnit:Action_UseAbilityOnEntity( abilityCY, CYTarget ); + return; + end + + if ( castCHDesire > 0 ) + then + hMinionUnit:Action_UseAbilityOnEntity( abilityCH, castCHTarget ); + return; + end + + if ( CastWWDesire > 0 ) + then + hMinionUnit:Action_UseAbility( abilityWW ); + return; + end + + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + end + + if string.find(hMinionUnit:GetUnitName(), "npc_dota_brewmaster_earth") then + + if ( hMinionUnit:IsUsingAbility() ) then return end + + abilityHB = hMinionUnit:GetAbilityByName( "brewmaster_earth_hurl_boulder" ); + abilitySC = hMinionUnit:GetAbilityByName( "brewmaster_thunder_clap" ); + castSCDesire = ConsiderSlithereenCrush(hMinionUnit); + CastHBDesire, HBTarget = ConsiderHB(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if ( castSCDesire > 0 ) + then + hMinionUnit:Action_UseAbility( abilitySC ); + return; + end + if ( CastHBDesire > 0 ) + then + hMinionUnit:Action_UseAbilityOnEntity( abilityHB, HBTarget ); + return; + end + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + end + + if string.find(hMinionUnit:GetUnitName(), "npc_dota_brewmaster_fire") then + + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + end + + if hMinionUnit:IsIllusion() then + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( bot:GetLocation() + RandomVector(100) ); + return + end + + end +end + +end + +function CanCastCYOnTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable(); +end +function CanCastSlithereenCrushOnTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable(); +end + +function IsDisabled(npcTarget) + if npcTarget:IsRooted( ) or npcTarget:IsStunned( ) or npcTarget:IsHexed( ) or npcTarget:IsNightmared( ) or npcTarget:IsSilenced( ) then + return true; + end + return false; +end + +function GetFountain(enemy) + if enemy then + if GetTeam( ) == TEAM_DIRE then + return RB; + else + return DB; + end + else + if GetTeam( ) == TEAM_DIRE then + return DB; + else + return RB; + end + end +end + +function ConsiderAttacking(hMinionUnit) + local radius = 1600; + local target = nil; + + if IsDisabled(hMinionUnit) then + return BOT_ACTION_DESIRE_NONE, nil; + end + + local units = hMinionUnit:GetNearbyHeroes(radius, true, BOT_MODE_NONE); + + if units == nil or #units == 0 then + units = hMinionUnit:GetNearbyLaneCreeps(radius, true); + end + if units == nil or #units == 0 then + units = hMinionUnit:GetNearbyTowers(radius, true); + end + if units == nil or #units == 0 then + units = hMinionUnit:GetNearbyBarracks(radius, true); + end + + if units ~= nil and #units > 0 then + target = GetWeakestUnit(units); + if target ~= nil then + return BOT_ACTION_DESIRE_HIGH, target; + end + end + + return BOT_ACTION_DESIRE_NONE, nil; +end + +function GetWeakestUnit(tableNearbyEntity) + local target = nil; + local minHP = 100000; + for _,unit in pairs(tableNearbyEntity) + do + local HP = unit:GetHealth(); + if not unit:IsInvulnerable() and HP < minHP then + target = unit; + minHP = HP; + end + end + return target; +end + +function ConsiderMove(hMinionUnit) + local radius = 1000; + local NearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( radius, true, BOT_MODE_NONE ); + local NearbyEnemyCreeps = hMinionUnit:GetNearbyLaneCreeps( radius, true ); + local NearbyEnemyTowers = hMinionUnit:GetNearbyTowers( radius, true ); + local NearbyEnemyBarracks = hMinionUnit:GetNearbyBarracks( radius, true ); + + if #NearbyEnemyHeroes == 0 and #NearbyEnemyCreeps == 0 and #NearbyEnemyTowers == 0 and #NearbyEnemyBarracks == 0 then + local ancient = GetAncient(GetOpposingTeam()); + if ancient ~= nil then + return BOT_ACTION_DESIRE_HIGH, ancient:GetLocation(); + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function ConsiderRetreat(hMinionUnit) + local tableNearbyAllyHeroes = hMinionUnit:GetNearbyHeroes( 1200, false, BOT_MODE_NONE ); + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( 1200, true, BOT_MODE_NONE ); + if #tableNearbyAllyHeroes == 0 and #tableNearbyEnemyHeroes >= 2 then + local location = GetFountain(false) + return BOT_ACTION_DESIRE_LOW, location; + end + return BOT_ACTION_DESIRE_NONE, 0; +end + + +function ConsiderDM(hMinionUnit) + + if not abilityDM:IsFullyCastable() or abilityDM:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = abilityDM:GetCastRange(); + local nRadius = abilityDM:GetSpecialValueInt( "radius" ); + + local Allies = hMinionUnit:GetNearbyHeroes( nCastRange + nRadius, false, BOT_MODE_NONE ); + for _,Ally in pairs( Allies ) + do + if ( IsDisabled(Ally) ) + then + return BOT_ACTION_DESIRE_LOW, Ally:GetLocation(); + end + end + + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( 1000, true, BOT_MODE_NONE ); + if #tableNearbyEnemyHeroes == 1 and tableNearbyEnemyHeroes[1]:HasModifier("modifier_brewmaster_storm_cyclone") then + return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyHeroes[1]:GetLocation() + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderCY(hMinionUnit) + + if not abilityCY:IsFullyCastable() or abilityCY:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = abilityCY:GetCastRange(); + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = hMinionUnit:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 1 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + local EnemyHeroes = hMinionUnit:GetNearbyHeroes( 1000, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( EnemyHeroes ) + do + if ( CanCastCYOnTarget( npcEnemy ) and not IsDisabled(npcEnemy) ) + then + local nDamage = npcEnemy:GetEstimatedDamageToTarget( false, hMinionUnit, 3.0, DAMAGE_TYPE_ALL ); + if ( nDamage > nMostDangerousDamage ) + then + nMostDangerousDamage = nDamage; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_LOW, npcMostDangerousEnemy; + end + end + + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( 2*nCastRange, true, BOT_MODE_NONE ); + + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy; + end + end + + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( CanCastCYOnTarget( npcEnemy ) and not IsDisabled(npcEnemy) and npcEnemy:GetActiveMode() == BOT_MODE_RETREAT ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderCorrosiveHaze(hMinionUnit) + + if not abilityCH:IsFullyCastable() or abilityCH:IsHidden() or not bot:HasScepter() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = abilityCH:GetCastRange(); + + -- If we're in a teamfight, use it on the scariest enemy + local tableNearbyAttackingAlliedHeroes = hMinionUnit:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK ); + if ( #tableNearbyAttackingAlliedHeroes >= 1 ) + then + + local npcMostDangerousEnemy = nil; + local nMostDangerousDamage = 0; + + local EnemyHeroes = hMinionUnit:GetNearbyHeroes( 1000, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( EnemyHeroes ) + do + if ( CanCastCYOnTarget( npcEnemy ) ) + then + local nDamage = npcEnemy:GetEstimatedDamageToTarget( false, hMinionUnit, 3.0, DAMAGE_TYPE_ALL ); + if ( nDamage > nMostDangerousDamage ) + then + nMostDangerousDamage = nDamage; + npcMostDangerousEnemy = npcEnemy; + end + end + end + + if ( npcMostDangerousEnemy ~= nil ) + then + return BOT_ACTION_DESIRE_LOW, npcMostDangerousEnemy; + end + end + + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange + 200, true, BOT_MODE_NONE ); + + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( CanCastCYOnTarget( npcEnemy ) and npcEnemy:GetActiveMode() == BOT_MODE_RETREAT ) + then + return BOT_ACTION_DESIRE_LOW, npcEnemy; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderWW(hMinionUnit) + + if not abilityWW:IsFullyCastable() or abilityWW:IsHidden() then + return BOT_ACTION_DESIRE_NONE; + end + + local tableNearbyEnemyCreeps = hMinionUnit:GetNearbyLaneCreeps( 1300, true ); + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( 700, true, BOT_MODE_NONE ); + + if ( #tableNearbyEnemyHeroes == 0 and #tableNearbyEnemyCreeps == 0 ) then + return BOT_ACTION_DESIRE_HIGH; + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderSlithereenCrush(hMinionUnit) + + -- Make sure it's castable + if ( not abilitySC:IsFullyCastable() or abilitySC:IsHidden() or not bot:HasScepter() ) then + return BOT_ACTION_DESIRE_NONE; + end + + -- Get some of its values + local nRadius = abilitySC:GetSpecialValueInt( "radius" ); + local nCastRange = 0; + local nDamage = abilitySC:GetSpecialValueInt("damage"); + + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius-150, true, BOT_MODE_NONE ); + + if ( tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 1 ) then + return BOT_ACTION_DESIRE_HIGH; + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderHB(hMinionUnit) + + if not abilityHB:IsFullyCastable() or abilityHB:IsHidden() then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local nCastRange = abilityHB:GetCastRange(); + + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( 1200, true, BOT_MODE_NONE ); + + local target = GetWeakestUnit(tableNearbyEnemyHeroes); + + if target ~= nil then + return BOT_ACTION_DESIRE_HIGH, target; + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end diff --git a/bot_broodmother.lua b/bot_broodmother.lua new file mode 100644 index 00000000..5813c29c --- /dev/null +++ b/bot_broodmother.lua @@ -0,0 +1,70 @@ +local npcBot = GetBot(); +local MoveDesire = 0; +local AttackDesire = 0; +local npcBotAR = 200; +local ProxRange = 1300; + +function MinionThink( hMinionUnit ) + if not hMinionUnit:IsNull() and hMinionUnit ~= nil and ( hMinionUnit:GetUnitName() == 'npc_dota_broodmother_spiderling' or hMinionUnit:IsIllusion() ) then + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + + if (AttackDesire > 0) + then + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + hMinionUnit:Action_MoveToLocation( Location ); + return + end + end +end + +function CanBeAttacked( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsInvulnerable(); +end + +function GetBase() + local RB = Vector(-7200,-6666) + local DB = Vector(7137,6548) + if GetTeam( ) == TEAM_DIRE then + return DB; + elseif GetTeam( ) == TEAM_RADIANT then + return RB; + end +end + +function ConsiderAttacking(hMinionUnit) + + local target = npcBot:GetTarget(); + local AR = hMinionUnit:GetAttackRange(); + local AD = hMinionUnit:GetAttackDamage(); + + if target == nil or target:IsTower() or target:IsBuilding() then + target = npcBot:GetAttackTarget(); + end + + if target ~= nil and GetUnitToUnitDistance(hMinionUnit, npcBot) <= ProxRange then + return BOT_ACTION_DESIRE_MODERATE, target; + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function ConsiderMove(hMinionUnit) + if not npcBot:IsAlive() then + local loc = GetBase() + return BOT_ACTION_DESIRE_HIGH, loc; + end + + local target = npcBot:GetAttackTarget() + + if target == nil or ( target ~= nil and not CanBeAttacked(target) ) or GetUnitToUnitDistance(hMinionUnit, npcBot) > ProxRange then + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetXUnitsTowardsLocation(GetAncient(GetOpposingTeam()):GetLocation(), 200); + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end diff --git a/bot_chen.lua b/bot_chen.lua new file mode 100644 index 00000000..29036781 --- /dev/null +++ b/bot_chen.lua @@ -0,0 +1,5 @@ +local MinionUtility = dofile( GetScriptDirectory().."/MinionUtility" ) + +function MinionThink( hMinionUnit ) + MinionUtility.MinionThink(hMinionUnit) +end diff --git a/bot_earth_spirit.lua b/bot_earth_spirit.lua new file mode 100644 index 00000000..e6db55c8 --- /dev/null +++ b/bot_earth_spirit.lua @@ -0,0 +1,49 @@ +local bot = GetBot(); +local AttackDesire = 0; +local MoveDesire = 0; + + +function MinionThink( hMinionUnit ) + + if hMinionUnit:IsIllusion() then + local target = bot:GetAttackTarget() + AttackDesire, Target = ConsiderAttack(hMinionUnit, target) + MoveDesire, Location = ConsiderMove(hMinionUnit, target) + + if AttackDesire > 0 then + hMinionUnit:Action_AttackUnit(Target, true) + return + end + + if MoveDesire > 0 then + hMinionUnit:Action_MoveToLocation(Location) + return + end + + end + +end + +function ConsiderAttack(hMinionUnit, target) + + if target ~= nil and target:IsAlive() and not target:IsInvulnerable() then + return BOT_ACTION_DESIRE_HIGH, target; + end + + return BOT_ACTION_DESIRE_NONE, nil; + +end + +function ConsiderMove(hMinionUnit, target) + + if AttackDesire > 0 then + return BOT_ACTION_DESIRE_NONE, 0; + end + + if target == nil then + return BOT_ACTION_DESIRE_HIGH, bot:GetLocation(); + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end \ No newline at end of file diff --git a/bot_elder_titan.lua b/bot_elder_titan.lua new file mode 100644 index 00000000..a697b496 --- /dev/null +++ b/bot_elder_titan.lua @@ -0,0 +1,179 @@ +local castSCDesire = 0; +local ReturnDesire = 0; +local MoveDesire = 0; +local ReturnTime = 0; +local npcBot = GetBot(); +local abilityW = ""; +local abilitySC = ""; +local radius = 350; +local RB = Vector(-7200,-6666) +local DB = Vector(7137,6548) +local castReturn = false; + +print(GetBot():GetUnitName()) + +function MinionThink( hMinionUnit ) + + if npcBot:HasModifier('modifier_elder_titan_ancestral_spirit_buff') or not npcBot:IsAlive() then + castReturn = false; + end + + if hMinionUnit:GetUnitName() == "npc_dota_elder_titan_ancestral_spirit" and npcBot:IsAlive() then + + if abilitySC == "" then abilitySC = npcBot:GetAbilityByName( "elder_titan_echo_stomp" ); end + + if abilityW == "" then abilityW = npcBot:GetAbilityByName('elder_titan_ancestral_spirit'); end + + if not abilityW:IsHidden() then return; end + + if abilitySC:IsInAbilityPhase() or npcBot:IsChanneling() then npcBot:Action_ClearActions(false) return end + + if ( npcBot:IsUsingAbility() or npcBot:IsCastingAbility() ) then return end + + abilityRT = npcBot:GetAbilityByName( "elder_titan_return_spirit" ); + MoveDesire, Location = ConsiderMove(hMinionUnit); + ReturnDesire = Return(hMinionUnit); + castSCDesire = ConsiderSlithereenCrush(hMinionUnit); + + if ( castSCDesire > 0 ) + then + --print("Stomp") + npcBot:Action_UseAbility( abilitySC ); + return; + end + + if ( ReturnDesire > 0 and castReturn == false ) + then + --print("Return") + castReturn = true; + npcBot:Action_UseAbility( abilityRT ); + return; + end + + if ( MoveDesire > 0 ) + then + --print("Move") + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + end + +end + +function CanCastSlithereenCrushOnTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable(); +end + +function Return(hMinionUnit) + + if castSCDesire > 0 + then + return BOT_ACTION_DESIRE_NONE; + end + + if abilityRT:IsFullyCastable() and not abilityRT:IsHidden() and abilitySC:GetCooldownTimeRemaining() > 4 then + return BOT_ACTION_DESIRE_MODERATE; + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderSlithereenCrush(hMinionUnit) + + -- Make sure it's castable + if ( not abilitySC:IsFullyCastable() ) then + return BOT_ACTION_DESIRE_NONE; + end + + + -- Get some of its values + local nRadius = abilitySC:GetSpecialValueInt( "radius" ); + local nCastRange = 0; + local nDamage = abilitySC:GetSpecialValueInt( "stomp_damage" ); + + -------------------------------------- + -- Mode based usage + -------------------------------------- + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcEnemy:IsChanneling() ) + then + return BOT_ACTION_DESIRE_LOW; + end + end + + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE ); + for _,npcEnemy in pairs( tableNearbyEnemyHeroes ) + do + if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) + then + if ( CanCastSlithereenCrushOnTarget( npcEnemy ) ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + end + + if ( npcBot:GetActiveMode() == BOT_MODE_FARM or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or + npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT ) + then + local locationAoE = hMinionUnit:FindAoELocation( true, false, hMinionUnit:GetLocation(), 0, nRadius, 0, 1500 ); + if ( locationAoE.count >= 3 and GetUnitToLocationDistance( hMinionUnit, locationAoE.targetloc ) < nRadius - 200 and npcBot:GetMana()/npcBot:GetMaxMana() > 0.6 ) then + return BOT_ACTION_DESIRE_LOW; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) + then + local npcTarget = npcBot:GetTarget(); + + if ( npcTarget ~= nil and npcTarget:IsHero() ) + then + if ( CanCastSlithereenCrushOnTarget( npcTarget ) and GetUnitToUnitDistance( hMinionUnit, npcTarget ) < nRadius - 200 ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderMove(hMinionUnit) + + if ( castSCDesire > 0 or ReturnDesire > 0 or castReturn == true ) + then + return BOT_ACTION_DESIRE_NONE, 0; + end + + local NearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( radius, true, BOT_MODE_NONE ); + + if NearbyEnemyHeroes[1] == nil then + local location = RB; + if GetTeam( ) == TEAM_RADIANT then + location = DB; + end + return BOT_ACTION_DESIRE_MODERATE, location; + else + return BOT_ACTION_DESIRE_MODERATE, NearbyEnemyHeroes[1]:GetLocation(); + end + + return BOT_ACTION_DESIRE_NONE, 0; +end \ No newline at end of file diff --git a/bot_enchantress.lua b/bot_enchantress.lua new file mode 100644 index 00000000..29036781 --- /dev/null +++ b/bot_enchantress.lua @@ -0,0 +1,5 @@ +local MinionUtility = dofile( GetScriptDirectory().."/MinionUtility" ) + +function MinionThink( hMinionUnit ) + MinionUtility.MinionThink(hMinionUnit) +end diff --git a/bot_gyrocopter.lua b/bot_gyrocopter.lua new file mode 100644 index 00000000..63a54fd7 --- /dev/null +++ b/bot_gyrocopter.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.CantBeControlled(hMinionUnit:GetUnitName()) then + minionutils.CantBeControlledThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_lone_druid.lua b/bot_lone_druid.lua new file mode 100644 index 00000000..02c9ccfe --- /dev/null +++ b/bot_lone_druid.lua @@ -0,0 +1,256 @@ +--local minion = dofile( GetScriptDirectory().."/MinionUtility" ) +local npcBot = GetBot(); +local castRTDesire = 0; +local castSRDesire = 0; +local RetreatDesire = 0; +local MoveDesire = 0; +local AttackDesire = 0; +local npcBotAR = 0; +local ProxRange = 1300; +local bearState = ""; + +local BearItem = { + "item_stout_shield", + "item_boots", + "item_orb_of_venom", + "item_blight_stone" +} +function MinionThink( hMinionUnit ) + +if not hMinionUnit:IsNull() and hMinionUnit ~= nil then + if string.find(hMinionUnit:GetUnitName(), "npc_dota_lone_druid_bear") then + + if hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() == 1.0 then bearState = "" end + + if ( hMinionUnit:IsUsingAbility() or hMinionUnit:IsChanneling() or not hMinionUnit:IsAlive() ) then return end + + abilityFG = npcBot:GetAbilityByName( "lone_druid_spirit_bear" ); + abilityES = npcBot:GetAbilityByName( "lone_druid_savage_roar" ); + abilityRT = hMinionUnit:GetAbilityByName( "lone_druid_spirit_bear_return" ); + abilitySR = hMinionUnit:GetAbilityByName( "lone_druid_savage_roar_bear" ); + + BearPurchaseItem(hMinionUnit) + + castRTDesire = ConsiderReturn(hMinionUnit); + castSRDesire = ConsiderSavageRoar(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + if hMinionUnit:GetMaxHealth() - hMinionUnit:GetHealth() > 150 and not hMinionUnit:HasModifier('modifier_tango_heal') then + local tango = hMinionUnit:FindItemSlot('item_tango_single'); + if tango >= 0 and tango <= 5 then + local item = hMinionUnit:GetItemInSlot(tango); + if item ~= nil and item:IsFullyCastable() then + local tree = hMinionUnit:GetNearbyTrees(1200); + if tree[1] ~= nil then + --print("use tango"..tostring(tango).." "..item:GetName().." "..tostring(tree[1])) + hMinionUnit:Action_UseAbilityOnTree(item, tree[1]); + return + end + end + end + end + + if castRTDesire > 0 then + hMinionUnit:Action_UseAbility(abilityRT); + return + end + if castSRDesire > 0 then + hMinionUnit:Action_UseAbility(abilitySR); + return + end + if ( RetreatDesire > 0 ) + then + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + if bearState == "" and RetreatDesire == BOT_ACTION_DESIRE_HIGH then bearState = "retreat"; end + return; + end + if (AttackDesire > 0) + then + --print("attack") + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + --print("move") + hMinionUnit:Action_MoveToLocation( Location ); + return + end + elseif hMinionUnit:IsIllusion() then + if (AttackDesire > 0) + then + --print("attack") + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if (MoveDesire > 0) + then + --print("move") + hMinionUnit:Action_MoveToLocation( Location ); + return + end + end +end + +end + + +function BearPurchaseItem(hMinionUnit) + + if ( BearItem == nil or #(BearItem) == 0 ) then + hMinionUnit:SetNextItemPurchaseValue( 0 ); + return; + end + local sNextItem = BearItem[1]; + hMinionUnit:SetNextItemPurchaseValue( GetItemCost( sNextItem ) ); + if ( npcBot:GetGold() >= GetItemCost( sNextItem ) and hMinionUnit:DistanceFromFountain() < 100 ) then + if ( hMinionUnit:ActionImmediate_PurchaseItem( sNextItem ) == PURCHASE_ITEM_SUCCESS ) then + table.remove( BearItem, 1 ); + end + end +end + +function CanCastSavageRoarOnTarget( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable(); +end + +function CanBeAttacked( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsInvulnerable(); +end + +function ConsiderReturn(hMinionUnit) + + if bearState == "retreat" or RetreatDesire > 0 or abilityFG:GetLevel() < 2 or not abilityRT:IsFullyCastable() or abilityRT:IsHidden() then + return BOT_ACTION_DESIRE_NONE; + end + + local bearDist = GetUnitToUnitDistance(hMinionUnit, npcBot); + local pHP = hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth(); + + if hMinionUnit:DistanceFromFountain() > 0 and bearDist > ProxRange then + return BOT_ACTION_DESIRE_MODERATE + end + + if hMinionUnit:DistanceFromFountain() == 0 and pHP == 1.0 and bearDist > ProxRange then + return BOT_ACTION_DESIRE_MODERATE + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderSavageRoar(hMinionUnit) + + if abilityES:GetLevel() < 1 or not abilitySR:IsFullyCastable() or abilitySR:IsHidden() then + return BOT_ACTION_DESIRE_NONE; + end + + -- Get some of its values + local nRadius = abilitySR:GetSpecialValueInt( "radius" ); + + -- If we're seriously retreating, see if we can land a stun on someone who's damaged us recently + if ( ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) or RetreatDesire > 0 ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + if ( tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 1 ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + + -- If we're going after someone + if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or + npcBot:GetActiveMode() == BOT_MODE_GANK or + npcBot:GetActiveMode() == BOT_MODE_ATTACK or + npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY + ) + then + local npcTarget = npcBot:GetTarget(); + if ( npcTarget ~= nil and npcTarget:IsHero() ) + then + if ( CanCastSavageRoarOnTarget( npcTarget ) and GetUnitToUnitDistance( npcTarget, hMinionUnit ) < nRadius and + ( npcTarget:IsChanneling() or npcTarget:IsUsingAbility() ) ) + then + return BOT_ACTION_DESIRE_MODERATE; + end + end + end + + if hMinionUnit:WasRecentlyDamagedByAnyHero( 2.0 ) and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.45 then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + if tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 1 then + return BOT_ACTION_DESIRE_MODERATE; + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function GetBase() + local RB = Vector(-7200,-6666) + local DB = Vector(7137,6548) + if GetTeam( ) == TEAM_DIRE then + return DB; + elseif GetTeam( ) == TEAM_RADIANT then + return RB; + end +end + +function ConsiderRetreat(hMinionUnit) + + if hMinionUnit:DistanceFromFountain() == 0 and hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 1.0 then + local loc = GetBase() + return BOT_ACTION_DESIRE_HIGH, loc; + end + + local mode = npcBot:GetActiveMode(); + + if not ( mode == BOT_MODE_ATTACK or mode == BOT_MODE_DEFEND_ALLY ) and ( hMinionUnit:WasRecentlyDamagedByAnyHero(2.0) or + hMinionUnit:WasRecentlyDamagedByTower(2.0) ) then + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetXUnitsTowardsLocation(GetAncient(GetTeam()):GetLocation(), 200); + end + + if hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth() < 0.20 then + local loc = GetBase() + return BOT_ACTION_DESIRE_HIGH, loc; + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderAttacking(hMinionUnit) + + local target = npcBot:GetTarget(); + local AR = hMinionUnit:GetAttackRange(); + local OAR = npcBot:GetAttackRange(); + local AD = hMinionUnit:GetAttackDamage(); + + if target == nil or target:IsTower() or target:IsBuilding() then + target = npcBot:GetAttackTarget(); + end + + if target ~= nil and GetUnitToUnitDistance(hMinionUnit, npcBot) <= ProxRange then + return BOT_ACTION_DESIRE_MODERATE, target; + end + + return BOT_ACTION_DESIRE_NONE, nil; +end + +function ConsiderMove(hMinionUnit) + + local target = npcBot:GetAttackTarget(); + + if target == nil or ( target ~= nil and not CanBeAttacked(target) ) or (target ~= nil and GetUnitToUnitDistance(target, npcBot) > ProxRange) then + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetXUnitsTowardsLocation(GetAncient(GetOpposingTeam()):GetLocation(), 200); + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + + + \ No newline at end of file diff --git a/bot_monkey_king.lua b/bot_monkey_king.lua new file mode 100644 index 00000000..698c771a --- /dev/null +++ b/bot_monkey_king.lua @@ -0,0 +1,25 @@ +local bot = GetBot(); +local trueMK = nil; +for i, id in pairs(GetTeamPlayers(GetTeam())) do + if IsPlayerBot(id) and GetSelectedHeroName(id) == 'npc_dota_hero_monkey_king' then + local member = GetTeamMember(i); + if member ~= nil then + trueMK = member; + end + end +end +--print(tostring(trueMK)) +--print(tostring(GetBot())..tostring(GetBot():GetLocation())..tostring(GetBot():IsInvulnerable())..tostring(trueMK==GetBot())) +if trueMK == nil or bot == trueMK then + print("Bot MK "..tostring(bot).." is true MK") + return; +end +print("Bot MK "..tostring(bot).." isn't true MK") + +function MinionThink( hMinionUnit ) + +end + +function Think() + +end \ No newline at end of file diff --git a/bot_pugna.lua b/bot_pugna.lua new file mode 100644 index 00000000..654d0129 --- /dev/null +++ b/bot_pugna.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.IsAttackingWard(hMinionUnit:GetUnitName()) then + minionutils.AttackingWardThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_shadow_shaman.lua b/bot_shadow_shaman.lua new file mode 100644 index 00000000..654d0129 --- /dev/null +++ b/bot_shadow_shaman.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.IsAttackingWard(hMinionUnit:GetUnitName()) then + minionutils.AttackingWardThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_techies.lua b/bot_techies.lua new file mode 100644 index 00000000..7b13c504 --- /dev/null +++ b/bot_techies.lua @@ -0,0 +1,28 @@ +local npcBot = nil; + +function MinionThink( hMinionUnit ) + + if npcBot == nil then npcBot = GetBot(); end + + if not hMinionUnit:IsNull() and hMinionUnit ~= nil then + if hMinionUnit:GetUnitName() == "npc_dota_techies_remote_mine" then + + local abilityOO = hMinionUnit:GetAbilityByName( "techies_remote_mines_self_detonate" ); + + local nRadius = abilityOO:GetSpecialValueInt( "radius" ); + local nearbyHeroes = hMinionUnit:GetNearbyHeroes(nRadius - 100, true, BOT_MODE_NONE) + + if nearbyHeroes ~= nil and #nearbyHeroes >= 1 then + hMinionUnit:Action_UseAbility(abilityOO) + return + end + + local nearbyCreeps = hMinionUnit:GetNearbyLaneCreeps(nRadius - 50, true) + if nearbyCreeps ~= nil and #nearbyCreeps >= 5 then + hMinionUnit:Action_UseAbility(abilityOO) + return + end + + end + end +end diff --git a/bot_templar_assassin.lua b/bot_templar_assassin.lua new file mode 100644 index 00000000..7a250ed4 --- /dev/null +++ b/bot_templar_assassin.lua @@ -0,0 +1,23 @@ +local npcBot = nil; + +function MinionThink( hMinionUnit ) + + if npcBot == nil then npcBot = GetBot(); end + +if not hMinionUnit:IsNull() and hMinionUnit ~= nil then + if hMinionUnit:GetUnitName() == "npc_dota_templar_assassin_psionic_trap" and hMinionUnit ~= nil and hMinionUnit:GetHealth() > 0 + then + local abilitySTP = hMinionUnit:GetAbilityByName( "templar_assassin_self_trap" ); + local abilityTP = npcBot:GetAbilityByName( "templar_assassin_trap" ); + local nRadius = abilitySTP:GetSpecialValueInt("trap_radius"); + local nRange = npcBot:GetAttackRange(); + local Enemies = hMinionUnit:GetNearbyHeroes(nRadius, true, BOT_MODE_NONE); + local Allies = hMinionUnit:GetNearbyHeroes(2*nRadius, false, BOT_MODE_NONE); + local distance = GetUnitToUnitDistance(npcBot, hMinionUnit); + if Enemies ~= nil and #Enemies >=1 and ( distance < 800 or Allies ~= nil ) and abilityTP:IsFullyCastable() then + npcBot:Action_UseAbility( abilityTP ); + return; + end + end +end +end diff --git a/bot_undying.lua b/bot_undying.lua new file mode 100644 index 00000000..63a54fd7 --- /dev/null +++ b/bot_undying.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.CantBeControlled(hMinionUnit:GetUnitName()) then + minionutils.CantBeControlledThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_venomancer.lua b/bot_venomancer.lua new file mode 100644 index 00000000..654d0129 --- /dev/null +++ b/bot_venomancer.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.IsAttackingWard(hMinionUnit:GetUnitName()) then + minionutils.AttackingWardThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_visage.lua b/bot_visage.lua new file mode 100644 index 00000000..7889c4f9 --- /dev/null +++ b/bot_visage.lua @@ -0,0 +1,191 @@ +local npcBot = GetBot(); +local castSFDesire = 0; +local MoveDesire = 0; +local AttackDesire = 0; +local npcBotAR = 0; +local ProxRange = 1500; +function MinionThink( hMinionUnit ) + +if not hMinionUnit:IsNull() and hMinionUnit ~= nil then + if string.find(hMinionUnit:GetUnitName(), "npc_dota_visage_familiar") then + if ( hMinionUnit:IsUsingAbility() or not hMinionUnit:IsAlive() ) then return end + + abilitySF = hMinionUnit:GetAbilityByName( "visage_summon_familiars_stone_form" ); + castSFDesire = ConsiderStoneForm(hMinionUnit); + AttackDesire, AttackTarget = ConsiderAttacking(hMinionUnit); + MoveDesire, Location = ConsiderMove(hMinionUnit); + RetreatDesire, RetreatLocation = ConsiderRetreat(hMinionUnit); + + + if castSFDesire > 0 then + --print("sf") + hMinionUnit:Action_UseAbility(abilitySF); + return + end + if (AttackDesire > 0) + then + --print("attack") + hMinionUnit:Action_AttackUnit( AttackTarget, true ); + return + end + if ( RetreatDesire > 0 ) + then + --print("retreat") + hMinionUnit:Action_MoveToLocation( RetreatLocation ); + return; + end + if (MoveDesire > 0) + then + --print("move") + hMinionUnit:Action_MoveToLocation( Location ); + return + end + + end +end + +end + +function CanBeAttacked( npcTarget ) + return npcTarget:CanBeSeen() and not npcTarget:IsInvulnerable(); +end + +function IsDisabled(npcTarget) + if npcTarget:IsRooted( ) or npcTarget:IsStunned( ) or npcTarget:IsHexed( ) or npcTarget:IsNightmared( ) or npcTarget:IsSilenced( ) then + return true; + end + return false; +end + +function GetBase() + local RB = Vector(-7200,-6666) + local DB = Vector(7137,6548) + if GetTeam( ) == TEAM_DIRE then + return DB; + elseif GetTeam( ) == TEAM_RADIANT then + return RB; + end +end + +function ConsiderStoneForm(hMinionUnit) + + if not abilitySF:IsFullyCastable() or + hMinionUnit:HasModifier("modifier_visage_summon_familiars_stone_form_buff") + then + return BOT_ACTION_DESIRE_NONE; + end + + local nRadius = abilitySF:GetSpecialValueInt("stun_radius"); + local nHealth = hMinionUnit:GetHealth() / hMinionUnit:GetMaxHealth(); + local SAStack = 0; + local npcModifier = hMinionUnit:NumModifiers(); + for i = 0, npcModifier + do + if hMinionUnit:GetModifierName(i) == "modifier_visage_summon_familiars_damage_charge" then + SAStack = hMinionUnit:GetModifierStackCount(i); + break; + end + end + + if nHealth < 0.55 then + return BOT_ACTION_DESIRE_HIGH; + end + + if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) + then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + if tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 1 then + return BOT_ACTION_DESIRE_HIGH; + end + end + + if SAStack < 1 then + local tableNearbyEnemyHeroes = hMinionUnit:GetNearbyHeroes( nRadius, true, BOT_MODE_NONE ); + if tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 1 then + return BOT_ACTION_DESIRE_HIGH; + end + end + + return BOT_ACTION_DESIRE_NONE; + +end + +function ConsiderAttacking(hMinionUnit) + + if hMinionUnit:HasModifier("modifier_visage_summon_familiars_stone_form_buff") + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + local target = npcBot:GetTarget(); + local AR = hMinionUnit:GetAttackRange(); + local OAR = npcBot:GetAttackRange(); + local AD = hMinionUnit:GetAttackDamage(); + + if target == nil or target:IsTower() or target:IsBuilding() then + target = npcBot:GetAttackTarget(); + end + + if target ~= nil and CanBeAttacked(target) and GetUnitToUnitDistance(hMinionUnit, npcBot) <= ProxRange then + return BOT_ACTION_DESIRE_MODERATE, target; + end + + local enemies = npcBot:GetNearbyHeroes(1300, true, BOT_MODE_NONE); + if not npcBot:IsAlive() or ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and #enemies == 0 ) then + local followTarget = nil; + local closest = nil; + local closestDist = 100000; + for i,id in pairs(GetTeamPlayers(GetTeam())) do + local member = GetTeamMember(i); + if member ~= nil and member:IsAlive() then + local target = member:GetTarget(); + if target == nil or target:IsTower() or target:IsBuilding() then + target = member:GetAttackTarget(); + end + local distance = GetUnitToUnitDistance(member, hMinionUnit); + if target ~= nil and GetUnitToUnitDistance(member, target) <= ProxRange and distance < closestDist then + closest = member; + closestDist = distance; + followTarget = target; + end + end + end + if closest ~= nil and followTarget ~= nil then + return BOT_ACTION_DESIRE_MODERATE, followTarget; + end + end + + return BOT_ACTION_DESIRE_NONE, 0; +end + +function ConsiderMove(hMinionUnit) + + if hMinionUnit:HasModifier("modifier_visage_summon_familiars_stone_form_buff") or not npcBot:IsAlive() or GetUnitToUnitDistance(hMinionUnit, npcBot) < 100 + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + local target = npcBot:GetAttackTarget() + + if target == nil or ( target ~= nil and not CanBeAttacked(target) ) or (target ~= nil and GetUnitToUnitDistance(target, npcBot) > ProxRange) then + return BOT_ACTION_DESIRE_MODERATE, npcBot:GetXUnitsTowardsLocation(GetAncient(GetOpposingTeam()):GetLocation(), 200); + end + + return BOT_ACTION_DESIRE_NONE, 0; + +end + +function ConsiderRetreat(hMinionUnit) + + if hMinionUnit:HasModifier("modifier_visage_summon_familiars_stone_form_buff") or hMinionUnit:DistanceFromFountain() == 0 + then + return BOT_ACTION_DESIRE_NONE, {}; + end + + if not npcBot:IsAlive() then + local loc = GetBase() + return BOT_ACTION_DESIRE_HIGH, loc; + end + + return BOT_ACTION_DESIRE_NONE, 0; +end diff --git a/bot_weaver.lua b/bot_weaver.lua new file mode 100644 index 00000000..63a54fd7 --- /dev/null +++ b/bot_weaver.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.CantBeControlled(hMinionUnit:GetUnitName()) then + minionutils.CantBeControlledThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/bot_zuus.lua b/bot_zuus.lua new file mode 100644 index 00000000..654d0129 --- /dev/null +++ b/bot_zuus.lua @@ -0,0 +1,13 @@ +local minionutils = dofile( GetScriptDirectory().."/NewMinionUtil" ) + +function MinionThink( hMinionUnit ) + if minionutils.IsValidUnit(hMinionUnit) then + if hMinionUnit:IsIllusion() then + minionutils.IllusionThink(hMinionUnit); + elseif minionutils.IsAttackingWard(hMinionUnit:GetUnitName()) then + minionutils.AttackingWardThink(hMinionUnit); + else + return; + end + end +end \ No newline at end of file diff --git a/hero_selection.lua b/hero_selection.lua index 1502a365..7c7d24d2 100644 --- a/hero_selection.lua +++ b/hero_selection.lua @@ -3,6 +3,7 @@ -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- local role = require(GetScriptDirectory() .. "/RoleUtility") +local bnUtil = require(GetScriptDirectory() .. "/BotNameUtility"); hero_pool={"npc_dota_hero_abaddon", "npc_dota_hero_abyssal_underlord", @@ -175,7 +176,7 @@ hero_pool_my={ -- "npc_dota_hero_ember_spirit", -- "npc_dota_hero_shadow_shaman", - "npc_dota_hero_centaur", + -- "npc_dota_hero_centaur", -- "npc_dota_hero_venomancer", -- "npc_dota_hero_doom_bringer", -- "npc_dota_hero_slardar", @@ -245,6 +246,32 @@ hero_pool_my={ -- "npc_dota_hero_ancient_apparition", -- "npc_dota_hero_arc_warden", -- "npc_dota_hero_gyrocopter", + + "npc_dota_hero_batrider", + "npc_dota_hero_beastmaster", + "npc_dota_hero_bounty_hunter", + "npc_dota_hero_brewmaster", + "npc_dota_hero_broodmother", + + "npc_dota_hero_chen", + "npc_dota_hero_dark_seer", + "npc_dota_hero_disruptor", + "npc_dota_hero_earth_spirit", + "npc_dota_hero_elder_titan", + + + "npc_dota_hero_enchantress", + "npc_dota_hero_enigma", + "npc_dota_hero_keeper_of_the_light", + "npc_dota_hero_lycan", + "npc_dota_hero_magnataur", + + "npc_dota_hero_medusa", + "npc_dota_hero_mirana", + "npc_dota_hero_monkey_king", + "npc_dota_hero_pudge", + "npc_dota_hero_sand_king", + } allBotHeroes={ "npc_dota_hero_zuus", @@ -331,6 +358,30 @@ allBotHeroes={ "npc_dota_hero_ancient_apparition", "npc_dota_hero_arc_warden", "npc_dota_hero_gyrocopter", + + "npc_dota_hero_batrider", + "npc_dota_hero_beastmaster", + "npc_dota_hero_bounty_hunter", + "npc_dota_hero_brewmaster", + "npc_dota_hero_broodmother", + + "npc_dota_hero_chen", + "npc_dota_hero_dark_seer", + "npc_dota_hero_disruptor", + "npc_dota_hero_earth_spirit", + "npc_dota_hero_elder_titan", + + "npc_dota_hero_enchantress", + "npc_dota_hero_enigma", + "npc_dota_hero_keeper_of_the_light", + "npc_dota_hero_lycan", + "npc_dota_hero_magnataur", + + "npc_dota_hero_medusa", + "npc_dota_hero_mirana", + "npc_dota_hero_monkey_king", + "npc_dota_hero_pudge", + "npc_dota_hero_sand_king", } hero_pool_1={ "npc_dota_hero_chaos_knight", @@ -348,6 +399,8 @@ hero_pool_1={ "npc_dota_hero_spectre", --"npc_dota_hero_antimage", "npc_dota_hero_gyrocopter", + "npc_dota_hero_lycan", + "npc_dota_hero_monkey_king", } hero_pool_2={ "npc_dota_hero_zuus", @@ -362,6 +415,7 @@ hero_pool_2={ "npc_dota_hero_death_prophet", "npc_dota_hero_alchemist", "npc_dota_hero_arc_warden", + "npc_dota_hero_medusa", } hero_pool_3={ "npc_dota_hero_huskar", @@ -382,6 +436,14 @@ hero_pool_3={ "npc_dota_hero_tiny", "npc_dota_hero_windrunner", "npc_dota_hero_abyssal_underlord", + "npc_dota_hero_batrider", + "npc_dota_hero_beastmaster", + "npc_dota_hero_brewmaster", + "npc_dota_hero_broodmother", + "npc_dota_hero_dark_seer", + "npc_dota_hero_enchantress", + "npc_dota_hero_magnataur", + "npc_dota_hero_mirana", } hero_pool_4={ "npc_dota_hero_skywrath_mage", @@ -394,6 +456,11 @@ hero_pool_4={ "npc_dota_hero_bane", "npc_dota_hero_earthshaker", "npc_dota_hero_omniknight", + "npc_dota_hero_bounty_hunter", + --"npc_dota_hero_elder_titan", + "npc_dota_hero_enigma", + "npc_dota_hero_pudge", + "npc_dota_hero_sand_king", } hero_pool_5={ "npc_dota_hero_ogre_magi", @@ -408,11 +475,19 @@ hero_pool_5={ "npc_dota_hero_winter_wyvern", "npc_dota_hero_warlock", "npc_dota_hero_ancient_apparition", + "npc_dota_hero_chen", + --"npc_dota_hero_disruptor", + "npc_dota_hero_earth_spirit", + "npc_dota_hero_keeper_of_the_light", } hero_pool_new={hero_pool_2,hero_pool_1,hero_pool_4,hero_pool_5,hero_pool_3} ---------------------------------------------------------------------------------------------------- local debug_mode=false +function GetBotNames() + return bnUtil.GetDota2Team(); +end + function Think() if GetGameMode() == GAMEMODE_AP then diff --git a/item_purchase_abaddon.lua b/item_purchase_abaddon.lua index 8e1a2c28..d5c02fd2 100644 --- a/item_purchase_abaddon.lua +++ b/item_purchase_abaddon.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_abyssal_underlord.lua b/item_purchase_abyssal_underlord.lua index e1f27621..cf38e25a 100644 --- a/item_purchase_abyssal_underlord.lua +++ b/item_purchase_abyssal_underlord.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_alchemist.lua b/item_purchase_alchemist.lua index cabe2967..39c4dd64 100644 --- a/item_purchase_alchemist.lua +++ b/item_purchase_alchemist.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_ancient_apparition.lua b/item_purchase_ancient_apparition.lua index af95d6d0..eb41bb02 100644 --- a/item_purchase_ancient_apparition.lua +++ b/item_purchase_ancient_apparition.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_antimage.lua b/item_purchase_antimage.lua index d163ab15..4f8d32a5 100644 --- a/item_purchase_antimage.lua +++ b/item_purchase_antimage.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_arc_warden.lua b/item_purchase_arc_warden.lua index a7104096..cc107e9a 100644 --- a/item_purchase_arc_warden.lua +++ b/item_purchase_arc_warden.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_axe.lua b/item_purchase_axe.lua index 3a129249..3d5b8675 100644 --- a/item_purchase_axe.lua +++ b/item_purchase_axe.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_bane.lua b/item_purchase_bane.lua index 634c1e8c..8b673c43 100644 --- a/item_purchase_bane.lua +++ b/item_purchase_bane.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_batrider.lua b/item_purchase_batrider.lua new file mode 100644 index 00000000..7595c3fa --- /dev/null +++ b/item_purchase_batrider.lua @@ -0,0 +1,45 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_wind_lace", + "item_branches", + "item_branches", + "item_boots", + "item_ring_of_regen", --绿鞋 + "item_circlet", + "item_magic_stick", --大魔棒 + "item_gauntlets", + "item_circlet", + "item_recipe_bracer", + "item_wind_lace", + "item_sobi_mask", + "item_recipe_ancient_janggo", --战鼓 + "item_blink", --跳刀 + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + "item_wind_lace", + "item_void_stone", + "item_staff_of_wizardry", + "item_recipe_cyclone", --风杖 + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_beastmaster.lua b/item_purchase_beastmaster.lua new file mode 100644 index 00000000..a3c73855 --- /dev/null +++ b/item_purchase_beastmaster.lua @@ -0,0 +1,51 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_wind_lace", + "item_ring_of_regen", --绿鞋 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_chainmail", + "item_sobi_mask", + "item_blight_stone", --勋章 + "item_talisman_of_evasion", --大勋章 + + "item_staff_of_wizardry", + "item_belt_of_strength", + "item_recipe_necronomicon", + "item_recipe_necronomicon", + "item_recipe_necronomicon", --死灵书 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_ring_of_protection", + "item_sobi_mask", + "item_lifesteal", --祭品 + + "item_platemail", + "item_ring_of_health", + "item_void_stone", + "item_energy_booster", --清莲宝珠 + "item_vitality_booster", + "item_vitality_booster", + "item_reaver", --龙心7.06 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_bloodseeker.lua b/item_purchase_bloodseeker.lua index 5bdb3887..00a91db9 100644 --- a/item_purchase_bloodseeker.lua +++ b/item_purchase_bloodseeker.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_bounty_hunter.lua b/item_purchase_bounty_hunter.lua new file mode 100644 index 00000000..bc64b4a4 --- /dev/null +++ b/item_purchase_bounty_hunter.lua @@ -0,0 +1,56 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_energy_booster", --秘法鞋 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_circlet", + "item_ring_of_protection", + "item_recipe_urn_of_shadows", + "item_infused_raindrop", --骨灰盒7.06 + "item_vitality_booster", + "item_wind_lace", + "item_recipe_spirit_vessel", --大骨灰7.07 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_chainmail", + "item_recipe_buckler" , + "item_branches", + "item_recipe_mekansm", --梅肯 + + "item_recipe_guardian_greaves", --卫士胫甲 + + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + + "item_ring_of_health", + "item_void_stone", + "item_platemail", + "item_energy_booster", --清莲宝珠 + + "item_platemail", + "item_chainmail", + "item_hyperstone", + "item_recipe_assault", --强袭 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_brewmaster.lua b/item_purchase_brewmaster.lua new file mode 100644 index 00000000..14cc4eef --- /dev/null +++ b/item_purchase_brewmaster.lua @@ -0,0 +1,49 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_blades_of_attack", + "item_blades_of_attack", --相位 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_ring_of_protection", + "item_sobi_mask", + "item_lifesteal", --祭品 + + "item_blink", --跳刀 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_ring_of_health", + "item_void_stone", + "item_platemail", + "item_energy_booster", --清莲宝珠 + + "item_platemail", + "item_chainmail", + "item_hyperstone", + "item_recipe_assault", --强袭 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_bristleback.lua b/item_purchase_bristleback.lua index db67d463..7e121366 100644 --- a/item_purchase_bristleback.lua +++ b/item_purchase_bristleback.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_broodmother.lua b/item_purchase_broodmother.lua new file mode 100644 index 00000000..e503b9c2 --- /dev/null +++ b/item_purchase_broodmother.lua @@ -0,0 +1,51 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_belt_of_strength", + "item_gloves", --假腿 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_ring_of_protection", + "item_sobi_mask", + "item_lifesteal", --祭品 + + "item_chainmail", + "item_sobi_mask", + "item_blight_stone", --勋章 + + "item_blade_of_alacrity", + "item_blade_of_alacrity", + "item_robe", + "item_recipe_diffusal_blade", --散失刀 + + "item_talisman_of_evasion", --大勋章 + + "item_mithril_hammer", + "item_mithril_hammer", + "item_blight_stone", --黯灭 + + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_centaur.lua b/item_purchase_centaur.lua index c49465a5..83aeccf9 100644 --- a/item_purchase_centaur.lua +++ b/item_purchase_centaur.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_chaos_knight.lua b/item_purchase_chaos_knight.lua index 2479e0a7..9aad31ee 100644 --- a/item_purchase_chaos_knight.lua +++ b/item_purchase_chaos_knight.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_chen.lua b/item_purchase_chen.lua new file mode 100644 index 00000000..d942d616 --- /dev/null +++ b/item_purchase_chen.lua @@ -0,0 +1,59 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_wind_lace", + "item_branches", + "item_branches", + "item_boots", + "item_circlet", + "item_magic_stick", --大魔棒 + "item_energy_booster", --秘法鞋 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_gloves", + "item_recipe_helm_of_the_dominator", --支配 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_chainmail", + "item_recipe_buckler" , + "item_branches", + "item_recipe_mekansm", --梅肯 + "item_recipe_guardian_greaves", --卫士胫甲 + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_wind_lace", + "item_void_stone", + "item_staff_of_wizardry", + "item_recipe_cyclone", --风杖 + + "item_mystic_staff", + "item_ultimate_orb", + "item_void_stone", --羊刀 + +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.BuyCourier() --购买信使 对于5号位保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_clinkz.lua b/item_purchase_clinkz.lua index 1bad5218..1204c074 100644 --- a/item_purchase_clinkz.lua +++ b/item_purchase_clinkz.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_crystal_maiden.lua b/item_purchase_crystal_maiden.lua index 70916623..897141f4 100644 --- a/item_purchase_crystal_maiden.lua +++ b/item_purchase_crystal_maiden.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_dark_seer.lua b/item_purchase_dark_seer.lua new file mode 100644 index 00000000..84b288e5 --- /dev/null +++ b/item_purchase_dark_seer.lua @@ -0,0 +1,56 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_energy_booster", --秘法鞋 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_cloak", + "item_ring_of_health", + "item_ring_of_regen", --挑战 + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_recipe_pipe" , --笛子 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_chainmail", + "item_recipe_buckler" , + "item_branches", + "item_recipe_mekansm", --梅肯 + "item_recipe_guardian_greaves", --卫士胫甲 + + "item_blink", --跳刀 + + "item_platemail", + "item_ring_of_health", + "item_void_stone", + "item_energy_booster", --清莲宝珠 + + "item_platemail", + "item_mystic_staff", + "item_recipe_shivas_guard" , --希瓦 + + "item_vitality_booster", + "item_vitality_booster", + "item_reaver", --龙心7.06 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_dazzle.lua b/item_purchase_dazzle.lua index 3a36c267..13e9ca31 100644 --- a/item_purchase_dazzle.lua +++ b/item_purchase_dazzle.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_death_prophet.lua b/item_purchase_death_prophet.lua index 15f382fe..753008fc 100644 --- a/item_purchase_death_prophet.lua +++ b/item_purchase_death_prophet.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_disruptor.lua b/item_purchase_disruptor.lua new file mode 100644 index 00000000..ec6d67d6 --- /dev/null +++ b/item_purchase_disruptor.lua @@ -0,0 +1,52 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_wind_lace", + "item_branches", + "item_branches", + "item_boots", + "item_ring_of_regen", --绿鞋 + "item_circlet", + "item_magic_stick", --大魔棒 + + "item_circlet", + "item_ring_of_protection", + "item_recipe_urn_of_shadows", + "item_infused_raindrop", --骨灰盒7.06 + + "item_cloak", + "item_shadow_amulet", --微光 + + "item_vitality_booster", + "item_wind_lace", + "item_recipe_spirit_vessel", --大骨灰7.07 + + + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_mystic_staff", + "item_ultimate_orb", + "item_void_stone", --羊刀 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.BuyCourier() --购买信使 对于5号位保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_doom_bringer.lua b/item_purchase_doom_bringer.lua index 22b0fda0..8ec59658 100644 --- a/item_purchase_doom_bringer.lua +++ b/item_purchase_doom_bringer.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { @@ -36,9 +36,10 @@ local ItemsToBuy = "item_ogre_axe", "item_blade_of_alacrity", --蓝杖 - "item_vitality_booster", - "item_vitality_booster", - "item_reaver", --龙心7.06 + "item_hyperstone", + "item_platemail", + "item_chainmail", + "item_recipe_assault", --强袭 } utility.checkItemBuild(ItemsToBuy) diff --git a/item_purchase_dragon_knight.lua b/item_purchase_dragon_knight.lua index 540c0c81..8bb0c046 100644 --- a/item_purchase_dragon_knight.lua +++ b/item_purchase_dragon_knight.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_drow_ranger.lua b/item_purchase_drow_ranger.lua index f7255638..01908494 100644 --- a/item_purchase_drow_ranger.lua +++ b/item_purchase_drow_ranger.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_earth_spirit.lua b/item_purchase_earth_spirit.lua new file mode 100644 index 00000000..03716d61 --- /dev/null +++ b/item_purchase_earth_spirit.lua @@ -0,0 +1,51 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_orb_of_venom", --毒球 + "item_branches", + "item_branches", + "item_boots", + "item_wind_lace", + "item_ring_of_regen", --绿鞋 + "item_circlet", + "item_magic_stick", --大魔棒 + + "item_circlet", + "item_ring_of_protection", + "item_recipe_urn_of_shadows", + "item_infused_raindrop", --骨灰盒7.06 + + "item_cloak", + "item_shadow_amulet", --微光 + + "item_vitality_booster", + "item_wind_lace", + "item_recipe_spirit_vessel", --大骨灰7.07 + + "item_blink", --跳刀 + + "item_staff_of_wizardry", + "item_void_stone", + "item_recipe_cyclone", + "item_wind_lace", --风杖 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.BuyCourier() --购买信使 对于5号位保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_earthshaker.lua b/item_purchase_earthshaker.lua index 4a55d325..41ed5acf 100644 --- a/item_purchase_earthshaker.lua +++ b/item_purchase_earthshaker.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_elder_titan.lua b/item_purchase_elder_titan.lua new file mode 100644 index 00000000..1b4f5c7d --- /dev/null +++ b/item_purchase_elder_titan.lua @@ -0,0 +1,54 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_energy_booster", --秘法鞋 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_cloak", + "item_ring_of_health", + "item_ring_of_regen", --挑战 + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_recipe_pipe" , --笛子 + + "item_gauntlets", + "item_circlet", + "item_recipe_bracer", + "item_gauntlets", + "item_circlet", + "item_recipe_bracer", + "item_staff_of_wizardry", + "item_recipe_rod_of_atos", --阿托斯7.06 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_platemail", + "item_mystic_staff", + "item_recipe_shivas_guard" , --希瓦 + + "item_vitality_booster", + "item_vitality_booster", + "item_reaver", --龙心7.06 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_ember_spirit.lua b/item_purchase_ember_spirit.lua index ee4039ee..9d1c5553 100644 --- a/item_purchase_ember_spirit.lua +++ b/item_purchase_ember_spirit.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_enchantress.lua b/item_purchase_enchantress.lua new file mode 100644 index 00000000..6820b235 --- /dev/null +++ b/item_purchase_enchantress.lua @@ -0,0 +1,57 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_orb_of_venom"; + "item_branches", + "item_branches", + + "item_boots", + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_blades_of_attack", + "item_blades_of_attack", --相位 + + "item_cloak", + "item_ring_of_health", + "item_ring_of_regen", --挑战 + + "item_boots_of_elves", + "item_boots_of_elves", + "item_ogre_axe", --魔龙枪 + "item_ring_of_health", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推7.06 + "item_recipe_hurricane_pike", --大推推 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_recipe_pipe" , --笛子 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_mystic_staff", + "item_ultimate_orb", + "item_void_stone", --羊刀 + + "item_hyperstone", + "item_javelin", + "item_javelin", --金箍棒7.07 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_enigma.lua b/item_purchase_enigma.lua new file mode 100644 index 00000000..878256cc --- /dev/null +++ b/item_purchase_enigma.lua @@ -0,0 +1,54 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_branches", + "item_branches", + "item_boots", + "item_circlet", + "item_magic_stick", --大魔棒 + "item_energy_booster", --秘法鞋 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_chainmail", + "item_recipe_buckler" , + "item_branches", + "item_recipe_mekansm", --梅肯 + + "item_blink", --跳刀 + + "item_recipe_guardian_greaves", --卫士胫甲 + + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_point_booster", + "item_vitality_booster", + "item_energy_booster", + "item_mystic_staff", --玲珑心 + + "item_mystic_staff", + "item_ultimate_orb", + "item_void_stone", --羊刀 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_faceless_void.lua b/item_purchase_faceless_void.lua index 6878eb3a..d9687e74 100644 --- a/item_purchase_faceless_void.lua +++ b/item_purchase_faceless_void.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_gyrocopter.lua b/item_purchase_gyrocopter.lua index dbff1cb8..5acb26d6 100644 --- a/item_purchase_gyrocopter.lua +++ b/item_purchase_gyrocopter.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_huskar.lua b/item_purchase_huskar.lua index 6ad916db..9eac93e5 100644 --- a/item_purchase_huskar.lua +++ b/item_purchase_huskar.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_jakiro.lua b/item_purchase_jakiro.lua index 741371da..3b436f49 100644 --- a/item_purchase_jakiro.lua +++ b/item_purchase_jakiro.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_juggernaut.lua b/item_purchase_juggernaut.lua index 6fa32082..79c04638 100644 --- a/item_purchase_juggernaut.lua +++ b/item_purchase_juggernaut.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_keeper_of_the_light.lua b/item_purchase_keeper_of_the_light.lua new file mode 100644 index 00000000..32af52f8 --- /dev/null +++ b/item_purchase_keeper_of_the_light.lua @@ -0,0 +1,44 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_clarity", + "item_branches", + "item_branches", + "item_wind_lace", + "item_boots", + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + "item_wind_lace", + "item_ring_of_regen", --绿鞋 + "item_cloak", + "item_shadow_amulet", --微光 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + + "item_ghost", --绿杖 + + "item_mystic_staff", + "item_ultimate_orb", + "item_void_stone", --羊刀 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.BuySupportItem() --购买辅助物品 对于辅助英雄保留这一行 + utility.BuyCourier() --购买信使 对于5号位保留这一行 + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_legion_commander.lua b/item_purchase_legion_commander.lua index 240196ad..3bce6722 100644 --- a/item_purchase_legion_commander.lua +++ b/item_purchase_legion_commander.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_leshrac.lua b/item_purchase_leshrac.lua index bccbd03c..35b1a0af 100644 --- a/item_purchase_leshrac.lua +++ b/item_purchase_leshrac.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_lich.lua b/item_purchase_lich.lua index 403c926d..5bb1ecfc 100644 --- a/item_purchase_lich.lua +++ b/item_purchase_lich.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_life_stealer.lua b/item_purchase_life_stealer.lua index c5a3504b..e7c24b54 100644 --- a/item_purchase_life_stealer.lua +++ b/item_purchase_life_stealer.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_lina.lua b/item_purchase_lina.lua index 5c3e576f..8cc5acfb 100644 --- a/item_purchase_lina.lua +++ b/item_purchase_lina.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_lion.lua b/item_purchase_lion.lua index 4ca32653..bcd502f2 100644 --- a/item_purchase_lion.lua +++ b/item_purchase_lion.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_luna.lua b/item_purchase_luna.lua index 479e3713..a0d84a3b 100644 --- a/item_purchase_luna.lua +++ b/item_purchase_luna.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_lycan.lua b/item_purchase_lycan.lua new file mode 100644 index 00000000..28b24e56 --- /dev/null +++ b/item_purchase_lycan.lua @@ -0,0 +1,52 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_belt_of_strength", + "item_gloves", --假腿 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_ring_of_protection", + "item_sobi_mask", + "item_lifesteal", --祭品 + + "item_staff_of_wizardry", + "item_belt_of_strength", + "item_recipe_necronomicon", + "item_recipe_necronomicon", + "item_recipe_necronomicon", --死灵书 + + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb + + "item_belt_of_strength", + "item_ogre_axe", + "item_recipe_sange", + "item_talisman_of_evasion", --天堂 + + "item_hyperstone", + "item_platemail", + "item_chainmail", + "item_recipe_assault", --强袭 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_magnataur.lua b/item_purchase_magnataur.lua new file mode 100644 index 00000000..7bf24007 --- /dev/null +++ b/item_purchase_magnataur.lua @@ -0,0 +1,47 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_energy_booster", --秘法鞋 + + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_vitality_booster", + "item_ring_of_health", --先锋 + "item_blink", --跳刀 + "item_chainmail", + "item_recipe_buckler" , + "item_branches", + "item_recipe_crimson_guard", --赤红甲 + + "item_ring_of_regen", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推 + + "item_platemail", + "item_mystic_staff", + "item_recipe_shivas_guard" , --希瓦 + + "item_ring_of_health", + "item_void_stone", + "item_ring_of_health", + "item_void_stone", + "item_recipe_refresher", --刷新球 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_medusa.lua b/item_purchase_medusa.lua new file mode 100644 index 00000000..2a9bb7f8 --- /dev/null +++ b/item_purchase_medusa.lua @@ -0,0 +1,59 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_clarity", + "item_branches", + "item_branches", + "item_boots", + "item_circlet", + "item_magic_stick", --大魔棒 + "item_blades_of_attack", + "item_blades_of_attack", --相位 + + "item_slippers", + "item_circlet", + "item_recipe_wraith_band", + "item_ring_of_protection", + "item_sobi_mask", --天鹰 + + "item_lifesteal", + "item_quarterstaff", --疯狂面具7.06 + + "item_ring_of_health", + "item_void_stone", + "item_ultimate_orb", + "item_recipe_sphere", --林肯 + + "item_boots_of_elves", + "item_boots_of_elves", + "item_ogre_axe", --魔龙枪 + "item_ring_of_health", + "item_staff_of_wizardry", + "item_recipe_force_staff", --推推7.06 + "item_recipe_hurricane_pike", --大推推 + + "item_point_booster", + "item_ultimate_orb", + "item_ultimate_orb", --冰眼 + + "item_hyperstone", + "item_javelin", + "item_javelin", --金箍棒7.07 + + "item_quarterstaff", + "item_eagle", + "item_talisman_of_evasion", --蝴蝶 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_mirana.lua b/item_purchase_mirana.lua new file mode 100644 index 00000000..13a75fff --- /dev/null +++ b/item_purchase_mirana.lua @@ -0,0 +1,54 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.3 +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) --导入通用函数库 + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_clarity", + "item_branches", + "item_branches", + "item_boots", + "item_circlet", + "item_magic_stick", --大魔棒 + "item_energy_booster", --秘法鞋 + + "item_slippers", + "item_circlet", + "item_recipe_wraith_band", + "item_ring_of_protection", + "item_sobi_mask", --天鹰 + + "item_blade_of_alacrity", + "item_blade_of_alacrity", + "item_robe", + "item_recipe_diffusal_blade", --散失刀 + + "item_boots_of_elves", + "item_blade_of_alacrity", + "item_recipe_yasha", --夜叉 + "item_ultimate_orb", + "item_recipe_manta", --分身 + + "item_point_booster", + "item_staff_of_wizardry", + "item_ogre_axe", + "item_blade_of_alacrity", --蓝杖 + + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb + + "item_quarterstaff", + "item_eagle", + "item_talisman_of_evasion", --蝴蝶 +} + +utility.checkItemBuild(ItemsToBuy) --检查装备列表 + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) --购买装备 +end \ No newline at end of file diff --git a/item_purchase_monkey_king.lua b/item_purchase_monkey_king.lua new file mode 100644 index 00000000..77aae661 --- /dev/null +++ b/item_purchase_monkey_king.lua @@ -0,0 +1,49 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_stout_shield", + "item_branches", + "item_branches", + "item_boots", + "item_blades_of_attack", + "item_blades_of_attack", --相位 + + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + + "item_quarterstaff", + "item_robe", + "item_sobi_mask", + "item_ogre_axe", --连击刀 + + + "item_shadow_amulet", + "item_claymore", --隐刀 + "item_ultimate_orb", + "item_recipe_silver_edge", --大隐刀 + + "item_ogre_axe", + "item_mithril_hammer", + "item_recipe_black_king_bar", --bkb + + "item_point_booster", + "item_ultimate_orb", + "item_ultimate_orb", --冰眼 + + "item_vitality_booster", + "item_vitality_booster", + "item_reaver", --龙心7.06 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_necrolyte.lua b/item_purchase_necrolyte.lua index 31b7cd12..f1296c25 100644 --- a/item_purchase_necrolyte.lua +++ b/item_purchase_necrolyte.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_nevermore.lua b/item_purchase_nevermore.lua index 512d94e7..27d2b575 100644 --- a/item_purchase_nevermore.lua +++ b/item_purchase_nevermore.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_night_stalker.lua b/item_purchase_night_stalker.lua index 33128696..1925f322 100644 --- a/item_purchase_night_stalker.lua +++ b/item_purchase_night_stalker.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_ogre_magi.lua b/item_purchase_ogre_magi.lua index 1160ebb4..dc9f21e6 100644 --- a/item_purchase_ogre_magi.lua +++ b/item_purchase_ogre_magi.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_omniknight.lua b/item_purchase_omniknight.lua index d482f348..080b27ef 100644 --- a/item_purchase_omniknight.lua +++ b/item_purchase_omniknight.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_oracle.lua b/item_purchase_oracle.lua index b93a674a..39f2debc 100644 --- a/item_purchase_oracle.lua +++ b/item_purchase_oracle.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_phantom_assassin.lua b/item_purchase_phantom_assassin.lua index 3a3e4933..0231b933 100644 --- a/item_purchase_phantom_assassin.lua +++ b/item_purchase_phantom_assassin.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_pudge.lua b/item_purchase_pudge.lua new file mode 100644 index 00000000..8e2d2e73 --- /dev/null +++ b/item_purchase_pudge.lua @@ -0,0 +1,59 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +local utility = require( GetScriptDirectory().."/utility" ) + +local ItemsToBuy = +{ + "item_tango", + "item_flask", + "item_wind_lace", + "item_branches", + "item_branches", + "item_boots", + "item_ring_of_regen", --绿鞋 + "item_magic_stick", + "item_enchanted_mango", --大魔棒7.07 + "item_circlet", + "item_ring_of_protection", + "item_recipe_urn_of_shadows", + "item_infused_raindrop", --骨灰盒7.06 + "item_vitality_booster", + "item_wind_lace", + "item_recipe_spirit_vessel", --大骨灰7.07 + + "item_cloak", + "item_ring_of_health", + "item_ring_of_regen", --挑战 + "item_ring_of_regen", + "item_recipe_headdress", + "item_branches", + "item_recipe_pipe" , --笛子 + + "item_gauntlets", + "item_circlet", + "item_recipe_bracer", + "item_gauntlets", + "item_circlet", + "item_recipe_bracer", + "item_staff_of_wizardry", + "item_recipe_rod_of_atos", --阿托斯7.06 + + "item_vitality_booster", + "item_vitality_booster", + "item_reaver", --龙心7.06 + + "item_ring_of_health", + "item_void_stone", + "item_platemail", + "item_energy_booster", --清莲宝珠 +} + +utility.checkItemBuild(ItemsToBuy) + +function ItemPurchaseThink() + utility.BuyCourier() + utility.BuySupportItem() + utility.ItemPurchase(ItemsToBuy) +end \ No newline at end of file diff --git a/item_purchase_pugna.lua b/item_purchase_pugna.lua index 1cef2ae8..c7610a8c 100644 --- a/item_purchase_pugna.lua +++ b/item_purchase_pugna.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_queenofpain.lua b/item_purchase_queenofpain.lua index 6f54772a..5decd507 100644 --- a/item_purchase_queenofpain.lua +++ b/item_purchase_queenofpain.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_razor.lua b/item_purchase_razor.lua index 5220e9ee..e983fd13 100644 --- a/item_purchase_razor.lua +++ b/item_purchase_razor.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_riki.lua b/item_purchase_riki.lua index 1b520e9f..a4179486 100644 --- a/item_purchase_riki.lua +++ b/item_purchase_riki.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_sand_king.lua b/item_purchase_sand_king.lua index a279843e..77cf0b5d 100644 --- a/item_purchase_sand_king.lua +++ b/item_purchase_sand_king.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { @@ -41,6 +41,6 @@ local ItemsToBuy = utility.checkItemBuild(ItemsToBuy) function ItemPurchaseThink() - utility.BuyCourier() + utility.BuySupportItem() utility.ItemPurchase(ItemsToBuy) end \ No newline at end of file diff --git a/item_purchase_shadow_shaman.lua b/item_purchase_shadow_shaman.lua index 7ab852e9..264a5a50 100644 --- a/item_purchase_shadow_shaman.lua +++ b/item_purchase_shadow_shaman.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_silencer.lua b/item_purchase_silencer.lua index 996b91c4..c37697bd 100644 --- a/item_purchase_silencer.lua +++ b/item_purchase_silencer.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_skeleton_king.lua b/item_purchase_skeleton_king.lua index 34b172e8..46797f97 100644 --- a/item_purchase_skeleton_king.lua +++ b/item_purchase_skeleton_king.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_skywrath_mage.lua b/item_purchase_skywrath_mage.lua index fa928301..12564dd5 100644 --- a/item_purchase_skywrath_mage.lua +++ b/item_purchase_skywrath_mage.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_slardar.lua b/item_purchase_slardar.lua index dc8ca947..6dd0d31a 100644 --- a/item_purchase_slardar.lua +++ b/item_purchase_slardar.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_slark.lua b/item_purchase_slark.lua index 3fa9d9ac..d0dfa7fd 100644 --- a/item_purchase_slark.lua +++ b/item_purchase_slark.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_sniper.lua b/item_purchase_sniper.lua index 7f8fd455..e4344c39 100644 --- a/item_purchase_sniper.lua +++ b/item_purchase_sniper.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_spectre.lua b/item_purchase_spectre.lua index 4c87c7b4..1aaf5329 100644 --- a/item_purchase_spectre.lua +++ b/item_purchase_spectre.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_spirit_breaker.lua b/item_purchase_spirit_breaker.lua index db8aab26..d91c9007 100644 --- a/item_purchase_spirit_breaker.lua +++ b/item_purchase_spirit_breaker.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_sven.lua b/item_purchase_sven.lua index 62bb8836..743eeb21 100644 --- a/item_purchase_sven.lua +++ b/item_purchase_sven.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_tidehunter.lua b/item_purchase_tidehunter.lua index 6f9eea15..22f18d7e 100644 --- a/item_purchase_tidehunter.lua +++ b/item_purchase_tidehunter.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_tiny.lua b/item_purchase_tiny.lua index e5b05184..3bd29e2e 100644 --- a/item_purchase_tiny.lua +++ b/item_purchase_tiny.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_treant.lua b/item_purchase_treant.lua index 3e3cee36..00e0ac73 100644 --- a/item_purchase_treant.lua +++ b/item_purchase_treant.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_undying.lua b/item_purchase_undying.lua index c9565c3f..d97d7cc5 100644 --- a/item_purchase_undying.lua +++ b/item_purchase_undying.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_ursa.lua b/item_purchase_ursa.lua index d7406230..9323dd8f 100644 --- a/item_purchase_ursa.lua +++ b/item_purchase_ursa.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_vengefulspirit.lua b/item_purchase_vengefulspirit.lua index 79fd3d38..62ea6563 100644 --- a/item_purchase_vengefulspirit.lua +++ b/item_purchase_vengefulspirit.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_venomancer.lua b/item_purchase_venomancer.lua index afa33f6c..7c1a98bb 100644 --- a/item_purchase_venomancer.lua +++ b/item_purchase_venomancer.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_viper.lua b/item_purchase_viper.lua index e4e0333a..cb47435e 100644 --- a/item_purchase_viper.lua +++ b/item_purchase_viper.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_warlock.lua b/item_purchase_warlock.lua index 8e34bcd0..a584376f 100644 --- a/item_purchase_warlock.lua +++ b/item_purchase_warlock.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_windrunner.lua b/item_purchase_windrunner.lua index 39278171..812fc2ae 100644 --- a/item_purchase_windrunner.lua +++ b/item_purchase_windrunner.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_winter_wyvern.lua b/item_purchase_winter_wyvern.lua index cb26e76e..33844c3d 100644 --- a/item_purchase_winter_wyvern.lua +++ b/item_purchase_winter_wyvern.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/item_purchase_zuus.lua b/item_purchase_zuus.lua index 189f3af5..fc49bad8 100644 --- a/item_purchase_zuus.lua +++ b/item_purchase_zuus.lua @@ -2,7 +2,7 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require( GetScriptDirectory().."/utility" ) +local utility = require( GetScriptDirectory().."/utility" ) local ItemsToBuy = { diff --git a/mode_laning_generic.lua b/mode_laning_generic.lua index 9b599424..af43f5f8 100644 --- a/mode_laning_generic.lua +++ b/mode_laning_generic.lua @@ -3,7 +3,7 @@ -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- --- function GetDesire() +function GetDesire() -- local npcBot = GetBot(); @@ -11,8 +11,8 @@ -- then -- return 0.3 -- else - -- return 0.25 - -- end + return 0.25 + --end --- end +end ---------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/mode_rune_generic.lua b/mode_rune_generic.lua index ef03283b..2be6dac4 100644 --- a/mode_rune_generic.lua +++ b/mode_rune_generic.lua @@ -5,7 +5,7 @@ ------- _G._savedEnv = getfenv() module( "mode_generic_rune", package.seeall ) -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) local role = require(GetScriptDirectory() .. "/RoleUtility") ---------- local AllRunes={ diff --git a/mode_side_shop_generic.lua b/mode_side_shop_generic.lua index 6e01e607..755f8300 100644 --- a/mode_side_shop_generic.lua +++ b/mode_side_shop_generic.lua @@ -3,7 +3,7 @@ -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) function GetDesire() local npcBot = GetBot(); diff --git a/mode_side_shop_keeper_of_the_light.lua b/mode_side_shop_keeper_of_the_light.lua new file mode 100644 index 00000000..df3e8e1c --- /dev/null +++ b/mode_side_shop_keeper_of_the_light.lua @@ -0,0 +1,69 @@ +---------------------------------------------------------------------------- +-- Ranked Matchmaking AI v1.0a +-- Author: adamqqq Email:adamqqq@163.com +---------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------- +local IsChanneling=false + +function GetDesire() + local npcBot = GetBot(); + local ability = npcBot:GetAbilityByName("keeper_of_the_light_illuminate") + if((npcBot:IsUsingAbility() and (npcBot:GetActiveMode() == BOT_MODE_LANING or npcBot:GetActiveMode() == BOT_MODE_ATTACK) ) or npcBot:IsChanneling()) + then + IsChanneling=true + return 0.95 + else + IsChanneling=false + end + return SideShopGetDesire() +end + +function Think() + if(IsChanneling==true) + then + --print("keeper of the light is avoid interupt channeling") + --do nothing + else + SideShopThink(); + end +end + +function SideShopGetDesire() + + local npcBot = GetBot(); + + local desire = 0.0; + + local enemys = npcBot:GetNearbyHeroes(600,true,BOT_MODE_NONE) + if ( npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:WasRecentlyDamagedByAnyHero(5.0) or #enemys>=1) --不应打断持续施法 + then + return 0 + end + + if ( npcBot.sideShopMode == true and npcBot:GetGold() >= npcBot:GetNextItemPurchaseValue()) then + local d=npcBot:DistanceFromSideShop() + if d<2500 + then + desire = (2500-d)/2500*0.3+0.3; --根据离边路商店的距离返回欲望值 + end + end + + return desire + +end + +function SideShopThink() + + local npcBot = GetBot(); + + local shopLoc1 = GetShopLocation( GetTeam(), SHOP_SIDE ); + local shopLoc2 = GetShopLocation( GetTeam(), SHOP_SIDE2 ); + + if ( GetUnitToLocationDistance(npcBot, shopLoc1) <= GetUnitToLocationDistance(npcBot, shopLoc2) ) then --选择前往距离自己更近的商店 + npcBot:Action_MoveToLocation( shopLoc1 ); + else + npcBot:Action_MoveToLocation( shopLoc2 ); + end +end +---------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/mode_team_roam_generic.lua b/mode_team_roam_generic.lua index 48c2c0ee..3278548a 100644 --- a/mode_team_roam_generic.lua +++ b/mode_team_roam_generic.lua @@ -2,11 +2,12 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -require(GetScriptDirectory() .. "/utility") +local utility = require( GetScriptDirectory().."/utility" ) local role = require(GetScriptDirectory() .. "/RoleUtility") local HeroMode -function CDOTA_Bot_Script:GetFactor() - return self:GetHealth()/self:GetMaxHealth()+self:GetMana()/self:GetMaxMana() + +function OnStart() + end function GetDesire() @@ -276,7 +277,7 @@ function ConsiderTeamRoam() if(factor>0.7) then local nearBuilding = utility.GetNearestBuilding(GetTeam(), npcBot:GetLocation()) - local location = GetUnitsTowardsLocation(nearBuilding,GetAncient(GetTeam()),600) + local location = utility.GetUnitsTowardsLocation(nearBuilding,GetAncient(GetTeam()),600) npcBot.TeamRoamAssemblyPoint=location npcBot:ActionImmediate_Chat("Let's Gank "..string.gsub(target:GetUnitName(),"npc_dota_hero_","").." together! ",false) print(npcBot:GetPlayerID().." @TeamRoam@ Let's Gank together! Factor:"..factor.." target:"..target:GetUnitName()) @@ -622,4 +623,4 @@ function OnEnd() npcBot.TeamRoamTargetID=nil npcBot.TeamRoamLeader=nil npcBot.TeamRoamTimer=nil -end +end \ No newline at end of file diff --git a/mode_ward_generic.lua b/mode_ward_generic.lua index b2894242..4e770eed 100644 --- a/mode_ward_generic.lua +++ b/mode_ward_generic.lua @@ -14,7 +14,7 @@ local itemWard = nil; local targetLoc = nil; local wardCastTime = -90; local swapTime = -90; - +local targetLoc, targetDist; local chat = false; diff --git a/old code.txt b/old code.txt deleted file mode 100644 index 1260ef22..00000000 --- a/old code.txt +++ /dev/null @@ -1,377 +0,0 @@ - ---[[-------------------------------------- --- Level Ability and Talent --------------------------------------- - --- check skill build vs current level -if #AbilityToLevelUp > 26-npcBot:GetLevel() then - for i=1, npcBot:GetLevel() do - print("remove"..AbilityToLevelUp[1]) - table.remove(AbilityToLevelUp, 1) - end -end - -function ChooseTalent() - local level=npcBot:GetLevel() - for i,temp in pairs (AbilityToLevelUp) - do - if temp=="talent" - then - table.remove(AbilityToLevelUp,i) - if level>=10 and level<15 - then - table.insert(AbilityToLevelUp,i,Talents[1]) - end - if level>=15 and level<20 - then - table.insert(AbilityToLevelUp,i,Talents[3]) - end - if level>=20 and level<25 - then - table.insert(AbilityToLevelUp,i,Talents[5]) - end - if level>=25 - then - table.insert(AbilityToLevelUp,i,Talents[7]) - end - end - end - - return - - --[[local talent="" - if(npcBot:GetLevel()>=25) - then - talent=Talents[7] - npcBot:ActionImmediate_LevelAbility(talent); - end - if(npcBot:GetLevel()>=20) - then - talent=Talents[5] - npcBot:ActionImmediate_LevelAbility(talent); - end - if(npcBot:GetLevel()>=15) - then - talent=Talents[3] - npcBot:ActionImmediate_LevelAbility(talent); - end - if(npcBot:GetLevel()>=10) - then - talent=Talents[1] - npcBot:ActionImmediate_LevelAbility(talent); - end - return]]-- -end]]-- - ---[[function ConsiderShrine() - local Shrines={ SHRINE_BASE_1, - SHRINE_BASE_2, - SHRINE_BASE_3, - SHRINE_BASE_4, - SHRINE_BASE_5, - SHRINE_JUNGLE_1, - SHRINE_JUNGLE_2 } - - local npcBot=GetBot() - - if(npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot.GoingToShrine==false and (npcBot:GetHealth()/npcBot:GetMaxHealth()<0.4 or npcBot:GetMaxHealth()-npcBot:GetHealth()>=600)) - then - npcBot:ActionImmediate_Chat("shrine consider",true) - local TargetShrine - local min_distance=10000 - for _,s in pairs(Shrines) - do - local shrine=GetShrine(GetTeam(),s) - if(shrine~=nil) - then - if(GetShrineCooldown(shrine)<10 or IsShrineHealing(shrine)==true) - then - if(GetUnitToUnitDistance(npcBot,shrine)=300 or ally:GetMana()/ally:GetMaxMana()<0.5) and GetUnitToUnitDistance(ally,npcBot.Shrine)<=6000) - then - ally.Shrine=TargetShrine - ally.GoingToShrine=true - end - end - end - end - - if(npcBot.GoingToShrine==true and npcBot.Shrine~=nil) - then - if(GetUnitToUnitDistance(npcBot,npcBot.Shrine)<100 and GetShrineCooldown(npcBot.Shrine)<5) - then - local allys = npcBot:GetNearbyHeroes( 1600, false, BOT_MODE_NONE ); - local ready=true - for _,ally in pairs(allys) - do - if(GetUnitToUnitDistance(ally,npcBot.Shrine)>500) - then - ready=false - end - end - for _,ally in pairs (GetUnitList(UNIT_LIST_ALLIED_HEROES )) - do - if(IsPlayerBot(ally:GetPlayerID())==true) - then - if(ally.GoingToShrine==true and GetUnitToUnitDistance(ally,npcBot.Shrine)>500) - then - ready=false - end - end - end - - if(ready==true) - then - npcBot:Action_UseShrine(npcBot.Shrine) - else - npcBot:Action_MoveToUnit(npcBot.Shrine) - end - else - npcBot:Action_MoveToUnit(npcBot.Shrine) - end - else - npcBot.GoingToShrine=false - npcBot.Shrine=nil - end - - if(IsShrineHealing(npcBot.Shrine)==true) - then - if(npcBot:NumQueuedActions()<=5) - then - npcBot:ActionQueue_MoveToUnit(npcBot.Shrine) - end - end - - if(npcBot.Shrine==nil or GetShrineCooldown(npcBot.Shrine)>10 or npcBot:GetHealth()/npcBot:GetMaxHealth()>0.6) - then - npcBot.GoingToShrine=false - npcBot.Shrine=nil - end -end ---------]]-- - ---[[function CourierUsageThink2() - local npcBot=GetBot() - local courier=GetCourier(0) - if(courier==nil) - then - return - end - local allys=courier:GetNearbyHeroes( 600, false, BOT_MODE_NONE ); - local towers=courier:GetNearbyTowers(1000,true) - if(towers==nil) then towers={} end - - local state=GetCourierState(courier) - --[[if(npcBot:IsAlive()==false or npcBot:GetHealth()<=100) - then - return - end]]-- - - if(courier:WasRecentlyDamagedByAnyHero(2) or courier:WasRecentlyDamagedByTower(2) or #towers >=1) - then - if(courier:GetMaxHealth()==150) - then - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_BURST) - end - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_RETURN) - return - end - - if(npcBot:GetCourierValue()>=900 and courier:GetMaxHealth()==150) - then - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_BURST) - return - end - --print(npcBot:GetUnitName().." "..npcBot:GetStashValue().." "..npcBot:GetCourierValue().." "..GetCourierState(courier))--or (state == COURIER_STATE_IDLE and #allys==0) - if (npcBot:GetStashValue() >= 400 and state == COURIER_STATE_AT_BASE and courier:DistanceFromSecretShop()>=100 and courier:DistanceFromFountain()<=1000) - then - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_TAKE_AND_TRANSFER_ITEMS) - return - end - if((state == COURIER_STATE_AT_BASE or state == COURIER_STATE_IDLE ) and npcBot.secretShopMode == true) - then - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_SECRET_SHOP) - return - end - if(state==COURIER_STATE_IDLE) - then - if(courier.idletime==nil) - then - courier.idletime=GameTime() - else - if(GameTime()-courier.idletime>10) - then - npcBot:ActionImmediate_Courier(courier, COURIER_ACTION_RETURN) - courier.idletime=nil - return - end - - end - end -end]]-- - -function UpdateLaneAssignments() - local lanes= - { - [1]=LANE_MID, - [2]=LANE_BOT, - [3]=LANE_TOP, - [4]=LANE_BOT, - [5]=LANE_TOP, - } - --[[for i=1,5,1 do - local bot=GetTeamMember(GetTeam(),i); - if bot~=nil - then - if bot:GetUnitName()=="npc_dota_hero_zuus" - then - lanes[i]=LANE_MID - end - end - end]]-- - return lanes; -end - ---[[function GetBotNames () - return {"恒是传说","恒是强者","恒是新手","恒是菜鸡","恒是普通"} -end]]-- - - - ---[[ --BOT EXPERIMENT's code from http://steamcommunity.com/sharedfiles/filedetails/?id=837040016 -function CanBuybackUpperRespawnTime( respawnTime ) - - local npcBot = GetBot(); - - if ( not npcBot:IsAlive() and respawnTime ~= nil and npcBot:GetRespawnTime() >= respawnTime - and npcBot:GetBuybackCooldown() <= 0 and npcBot:GetGold() > npcBot:GetBuybackCost() ) then - return true; - end - - return false; - -end ---BOT EXPERIMENT's code from http://steamcommunity.com/sharedfiles/filedetails/?id=837040016 -function BuybackUsageThink() - --[[local npcBot = GetBot(); - if npcBot:HasBuyback() then - print(npcBot:GetUnitName()); - end - if npcBot:IsAlive() or (not npcBot:HasBuyback()) then - return; - end - if GetLaneFrontAmount(GetTeam(), LANE_TOP, false) < 0.2 or - GetLaneFrontAmount(GetTeam(), LANE_MID, false) < 0.2 or - GetLaneFrontAmount(GetTeam(), LANE_BOT, false) < 0.2 then - npcBot:ActionImmediate_Buyback(); - end]]-- - - - local npcBot = GetBot(); - - -- no buyback, no need to use GetUnitList() for performance considerations - if ( npcBot:IsAlive() or (not npcBot:HasBuyback()) or npcBot:GetRespawnTime()<=15 ) then - return; - end - - local tower_top_3 = GetTower( GetTeam(), TOWER_TOP_3 ); - local tower_mid_3 = GetTower( GetTeam(), TOWER_MID_3 ); - local tower_bot_3 = GetTower( GetTeam(), TOWER_BOT_3 ); - local tower_base_1 = GetTower( GetTeam(), TOWER_BASE_1 ); - local tower_base_2 = GetTower( GetTeam(), TOWER_BASE_2 ); - - local barracks_top_melee = GetBarracks( GetTeam(), BARRACKS_TOP_MELEE ); - local barracks_mid_melee = GetBarracks( GetTeam(), BARRACKS_MID_MELEE ); - local barracks_bot_melee = GetBarracks( GetTeam(), BARRACKS_BOT_MELEE ); - - local ancient = GetAncient( GetTeam() ); - - local buildList = { - tower_top_3, tower_mid_3, tower_bot_3, tower_base_1, tower_base_2, - barracks_top_melee, - barracks_mid_melee, - barracks_bot_melee, - ancient - }; - - for _, build in pairs(buildList) do - local tableNearbyEnemyHeroes = build:GetNearbyHeroes( 1600, true, BOT_MODE_NONE ); - local tableNearbyAllyHeroes = build:GetNearbyHeroes( 1600, false, BOT_MODE_NONE ); - - if ( tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= #tableNearbyAllyHeroes ) then - if ( build:GetHealth() / build:GetMaxHealth() < 0.5+ 1/math.max(build:TimeSinceDamagedByAnyHero(),5)*0.25 + 0.1*#tableNearbyEnemyHeroes and npcBot:GetRespawnTime()>=30 )then - npcBot:ActionImmediate_Buyback(); - return; - end - end - end - - if ( DotaTime() > 40 * 60 ) then - npcBot:ActionImmediate_Buyback(); - return - end -end ]]-- - -function ConsiderShrines() - local npcBot=GetBot() - - if(npcBot:GetActiveMode() == BOT_MODE_ITEM) - then - return - end - - local shrines=npcBot:GetNearbyShrines(1600,false) - if(npcBot:GetAssignedLane()==LANE_MID) - then - sh1=GetShrine(GetTeam(),SHRINE_JUNGLE_1) - sh2=GetShrine(GetTeam(),SHRINE_JUNGLE_2) - if(GetShrineCooldown(sh1)==0) - then - table.insert(shrines,sh1) - end - if(GetShrineCooldown(sh2)==0) - then - table.insert(shrines,sh2) - end - end - - if(#shrines==0 or npcBot:IsUsingAbility() or npcBot:IsChanneling()) - then - return - end - - if(npcBot:GetActiveMode() == BOT_MODE_RETREAT and (npcBot:GetHealth()/npcBot:GetMaxHealth()<0.4 or npcBot:GetMaxHealth()-npcBot:GetHealth()>=600)) - then - for _,s in pairs(shrines) - do - if(GetShrineCooldown(s)==0) - then - npcBot:Action_UseShrine(s) - return - end - end - end - - for _,s in pairs(shrines) - do - if(IsShrineHealing(s)==true and GetUnitToUnitDistance(npcBot,s)>=450) - then - npcBot:Action_MoveToLocation(s:GetLocation()) - return - end - end - -end \ No newline at end of file diff --git a/utility.lua b/utility.lua index f35dc673..098d3e72 100644 --- a/utility.lua +++ b/utility.lua @@ -2,33 +2,33 @@ -- Ranked Matchmaking AI v1.0a -- Author: adamqqq Email:adamqqq@163.com ---------------------------------------------------------------------------- -_G._savedEnv = getfenv() -module("utility", package.seeall) +local utilityModule={} --------------------------------------------------------------------------------------------------- ------This is global utility library,include some useful function.------ --------------------------------------------------------------------------------------------------- -function HasImmuneDebuff(npcEnemy) +function utilityModule.HasImmuneDebuff(npcEnemy) return npcEnemy:HasModifier("modifier_abaddon_borrowed_time") or npcEnemy:HasModifier("modifier_winter_wyvern_winters_curse") or npcEnemy:HasModifier("modifier_winter_wyvern_winters_curse_aura") end - -function NCanCast( npcEnemy )--normal judgement - return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable() and not HasImmuneDebuff(npcEnemy) and not npcEnemy:IsIllusion() +function utilityModule.NCanCast( npcEnemy )--normal judgement + return npcEnemy:CanBeSeen() and not npcEnemy:IsMagicImmune() and not npcEnemy:IsInvulnerable() and not utilityModule.HasImmuneDebuff(npcEnemy) and not npcEnemy:IsIllusion() end -function MiCanCast( npcEnemy )--magic immune - return npcEnemy:CanBeSeen() and not npcEnemy:IsInvulnerable() and not HasImmuneDebuff(npcEnemy) and not npcEnemy:IsIllusion() and not npcEnemy:HasModifier("modifier_item_sphere") and not npcEnemy:HasModifier("modifier_item_sphere_target") +function utilityModule.MiCanCast( npcEnemy )--magic immune + return npcEnemy:CanBeSeen() and not npcEnemy:IsInvulnerable() and not utilityModule.HasImmuneDebuff(npcEnemy) and not npcEnemy:IsIllusion() and not npcEnemy:HasModifier("modifier_item_sphere") and not npcEnemy:HasModifier("modifier_item_sphere_target") end -UCanCast=MiCanCast +function utilityModule.UCanCast( npcEnemy )--magic immune + return npcEnemy:CanBeSeen() and not npcEnemy:IsInvulnerable() and not utilityModule.HasImmuneDebuff(npcEnemy) and not npcEnemy:IsIllusion() and not npcEnemy:HasModifier("modifier_item_sphere") and not npcEnemy:HasModifier("modifier_item_sphere_target") +end -- gxc's code -- created by date: 2017/03/16 --- nBehavior = hAbility:GetTargetTeam, GetTargetType, GetTargetFlags or GetBehavior function returns +-- nBehavior = hAbility:GetTargetTeam, GetTargetType, GetTargetFlags or GetBehavior function utilityModule.utilityModule.returns -- nFlag = Ability Target Teams, Ability Target Types, Ability Target Flags or Ability Behavior Bitfields constant -function CheckFlag( nBehavior, nFlag ) +function utilityModule.CheckFlag( nBehavior, nFlag ) if ( nFlag == 0 ) then if ( nBehavior == 0 ) then @@ -44,7 +44,7 @@ end ----------------- local utility functions reordered for lua local visibility-------- --Perry's code from http://dev.dota2.com/showthread.php?t=274837 -function PerryGetHeroLevel()--ȡӢ۵ȼ ѲҪ˺ɵλGetLevel() +function utilityModule.PerryGetHeroLevel()--???????? ????????????????????λ????????GetLevel()??? local npcBot = GetBot(); local respawnTable = {8, 10, 12, 14, 16, 26, 28, 30, 32, 34, 36, 46, 48, 50, 52, 54, 56, 66, 70, 74, 78, 82, 86, 90, 100}; local nRespawnTime = npcBot:GetRespawnTime() +1 -- It gives 1 second lower values. @@ -55,14 +55,14 @@ function PerryGetHeroLevel()-- end end -function enemyDisabled(npcEnemy) +function utilityModule.enemyDisabled(npcEnemy) if npcEnemy:IsRooted( ) or npcEnemy:IsStunned( ) or npcEnemy:IsHexed( ) then return true; end return false; end -function IsEnemy(hUnit) +function utilityModule.IsEnemy(hUnit) local ourTeam=GetTeam() local Team=GetTeamForPlayer(hUnit:GetPlayerID()) if ourTeam==Team @@ -73,7 +73,7 @@ function IsEnemy(hUnit) end end -function PointToPointDistance(a,b) +function utilityModule.PointToPointDistance(a,b) local x1=a.x local x2=b.x local y1=a.y @@ -81,10 +81,19 @@ function PointToPointDistance(a,b) return math.sqrt(math.pow((y2-y1),2)+math.pow((x2-x1),2)) end -function GetDistance(a,b) - return PointToPointDistance(a,b) +function utilityModule.GetDistance(a,b) + return utilityModule.PointToPointDistance(a,b) +end + + +function CDOTA_Bot_Script:GetFactor() + return self:GetHealth()/self:GetMaxHealth()+self:GetMana()/self:GetMaxMana() end + + + + ---------------------------------------------------------------------------------------------------- --vector --BOT EXPERIMENT's code from http://steamcommunity.com/sharedfiles/filedetails/?id=837040016 @@ -116,31 +125,35 @@ function CDOTA_Bot_Script:GetXUnitsInBehind( nUnits ) return self:GetLocation() - self:GetForwardVector() * nUnits end +function CDOTA_Bot_Script:IsRoshan( ) + return string.find(self:GetUnitName(), "roshan") +end + ---------------------------------------------------------------------------------------------------- -function GetUnitsTowardsLocation(unit,target, nUnits) +function utilityModule.GetUnitsTowardsLocation(unit,target, nUnits) vMyLocation,vTargetLocation=unit:GetLocation(),target:GetLocation() local tempvector=(vTargetLocation-vMyLocation)/PointToPointDistance(vMyLocation,vTargetLocation) return vMyLocation+nUnits*tempvector end -function RandomInCastRangePoint(unit,target,CastRange,distance) +function utilityModule.RandomInCastRangePoint(unit,target,CastRange,distance) local i=0 repeat - l=GetUnitsTowardsLocation(unit,target,GetUnitToUnitDistance(unit,target)/2)+RandomVector(RandomInt(0,distance)) + l=utilityModule.GetUnitsTowardsLocation(unit,target,GetUnitToUnitDistance(unit,target)/2)+RandomVector(RandomInt(0,distance)) d=GetUnitToLocationDistance(unit,l) i=i+1 until( d<=CastRange or i>=10) if(i>=10) then - return GetUnitsTowardsLocation(unit,target,distance) + return utilityModule.GetUnitsTowardsLocation(unit,target,distance) else return l end end -function GetSafeVector(unit,distance) +function utilityModule.GetSafeVector(unit,distance) v=RandomVector(distance) if(unit:GetTeam()==TEAM_RADIANT) then @@ -165,7 +178,7 @@ function GetSafeVector(unit,distance) return v end -function GetEnemiesNearLocation(loc,dist) +function utilityModule.GetEnemiesNearLocation(loc,dist) if loc ==nil then return {}; end @@ -182,7 +195,7 @@ function GetEnemiesNearLocation(loc,dist) return Enemies; end -function GetAlliesNearLocation(loc,dist) +function utilityModule.GetAlliesNearLocation(loc,dist) if loc ==nil then return {}; end @@ -192,7 +205,7 @@ function GetAlliesNearLocation(loc,dist) for _,enID in pairs(GetTeamPlayers(GetTeam())) do local enemyInfo=GetHeroLastSeenInfo(enID)[1]; if enemyInfo~=nil and enemyInfo['location']~=nil then - if IsHeroAlive(enID) and utility.GetDistance(enemyInfo['location'],loc)<=dist and (utility.GetDistance(enemyInfo['location'],Vector(0,0))>10) and enemyInfo['time_since_seen']<10 then + if IsHeroAlive(enID) and utilityModule.GetDistance(enemyInfo['location'],loc)<=dist and (utilityModule.GetDistance(enemyInfo['location'],Vector(0,0))>10) and enemyInfo['time_since_seen']<10 then table.insert(Enemies,enID); end end @@ -206,14 +219,14 @@ end ---------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------- -function Fountain(team) +function utilityModule.Fountain(team) if team==TEAM_RADIANT then return Vector(-7093,-6542); end return Vector(7015,6534); end -function GetOtherTeam() +function utilityModule.GetOtherTeam() if GetTeam()==TEAM_RADIANT then return TEAM_DIRE; else @@ -221,7 +234,7 @@ function GetOtherTeam() end end -function GetWeakestUnit(EnemyUnits) +function utilityModule.GetWeakestUnit(EnemyUnits) if EnemyUnits==nil or #EnemyUnits==0 then return nil,10000; @@ -244,7 +257,7 @@ function GetWeakestUnit(EnemyUnits) return WeakestUnit,LowestHealth end -function GetStrongestUnit(EnemyUnits) +function utilityModule.GetStrongestUnit(EnemyUnits) if EnemyUnits==nil or #EnemyUnits==0 then return nil,0; @@ -267,8 +280,8 @@ function GetStrongestUnit(EnemyUnits) return StrongestUnit,HighestHealth end -function GetNearestBuilding(team, location) - local buildings = GetAllBuilding( team, location ) +function utilityModule.GetNearestBuilding(team, location) + local buildings = utilityModule.GetAllBuilding( team, location ) local minDist = 16000 ^ 2 local nearestBuilding = nil for k,v in pairs(buildings) do @@ -281,25 +294,25 @@ function GetNearestBuilding(team, location) return nearestBuilding end -function GetAllBuilding( team,location ) +function utilityModule.GetAllBuilding( team,location ) local buildings = {} for i=0,10 do local tower = GetTower(team,i) - if NotNilOrDead(tower) then + if utilityModule.NotNilOrDead(tower) then table.insert(buildings,tower) end end for i=0,5 do local barrack = GetBarracks( team, i ) - if NotNilOrDead(barrack) then + if utilityModule.NotNilOrDead(barrack) then table.insert(buildings,barrack) end end for i=0,4 do local shrine = GetShrine(team, i) - if NotNilOrDead(shrine) then + if utilityModule.NotNilOrDead(shrine) then table.insert(buildings,shrine) end end @@ -309,7 +322,7 @@ function GetAllBuilding( team,location ) return buildings end -function NotNilOrDead(unit) +function utilityModule.NotNilOrDead(unit) if unit==nil or unit:IsNull() then return false; end @@ -320,49 +333,49 @@ function NotNilOrDead(unit) end -------------------------------------------------------------------------- ItemPurchase -function SellExtraItem(ItemsToBuy) +function utilityModule.SellExtraItem(ItemsToBuy) local npcBot=GetBot() local level=npcBot:GetLevel() - item_travel_boots = NoNeedTpscrollForTravelBoots(); + item_travel_boots = utilityModule.NoNeedTpscrollForTravelBoots(); item_travel_boots_1 = item_travel_boots[1]; item_travel_boots_2 = item_travel_boots[2]; - if(IsItemSlotsFull()) + if(utilityModule.IsItemSlotsFull()) then if(GameTime()>15*60 or level>=7) then - SellSpecifiedItem("item_faerie_fire") - SellSpecifiedItem("item_enchanted_mango") - SellSpecifiedItem("item_tango") - SellSpecifiedItem("item_clarity") - SellSpecifiedItem("item_flask") + utilityModule.SellSpecifiedItem("item_faerie_fire") + utilityModule.SellSpecifiedItem("item_enchanted_mango") + utilityModule.SellSpecifiedItem("item_tango") + utilityModule.SellSpecifiedItem("item_clarity") + utilityModule.SellSpecifiedItem("item_flask") end if(GameTime()>20*60 or level>=10) then - SellSpecifiedItem("item_stout_shield") - SellSpecifiedItem("item_orb_of_venom") - SellSpecifiedItem("item_poor_mans_shield") - SellSpecifiedItem("item_quelling_blade") - SellSpecifiedItem("item_soul_ring") + utilityModule.SellSpecifiedItem("item_stout_shield") + utilityModule.SellSpecifiedItem("item_orb_of_venom") + utilityModule.SellSpecifiedItem("item_poor_mans_shield") + utilityModule.SellSpecifiedItem("item_quelling_blade") + utilityModule.SellSpecifiedItem("item_soul_ring") end if(GameTime()>30*60 or level>=15) then - SellSpecifiedItem("item_branches") - SellSpecifiedItem("item_bottle") - SellSpecifiedItem("item_magic_wand") - SellSpecifiedItem("item_magic_stick") - SellSpecifiedItem("item_urn_of_shadows") - SellSpecifiedItem("item_ancient_janggo") - SellSpecifiedItem("item_ring_of_basilius") - SellSpecifiedItem("item_ring_of_aquila") - SellSpecifiedItem("item_vladmir") + utilityModule.SellSpecifiedItem("item_branches") + utilityModule.SellSpecifiedItem("item_bottle") + utilityModule.SellSpecifiedItem("item_magic_wand") + utilityModule.SellSpecifiedItem("item_magic_stick") + utilityModule.SellSpecifiedItem("item_urn_of_shadows") + utilityModule.SellSpecifiedItem("item_ancient_janggo") + utilityModule.SellSpecifiedItem("item_ring_of_basilius") + utilityModule.SellSpecifiedItem("item_ring_of_aquila") + utilityModule.SellSpecifiedItem("item_vladmir") end if(GameTime()>35*60 or level>=20) then - SellSpecifiedItem("item_hand_of_midas") - if(GetItemSlotsCount()<6) + utilityModule.SellSpecifiedItem("item_hand_of_midas") + if(utilityModule.GetItemSlotsCount()<6) then - SellSpecifiedItem("item_dust") + utilityModule.SellSpecifiedItem("item_dust") end end if(GameTime()>40*60 and npcBot:GetGold()>2200 and (item_travel_boots[1]==nil and item_travel_boots[2]==nil) and npcBot.HaveTravelBoots~=true ) @@ -386,14 +399,14 @@ function SellExtraItem(ItemsToBuy) end -function ItemPurchase(ItemsToBuy) +function utilityModule.ItemPurchase(ItemsToBuy) local npcBot = GetBot(); -- buy item_tpscroll if(npcBot.secretShopMode~=true or npcBot:GetGold() >= 100) then - WeNeedTpscroll(); + utilityModule.WeNeedTpscroll(); end if ( #ItemsToBuy == 0 ) @@ -405,7 +418,7 @@ function ItemPurchase(ItemsToBuy) local sNextItem = ItemsToBuy[1]; npcBot:SetNextItemPurchaseValue( GetItemCost( sNextItem ) ) - SellExtraItem(ItemsToBuy) + utilityModule.SellExtraItem(ItemsToBuy) if(npcBot:DistanceFromFountain()<=1000 or npcBot:GetHealth()/npcBot:GetMaxHealth()<=0.4) then @@ -423,7 +436,7 @@ function ItemPurchase(ItemsToBuy) then if(npcBot.secretShopMode~=true and npcBot.sideShopMode ~=true) then - if (IsItemPurchasedFromSideShop( sNextItem ) and npcBot:DistanceFromSideShop() <= 4000) --ֻ·̵Ͻʱǰ·̵ + if (IsItemPurchasedFromSideShop( sNextItem ) and npcBot:DistanceFromSideShop() <= 4000) --????????·?????????????·??? then npcBot.sideShopMode = true; npcBot.secretShopMode = false; @@ -435,14 +448,14 @@ function ItemPurchase(ItemsToBuy) end end - local PurchaseResult=-2 --չĻ + local PurchaseResult=-2 --??????????????????? if(npcBot.sideShopMode == true) then if(npcBot:DistanceFromSideShop() <= 250) then PurchaseResult=npcBot:ActionImmediate_PurchaseItem( sNextItem ) end - elseif(npcBot.secretShopMode == true) --Ŀ̵꣬ʹƷ + elseif(npcBot.secretShopMode == true) --??????????????????????????????? then if(npcBot:DistanceFromSecretShop() <= 250) then @@ -452,10 +465,10 @@ function ItemPurchase(ItemsToBuy) local courier=GetCourier(0) if(courier==nil) then - BuyCourier() --ûʹĻṺ + utilityModule.BuyCourier() --??????????????????????????? else - local ItemCount=utility.GetItemSlotsCount2(courier) - if(courier:DistanceFromSecretShop() <= 250 and ItemCount<9) --ʹѵ̵ + local ItemCount=utilityModule.GetItemSlotsCount2(courier) + if(courier:DistanceFromSecretShop() <= 250 and ItemCount<9) --??????????? then PurchaseResult=GetCourier(0):ActionImmediate_PurchaseItem( sNextItem ) end @@ -464,13 +477,13 @@ function ItemPurchase(ItemsToBuy) PurchaseResult=npcBot:ActionImmediate_PurchaseItem( sNextItem ) end - if(PurchaseResult==PURCHASE_ITEM_SUCCESS) --ɹӳװƳƷ + if(PurchaseResult==PURCHASE_ITEM_SUCCESS) --??????????????????????? then npcBot.secretShopMode = false; npcBot.sideShopMode = false; table.remove( ItemsToBuy, 1 ) end - if(PurchaseResult==PURCHASE_ITEM_OUT_OF_STOCK) --Ʒ۶Ʒ + if(PurchaseResult==PURCHASE_ITEM_OUT_OF_STOCK) --?????????????????????? then SellSpecifiedItem("item_branches") SellSpecifiedItem("item_dust") @@ -480,26 +493,26 @@ function ItemPurchase(ItemsToBuy) SellSpecifiedItem("item_clarity") SellSpecifiedItem("item_flask") end - if(PurchaseResult==PURCHASE_ITEM_INVALID_ITEM_NAME or PurchaseResult==PURCHASE_ITEM_DISALLOWED_ITEM) --ڵƷƳƷ + if(PurchaseResult==PURCHASE_ITEM_INVALID_ITEM_NAME or PurchaseResult==PURCHASE_ITEM_DISALLOWED_ITEM) --???????????????????? then table.remove( ItemsToBuy, 1 ) end - if(PurchaseResult==PURCHASE_ITEM_INSUFFICIENT_GOLD ) --㣨ʵҲٳ֣ΪѾж˽Ǯ + if(PurchaseResult==PURCHASE_ITEM_INSUFFICIENT_GOLD ) --???????????????????????????????????????ж??????? then npcBot.secretShopMode = false; npcBot.sideShopMode = false; end - if(PurchaseResult==PURCHASE_ITEM_NOT_AT_SECRET_SHOP) --̵꣬ǰ̵ + if(PurchaseResult==PURCHASE_ITEM_NOT_AT_SECRET_SHOP) --????????????????????? then npcBot.secretShopMode = true npcBot.sideShopMode = false; end - if(PurchaseResult==PURCHASE_ITEM_NOT_AT_SIDE_SHOP) --ڱ·̵꣨ʵ֣Ϊڱ·̵Ʒ̵깺 + if(PurchaseResult==PURCHASE_ITEM_NOT_AT_SIDE_SHOP) --?????·?????????????????????????·???????????????????? then npcBot.sideShopMode = true npcBot.secretShopMode = false; end - if(PurchaseResult==PURCHASE_ITEM_NOT_AT_HOME_SHOP) --ڻ̵꣨ҲֵΪӢ۲ڼУôƷṺش + if(PurchaseResult==PURCHASE_ITEM_NOT_AT_HOME_SHOP) --??????????????????????????????????????У???????????????????? then npcBot.secretShopMode = false; npcBot.sideShopMode = false; @@ -515,7 +528,7 @@ function ItemPurchase(ItemsToBuy) end -function BuyCourier() +function utilityModule.BuyCourier() local npcBot=GetBot() local courier=GetCourier(0) if(courier==nil) @@ -538,7 +551,7 @@ function BuyCourier() end -function NoNeedTpscrollForTravelBoots() +function utilityModule.NoNeedTpscrollForTravelBoots() local npcBot = GetBot(); @@ -572,7 +585,7 @@ function NoNeedTpscrollForTravelBoots() end -function WeNeedTpscroll() +function utilityModule.WeNeedTpscroll() local npcBot = GetBot(); @@ -613,7 +626,7 @@ function WeNeedTpscroll() end -function SellSpecifiedItem( item_name ) +function utilityModule.SellSpecifiedItem( item_name ) local npcBot = GetBot(); @@ -639,7 +652,7 @@ function SellSpecifiedItem( item_name ) end -function GetItemSlotsCount2(npcBot) +function utilityModule.GetItemSlotsCount2(npcBot) local itemCount = 0; local item = nil; @@ -656,7 +669,7 @@ function GetItemSlotsCount2(npcBot) return itemCount end -function GetItemSlotsCount() +function utilityModule.GetItemSlotsCount() local npcBot = GetBot(); local itemCount = 0; @@ -674,8 +687,8 @@ function GetItemSlotsCount() return itemCount end -function IsItemSlotsFull() - local itemCount = GetItemSlotsCount(); +function utilityModule.IsItemSlotsFull() + local itemCount = utilityModule.GetItemSlotsCount(); if(itemCount>=8) then @@ -685,7 +698,7 @@ function IsItemSlotsFull() end end -function checkItemBuild(ItemsToBuy) +function utilityModule.checkItemBuild(ItemsToBuy) local ItemTableA= { "item_tango", @@ -719,7 +732,7 @@ function checkItemBuild(ItemsToBuy) end end -local invisibleHeroes = { +invisibleHeroes = { "npc_dota_hero_legion_commander", "npc_dota_hero_sand_king", "npc_dota_hero_treant", @@ -738,7 +751,7 @@ local invisibleHeroes = { "npc_dota_hero_invoker" }; --- function GetItemIncludeBackpack( item_name ) +-- function utilityModule.GetItemIncludeBackpack( item_name ) -- local npcBot = GetBot(); -- local item = nil; @@ -749,7 +762,7 @@ local invisibleHeroes = { -- return item; -- end -function GetItemIncludeBackpack(item_name) +function utilityModule.GetItemIncludeBackpack(item_name) local npcBot=GetBot() for i = 0, 16 do local item = npcBot:GetItemInSlot(i); @@ -762,7 +775,7 @@ function GetItemIncludeBackpack(item_name) return nil; end -function IsItemAvailable(item_name) +function utilityModule.IsItemAvailable(item_name) local npcBot = GetBot(); for i = 0, 5, 1 do @@ -776,8 +789,8 @@ function IsItemAvailable(item_name) return nil; end -function CheckInvisibleEnemy() - local enemyTeam=GetOtherTeam() +function utilityModule.CheckInvisibleEnemy() + local enemyTeam=utilityModule.GetOtherTeam() if ( enemyTeam ~= nil ) then for _, id in pairs( GetTeamPlayers(enemyTeam) ) do @@ -804,29 +817,29 @@ function CheckInvisibleEnemy() return false end -local hasInvisibleEnemy = false -local BuySupportItem_Timer=DotaTime() -function BuySupportItem() +hasInvisibleEnemy = false +BuySupportItem_Timer=DotaTime() +function utilityModule.BuySupportItem() local npcBot=GetBot() -- decide if there were several invisible enemy heroes. if(DotaTime()-BuySupportItem_Timer>=10) then BuySupportItem_Timer=DotaTime() - hasInvisibleEnemy=CheckInvisibleEnemy() + hasInvisibleEnemy=utilityModule.CheckInvisibleEnemy() end - if(GetItemSlotsCount()<6) + if(utilityModule.GetItemSlotsCount()<6) then - local item_ward_observer = GetItemIncludeBackpack( "item_ward_observer" ); - local item_ward_sentry2 = GetItemIncludeBackpack( "item_ward_dispenser" ) - local item_gem = GetItemIncludeBackpack( "item_gem" ) - local item_smoke = GetItemIncludeBackpack( "item_smoke_of_deceit") + local item_ward_observer = utilityModule.GetItemIncludeBackpack( "item_ward_observer" ); + local item_ward_sentry2 = utilityModule.GetItemIncludeBackpack( "item_ward_dispenser" ) + local item_gem = utilityModule.GetItemIncludeBackpack( "item_gem" ) + local item_smoke = utilityModule.GetItemIncludeBackpack( "item_smoke_of_deceit") if ( DotaTime() >= 0 and hasInvisibleEnemy == true ) then - local item_dust = GetItemIncludeBackpack( "item_dust" ); - local item_ward_sentry = GetItemIncludeBackpack( "item_ward_sentry" ) - if(item_gem==nil and HaveGem()==false) + local item_dust = utilityModule.GetItemIncludeBackpack( "item_dust" ); + local item_ward_sentry = utilityModule.GetItemIncludeBackpack( "item_ward_sentry" ) + if(item_gem==nil and utilityModule.HaveGem()==false) then if (item_dust==nil and item_ward_sentry==nil and item_ward_sentry2==nil and npcBot:GetGold() >= 2*GetItemCost("item_dust") and GetItemStockCount("item_gem") >= 1) then npcBot:ActionImmediate_PurchaseItem( "item_dust" ); @@ -837,13 +850,13 @@ function BuySupportItem() npcBot:ActionImmediate_PurchaseItem( "item_gem" ); end - -- if ( item_ward_observer==nil and item_dust==nil and item_ward_sentry==nil and item_ward_sentry2==nil and IsItemSlotsFull()==false and npcBot:GetGold() >= 2*GetItemCost("item_ward_sentry") ) then + -- if ( item_ward_observer==nil and item_dust==nil and item_ward_sentry==nil and item_ward_sentry2==nil and utilityModule.IsItemSlotsFull()==false and npcBot:GetGold() >= 2*GetItemCost("item_ward_sentry") ) then -- npcBot:ActionImmediate_PurchaseItem( "item_ward_sentry" ); -- end end end - if(DotaTime()>=40*60 and npcBot:GetGold() >= GetItemCost("item_gem") and GetItemStockCount("item_gem") >= 1 and item_gem==nil and HaveGem()==false) + if(DotaTime()>=40*60 and npcBot:GetGold() >= GetItemCost("item_gem") and GetItemStockCount("item_gem") >= 1 and item_gem==nil and utilityModule.HaveGem()==false) then npcBot:ActionImmediate_PurchaseItem( "item_gem" ); end @@ -861,7 +874,7 @@ function BuySupportItem() end -function HaveGem() +function utilityModule.HaveGem() for k,hero in pairs(GetUnitList( UNIT_LIST_ALLIED_HEROES ) ) do local gem=hero:FindItemSlot( "item_gem" ) @@ -873,7 +886,7 @@ function HaveGem() return false end -function CheckAbilityBuild(AbilityToLevelUp) +function utilityModule.CheckAbilityBuild(AbilityToLevelUp) local npcBot=GetBot() if #AbilityToLevelUp > 26-npcBot:GetLevel() then for i=1, npcBot:GetLevel() do @@ -883,8 +896,8 @@ function CheckAbilityBuild(AbilityToLevelUp) end end -local debug_mode = false -function DebugTalk(message) +function utilityModule.DebugTalk(message) + local debug_mode = false if(debug_mode==true) then local npcBot=GetBot() @@ -892,7 +905,7 @@ function DebugTalk(message) end end -function DebugTalk_Delay(message) +function utilityModule.DebugTalk_Delay(message) local npcBot=GetBot() if(npcBot.LastSpeaktime==nil) @@ -908,4 +921,4 @@ end -------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- -for k,v in pairs( utility ) do _G._savedEnv[k] = v end \ No newline at end of file +return utilityModule; \ No newline at end of file