-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathDragonKnight.lua
110 lines (87 loc) · 4.28 KB
/
DragonKnight.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
-- File: DragonKnight.lua
-- Author: EroicaCpp (https://github.com/Eroica-cpp/dota2scripts)
-- Version: 1.0
-- Release Date: 2017/6/26
local Utility = require("Utility")
local DragonKnight = {}
local optionKillSteal = Menu.AddOption({"Hero Specific", "Dragon Knight"}, "Kill Steal", "Cast breathe fire on enemy to KS")
local optionAutoStun = Menu.AddOption({"Hero Specific", "Dragon Knight"}, "Auto Stun", "Auto stun enemy in range")
local optionAwareness = Menu.AddOption({"Hero Specific", "Dragon Knight"}, "Awareness", "Show how many hits left to kill enemy")
local font = Renderer.LoadFont("Tahoma", 30, Enum.FontWeight.EXTRABOLD)
function DragonKnight.OnUpdate()
if Menu.IsEnabled(optionKillSteal) then
DragonKnight.KillSteal()
end
if Menu.IsEnabled(optionAutoStun) then
DragonKnight.AutoStun()
end
end
function DragonKnight.OnDraw()
if not Menu.IsEnabled(optionAwareness) then return end
local myHero = Heroes.GetLocal()
if not myHero or NPC.GetUnitName(myHero) ~= "npc_dota_hero_dragon_knight" then return end
local fire_damage = 0
local fire = NPC.GetAbility(myHero, "dragon_knight_breathe_fire")
if fire and Ability.IsCastable(fire, NPC.GetMana(myHero)) then
fire_damage = 20 + 70 * Ability.GetLevel(fire)
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.GetDamageMultiplierVersus(myHero, enemy) * NPC.GetTrueDamage(myHero) * NPC.GetArmorDamageMultiplier(enemy)
local magical_damage = fire_damage * NPC.GetMagicalArmorDamageMultiplier(enemy)
local enemyHpLeft = enemyHp - magical_damage
local hitsLeft = math.ceil(enemyHpLeft / (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 DragonKnight.KillSteal()
local myHero = Heroes.GetLocal()
if not myHero then return end
if not Utility.IsSuitableToCastSpell(myHero) then return end
local fire = NPC.GetAbility(myHero, "dragon_knight_breathe_fire")
if not fire or not Ability.IsCastable(fire, NPC.GetMana(myHero)) then return end
local damage = 20 + 70 * Ability.GetLevel(fire)
local range = 900
local enemyHeroes = NPC.GetHeroesInRadius(myHero, range, Enum.TeamType.TEAM_ENEMY)
if not enemyHeroes or #enemyHeroes <= 0 then return end
for i, enemy in ipairs(enemyHeroes) do
local true_damage = damage * NPC.GetMagicalArmorDamageMultiplier(enemy)
if not NPC.IsIllusion(enemy) and Utility.CanCastSpellOn(enemy) and Entity.GetHealth(enemy) <= true_damage then
local dir = Entity.GetAbsOrigin(enemy) - Entity.GetAbsOrigin(myHero)
local pos = Entity.GetAbsOrigin(myHero) + dir:Normalized():Scaled(450)
Ability.CastPosition(fire, pos)
return
end
end
end
function DragonKnight.AutoStun()
local myHero = Heroes.GetLocal()
if not myHero then return end
if not Utility.IsSuitableToCastSpell(myHero) then return end
local stun = NPC.GetAbility(myHero, "dragon_knight_dragon_tail")
if not stun or not Ability.IsCastable(stun, NPC.GetMana(myHero)) then return end
local range = 150
if NPC.HasModifier(myHero, "modifier_dragon_knight_dragon_form") then range = 400 end
local enemyHeroes = NPC.GetHeroesInRadius(myHero, range, Enum.TeamType.TEAM_ENEMY)
if not enemyHeroes or #enemyHeroes <= 0 then return end
for i, enemy in ipairs(enemyHeroes) do
if not NPC.IsIllusion(enemy) and Utility.CanCastSpellOn(enemy) and not Utility.IsLotusProtected(enemy) and not Utility.IsDisabled(enemy) then
Ability.CastTarget(stun, enemy)
return
end
end
end
return DragonKnight