Log in

View Full Version : rune shooter script [Working but not finished]



yompa93
12-10-2016, 10:52 AM
Hey!

This is something i worked on a while ago but gave up on, might add a hotkey function on it so it's easy to turn on/off but that's about it. It will shoot the chosen rune to where it can reach to most creatures, but it tries to shoot through things it cant shoot through. If anyone is up for it, do complete it! :p



rune = 'avalanche rune'
AmountToUseRune = 2

runeID = Item.GetID(rune)
function GetMobs()
MobPosition = {}
local creatures = Self.GetSpectators()
for i = 1, #creatures do
if creatures[i]:isMonster() and creatures[i]:isValid() and creatures[i]:ID() ~= Self.ID() and creatures[i]:isVisible() and creatures[i]:isOnScreen() then
MobPosition[i] = creatures[i]:Position()
end
end
return MobPosition
end

function getXY()
mobAmount = 0
StartX = 0
EndX = 0
StartY = 0
EndY = 0
MobPos = GetMobs()
mobReach = {}
tabl = {}
PX = {}
PY = {}
for i = 1, #MobPos do
mobReach[i] = 0
if MobPos[i].x < StartX then StartX = MobPos[i].x elseif StartX == 0 then StartX = MobPos[i].x end
if MobPos[i].y < StartY then StartY = MobPos[i].y elseif StartY == 0 then StartY = MobPos[i].y end
if MobPos[i].x > EndX then EndX = MobPos[i].x end
if MobPos[i].y > EndY then EndY = MobPos[i].y end
end
SX = (EndX-StartX)+1
SY = (EndY-StartY)+1
Size = SX*SY
for i = 1, Size do
mobReach[i] = 0
end
k = 0
for posX = StartX, EndX do
for posY = StartY, EndY do
k = k + 1
for x = -3, 3 do
for y = -3, 3 do
for i = 1, #MobPos do
if posX + x == MobPos[i].x and posY + y == MobPos[i].y and Map.IsTileWalkable(posX + x, posY + y, Self.Position().z) and not (x == 3 and y == 3 or x == 3 and y == 2 or x == 2 and y == 3 or x == -3 and y == -3 or x == -3 and y == -2 or x == -2 and y == -3) then
mobReach[k] = mobReach[k] + 1
PX[k] = posX
PY[k] = posY
end
end
end
end
end
end
PSX = 0
PSY = 0
for i = 1, Size do
if mobReach[i] > mobAmount then mobAmount = mobReach[i] PSX = PX[i] PSY = PY[i] end
end
tabl = {x = PSX, y = PSY}
return tabl
end

mobAmount = 0
Module.New('test', function(mod)
getXY()
if mobAmount >= AmountToUseRune then
if Self.GetSpellCooldown('exori san') == 0 then
Self.UseItemWithGround(runeID, tabl.x, tabl.y, Self.Position().z)
end
end
end)