-
Notifications
You must be signed in to change notification settings - Fork 52
/
Void.lua
95 lines (77 loc) · 3.82 KB
/
Void.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
local Utility = require("Utility")
local Void = {}
local optionKillStealCounter = Menu.AddOption({"Hero Specific", "Void"}, "Show KS Counter", "Show how many hits remains to kill.")
local optionAutoTimeDilation = Menu.AddOption({"Hero Specific", "Void"}, "Auto Time Dilation", "Auto cast time dilation when enemy is around")
function Void.OnUpdate()
if Menu.IsEnabled(optionAutoTimeDilation) then
Void.AutoTimeDilation()
end
end
function Void.AutoTimeDilation()
local myHero = Heroes.GetLocal()
if not myHero or not Utility.IsSuitableToCastSpell(myHero) then return end
local spell = NPC.GetAbility(myHero, "faceless_void_time_dilation")
if not spell or not Ability.IsCastable(spell, NPC.GetMana(myHero) - 200) then return end
local radius = 775
-- only auto cast time dilation when chrono is on cool down
local chrono = NPC.GetAbility(myHero, "faceless_void_chronosphere")
if chrono and Ability.IsCastable(chrono, NPC.GetMana(myHero)) then
return
end
for i = 1, Heroes.Count() do
local enemy = Heroes.Get(i)
if enemy and not NPC.IsIllusion(enemy) and not Entity.IsSameTeam(myHero, enemy)
and Utility.CanCastSpellOn(enemy) and NPC.IsEntityInRange(myHero, enemy, radius)
and (Utility.GetFixTimeLeft(enemy) <= 0.3 or not Utility.IsDisabled(enemy)) then
Ability.CastNoTarget(spell)
return
end
end
end
-- show how many hits left to KS
function Void.OnDraw()
if not Menu.IsEnabled(optionKillStealCounter) then return end
local myHero = Heroes.GetLocal()
if not myHero or NPC.GetUnitName(myHero) ~= "npc_dota_hero_faceless_void" then return end
-- if NPC.GetCurrentLevel(myHero) < 6 then return end
local faceless_void_time_lock = NPC.GetAbility(myHero, "faceless_void_time_lock")
local prob = 0
local magicalDamage = 0
if faceless_void_time_lock and Ability.GetLevel(faceless_void_time_lock) >= 1 then
prob = 0.08 + 0.04 * Ability.GetLevel(faceless_void_time_lock)
magicalDamage = 15 + 5 * Ability.GetLevel(faceless_void_time_lock)
end
-- the expectation of extra hits:
-- expectation = prob + prob**2 + ... + prob**n, (n to \infty)
expectation = prob / (1 - prob)
local faceless_void_chronosphere = NPC.GetAbility(myHero, "faceless_void_chronosphere")
local duration = 0
if faceless_void_chronosphere and Ability.GetLevel(faceless_void_chronosphere) >= 1 then
duration = 3.5 + 0.5 * Ability.GetLevel(faceless_void_time_lock)
end
local attacksPerChrono = math.floor(duration * NPC.GetAttacksPerSecond(myHero))
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 oneHitMagicalDamage = expectation * Utility.GetRealDamage(myHero, enemy, magicalDamage)
local oneHitPhysicalDamage = (1 + expectation) * Utility.GetTrueDamage(myHero) * NPC.GetArmorDamageMultiplier(enemy)
local oneHitDamage = oneHitMagicalDamage + oneHitPhysicalDamage
local hitsLeft = math.ceil(Entity.GetHealth(enemy) / oneHitDamage)
-- draw
local pos = Entity.GetAbsOrigin(enemy)
local x, y, visible = Renderer.WorldToScreen(pos)
local font = Renderer.LoadFont("Tahoma", 30, Enum.FontWeight.EXTRABOLD)
text = string.format("%d (%d)", hitsLeft, attacksPerChrono)
-- red : can kill; green : cant kill
if hitsLeft <= attacksPerChrono then
Renderer.SetDrawColor(255, 0, 0, 255)
Renderer.DrawTextCentered(font, x, y, text, 1)
else
Renderer.SetDrawColor(0, 255, 0, 255)
Renderer.DrawTextCentered(font, x, y, text, 1)
end
end
end
end
return Void