forked from Eroica-cpp/dota2scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Abaddon.lua
100 lines (80 loc) · 3.64 KB
/
Abaddon.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
local Utility = require("Utility")
local Abaddon = {}
local optionAutoSave = Menu.AddOption({"Hero Specific", "Abaddon"}, "Auto Save", "Auto cast 'Aphotic Shield' to save needed ally")
local optionKillSteal = Menu.AddOption({"Hero Specific", "Abaddon"}, "Kill Steal", "Auto cast 'Mist Coil' to KS")
local optionAwareness = Menu.AddOption({"Hero Specific", "Abaddon"}, "Awareness", "Show how many hits left to kill enemy")
local font = Renderer.LoadFont("Tahoma", 30, Enum.FontWeight.EXTRABOLD)
function Abaddon.OnUpdate()
local myHero = Heroes.GetLocal()
if not myHero then return end
if not Utility.IsSuitableToCastSpell(myHero) then return end
if Menu.IsEnabled(optionAutoSave) then
Abaddon.AutoSave(myHero)
end
if Menu.IsEnabled(optionKillSteal) then
Abaddon.KillSteal(myHero)
end
end
function Abaddon.OnDraw()
if not Menu.IsEnabled(optionAwareness) then return end
local myHero = Heroes.GetLocal()
if not myHero or NPC.GetUnitName(myHero) ~= "npc_dota_hero_abaddon" then return end
local coil_damage = 0
local coil = NPC.GetAbility(myHero, "abaddon_death_coil")
if coil and Ability.IsCastable(coil, NPC.GetMana(myHero)) then
coil_damage = 50 + 50 * Ability.GetLevel(coil)
end
for i = 1, Heroes.Count() do
local enemy = Heroes.Get(i)
if not NPC.IsIllusion(enemy) and not Entity.IsSameTeam(myHero, enemy) and not Entity.IsDormant(enemy) and Entity.IsAlive(enemy) then
local enemyHp = Entity.GetHealth(enemy)
local physical_damage = NPC.GetTrueDamage(myHero) * NPC.GetArmorDamageMultiplier(enemy)
local magical_damage = coil_damage * NPC.GetMagicalArmorDamageMultiplier(enemy)
local enemyHpLeft = enemyHp - magical_damage
local hitsLeft = math.ceil(enemyHpLeft / math.max(physical_damage, 1))
-- draw
local pos = Entity.GetAbsOrigin(enemy)
local x, y, visible = Renderer.WorldToScreen(pos)
-- red : can kill; green : cant kill
if enemyHpLeft <= 0 then
Renderer.SetDrawColor(255, 0, 0, 255)
Renderer.DrawTextCentered(font, x, y, "Kill", 1)
else
Renderer.SetDrawColor(0, 255, 0, 255)
Renderer.DrawTextCentered(font, x, y, hitsLeft, 1)
end
end
end
end
function Abaddon.AutoSave(myHero)
local shield = NPC.GetAbility(myHero, "abaddon_aphotic_shield")
if not shield or not Ability.IsCastable(shield, NPC.GetMana(myHero)) then return end
if Utility.NeedToBeSaved(myHero) and Utility.CanCastSpellOn(myHero) then
Ability.CastTarget(shield, myHero)
return
end
local range = 500
local allies = NPC.GetHeroesInRadius(myHero, range, Enum.TeamType.TEAM_FRIEND)
for i, ally in ipairs(allies) do
if Utility.NeedToBeSaved(ally) and Utility.CanCastSpellOn(ally) then
Ability.CastTarget(shield, ally)
return
end
end
end
function Abaddon.KillSteal(myHero)
local coil = NPC.GetAbility(myHero, "abaddon_death_coil")
if not coil or not Ability.IsCastable(coil, NPC.GetMana(myHero)) then return end
local damage = 50 + 50 * Ability.GetLevel(coil)
local range = 800
local enemies = NPC.GetHeroesInRadius(myHero, range, Enum.TeamType.TEAM_ENEMY)
if not enemies or #enemies <= 0 then return end
for i, enemy in ipairs(enemies) do
local true_damage = damage * NPC.GetMagicalArmorDamageMultiplier(enemy)
if Entity.GetHealth(enemy) <= true_damage and Utility.CanCastSpellOn(enemy) then
Ability.CastTarget(coil, enemy)
return
end
end
end
return Abaddon