-
Notifications
You must be signed in to change notification settings - Fork 40
/
bot_spirit_breaker.lua
137 lines (114 loc) · 4.38 KB
/
bot_spirit_breaker.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
-------------------------------------------------------------------------------
--- AUTHOR: Nostrademous
--- GITHUB REPO: https://github.com/Nostrademous/Dota2-FullOverwrite
-------------------------------------------------------------------------------
local heroData = require( GetScriptDirectory().."/hero_data" )
local utils = require( GetScriptDirectory().."/utility" )
local dt = require( GetScriptDirectory().."/decision" )
local gHeroVar = require( GetScriptDirectory().."/global_hero_data" )
local ability = require( GetScriptDirectory().."/abilityUse/abilityUse_spirit_breaker" )
require( GetScriptDirectory().."/item_usage" )
function setHeroVar(var, value)
local bot = GetBot()
gHeroVar.SetVar(bot:GetPlayerID(), var, value)
end
function getHeroVar(var)
local bot = GetBot()
return gHeroVar.GetVar(bot:GetPlayerID(), var)
end
local SKILL_Q = heroData.spirit_breaker.SKILL_0
local SKILL_W = heroData.spirit_breaker.SKILL_1
local SKILL_E = heroData.spirit_breaker.SKILL_2
local SKILL_R = heroData.spirit_breaker.SKILL_3
local TALENT1 = heroData.spirit_breaker.TALENT_0
local TALENT2 = heroData.spirit_breaker.TALENT_1
local TALENT3 = heroData.spirit_breaker.TALENT_2
local TALENT4 = heroData.spirit_breaker.TALENT_3
local TALENT5 = heroData.spirit_breaker.TALENT_4
local TALENT6 = heroData.spirit_breaker.TALENT_5
local TALENT7 = heroData.spirit_breaker.TALENT_6
local TALENT8 = heroData.spirit_breaker.TALENT_7
local AbilityPriority = {
SKILL_Q, SKILL_E, SKILL_Q, SKILL_E, SKILL_Q,
SKILL_R, SKILL_Q, SKILL_E, SKILL_E, TALENT1,
SKILL_W, SKILL_R, SKILL_W, SKILL_W, TALENT3,
SKILL_W, SKILL_R, TALENT6, TALENT7
}
local botSB = dt:new()
function botSB:new(o)
o = o or dt:new(o)
setmetatable(o, self)
self.__index = self
return o
end
local sbBot = botSB:new{abilityPriority = AbilityPriority}
function sbBot:ConsiderAbilityUse()
return ability.AbilityUsageThink(GetBot())
end
function sbBot:GetNukeDamage(bot, target)
return ability.nukeDamage( bot, target )
end
function sbBot:QueueNuke(bot, target, actionQueue, engageDist)
return ability.queueNuke( bot, target, actionQueue, engageDist )
end
function sbBot:DoHeroSpecificInit(bot)
end
function Think()
local bot = GetBot()
-- We are charging
if (bot.dontInterruptTimer and (GameTime() - bot.dontInterruptTimer) < 1.0) or
bot:HasModifier("modifier_spirit_breaker_charge_of_darkness") then
ConsiderActionsWhileCharging(bot)
return
end
sbBot:Think(bot)
end
function sbBot:IsReadyToGank(bot)
local charge = bot:GetAbilityByName(SKILL_Q)
return charge:GetLevel() >= 2 and charge:IsFullyCastable()
end
function ConsiderActionsWhileCharging(bot)
-- we are retreating
if bot.SelfRef:getCurrentMode():GetName() == "retreat" then
local enemies = gHeroVar.GetNearbyEnemies(bot, 1600)
if #enemies == 0 then
bot:Action_ClearActions(true)
return
end
end
local target = getHeroVar("RoamTarget")
if not target then target = getHeroVar("Target") end
-- target TP'ed somewhere bad
if not utils.ValidTarget(target) then
bot:Action_ClearActions(true)
return
else
if GetUnitToLocationDistance(target, utils.Fountain(utils.GetOtherTeam())) < 1250 then
bot:Action_ClearActions(true)
return
end
end
local sb = utils.IsItemAvailable("item_invis_sword")
if sb then
local chargeSpeed = bot:GetAbilityByName(SKILL_Q):GetSpecialValueInt("movement_speed")
if not utils.ValidTarget(target) then target = getHeroVar("Target") end
if utils.ValidTarget(target) then
local timeToArrival = GetUnitToUnitDistance(bot, target)/chargeSpeed
if timeToArrival < 10.0 and timeToArrival > 2.0 then
item_usage.UseShadowBlade()
return
end
end
end
local se = utils.IsItemAvailable("item_silver_edge")
if se then
local chargeSpeed = bot:GetAbilityByName(SKILL_Q):GetSpecialValueInt("movement_speed")
if not utils.ValidTarget(target) then target = getHeroVar("Target") end
if utils.ValidTarget(target) then
if GetUnitToUnitDistance(bot, target)/chargeSpeed < 10.0 then
item_usage.UseSilverEdge()
return
end
end
end
end