diff --git a/mode_secret_shop_generic.lua b/mode_secret_shop_generic.lua index 2a54941..e74cea2 100644 --- a/mode_secret_shop_generic.lua +++ b/mode_secret_shop_generic.lua @@ -69,8 +69,22 @@ function OnEnd() end -function Think() +local fullInvCheck = -90 + +local earlyGameItem = { + "item_clarity", + "item_faerie_fire", + "item_tango", + "item_flask", + -- "item_orb_of_venom", + "item_bracer", + "item_wraith_band", + "item_null_talisman", + "item_infused_raindrop", + "item_bottle", +} +function Think() if bot:IsChanneling() or bot:NumQueuedActions() > 0 or bot:IsCastingAbility() @@ -79,6 +93,59 @@ function Think() return end + local botLevel = bot:GetLevel() + local currentTime = DotaTime() + local botWorth = bot:GetNetWorth() + + --卖掉一些早期的低端物品用来腾格子 + if (GetGameMode() ~= 23 and botLevel > 6 and currentTime > fullInvCheck + 1.0 + and (bot:DistanceFromFountain() <= 200 or bot:DistanceFromSecretShop() <= 200)) + or (GetGameMode() == 23 and botLevel > 9 and currentTime > fullInvCheck + 1.0) + then + local emptySlot = X.GetEmptyInventoryAmount(bot) + local slotToSell = nil + + local preEmpty = 2 + if botLevel <= 17 then preEmpty = 1 end + if emptySlot <= preEmpty - 1 + then + for i = 1, #earlyGameItem + do + local itemName = earlyGameItem[i] + local itemSlot = bot:FindItemSlot(itemName) + if itemSlot >= 0 and itemSlot <= 8 + then + slotToSell = itemSlot + break + end + end + end + + --避免过早卖掉大魔棒 + if botWorth > 9999 + then + local wand = bot:FindItemSlot("item_magic_wand") + local assitItem = bot:FindItemSlot("item_infused_raindrop") + if assitItem < 0 then assitItem = bot:FindItemSlot("item_bracer") end + if assitItem < 0 then assitItem = bot:FindItemSlot("item_null_talisman") end + if assitItem < 0 then assitItem = bot:FindItemSlot("item_wraith_band") end + if assitItem >= 0 + and wand >= 6 + and wand <= 8 + then + slotToSell = assitItem + end + end + + if slotToSell ~= nil + then + bot:ActionImmediate_SellItem(bot:GetItemInSlot(slotToSell)) + return + end + + fullInvCheck = currentTime + end + if bot:DistanceFromSecretShop() == 0 then bot:Action_MoveToLocation(preferedShop + RandomVector(200)) @@ -90,23 +157,26 @@ function Think() bot:Action_MoveToLocation(preferedShop + RandomVector(20)); return; end +end + +function X.GetEmptyInventoryAmount( bot ) + + local amount = 0 + for i = 0, 8 + do + local item = bot:GetItemInSlot( i ) + if item == nil + then + amount = amount + 1 + end + end + + return amount end --这些是AI会主动走到商店出售的物品 function X.HaveItemToSell() - local earlyGameItem = { - "item_clarity", - "item_faerie_fire", - "item_tango", - "item_flask", - -- "item_orb_of_venom", - "item_bracer", - "item_wraith_band", - "item_null_talisman", - "item_infused_raindrop", - "item_bottle", - } for _, item in pairs(earlyGameItem) do local slot = bot:FindItemSlot(item) if slot >= 0 and slot <= 8 then