forked from redprince/BoL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimedSpells.lua
74 lines (66 loc) · 2.92 KB
/
timedSpells.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
local TIMERTYPE_ENDPOS = 1
local TIMERTYPE_STARTPOS = 2
local TIMERTYPE_CASTER = 3
local timedDrawings = {}
function OnDraw()
for i, tDraw in pairs(timedDrawings) do
if tDraw.endTime > os.clock() and tDraw.startTime < os.clock() then
if tDraw.stickTo then
DrawText3D(tostring(round(tDraw.endTime - os.clock(),1)), tDraw.stickTo.pos.x, tDraw.stickTo.pos.y, tDraw.stickTo.pos.z, 30, ARGB(255,255,255,255), true)
else
DrawText3D(tostring(round(tDraw.endTime - os.clock(),1)), tDraw.pos.x, tDraw.pos.y, tDraw.pos.z, 30, ARGB(255,255,255,255), true)
end
end
end
end
function OnProcessSpell(caster,spell)
if caster ~= nil and caster.valid and caster.type == "AIHeroClient" then
if spell and spell.name and timerType(spell.name) then
local tType, duration, delay = timerType(spell.name)
if tType == TIMERTYPE_ENDPOS then
addTimedDrawPos(spell.endPos.x, spell.endPos.y, spell.endPos.z, duration, delay)
elseif tType == TIMERTYPE_STARTPOS then
addTimedDrawPos(spell.startPos.x, spell.startPos.y, spell.startPos.z, duration, delay)
elseif tType == TIMERTYPE_CASTER then
addTimedDrawStick(caster, duration, delay)
end
end
end
end
-- add a new timer in the timed drawings table (with position)
function addTimedDrawPos(posX, posY, posZ, duration, delay)
local tmpID = math.random(1,10000)
table.insert(timedDrawings, {id = tmpID, startTime = os.clock() + (delay or 0), endTime = os.clock() + (delay or 0) + duration, pos = Vector(posX, posY, posZ)})
DelayAction(function() removeTimedDraw(tmpID) end, duration)
end
-- add a new timer in the timed drawings table (with target)
function addTimedDrawStick(target, duration, delay)
local tmpID = math.random(1,10000)
table.insert(timedDrawings, {id = tmpID, startTime = os.clock() + (delay or 0), endTime = os.clock() + (delay or 0) + duration, stickTo = target})
DelayAction(function() removeTimedDraw(tmpID) end, duration)
end
-- remove a timer from the timed drawings table
function removeTimedDraw(timerID)
for i, timedDr in pairs(timedDrawings) do
if timedDr.id == timerID then
table.remove(timedDrawings, i)
break
end
end
end
-- check if a spell timer is supported, returning target type, duration and delay
function timerType(spellName)
if spellName == "AkaliSmokeBomb" then -- akali bubble
return TIMERTYPE_ENDPOS, 8
elseif spellName == "UndyingRage" then -- trynda ult
return TIMERTYPE_CASTER, 5, 0.5
elseif spellName == "JudicatorIntervention" then -- kayle ult
return TIMERTYPE_CASTER, 3
elseif spellName == "ThreshW" then -- thresh lantern
return TIMERTYPE_ENDPOS, 6
end
end
-- rounds a number
function round(num, dec)
return string.format("%." .. (dec or 0) .. "f", num)
end