Dota 2

Bot API bug

Bots immediately swap their item_ward_observer's with any other item from backpack, if any. Can be fixed by using item_ward_dispenser instead. Here's the code to reproduce the bug:


mode_ward_generic.lua

“` local bot = GetBot();

function GetDesire() return BOT_MODE_DESIRE_ABSOLUTE; end

function OnStart() bot:ActionImmediate_Chat('enter',false); end

function OnEnd() bot:ActionImmediate_Chat("exit",false); end

local lastSwap = DotaTime();

function Think()

if GetGameState()~=GAME_STATE_PRE_GAME and GetGameState()~= GAME_STATE_GAME_IN_PROGRESS then return; end if DotaTime() - lastSwap < 1 then return end; if bot:GetUnitName() ~= "npc_dota_hero_lina" and bot:GetUnitName() ~= "npc_dota_hero_bane" then return end local branches = 0; local wards = 0; for i = 0, 8 do if bot:GetItemInSlot(i) ~= nil then if bot:GetItemInSlot(i):GetName() == 'item_branches' then branches = branches + 1; end if bot:GetItemInSlot(i):GetName() == 'item_ward_dispenser' or bot:GetItemInSlot(i):GetName() == 'item_ward_observer' then wards = wards + 1; end end end if branches < 6 then bot:ActionImmediate_PurchaseItem ('item_branches'); return; end if wards < 1 then bot:ActionImmediate_PurchaseItem ('item_ward_observer'); if bot:GetUnitName() == "npc_dota_hero_bane" then bot:ActionImmediate_PurchaseItem ('item_ward_sentry'); end return; end local wardSlot = -1; for i = 0,8 do local item = bot:GetItemInSlot(i); if item ~= nil then if item:GetName() == 'item_ward_dispenser' or item:GetName() == 'item_ward_observer' then wardSlot = i; break; end end end if wardSlot > 5 then local leastCostItem = FindLeastItemSlot(); bot:ActionImmediate_SwapItems(wardSlot, leastCostItem); bot:ActionImmediate_Chat('swap ' .. wardSlot .. ' and ' .. leastCostItem, false); lastSwap = DotaTime(); end local item = bot:GetItemInSlot(wardSlot); bot:Action_UseAbilityOnLocation(item, Vector(0.000000, 0.000000, 0.000000)); 

end

Read more:  Heroes Mix-Up #3: Tannorath, The Omen

function FindLeastItemSlot() local minCost = 100000; local idx = -1; for i=0,5 do if bot:GetItemInSlot(i) ~= nil then local itemName = bot:GetItemInSlot(i):GetName(); if itemName ~= "item_aegis" and itemName ~= "item_ward_observer" and itemName ~= "item_ward_dispenser" then local cost = GetItemCost(itemName); if( cost < minCost ) then minCost = cost; idx = i; end end else return i; end end return idx; end

function FindMostItemSlot() local maxCost = 0; local idx = -1; for i=6,8 do if bot:GetItemInSlot(i) ~= nil then local _item = bot:GetItemInSlot(i):GetName() if( GetItemCost(_item) > maxCost ) then maxCost = GetItemCost(_item); idx = i; end end end return idx; end “`


hero_selection.lua

function Think() if ( GetTeam() == TEAM_RADIANT ) then print( "selecting radiant" ); SelectHero( 1, "npc_dota_hero_lina" ); SelectHero( 2, "npc_dota_hero_axe" ); SelectHero( 3, "npc_dota_hero_bane" ); SelectHero( 4, "npc_dota_hero_bloodseeker" ); -- SelectHero( 4, "npc_dota_hero_crystal_maiden" ); elseif ( GetTeam() == TEAM_DIRE ) then print( "selecting dire" ); SelectHero( 5, "npc_dota_hero_drow_ranger" ); SelectHero( 6, "npc_dota_hero_earthshaker" ); SelectHero( 7, "npc_dota_hero_juggernaut" ); SelectHero( 8, "npc_dota_hero_mirana" ); SelectHero( 9, "npc_dota_hero_nevermore" ); end end


item_purchase_bane.lua and item_purchase_lina.lua

function ItemPurchaseThink() end

Source

Similar Guides


More about Dota 2

Post: "Bot API bug" specifically for the game Dota 2. Other useful information about this game:





Top 20 NEW Medieval Games of 2021

Swords, dragons, knights, castles - if you love any of this stuff, you might like these games throughout 2021.



10 NEW Shooter Games of 2021 With Over The Top Action

We've been keeping our eye on these crazy action oriented first and third person shooter games releasing this year. What's on your personal list? Let us know!



Top 10 NEW Survival Games of 2021

Survival video games are still going strong in 2021. Here's everything to look forward to on PC, PS5, Xbox Series X, Nintendo Switch, and beyond.



You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *