-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathability_item_usage_generic.lua
More file actions
87 lines (68 loc) · 2.74 KB
/
ability_item_usage_generic.lua
File metadata and controls
87 lines (68 loc) · 2.74 KB
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
----------------------------------------------------------------------------------------------------
_G._savedEnv = getfenv()
module( "ability_item_usage_generic", package.seeall )
----------------------------------------------------------------------------------------------------
local itemFunctions = {}
itemFunctions["item_bottle"] = function(bot, item)
if not bot:HasModifier("modifier_bottle_regeneration") and item:GetCurrentCharges() > 0 and bot:TimeSinceDamagedByAnyHero() > 2 and bot:GetMaxMana() - bot:GetMana() >= 60 and bot:GetMaxHealth() - bot:GetHealth() >= 90 then
bot:Action_UseAbility(item)
end
end
itemFunctions["item_courier"] = function(bot, item)
bot:Action_UseAbility(item)
end
itemFunctions["item_tome_of_knowledge"] = function(bot, item)
bot:Action_UseAbility(item)
end
itemFunctions["item_clarity"] = function(bot, item)
if not bot:HasModifier("modifier_clarity_potion") and bot:TimeSinceDamagedByAnyHero() > 4 and bot:GetMaxMana() - bot:GetMana() >= 190 then
bot:Action_UseAbilityOnEntity(item, bot)
end
end
itemFunctions["item_flask"] = function(bot, item)
if not bot:HasModifier("modifier_flask_healing") and #bot:GetNearbyHeroes(1600, true, BOT_MODE_NONE) == 0 and bot:GetMaxHealth() - bot:GetHealth() >= 400 then
bot:Action_UseAbilityOnEntity(item, bot)
end
end
itemFunctions["item_faerie_fire"] = function(bot, item)
if bot:GetHealth() <= 70 then
bot:Action_UseAbility(item)
end
end
itemFunctions["item_magic_stick"] = function(bot, item)
if item:GetCurrentCharges() > 0 and bot:GetHealth() <= 200 then
bot:Action_UseAbility(item)
end
end
itemFunctions["item_magic_wand"] = itemFunctions["item_magic_stick"]
itemFunctions["item_tango"] = function(bot, item)
if not bot:HasModifier("modifier_tango_heal") and bot:GetMaxHealth() - bot:GetHealth() >= 115 then
local tree = bot:GetNearbyTrees(item:GetCastRange())[1]
if tree then
bot:Action_UseAbilityOnTree(item, tree)
end
end
end
itemFunctions["item_tango_single"] = itemFunctions["item_tango"]
function ItemUsageThink(itemFunctionOverride)
itemFunctionOverride = itemFunctionOverride or {}
local function f()
local bot = GetBot()
for i = 0,5 do
local item = bot:GetItemInSlot(i)
if item and item:IsFullyCastable() then
if itemFunctionOverride[item:GetName()] then
itemFunctionOverride[item:GetName()](bot, item)
elseif itemFunctions[item:GetName()] then
itemFunctions[item:GetName()](bot, item)
end
end
end
end
local status,err = pcall(f)
if not status then
print(err)
end
end
----------------------------------------------------------------------------------------------------
for k,v in pairs( ability_item_usage_generic ) do _G._savedEnv[k] = v end