-
Notifications
You must be signed in to change notification settings - Fork 1
/
ability_item_usage_meepo.lua
292 lines (280 loc) · 9.65 KB
/
ability_item_usage_meepo.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
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 meepoStatus = require(GetScriptDirectory() .."/meepo_status" )
local teamStatus = require( GetScriptDirectory() .."/team_status" )
function AbilityLevelUpThink()
ability_item_usage_generic.AbilityLevelUpThink();
end
function BuybackUsageThink()
ability_item_usage_generic.BuybackUsageThink();
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink();
end
if not GetBot():IsIllusion() then
meepoStatus.AddMeepo(GetBot())
teamStatus.AddHero(GetBot())
else
print("ILLUSION ALERT!")
end
local castNetDesire = 0;
local castPoofDesire = 0;
local castBlinkInitDesire = 0;
local castTalonDesire = 0;
local min = 0
local sec = 0
local courierTime = 0
function AbilityUsageThink()
local npcBot = GetBot();
min = math.floor(DotaTime() / 60)
sec = DotaTime() % 60
if ( npcBot:IsUsingAbility() ) then return end
abilityNet = npcBot:GetAbilityByName( "meepo_earthbind" );
abilityPoof = npcBot:GetAbilityByName( "meepo_poof" );
itemBlink = "item_blink";
itemTalon = "item_iron_talon";
for i=0, 5 do
if(npcBot:GetItemInSlot(i) ~= nil) then
local _item = npcBot:GetItemInSlot(i):GetName()
if(_item == itemBlink) then
itemBlink = npcBot:GetItemInSlot(i);
meepoStatus.SetIsFarmed(true)
end
if(_item == itemTalon) then
itemTalon = npcBot:GetItemInSlot(i);
end
end
end
castNetDesire, castNetTarget = ConsiderEarthBind();
castPoofDesire, castPoofTarget = ConsiderPoof();
castBlinkInitDesire, castBlinkInitTarget = ConsiderBlinkInit();
castTalonDesire, castTalonTarget = ConsiderTalon();
local highestDesire = castNetDesire;
local desiredSkill = 1;
if ( castPoofDesire > highestDesire)
then
highestDesire = castPoofDesire;
desiredSkill = 2;
end
if ( castBlinkInitDesire > highestDesire)
then
highestDesire = castBlinkInitDesire;
desiredSkill = 3;
end
if ( castTalonDesire > highestDesire)
then
highestDesire = castTalonDesire;
desiredSkill = 4;
end
if highestDesire == 0 then return;
elseif desiredSkill == 1 then
npcBot:Action_UseAbilityOnLocation( abilityNet, castNetTarget );
elseif desiredSkill == 2 then
npcBot:Action_UseAbilityOnEntity( abilityPoof, castPoofTarget );
elseif desiredSkill == 3 then
performBlinkInit( castBlinkInitTarget );
elseif desiredSkill == 4 then
npcBot:Action_UseAbilityOnEntity( itemTalon, castTalonTarget );
end
end
function CanCastEarthBindOnTarget( npcTarget )
return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
end
function ConsiderEarthBind()
local npcBot = GetBot();
if ( not abilityNet:IsFullyCastable() ) then
return BOT_ACTION_DESIRE_NONE;
end
local nRadius = abilityNet:GetSpecialValueInt( "radius" );
local nCastRange = abilityNet:GetCastRange();
local nSpeed = abilityNet:GetSpecialValueInt( "speed" )
if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH )
then
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange + nRadius, true, BOT_MODE_NONE );
for _,npcTarget in pairs( tableNearbyEnemyHeroes )
do
if ( npcBot:WasRecentlyDamagedByHero( npcTarget, 2.0 ) )
then
if ( CanCastEarthBindOnTarget( npcTarget ) )
then
return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetXUnitsInFront(100);
end
end
end
end
if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or
npcBot:GetActiveMode() == BOT_MODE_ATTACK or
npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or
npcBot:GetActiveMode() == BOT_MODE_GANK or
npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY )
then
local npcTarget = npcBot:GetTarget();
if ( npcTarget ~= nil )
then
if ( not npcTarget:HasModifier("modifier_meepo_earthbind") and CanCastEarthBindOnTarget( npcTarget ) and GetUnitToUnitDistance( npcBot, npcTarget ) < nCastRange)
then
local closest = 0
local distance = 100000
for _,meepo in pairs(meepoStatus.GetMeepos()) do
local net = meepo:GetAbilityByName("meepo_earthbind")
if net:IsFullyCastable() or net:GetCooldownTimeRemaining() > 7 then
if GetUnitToUnitDistance(meepo, npcTarget) < distance then
distance = GetUnitToUnitDistance(meepo, npcTarget)
closest = meepo
end
end
end
if closest ~= npcBot then
return BOT_ACTION_DESIRE_NONE
end
return BOT_ACTION_DESIRE_MODERATE, (npcTarget:GetExtrapolatedLocation( GetUnitToUnitDistance( npcBot, npcTarget ) / 857 ));
end
end
end
if npcBot:GetActiveMode() == BOT_MODE_ATTACK
then
local npcTarget = npcBot:GetTarget();
if ( npcTarget ~= nil)
then
if ( CanCastEarthBindOnTarget( npcTarget ) and GetUnitToUnitDistance( npcBot, npcTarget ) < 160)
then
return BOT_ACTION_DESIRE_MODERATE, npcTarget:GetXUnitsInFront(100);
end
end
end
return BOT_ACTION_DESIRE_NONE;
end
function CanCastPoofOnTarget( npcTarget )
return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
end
function ConsiderPoof()
local npcBot = GetBot();
if ( not abilityPoof:IsFullyCastable() ) then
return BOT_ACTION_DESIRE_NONE;
end
if ( castNetDesire > 0 ) then
return BOT_ACTION_DESIRE_NONE;
end
local nRadius = abilityPoof:GetSpecialValueInt( "radius" );
local nDamage = abilityPoof:GetAbilityDamage();
if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH )
then
for _,meepo in pairs( meepoStatus.GetMeepos() )
do
if (meepo:GetActiveMode() ~= BOT_MODE_EVASIVE_MANEUVERS and
meepo:GetActiveMode() ~= BOT_MODE_ATTACK and
meepo:GetActiveMode() ~= BOT_MODE_ROSHAN and
meepo:GetActiveMode() ~= BOT_MODE_DEFEND_ALLY and
GetUnitToUnitDistance( npcBot, meepo ) > 1500 and
meepo:DistanceFromFountain() < npcBot:DistanceFromFountain() )
then
return BOT_ACTION_DESIRE_MODERATE, meepo;
end
end
end
if ( npcBot:GetActiveMode() == BOT_MODE_LANING)
then
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1300, true, BOT_MODE_NONE );
local npcTarget = tableNearbyEnemyHeroes[1];
if ( npcTarget ~= nil )
then
if ( CanCastPoofOnTarget( npcTarget ) and GetUnitToUnitDistance( npcBot, npcTarget ) < nRadius / 2 )
then
if(npcBot:GetMana() > (npcBot:GetMaxMana() * .75))
then
return BOT_ACTION_DESIRE_MODERATE, npcBot;
end
end
else
end
end
if ( npcBot:GetActiveMode() == BOT_MODE_FARM and not ((min % 2 == 0 and sec > 40) or (min %2 == 1 and sec < 3)))
then
local tableNearbyCreeps = npcBot:GetNearbyCreeps( nRadius, true )
if(npcBot:GetMana() > (npcBot:GetMaxMana() * (.4 - (1 - (npcBot:GetHealth() / npcBot:GetMaxHealth())))) and #tableNearbyCreeps >= 2)
then
return BOT_ACTION_DESIRE_MODERATE, npcBot;
end
end
if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or
npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT or
npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID)
then
local tableNearbyCreeps = npcBot:GetNearbyCreeps( nRadius, true )
if(npcBot:GetMana() > (npcBot:GetMaxMana() * (.4 - (1 - (npcBot:GetHealth() / npcBot:GetMaxHealth())))) and #tableNearbyCreeps >= 4)
then
return BOT_ACTION_DESIRE_MODERATE, npcBot;
end
end
if npcBot:GetActiveMode() ~= BOT_MODE_RETREAT and npcBot:GetHealth() > (npcBot:GetMaxHealth() * .4) then
for _,meepo in pairs(meepoStatus.GetMeepos()) do
tableNearbyEnemyHeroes = meepo:GetNearbyHeroes( 1300, true, BOT_MODE_NONE );
if tableNearbyEnemyHeroes ~= nil and GetUnitToUnitDistance(npcBot, meepo) > 2000 then
if meepo:WasRecentlyDamagedByAnyHero( 1.0 ) then
return BOT_ACTION_DESIRE_HIGH, meepo
end
end
end
end
if npcBot:GetActiveMode() ~= BOT_MODE_RETREAT and npcBot:GetHealth() > (npcBot:GetMaxHealth() * .4) then
for _,meepo in pairs(meepoStatus.GetMeepos()) do
tableNearbyEnemyHeroes = meepo:GetNearbyHeroes( 160, true, BOT_MODE_NONE );
if tableNearbyEnemyHeroes ~= nil and npcBot:GetHealth() > meepo:GetHealth() then
if tableNearbyEnemyHeroes[1] ~= nil and meepo:GetActiveMode() ~= BOT_MODE_LANING then
return BOT_ACTION_DESIRE_HIGH, meepo;
end
end
end
end
return BOT_ACTION_DESIRE_NONE;
end
function ConsiderBlinkInit()
local npcBot = GetBot();
if not abilityPoof:IsFullyCastable()
then
return BOT_ACTION_DESIRE_NONE, 0;
end
local nCastRange = 1200;
local nRadius = abilityPoof:GetSpecialValueInt( "radius" );
local dmg = abilityPoof:GetAbilityDamage() * #meepoStatus.GetMeepos() * 1.25
local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1300, true, BOT_MODE_NONE );
for k,v in ipairs(tableNearbyEnemyHeroes) do
if(v:GetHealth() < dmg) then
return BOT_ACTION_DESIRE_MODERATE, v:GetLocation()
end
end
return BOT_ACTION_DESIRE_NONE, 0;
end
function performBlinkInit( castBlinkInitTarget )
local npcBot = GetBot();
if( itemBlink ~= "item_blink" and itemBlink:IsFullyCastable()) then
npcBot:Action_UseAbilityOnLocation( itemBlink, castBlinkInitTarget);
end
end
function ConsiderTalon()
local npcBot = GetBot();
if ( itemTalon == "item_iron_talon" or not itemTalon:IsFullyCastable() ) then
return BOT_ACTION_DESIRE_NONE;
end
if npcBot:GetActiveMode() == BOT_MODE_FARM then
local tableNearbyCreeps = npcBot:GetNearbyCreeps( 300, true )
local health = 0
local highHealthTarget = 0
for _,v in pairs(tableNearbyCreeps) do
if v:GetHealth() > health then
health = v:GetHealth()
highHealthTarget = v
end
end
if health > 0 then
return BOT_ACTION_DESIRE_HIGH, highHealthTarget
end
end
return BOT_ACTION_DESIRE_NONE
end
if DotaTime() < 0 then
return
end