-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
ability_item_usage_rattletrap.lua
159 lines (142 loc) · 4.68 KB
/
ability_item_usage_rattletrap.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
-- v1.7 template by AaronSong321
local utility = require(GetScriptDirectory() .. "/utility")
local ability_item_usage_generic = require(GetScriptDirectory() .. "/ability_item_usage_generic")
local AbilityExtensions = require(GetScriptDirectory() .. "/util/AbilityAbstraction")
local npcBot = GetBot()
if npcBot == nil or npcBot:IsIllusion() then
return
end
if npcBot:IsIllusion() then
return
end
local AbilityNames, Abilities, Talents = AbilityExtensions:InitAbility(npcBot)
--local CanCast = {utility.NCanCast,utility.UCanCast,utility.NCanCast,utility.UCanCast,utility.UCanCast}
local AbilityToLevelUp =
{
AbilityNames[2],
AbilityNames[3],
AbilityNames[3],
AbilityNames[1],
AbilityNames[3],
AbilityNames[5],
AbilityNames[3],
AbilityNames[2],
AbilityNames[2],
"talent",
AbilityNames[2],
AbilityNames[1],
AbilityNames[1],
AbilityNames[1],
"talent",
AbilityNames[5],
"nil",
AbilityNames[5],
"nil",
"talent",
"nil",
"nil",
"nil",
"nil",
"talent",
}
local TalentTree = {
function()
return Talents[1]
end,
function()
return Talents[4]
end,
function()
return Talents[5]
end,
function()
return Talents[8]
end
}
utility.CheckAbilityBuild(AbilityToLevelUp)
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
local cast = {}
cast.Desire = {}
cast.Target = {}
cast.Type = {}
local CanCast = {}
CanCast[1] = function(t) return AbilityExtensions:NormalCanCast(t, false, DAMAGE_TYPE_MAGICAL, false) end
CanCast[2] = CanCast[1]
CanCast[3] = function(t)
local ability = npcBot:GetAbilityByName("special_bonus_unique_clockwerk_6")
local breakInvisible = ability:GetLevel() == 1 and not ability:CanAbilityBeUpgraded()
if breakInvisible then
return AbilityExtensions:NormalCanCast(t, true, DAMAGE_TYPE_MAGICAL, false, false)
else
return AbilityExtensions:NormalCanCast(t, true, DAMAGE_TYPE_MAGICAL, false, t:IsInvisible())
end
end
CanCast[4] = function() return true end
CanCast[5] = CanCast[4]
CanCast[6] = function(t)
return AbilityExtensions:NormalCanCast(t, false, DAMAGE_TYPE_MAGICAL, true)
end
local Consider = {}
local attackRange
local healthPercent
local mana
local manaPercent
Consider[1] = function()
local ability = Abilities[1]
if not ability:IsFullyCastable() then
return 0
end
local abilityLevel = ability:GetLevel()
local castRange = ability:GetCastRange()
local castPoint = ability:GetCastPoint()
local manaCost = ability:GetManaCost()
local duration = ability:GetDuration()
local enemies = AbilityExtensions:GetNearbyHeroes(npcBot, castRange)
local realEnemies = AbilityExtensions:Filter(enemies,
function(t) return AbilityExtensions:MayNotBeIllusion(npcBot, t) end)
local targettableEnemies = AbilityExtensions:Filter(realEnemies,
function(t) return AbilityExtensions:NormalCanCast(t, false, DAMAGE_TYPE_MAGICAL, false) end)
local friends = AbilityExtensions:GetNearbyHeroes(npcBot, 1200, true)
local friendCount = AbilityExtensions:GetEnemyHeroNumber(npcBot, friends)
local enemyCreeps = AbilityExtensions:GetNearbyAttackableCreeps(npcBot, castRange)
local friendCreeps = AbilityExtensions:GetNearbyAttackableCreeps(npcBot, npcBot:GetAttackRange() + 150, false)
local neutralCreeps = npcBot:GetNearbyNeutralCreeps(castRange)
local damage = ability:GetSpecialValueInt("total_damage")
local weakestEnemy, enemyHealth = utility.GetWeakestUnit(targettableEnemies)
local weakCreeps = AbilityExtensions:Filter(enemyCreeps,
function(t) return t:GetHealth() < t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) end)
local weakestCreep = utility.GetWeakestUnit(weakCreeps)
local forbiddenCreeps = AbilityExtensions:Filter(enemyCreeps, function(t)
return t:GetHealth() > t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) and
t:GetHealth() <=
t:GetActualIncomingDamage(damage, DAMAGE_TYPE_MAGICAL) +
AbilityExtensions:AttackOnceDamage(npcBot, t) * (0.9 + #enemyCreeps * 0.1)
end)
if #friendCreeps == 0 then
forbiddenCreeps = {}
end
return 0
end
AbilityExtensions:AutoModifyConsiderFunction(npcBot, Consider, Abilities)
function AbilityUsageThink()
if npcBot:IsChanneling() or npcBot:IsSilenced() then
return
end
attackRange = npcBot:GetAttackRange()
healthPercent = AbilityExtensions:GetHealthPercent(npcBot)
mana = npcBot:GetMana()
manaPercent = AbilityExtensions:GetManaPercent(npcBot)
cast = ability_item_usage_generic.ConsiderAbility(Abilities, Consider)
local abilityIndex, target, castType = ability_item_usage_generic.UseAbility(Abilities, cast)
end
function CourierUsageThink()
ability_item_usage_generic.CourierUsageThink()
end