-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathability_item_usage_monkey_king.lua
392 lines (342 loc) · 11.4 KB
/
ability_item_usage_monkey_king.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
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_shutnik" )
local utils = require(GetScriptDirectory() .. "/util")
local mutil = require(GetScriptDirectory() .. "/Mylogic")
if GetBot():IsInvulnerable() then
return;
end
function AbilityLevelUpThink()
ability_item_usage_generic.AbilityLevelUpThink();
end
function BuybackUsageThink()
ability_item_usage_generic.BuybackUsageThink();
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink();
end
local castBSDesire = 0;
local castTDDesire = 0;
local castPSDesire = 0;
local castPSEDesire = 0;
local castMCDesire = 0;
local castUTDesire = 0;
local castWCDesire = 0;
local abilityBS = nil;
local abilityTD = nil;
local abilityPS = nil;
local abilityPSE = nil;
local abilityMC = nil;
local abilityUT = nil;
local abilityWC = nil;
local PSLoc = {0, 0, 0};
local Ancient = GetAncient(GetTeam());
local npcBot = nil;
function AbilityUsageThink()
if npcBot == nil then npcBot = GetBot(); end
if abilityPSE == nil then abilityPSE = npcBot:GetAbilityByName( "monkey_king_primal_spring_early" ) end
castPSEDesire = ConsiderPrimalSpringEarly();
if ( castPSEDesire > 0 )
then
npcBot:Action_UseAbility( abilityPSE );
return;
end
if mutil.CanNotUseAbility(npcBot) then return end
if abilityBS == nil then abilityBS = npcBot:GetAbilityByName( "monkey_king_boundless_strike" ) end
if abilityTD == nil then abilityTD = npcBot:GetAbilityByName( "monkey_king_tree_dance" ) end
if abilityPS == nil then abilityPS = npcBot:GetAbilityByName( "monkey_king_primal_spring" ) end
if abilityMC == nil then abilityMC = npcBot:GetAbilityByName( "monkey_king_mischief" ) end
if abilityUT == nil then abilityUT = npcBot:GetAbilityByName( "monkey_king_untransform" ) end
if abilityWC == nil then abilityWC = npcBot:GetAbilityByName( "monkey_king_wukongs_command" ) end
castWCDesire, castWCLocation = ConsiderWukongCommand();
castBSDesire, castBSLocation = ConsiderBoundlessStrike();
castTDDesire, castTDTarget = ConsiderTreeDance();
castMCDesire = ConsiderMischief();
castUTDesire = ConsiderUntransform();
castPSDesire, castPSLocation = ConsiderPrimalSpring();
if ( castMCDesire > 0 )
then
npcBot:Action_UseAbility( abilityMC );
return;
end
if ( castUTDesire > 0 )
then
npcBot:Action_UseAbility( abilityUT );
return;
end
if ( castWCDesire > 0 )
then
npcBot:Action_UseAbilityOnLocation( abilityWC, castWCLocation );
return;
end
if ( castBSDesire > 0 )
then
npcBot:Action_UseAbilityOnLocation( abilityBS, castBSLocation );
return;
end
if ( castTDDesire > 0 )
then
npcBot:Action_UseAbilityOnTree( abilityTD, castTDTarget );
return;
end
if ( castPSDesire > 0 )
then
PSLoc = castPSLocation;
npcBot:Action_UseAbilityOnLocation( abilityPS, castPSLocation );
return;
end
end
function GetFurthestTree(trees)
if Ancient == nil then return nil end;
local furthest = nil;
local fDist = 10000;
for _,tree in pairs(trees)
do
local dist = GetUnitToLocationDistance(Ancient, GetTreeLocation(tree));
if dist < fDist then
furthest = tree;
fDist = dist;
end
end
return furthest;
end
function ConsiderBoundlessStrike()
if ( not abilityBS:IsFullyCastable() )
then
return BOT_ACTION_DESIRE_NONE, 0;
end
local nCastRange = abilityBS:GetCastRange();
local nCastPoint = abilityBS:GetCastPoint( );
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE );
for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
do
if ( npcEnemy:IsChanneling() )
then
return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation( nCastPoint );
end
end
if npcBot:HasModifier('modifier_monkey_king_jingu_mastery') then
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange , true, BOT_MODE_NONE );
for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
do
if (mutil.CanCastOnNonMagicImmune(npcEnemy) and mutil.IsInRange(npcEnemy, npcBot, nCastRange-200))
then
return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetExtrapolatedLocation( nCastPoint );
end
end
end
if mutil.IsRetreating(npcBot)
then
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_NONE );
for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
do
if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) )
then
return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetLocation( );
end
end
end
if mutil.IsInTeamFight(npcBot, 1200)
then
local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), nCastRange, 200, 0, 0 );
if ( locationAoE.count >= 2 )
then
return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc;
end
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if ( mutil.IsValidTarget(npcTarget) and mutil.CanCastOnNonMagicImmune(npcTarget) and mutil.IsInRange(npcTarget, npcBot, nCastRange-200) )
then
return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation( nCastPoint );
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end
function ConsiderTreeDance()
if ( not abilityTD:IsFullyCastable() or not abilityPS:IsFullyCastable() )
then
return BOT_ACTION_DESIRE_NONE, 0;
end
local nCastRange = abilityTD:GetCastRange();
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE );
if tableNearbyEnemyHeroes == nil then
return BOT_ACTION_DESIRE_NONE, 0;
end
if ( not abilityPS:IsFullyCastable() and not abilityPS:IsHidden() )
then
return BOT_ACTION_DESIRE_NONE, 0;
end
if mutil.IsRetreating(npcBot) and abilityPS:IsFullyCastable() and npcBot:DistanceFromFountain() > 1000 and #tableNearbyEnemyHeroes >= 1
then
local tableNearbyTrees = npcBot:GetNearbyTrees( nCastRange );
local furthest = GetFurthestTree(tableNearbyTrees);
if furthest ~= nil then
return BOT_ACTION_DESIRE_MODERATE, furthest;
end
end
if mutil.IsInTeamFight(npcBot, 1200)
then
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE );
for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
do
if ( mutil.IsInRange(npcEnemy, npcBot, nCastRange) )
then
local tableNearbyTrees = npcEnemy:GetNearbyTrees( nCastRange );
if tableNearbyTrees ~= nil and #tableNearbyTrees >= 1 then
return BOT_ACTION_DESIRE_MODERATE, tableNearbyTrees[1];
end
end
end
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if ( mutil.IsValidTarget(npcTarget) and mutil.CanCastOnNonMagicImmune(npcTarget) and mutil.IsInRange(npcTarget, npcBot, nCastRange) )
then
local tableNearbyTrees = npcTarget:GetNearbyTrees( nCastRange );
if tableNearbyTrees ~= nil and #tableNearbyTrees >= 1 then
return BOT_ACTION_DESIRE_MODERATE, tableNearbyTrees[1];
end
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end
function ConsiderPrimalSpring()
if ( not abilityPS:IsFullyCastable() or abilityPS:IsHidden() or abilityTD:GetCooldownTimeRemaining() > 1.4 )
then
return BOT_ACTION_DESIRE_NONE, 0;
end
local trees = npcBot:GetNearbyTrees(50);
if trees == nil or #trees == 0 then
return BOT_ACTION_DESIRE_NONE, 0;
end
local nCastRange = abilityPS:GetSpecialValueInt("max_distance");
local nRadius = abilityPS:GetSpecialValueInt("impact_radius");
local nCastPoint = abilityPS:GetChannelTime( );
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE );
if tableNearbyEnemyHeroes == nil then
return BOT_ACTION_DESIRE_NONE, 0;
end
if mutil.IsRetreating(npcBot) and #tableNearbyEnemyHeroes >= 1
then
local location = npcBot:GetXUnitsTowardsLocation( GetAncient(GetTeam()):GetLocation(), nCastRange );
return BOT_ACTION_DESIRE_MODERATE, location;
end
if mutil.IsInTeamFight(npcBot, 1200)
then
local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), nCastRange, nRadius, 0, 0 );
if ( locationAoE.count >= 2 )
then
return BOT_ACTION_DESIRE_LOW, locationAoE.targetloc;
end
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if mutil.IsValidTarget(npcTarget) and mutil.CanCastOnNonMagicImmune(npcTarget) and mutil.IsInRange(npcTarget, npcBot, nCastRange)
then
if mutil.IsDisabled(true, npcTarget) or npcTarget:GetMovementDirectionStability() < 1.0 then
return BOT_ACTION_DESIRE_HIGH, npcTarget:GetLocation( );
else
return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation( nCastPoint );
end
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end
function ConsiderPrimalSpringEarly()
if ( not abilityPSE:IsFullyCastable() or abilityPSE:IsHidden() )
then
return BOT_ACTION_DESIRE_NONE;
end
local trees = npcBot:GetNearbyTrees(50);
if trees == nil or #trees == 0 then
return BOT_ACTION_DESIRE_NONE;
end
local nRadius = 375;
if mutil.IsRetreating(npcBot)
then
return BOT_ACTION_DESIRE_MODERATE
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if mutil.IsValidTarget(npcTarget) and mutil.CanCastOnNonMagicImmune(npcTarget) and
( GetUnitToLocationDistance(npcTarget, PSLoc) >= ( 375 - 100 ) or npcTarget:GetHealth() <= 175 )
then
return BOT_ACTION_DESIRE_MODERATE;
end
end
return BOT_ACTION_DESIRE_NONE;
end
function ConsiderMischief()
if ( not abilityMC:IsFullyCastable() or abilityMC:IsHidden() )
then
return BOT_ACTION_DESIRE_NONE;
end
if mutil.IsRetreating(npcBot)
then
local tableNearbyEnemy = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_NONE );
if #tableNearbyEnemy >= 1 then
return BOT_ACTION_DESIRE_MODERATE
end
end
if mutil.IsDefending(npcBot) then
local tableNearbyAlly = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_NONE );
local tower = npcBot:GetNearbyTowers(1000, false);
if tower ~= nil and tableNearbyAlly ~= nil and #tower >= 1 and #tableNearbyAlly >= 2 then
return BOT_ACTION_DESIRE_MODERATE
end
end
return BOT_ACTION_DESIRE_NONE;
end
function ConsiderUntransform()
if ( not abilityUT:IsFullyCastable() or abilityUT:IsHidden() )
then
return BOT_ACTION_DESIRE_NONE;
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if mutil.IsValidTarget(npcTarget) and not mutil.IsInRange(npcTarget, npcBot, 1200)
then
return BOT_ACTION_DESIRE_MODERATE
end
end
if mutil.IsRetreating(npcBot) and not npcBot:WasRecentlyDamagedByAnyHero(4.0)
then
return BOT_ACTION_DESIRE_MODERATE
end
return BOT_ACTION_DESIRE_NONE;
end
function ConsiderWukongCommand()
if ( not abilityWC:IsFullyCastable() )
then
return BOT_ACTION_DESIRE_NONE, 0;
end
local nCastRange = abilityWC:GetSpecialValueInt("cast_range");
local nRadius = abilityWC:GetSpecialValueInt("second_radius");
if mutil.IsInTeamFight(npcBot, 1200)
then
local locationAoE = npcBot:FindAoELocation( true, true, npcBot:GetLocation(), nCastRange, nRadius/2, 0, 0 );
if ( locationAoE.count >= 2 )
then
return BOT_ACTION_DESIRE_MODERATE, locationAoE.targetloc;
end
end
if mutil.IsGoingOnSomeone(npcBot)
then
local npcTarget = npcBot:GetTarget();
if mutil.IsValidTarget(npcTarget) and mutil.IsInRange(npcTarget, npcBot, nCastRange+(nRadius/2))
then
local tableNearbyEnemyHeroes = npcTarget:GetNearbyHeroes( 1000, false, BOT_MODE_NONE );
if tableNearbyEnemyHeroes ~= nil and #tableNearbyEnemyHeroes >= 2 then
return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetExtrapolatedLocation(0.5);
end
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end