-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
ability_item_usage_tinker.lua
141 lines (119 loc) · 4.08 KB
/
ability_item_usage_tinker.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
140
141
local utility = require(GetScriptDirectory() .. "/utility")
local ability_item_usage_generic = require(GetScriptDirectory() .. "/ability_item_usage_generic")
local AbilityExtensions = require(GetScriptDirectory() .. "/util/AbilityAbstraction")
local debugmode = false
local npcBot = GetBot()
if npcBot == nil or npcBot:IsIllusion() then
return
end
local Talents = {}
local Abilities = {}
local AbilitiesReal = {}
ability_item_usage_generic.InitAbility(Abilities, AbilitiesReal, Talents)
local AbilityToLevelUp = {
Abilities[1],
Abilities[2],
Abilities[1],
Abilities[2],
Abilities[1],
Abilities[2],
Abilities[1],
Abilities[2],
Abilities[6],
"talent",
Abilities[3],
Abilities[6],
Abilities[3],
Abilities[3],
"talent",
Abilities[3],
"nil",
Abilities[6],
"nil",
"talent",
"nil",
"nil",
"nil",
"nil",
"talent",
}
local TalentTree = {
function() return Talents[2] end,
function() return Talents[3] end,
function() return Talents[5] end,
function() return Talents[7] end,
}
local Consider = {}
utility.CheckAbilityBuild(AbilityToLevelUp)
local function TryLastHitWithAttack(npc, target)
local time = npc:GetAttackPoint() + GetUnitToUnitDistance(npc, target) / npc:GetAttackProjectileSpeed()
return time
end
local function ReadyForLastHit(npc, target)
local damage = npc:GetAttackDamage()
if target:WasRecentlyDamagedByAnyHero(1.5) or target:WasRecentlyDamagedByCreep(1.7) then
damage = damage * 1.05
end
return target:GetActualIncomingDamage(damage, DAMAGE_TYPE_PHYSICAL) >= target:GetHealth()
end
Consider[1] = function()
local manaPercentage = AbilityExtensions:GetManaPercent(npcBot)
local ability = AbilitiesReal[1]
if not ability:IsFullyCastable() then
return 0
end
if npcBot:GetActiveMode() == BOT_MODE_LANING then
local enemyCreeps = npcBot:GetNearbyCreeps(1200, true)
local rangedCreep = AbilityExtensions:First(enemyCreeps, function(t)
return t:GetAttackRange() >= 500
end)
local enemy = AbilityExtensions:First(npcBot:GetNearbyHeroes(1200, true, BOT_MODE_NONE))
if rangedCreep ~= nil and enemy ~= nil then
if ReadyForLastHit(npcBot, rangedCreep) and manaPercentage >= 0.6 then
if enemy:GetAttackTarget() == rangedCreep then
return BOT_MODE_DESIRE_MODERATE, rangedCreep
end
if TryLastHitWithAttack(enemy, rangedCreep) < TryLastHitWithAttack(npcBot, rangedCreep) then
return BOT_MODE_DESIRE_MODERATE, rangedCreep
end
end
end
if enemy ~= nil then
local allCreeps = AbilityExtensions:Concat(npcBot:GetNearbyCreeps(900, true),
npcBot:GetNearbyCreeps(900, false))
allCreeps = AbilityExtensions:Filter(allCreeps,
function(t) return t:GetHealth() <= enemy:GetAttackDamage() * 1.2 end)
if #allCreeps >= 2 and manaPercentage >= 0.4 then
return BOT_MODE_DESIRE_MODERATE, enemy
end
if manaPercentage >= 0.6 then
return BOT_MODE_DESIRE_MODERATE, enemy
end
end
end
if AbilityExtensions:IsAttackingEnemies(npcBot) then
local enemies = npcBot:GetNearbyHeroes(900, true, BOT_MODE_NONE)
end
return 0
end
function BuybackUsageThink()
ability_item_usage_generic.BuybackUsageThink();
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink();
end
function AbilityLevelUpThink()
ability_item_usage_generic.AbilityLevelUpThink2(AbilityToLevelUp, TalentTree)
end
AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, AbilitiesReal)
function AbilityUsageThink()
if (npcBot:IsUsingAbility() or npcBot:IsChanneling() or npcBot:IsSilenced())
then
return
end
cast = ability_item_usage_generic.ConsiderAbility(AbilitiesReal, Consider)
ability_item_usage_generic.UseAbility(AbilitiesReal, cast)
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink()
end