From 8d68b8b1ac2082d59dbe0d9b090dfe67be0a2850 Mon Sep 17 00:00:00 2001 From: Keithen Date: Mon, 27 Mar 2017 22:27:13 +0200 Subject: [PATCH 1/2] api bug workaround --- global_hero_data.lua | 35 ++++++++++++++++++++++++++--------- modes/pushlane.lua | 13 ++++++++++++- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/global_hero_data.lua b/global_hero_data.lua index 6c94fca..2418e36 100644 --- a/global_hero_data.lua +++ b/global_hero_data.lua @@ -61,14 +61,31 @@ function X.GetNearbyAllies(bot, range) end function X.GetNearbyEnemyTowers(bot, range) - local endList = bot:GetNearbyTowers(range, true) - --local startList = X[bot:GetPlayerID()].NearbyEnemyTowers - --local endList = {} - --for _, val in pairs(startList) do - -- if GetUnitToUnitDistance(bot, val) <= range then - -- table.insert(endList, val) - -- end - --end + local startList = bot:GetNearbyTowers(range, true) + + endList = {} + for _, val in pairs(startList) do + if string.find(val:GetUnitName(), "tower") then + table.insert(endList, val) + end + end + return endList +end + +function X.GetNearbyEnemyBarracks(bot, range) + local endList = bot:GetNearbyBarracks(range, true) + if #endList > 0 then + print("[CRITICAL]: API bug fixed. plas adjust code. random uniqe marker: AWESDFWRGWFE") + end + + local startList = bot:GetNearbyTowers(range, true) + + endList = {} + for _, val in pairs(startList) do + if string.find(val:GetUnitName(), "rax") then + table.insert(endList, val) + end + end return endList end @@ -320,4 +337,4 @@ function X.ExecuteHeroActionQueue(bot) return end -return X \ No newline at end of file +return X diff --git a/modes/pushlane.lua b/modes/pushlane.lua index 566bfd5..7f16f0b 100644 --- a/modes/pushlane.lua +++ b/modes/pushlane.lua @@ -36,7 +36,7 @@ function X:Think(bot) local Towers = gHeroVar.GetNearbyEnemyTowers(bot, 750) local Shrines = bot:GetNearbyShrines(1200, true) - local Barracks = bot:GetNearbyBarracks(1200, true) + local Barracks = gHeroVar.GetNearbyBarracks(bot, 1200) local Ancient = GetAncient(utils.GetOtherTeam()) -- if there are no structures near by @@ -237,6 +237,17 @@ function X:Desire(bot) end end + local nearbyEBarracks = gHeroVar.GetNearbyEnemyBarracks(bot, Max(750, bot:GetAttackRange())) + if #nearbyEBarracks > 0 then + if not modifiers.IsBuildingGlyphed(nearbyEBarracks[1]) then + return BOT_MODE_DESIRE_HIGH + end + end + + if GetUnitToUnitDistance(GetAncient(utils.GetOtherTeam()), bot) < 1200 then + return BOT_MODE_DESIRE_HIGH + end + if #gHeroVar.GetNearbyAlliedCreep(bot, 1000) >= 1 and #gHeroVar.GetNearbyEnemies(bot, 1200) == 0 then return BOT_MODE_DESIRE_LOW end From 4789845bef3e73b2c2ba917f7098c4b7b4e7dbbf Mon Sep 17 00:00:00 2001 From: Keithen Date: Mon, 27 Mar 2017 22:44:20 +0200 Subject: [PATCH 2/2] typo --- modes/pushlane.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modes/pushlane.lua b/modes/pushlane.lua index 7f16f0b..555dcfc 100644 --- a/modes/pushlane.lua +++ b/modes/pushlane.lua @@ -36,7 +36,7 @@ function X:Think(bot) local Towers = gHeroVar.GetNearbyEnemyTowers(bot, 750) local Shrines = bot:GetNearbyShrines(1200, true) - local Barracks = gHeroVar.GetNearbyBarracks(bot, 1200) + local Barracks = gHeroVar.GetNearbyEnemyBarracks(bot, 1200) local Ancient = GetAncient(utils.GetOtherTeam()) -- if there are no structures near by