Something like this. I haven't tested it though so there might be a bug or two lurking around:
lua code:
MonsterNames = {"juggernaut", "Demon"}
Count = 5 -- Inclusive
MaxStandtime = 60 -- Seconds
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-- Preprocess the monster list for faster processing as well as
-- ensuring that no capitalization errors happen
local function preprocessMonsters(names)
local monsters = {}
for _, name in ipairs(names) do
monsters[name:lower()] = true
end
return monsters
end
local function monsterCount(monsters)
local count = 0
for name, c in Creature.iMonsters(range or 7) do
if monsters[name:lower()] then
count = count + 1
end
end
return count
end
-- Only ensures that we cast a spell which shares cooldown with the specified spell
local function ensuredCast(spell, mana)
-- First wait till it's off cooldown
while Self.GetSpellCooldown(spell) > 0 do
wait(100)
end
-- Then try casting it till its on cooldown
while Self.GetSpellCooldown(spell) < 200 do
-- Only wait if we fail to cast it
local _ = Self.Cast(spell, mana) == 0 or wait(100)
end
end
local standtime = 0
local lastpos = Self.Position()
local lasttrigger = os.time()
Module("Update standtime", function(self)
local pos = Self.Position()
if pos.x == lastpos.x and pos.y == lastpos.y and pos.z == lastpos.z then
standtime = standtime + (os.time() - lasttrigger)
else
standtime = 0
end
self:Delay(1000)
end)
local monsters = preprocessMonsters(MonsterNames)
local count = Count
local maxStandtime = MaxStandtime
Module("Logout When Lured", function(self)
if monsterCount(monsters) >= count or (not Self.isInPz() and standtime > maxStandtime) then
ensuredCast("utamo vita", 50)
-- Not sure if this wait is needed. I don't understand enough about the life of a packet.
wait(1000)
os.exit()
end
self:Delay(500)
end)