Code:
--Pacman's shitty area spell caster thingamajig
spell = {}
area = {}
--CONFIG
spell[1] = {words = "exevo frigo hur",
manacost = 25,
area = {{0,0,0,1},
{0,1,1,1},
{1,1,1,1},
{0,1,1,1},
{0,0,0,1}},
creaturecount = 2}
spell[2] = {words = "exevo gran frigo hur",
manacost = 170,
area = {{0,1,1},
{1,1,1},
{0,1,1}},
creaturecount = 1}
--initializing shit (i'm too shit at lua to know how to do this for sure inside the script :C)
e = 0
n = 0
s = 0
w = 0
largest = 0
print("Pacman's shit directional spell caster thingamajig")
function inarea(posc, sn)
sarea = spell[sn].area
compensatey = math.ceil((#sarea/2))
for y =1, #sarea do
for x=1, #sarea[1] do
if sarea[y][x] > 0 then
correctedy = y - compensatey
if posc.x == Self.Position().x + x and posc.y == Self.Position().y + correctedy then
e = e + sarea[y][x]
end
if posc.x == Self.Position().x - x and posc.y == Self.Position().y + correctedy then
w = w + sarea[y][x]
end
if posc.x == Self.Position().x + correctedy and posc.y == Self.Position().y + x then
s = s + sarea[y][x]
end
if posc.x == Self.Position().x + correctedy and posc.y == Self.Position().y - x then
n = n + sarea[y][x]
end
end
end
end
end
function findtargets(sn)
local creatures = Self.GetSpectators(false)
for i = 1, #creatures do
local cre = creatures[i]
if cre:isMonster() then
local crepos = cre:Position()
inarea(cre:Position(), sn)
end
end
largest = e
dir = "east"
if largest < s then
largest = s
dir = "south"
end
if largest < w then
largest = w
dir = "west"
end
if largest < n then
largest = n
dir = "north"
end
scount = spell[sn].creaturecount
swords = spell[sn].words
if largest >= scount and Self.CanCastSpell(swords) then
castaspell = true
end
e = 0
n = 0
s = 0
w = 0
largest = 0
end
while true do
for sn = 1, #spell do
findtargets(sn)
if castaspell then
Walker.Delay(1200)
setTargetingEnabled(false)
wait(200, 300)
Self.Turn(dir)
wait(300, 400)
Self.Cast(spell[sn].words, spell[sn].manacost)
wait(300, 400)
setTargetingEnabled(true)
wait(1600, 1900)
castaspell = false
end
wait(200, 400)
end
end