-
Notifications
You must be signed in to change notification settings - Fork 52
/
ability_item_usage_lich.lua
304 lines (257 loc) · 9.01 KB
/
ability_item_usage_lich.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
if GetBot():IsInvulnerable() or not GetBot():IsHero() or not string.find(GetBot():GetUnitName(), "hero") or GetBot():IsIllusion() then
return;
end
local ability_item_usage_generic = dofile( GetScriptDirectory().."/ability_item_usage_generic" )
local utils = require(GetScriptDirectory() .. "/util")
local mutils = require(GetScriptDirectory() .. "/MyUtility")
local abUtils = require(GetScriptDirectory() .. "/AbilityItemUsageUtility")
function AbilityLevelUpThink()
ability_item_usage_generic.AbilityLevelUpThink();
end
function BuybackUsageThink()
ability_item_usage_generic.BuybackUsageThink();
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink();
end
function ItemUsageThink()
ability_item_usage_generic.ItemUsageThink();
end
local bot = GetBot();
local abilities = {};
local castCombo1Desire = 0;
local castCombo2Desire = 0;
local castQDesire = 0;
local castWDesire = 0;
local castEDesire = 0;
local castRDesire = 0;
local lastCheck = -90;
function AbilityUsageThink()
if #abilities == 0 then abilities = mutils.InitiateAbilities(bot, {0,1,2,5}) end
if mutils.CantUseAbility(bot) then return end
castQDesire, targetQ = ConsiderQ();
castWDesire, targetW = ConsiderW();
castEDesire, targetE = ConsiderE();
castRDesire, targetR = ConsiderR();
if castRDesire > 0 then
bot:Action_UseAbilityOnEntity(abilities[4], targetR);
return
end
if castQDesire > 0 then
bot:Action_UseAbilityOnEntity(abilities[1], targetQ);
return
end
if castWDesire > 0 then
bot:Action_UseAbilityOnEntity(abilities[2], targetW);
return
end
if castEDesire > 0 then
local typeAOE = mutils.CheckFlag(abilities[3]:GetBehavior(), ABILITY_BEHAVIOR_POINT);
if typeAOE == true then
bot:Action_UseAbilityOnLocation( abilities[3], targetE:GetLocation() );
else
bot:Action_UseAbilityOnEntity( abilities[3], targetE );
end
return
end
end
function ConsiderQ()
if not mutils.CanBeCast(abilities[1]) then
return BOT_ACTION_DESIRE_NONE, nil;
end
local nCastRange = mutils.GetProperCastRange(false, bot, abilities[1]:GetCastRange());
local nCastPoint = abilities[1]:GetCastPoint();
local manaCost = abilities[1]:GetManaCost();
local nRadius = abilities[1]:GetSpecialValueInt( "radius" );
if mutils.IsRetreating(bot) and bot:WasRecentlyDamagedByAnyHero(2.0)
then
local target = mutils.GetVulnerableWeakestUnit(true, true, nCastRange, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
if bot:GetActiveMode() == BOT_MODE_LANING and mutils.CanSpamSpell(bot, manaCost)then
local target = mutils.GetVulnerableWeakestUnit(true, true, nCastRange, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
if mutils.IsInTeamFight(bot, 1300)
then
local locationAoE = bot:FindAoELocation( true, true, bot:GetLocation(), nCastRange, nRadius, nCastPoint, 0 );
if ( locationAoE.count >= 2 ) then
local target = mutils.GetVulnerableUnitNearLoc(true, true, nCastRange, nRadius, locationAoE.targetloc, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
end
if ( mutils.IsPushing(bot) or mutils.IsDefending(bot) ) and mutils.CanSpamSpell(bot, manaCost)
then
local locationAoE = bot:FindAoELocation( true, false, bot:GetLocation(), nCastRange, nRadius, 0, 0 );
if ( locationAoE.count >= 3 ) then
local target = mutils.GetVulnerableUnitNearLoc(false, true, nCastRange, nRadius, locationAoE.targetloc, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
end
if mutils.IsGoingOnSomeone(bot)
then
local target = bot:GetTarget();
if mutils.IsValidTarget(target) and mutils.CanCastOnNonMagicImmune(target) and mutils.IsInRange(target, bot, nCastRange)
then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
return BOT_ACTION_DESIRE_NONE, nil;
end
function ConsiderW()
if not mutils.CanBeCast(abilities[2]) then
return BOT_ACTION_DESIRE_NONE, nil;
end
local nCastRange = mutils.GetProperCastRange(false, bot, abilities[2]:GetCastRange());
local nCastPoint = abilities[2]:GetCastPoint();
local manaCost = abilities[2]:GetManaCost();
local nRadius = abilities[2]:GetSpecialValueInt( "radius" );
if mutils.IsRetreating(bot) and bot:WasRecentlyDamagedByAnyHero(2.0)
then
if abilities[1]:IsFullyCastable() == false and mutils.CanCastOnNonMagicImmune(bot) then
return BOT_ACTION_DESIRE_HIGH, bot;
end
end
if mutils.IsInTeamFight(bot, 1300) and mutils.CanCastOnNonMagicImmune(bot) == true
then
local enemies = bot:GetNearbyHeroes(nCastRange, true, BOT_MODE_NONE);
local locationAoE = bot:FindAoELocation( true, true, bot:GetLocation(), 0, nRadius, 0, 0 );
local unitCount = abUtils.CountVulnerableUnit(enemies, locationAoE, nRadius, 2);
if ( unitCount >= 2 )
then
return BOT_ACTION_DESIRE_LOW, bot;
end
end
if DotaTime() >= lastCheck + 0.5 then
local weakest = nil;
local minHP = 100000;
local enemies = bot:GetNearbyHeroes(1300, true, BOT_MODE_NONE);
local allies = bot:GetNearbyHeroes(nCastRange, false, BOT_MODE_NONE);
if #allies > 0 and #enemies >= 1 then
for i=1,#allies do
if mutils.CanCastOnNonMagicImmune(allies[i])
and allies[i]:WasRecentlyDamagedByAnyHero(2.0)
and ( allies[i]:GetAttackTarget() == nil or mutils.IsRetreating(allies[i]) )
and allies[i]:GetHealth() <= minHP
and allies[i]:GetHealth() <= 0.5*allies[i]:GetMaxHealth()
then
weakest = allies[i];
minHP = allies[i]:GetHealth();
end
end
end
if weakest ~= nil then
return BOT_ACTION_DESIRE_HIGH, weakest;
end
lastCheck = DotaTime();
end
if mutils.IsGoingOnSomeone(bot) and mutils.CanCastOnNonMagicImmune(bot) == true
then
local target = bot:GetTarget();
if mutils.IsValidTarget(target) and mutils.CanCastOnNonMagicImmune(target) and mutils.IsInRange(target, bot, nRadius)
then
return BOT_ACTION_DESIRE_HIGH, bot;
end
end
return BOT_ACTION_DESIRE_NONE, nil;
end
function ConsiderE()
if not mutils.CanBeCast(abilities[3])
then
return BOT_ACTION_DESIRE_NONE, nil;
end
local nCastRange = mutils.GetProperCastRange(false, bot, abilities[3]:GetCastRange());
local tableNearbyEnemyHeroes = bot:GetNearbyHeroes( nCastRange + 200, true, BOT_MODE_NONE );
--if we can kill any enemies
for _,npcEnemy in pairs(tableNearbyEnemyHeroes)
do
if mutils.CanCastOnNonMagicImmune(npcEnemy) and npcEnemy:IsChanneling() then
return BOT_ACTION_DESIRE_HIGH, npcEnemy;
end
end
if ( bot:GetActiveMode() == BOT_MODE_ROSHAN )
then
local npcTarget = bot:GetAttackTarget();
if ( mutils.IsRoshan(npcTarget) and mutils.CanCastOnMagicImmune(npcTarget) and mutils.IsInRange(npcTarget, bot, nCastRange)
and not mutils.IsDisabled(true, npcTarget) )
then
return BOT_ACTION_DESIRE_LOW, npcTarget;
end
end
if mutils.IsInTeamFight(bot, 1200)
then
local highesAD = 0;
local highesADUnit = nil;
for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
do
local EnemyAD = npcEnemy:GetAttackDamage();
if ( mutils.CanCastOnNonMagicImmune(npcEnemy) and not mutils.IsDisabled(true, npcEnemy) and
EnemyAD > highesAD )
then
highesAD = EnemyAD;
highesADUnit = npcEnemy;
end
end
if highesADUnit ~= nil then
return BOT_ACTION_DESIRE_HIGH, highesADUnit;
end
end
-- If we're going after someone
if mutils.IsGoingOnSomeone(bot)
then
local npcTarget = bot:GetTarget();
if mutils.IsValidTarget(npcTarget) and mutils.CanCastOnNonMagicImmune(npcTarget) and mutils.IsInRange(npcTarget, bot, nCastRange + 200)
and not mutils.IsDisabled(true, npcTarget)
then
return BOT_ACTION_DESIRE_HIGH, npcTarget;
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end
function ConsiderR()
if not mutils.CanBeCast(abilities[4]) then
return BOT_ACTION_DESIRE_NONE, nil;
end
local nCastRange = mutils.GetProperCastRange(false, bot, abilities[4]:GetCastRange());
local nCastPoint = abilities[4]:GetCastPoint();
local manaCost = abilities[4]:GetManaCost();
local nRadius = abilities[4]:GetSpecialValueInt( "jump_range" );
if mutils.IsRetreating(bot) and bot:WasRecentlyDamagedByAnyHero(2.0)
then
local target = mutils.GetVulnerableWeakestUnit(true, true, nCastRange, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
if mutils.IsInTeamFight(bot, 1300)
then
local locationAoE = bot:FindAoELocation( true, true, bot:GetLocation(), nCastRange, nRadius, nCastPoint, 0 );
if ( locationAoE.count >= 2 ) then
local target = mutils.GetVulnerableUnitNearLoc(true, true, nCastRange, nRadius, locationAoE.targetloc, bot);
if target ~= nil then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
end
if mutils.IsGoingOnSomeone(bot)
then
local target = bot:GetTarget();
if mutils.IsValidTarget(target) and mutils.CanCastOnNonMagicImmune(target) and mutils.IsInRange(target, bot, nCastRange)
then
local enemies = target:GetNearbyHeroes( nRadius-200, false, BOT_MODE_NONE );
local nInvUnit = mutils.CountInvUnits(false, enemies);
if nInvUnit >= 2 then
return BOT_ACTION_DESIRE_HIGH, target;
end
end
end
return BOT_ACTION_DESIRE_NONE, nil;
end