forked from BilbaoGotoxy/BoL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkillshotMeasure.lua
159 lines (135 loc) · 6.03 KB
/
SkillshotMeasure.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- Globals ---------------------------------------------------------------------
skillshotTable = {}
spellDataCache = {lastSpellName = nil, lastLineMissile = nil}
-- Code ------------------------------------------------------------------------
function OnLoad()
PrintChat(" >> Skillshot Measure loaded")
end
function OnProcessSpell(object, spell)
if object.name == player.name then
spellDataCache.lastSpellName = spell.name
spellDataCache[spellDataCache.lastSpellName] = {
castPosition = {x = object.x, y = object.y, z = object.z},
castSpellTick = GetTickCount()
}
end
end
function OnCreateObj(object)
if spellDataCache.lastLineMissile ~= nil and spellDataCache.lastSpellName ~= nil then
spellDataCache[spellDataCache.lastSpellName].particleObject = object
skillshotTable[spellDataCache.lastSpellName].projectileName = object.name
spellDataCache.lastSpellName = nil
spellDataCache.lastLineMissile = nil
end
if object.name == "LineMissile" and spellDataCache.lastSpellName ~= nil and lastLineMissile == nil then
spellDataCache.lastLineMissile = object
spellDataCache[spellDataCache.lastSpellName].startTick = GetTickCount()
spellDataCache[spellDataCache.lastSpellName].lineMissileObject = object
spellDataCache[spellDataCache.lastSpellName].maxRange = 0
if skillshotTable[spellDataCache.lastSpellName] == nil then
skillshotTable[spellDataCache.lastSpellName] = {
castDelayTable = {spellDataCache[spellDataCache.lastSpellName].startTick - spellDataCache[spellDataCache.lastSpellName].castSpellTick},
projectileSpeedTable = {},
rangeTable = {}
}
else
table.insert(skillshotTable[spellDataCache.lastSpellName].castDelayTable, spellDataCache[spellDataCache.lastSpellName].startTick - spellDataCache[spellDataCache.lastSpellName].castSpellTick)
end
end
end
function OnDeleteObj(object)
if object.name == "LineMissile" then
for spellName, spellDataCacheEntry in pairs(spellDataCache) do
if spellName ~= "lastSpellName" and spellName ~= "lastLineMissile" then
if spellDataCacheEntry.lineMissileObject ~= nil and object.networkID == spellDataCacheEntry.lineMissileObject.networkID then
range = GetDistance(object, spellDataCacheEntry.castPosition)
projectileSpeed = range / (GetTickCount() - spellDataCacheEntry.startTick) * 1000
if range < spellDataCacheEntry.maxRange then
range = spellDataCacheEntry.maxRange
projectileSpeed = range / (GetTickCount() - spellDataCacheEntry.startTick) * 1000 / 2
end
table.insert(skillshotTable[spellName].projectileSpeedTable, projectileSpeed)
table.insert(skillshotTable[spellName].rangeTable, range)
spellDataCacheEntry.lineMissileObject = nil
spellDataCacheEntry.particleObject = nil
end
end
end
end
end
function OnTick()
for spellName, spellDataCacheEntry in pairs(spellDataCache) do
if spellName ~= "lastSpellName" and spellName ~= "lastLineMissile" then
if spellDataCacheEntry.lineMissileObject ~= nil then
range = GetDistance(spellDataCacheEntry.lineMissileObject, spellDataCacheEntry.castPosition)
if range > spellDataCacheEntry.maxRange then
spellDataCacheEntry.maxRange = range
end
end
end
end
end
function OnDraw()
topOffset = 10
leftOffset = 10
for spellName, skillshot in pairs(skillshotTable) do
DrawText("spellName = " .. spellName, 16, leftOffset, topOffset, 0xFF00FF00)
topOffset = topOffset + 15
DrawText("projectileName = " .. skillshot.projectileName, 16, leftOffset, topOffset, 0xFF00FF00)
topOffset = topOffset + 15
minCastDelay = 99999
maxCastDelay = 0
castDelaySum = 0
castDelayCount = 0
for i, castDelay in ipairs(skillshot.castDelayTable) do
if castDelay < minCastDelay then minCastDelay = castDelay end
if castDelay > maxCastDelay then maxCastDelay = castDelay end
castDelaySum = castDelaySum + castDelay
castDelayCount = castDelayCount + 1
end
if castDelayCount > 0 then
castDelayAverage = castDelaySum / castDelayCount
DrawText("castDelay = " .. string.format("%.2f", castDelayAverage) .. " (" .. string.format("%.2f", minCastDelay) .. "-" .. string.format("%.2f", maxCastDelay) .. ")", 16, leftOffset, topOffset, 0xFF00FF00)
topOffset = topOffset + 15
end
minProjectileSpeed = 99999
maxProjectileSpeed = 0
projectileSpeedSum = 0
projectileSpeedCount = 0
for i, projectileSpeed in ipairs(skillshot.projectileSpeedTable) do
if projectileSpeed < minProjectileSpeed then minProjectileSpeed = projectileSpeed end
if projectileSpeed > maxProjectileSpeed then maxProjectileSpeed = projectileSpeed end
projectileSpeedSum = projectileSpeedSum + projectileSpeed
projectileSpeedCount = projectileSpeedCount + 1
end
if projectileSpeedCount > 0 then
projectileSpeedAverage = projectileSpeedSum / projectileSpeedCount
DrawText("projectileSpeed = " .. string.format("%.2f", projectileSpeedAverage) .. " (" .. string.format("%.2f", minProjectileSpeed) .. "-" .. string.format("%.2f", maxProjectileSpeed) .. ")", 16, leftOffset, topOffset, 0xFF00FF00)
topOffset = topOffset + 15
end
minRange = 99999
maxRange = 0
rangeSum = 0
rangeCount = 0
for i, range in ipairs(skillshot.rangeTable) do
if range < minRange then minRange = range end
if range > maxRange then maxRange = range end
rangeSum = rangeSum + range
rangeCount = rangeCount + 1
end
if rangeCount > 0 then
rangeAverage = rangeSum / rangeCount
DrawText("range = " .. string.format("%.2f", rangeAverage) .. " (" .. string.format("%.2f", minRange) .. "-" .. string.format("%.2f", maxRange) .. ")", 16, leftOffset, topOffset, 0xFF00FF00)
topOffset = topOffset + 15
end
topOffset = topOffset + 25
end
for spellName, spellDataCacheEntry in pairs(spellDataCache) do
if spellName ~= "lastSpellName" and spellName ~= "lastLineMissile" then
if spellDataCacheEntry.lineMissileObject ~= nil then
DrawCircle(spellDataCacheEntry.lineMissileObject.x, 0, spellDataCacheEntry.lineMissileObject.z, 70, 0x00FF00)
end
end
end
DrawCircle(myHero.x, myHero.y, myHero.z, GetDistance(myHero.minBBox, myHero.maxBBox) / 2, 0xFFFFFF)
end