-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_purchase_antimage.lua
139 lines (122 loc) · 4.38 KB
/
item_purchase_antimage.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---------------------------------
-- Item Purchase for Anti-Mage --
---------------------------------
-- Récupération du bot sur lequel le script est exécuté
local npcBot = GetBot()
_G.sNextItem = nil
canBePurchasedFromSideShop = false
mustBePurchaseFromSecretShop = false
local hasSetTreadsToAgi = false
local tableItemsToBuy = {
-- start items
"item_tango",
"item_stout_shield",
"item_quelling_blade",
"item_flask",
---- semi start items
"item_boots",
"item_ring_of_health",
"item_boots_of_elves",
"item_gloves",
-- go battlefury
---- perseverance
"item_void_stone",
---- remaining items
"item_demon_edge",
"item_recipe_bfury",
-- go manta
---- yasha
"item_blade_of_alacrity",
"item_boots_of_elves",
"item_recipe_yasha",
---- remaining items
"item_ultimate_orb",
"item_recipe_manta",
---- basher
"item_mithril_hammer",
"item_belt_of_strength",
"item_recipe_basher",
-- go aghs
"item_blade_of_alacrity",
"item_staff_of_wizardry",
"item_ogre_axe",
"item_point_booster",
-- go abyssal
---- vanguard
"item_ring_of_health",
"item_stout_shield",
"item_vitality_booster",
---- recipe
"item_recipe_abyssal_blade",
-- go butterfly
"item_talisman_of_evasion",
"item_eagle",
"item_quarterstaff",
-- go tp boots
"item_boots",
"item_recipe_travel_boots",
"item_recipe_travel_boots"
-- TODO: HERE, CONSIDER A MOONSHARD TO CONSUME?
}
----------------------------------------------------------------------------------------------------
function ItemPurchaseThink()
-- Si tous les items ont été achetés, on ne dépense plus d'argent
if (#tableItemsToBuy == 0) then
npcBot:SetNextItemPurchaseValue(0)
return
end
-- Le prochain item à acheter est le prochain item de la liste (la liste rétrécit au fur et à mesure que les items sont achetés)
if (OwnsTeleportationDevice() or DotaTime() < 420) then
_G.sNextItem = tableItemsToBuy[1]
else
_G.sNextItem = "item_tpscroll"
end
-- On définit la valeur du prochain item à acheter au bot
npcBot:SetNextItemPurchaseValue(GetItemCost(_G.sNextItem))
local canBePurchasedFromSideShop = IsItemPurchasedFromSideShop(_G.sNextItem)
local goldBeforePotentialPurchase = npcBot:GetGold()
-- Si le bot a assez d'argent, ...
if (npcBot:GetGold() >= GetItemCost(_G.sNextItem)) then
if (npcBot:GetActiveMode() == BOT_MODE_SIDE_SHOP and _G.NPCHasReachedSideShop) then
npcBot:ActionImmediate_PurchaseItem(_G.sNextItem)
else
if (npcBot:GetActiveMode() == BOT_MODE_SECRET_SHOP) then -- and _G.NPCHasReachedSecretShop) then
npcBot:ActionImmediate_PurchaseItem(_G.sNextItem)
else
if ((canBePurchasedFromSideShop and not _G.sideShopNearby) or (not canBePurchasedFromSideShop)) then -- do same for secret shop
npcBot:ActionImmediate_PurchaseItem(_G.sNextItem)
end
end
end
local goldAfterPotentialPurchase = npcBot:GetGold()
-- TODO: Switch to agi treads
-- if (OwnsPowerTreads() and not hasSetTreadsToAgi) then
-- Passage des power treads en mode agilité
-- npcBot:Action_UseAbility(npcBot:GetItemInSlot(npcBot:FindItemSlot("item_power_treads")));
-- npcBot:Action_UseAbility(npcBot:GetItemInSlot(npcBot:FindItemSlot("item_power_treads")));
-- hasSetTreadsToAgi = true;
-- end
-- On enlève l'item acheté de la liste des items à acheter sauf si l'item acheté est un TP ou de la regen
if (_G.sNextItem ~= "item_tpscroll" and goldAfterPotentialPurchase ~= goldBeforePotentialPurchase) then
table.remove(tableItemsToBuy, 1)
end
end
end
----------------------------------------------------------------------------------------------------
function OwnsTeleportationDevice()
if
(npcBot:FindItemSlot("item_tpscroll") ~= -1 or npcBot:FindItemSlot("item_recipe_travel_boots") ~= -1 or
npcBot:FindItemSlot("item_recipe_travel_boots_2") ~= -1)
then
return true
else
return false
end
end
function OwnsPowerTreads()
if (npcBot:FindItemSlot("item_power_treads") ~= -1) then
return true
else
return false
end
end