Best Answer
I'm not the best coder but here we go:
function TS()
tg = nil
for k,v in pairs(GetEnemyHeroes()) do
if v and GetTeam(v) ~= GetTeam(GetMyHero()) and IsVisible(v) and GetCurrentHP(v) > 0 then
if not tg then
tg = v
elseif tg then
local vp = GetOrigin(v)
local tgp = GetOrigin(tg)
local mp = GetMousePos()
local vDis = GetDistance(mp,vp)
local tDis = GetDistance(mp,tgp)
if vDis and tDis and vDis < tDis then
tg = v
end
end
end
end
end
OnTick(function(myHero)
TS()
end)
OnWndMsg(function (msg, param)
if param == 81 then
if msg == 256 and not click then
click = true
if tg and GetDistance(tg) <= GetRange(myHero) + 50 then
AttackUnit(tg)
else
MoveToXYZ(GetMousePos())
end
elseif msg == 257 then
click = false
end
end
end)
When you press Q, if there is any enemy hero in your AA range, you will attack the closest to your mouse, else, your hero will move to mouse pos.