-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathSpectre.lua
49 lines (38 loc) · 1.52 KB
/
Spectre.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
local Spectre = {}
Spectre.optionDagger = Menu.AddOption({"Hero Specific", "Spectre"}, "Auto Dagger", "Auto cast dagger for life steal")
Spectre.optionHaunt = Menu.AddOption({"Hero Specific", "Spectre"}, "Auto Haunt", "Auto haunt if can kill")
function Spectre.OnUpdate()
local myHero = Heroes.GetLocal()
if not myHero or NPC.GetUnitName(myHero) ~= "npc_dota_hero_spectre" then return end
if NPC.IsStunned(myHero) or NPC.IsSilenced(myHero) then return end
if Menu.IsEnabled(Spectre.optionDagger) then
Spectre.AutoDagger(myHero)
end
if Menu.IsEnabled(Spectre.optionHaunt) then
Spectre.AutoHaunt(myHero)
end
end
-- auto dagger for life steal
function Spectre.AutoDagger(myHero)
if not myHero then return end
local dagger = NPC.GetAbilityByIndex(myHero, 0)
if not dagger or not Ability.IsCastable(dagger, NPC.GetMana(myHero)) then return end
local level = Ability.GetLevel(dagger)
local damage = 50 * level
local range = 2000
local enemyAround = NPC.GetHeroesInRadius(myHero, range, Enum.TeamType.TEAM_ENEMY)
for i, enemy in ipairs(enemyAround) do
if not NPC.IsIllusion(enemy) and NPC.IsKillable(enemy)
and Entity.IsAlive(enemy) and not Entity.IsDormant(enemy)
and not NPC.HasState(npc, Enum.ModifierState.MODIFIER_STATE_MAGIC_IMMUNE) then
local true_damage = damage * NPC.GetMagicalArmorDamageMultiplier(enemy)
if Entity.GetHealth(enemy) <= true_damage then
Ability.CastTarget(dagger, enemy)
end
end
end
end
-- auto haunt if can kill, then haunt back
function Spectre.AutoHaunt(myHero)
end
return Spectre