- Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathDetect.lua
More file actions
Latest commit
159 lines (122 loc) · 5.52 KB
/
Copy pathDetect.lua
File metadata and controls
159 lines (122 loc) · 5.52 KB
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
-- package.loaded.Invoker = nil
localDraw=require("Draw")
localDict=require("Dict")
localMap=require("Map")
-- local Invoker = require("Invoker")
localDetect= {}
localoption=Menu.AddOption({ "Awareness" }, "Detect", "Alerts you when certain abilities are used.")
-- local optionInvokerMapHack = Menu.AddOption({"Hero Specific", "Invoker Extension"}, "Map Hack", "use information from particle efftects, to tornado tping enemy, or sun strike enemy if it is tping, farming or roshing.")
localoptionEnemyAround=Menu.AddOption({ "Awareness" }, "Enemy Around", "Show how many enemy hero around")
localfont=Renderer.LoadFont("Tahoma", 30, Enum.FontWeight.EXTRABOLD)
localheroList= {}
-- index -> {name = Str; entity = Object; pos = Vector(), time = Int}
localposInfo= {}
-- index -> spellname
localparticleInfo= {}
-- only for few cases
-- index -> heroName
localparticleHero= {}
-- For particle effects that cant be tracked by OnParticleUpdateEntity(),
-- but have name info from OnParticleCreate() and position info from OnParticleUpdate()
-- (has been replaced by Dict.Phrase2HeroName())
-- spellname -> heroname
localspellName2heroName= {}
-- know particle's index, spellname; have chance to know entity
-- Entity.GetAbsOrigin(particle.entity) is not correct. It just shows last seen position.
-- NPC.GetUnitName(particle.entity) can be useful, like know blink start position, smoke position, etc
functionDetect.OnParticleCreate(particle)
ifnotMenu.IsEnabled(option) thenreturnend
ifnotparticleornotparticle.indexthenreturnend
-- Log.Write("1. OnParticleCreate: " .. tostring(particle.index) .. " " .. particle.name .. " " .. NPC.GetUnitName(particle.entity))
particleInfo[particle.index] =particle.name
ifparticle.entitythen
particleHero[particle.index] =NPC.GetUnitName(particle.entity)
end
end
-- know particle's index, position
functionDetect.OnParticleUpdate(particle)
ifnotMenu.IsEnabled(option) thenreturnend
ifnotparticleornotparticle.indexthenreturnend
ifnotparticle.positionornotMap.IsValidPos(particle.position) thenreturnend
-- Log.Write("2. OnParticleUpdate: " .. tostring(particle.index) .. " " .. tostring(particle.position))
ifnotparticleInfo[particle.index] thenreturnend
localspellname=particleInfo[particle.index]
localname=Dict.Phrase2HeroName(spellname)
ifnotnameorname=="" thenname=particleHero[particle.index] end
Detect.Update(name, nil, particle.position, GameRules.GetGameTime())
-- if Menu.IsEnabled(optionInvokerMapHack) then
-- Invoker.MapHack(particle.position, spellname)
-- end
end
-- know particle's index, position, entity
functionDetect.OnParticleUpdateEntity(particle)
ifnotMenu.IsEnabled(option) thenreturnend
ifnotparticlethenreturnend
ifnotparticle.entityornotNPC.IsHero(particle.entity) thenreturnend
ifnotparticle.positionornotMap.IsValidPos(particle.position) thenreturnend
-- Log.Write("3. OnParticleUpdateEntity: " .. tostring(particle.index) .. " " .. NPC.GetUnitName(particle.entity) .. " " .. tostring(particle.position))
Detect.Update(NPC.GetUnitName(particle.entity), particle.entity, particle.position, GameRules.GetGameTime())
-- Invoker.MapHack(particle.position, "")
end
functionDetect.Update(name, entity, pos, time)
ifnotposInfothenreturnend
localinfo= {}
fori, valinipairs(posInfo) do
ifval.name==namethen
ifnametheninfo.name=nameend
ifentitytheninfo.entity=entityend
ifpostheninfo.pos=posend
iftimetheninfo.time=timeend
posInfo[i] =info
return
end
end
info.name, info.entity, info.pos, info.time=name, entity, pos, time
table.insert(posInfo, info)
end
functionDetect.OnDraw()
ifnotMenu.IsEnabled(option) thenreturnend
localmyHero=Heroes.GetLocal()
ifnotmyHerothen
heroList, posInfo, particleInfo, particleHero= {}, {}, {}, {}
return
end
localpos=Entity.GetAbsOrigin(myHero)
localcounter=0
localradius=1500
-- update hero list
fori=1, Heroes.Count() do
localhero=Heroes.Get(i)
localname=NPC.GetUnitName(hero)
ifnotheroList[name] andnotNPC.IsIllusion(hero) then
heroList[name] =hero
end
end
-- threshold for elapsed time
localthreshold=3
Draw.DrawMap()
-- draw visible enemy on new map
forname, enemyinpairs(heroList) do
ifenemyandnotEntity.IsSameTeam(myHero, enemy) andnotEntity.IsDormant(enemy) andEntity.IsAlive(enemy) then
Draw.DrawHeroOnMap(name, Entity.GetAbsOrigin(enemy))
end
end
-- draw enemy position given by particle effects
fori, infoinipairs(posInfo) do
ifinfoandinfo.nameandinfo.posandinfo.timeandmath.abs(GameRules.GetGameTime() -info.time) <=thresholdthen
-- no need to draw visible enemy hero on the ground
ifnotheroList[info.name] orEntity.IsDormant(heroList[info.name]) then
Draw.DrawHeroOnGround(info.name, info.pos)
end
-- no need to draw ally
ifnotheroList[info.name] ornotEntity.IsSameTeam(myHero, heroList[info.name]) then
Draw.DrawHeroOnMap(info.name, info.pos)
end
end
end
-- show how many enemy hero around
ifnotMenu.IsEnabled(optionEnemyAround) then
-- TBD
end
end
returnDetect