XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 6 of 6

Thread: utamo and exit when x amount of x monsters on screen

  1. #1
    Mageq's Avatar
    Join Date
    Aug 2012
    Posts
    396
    Mentioned
    19 Post(s)
    Tagged
    0 Thread(s)

    utamo and exit when x amount of x monsters on screen

    Hi, if somebody could help me to write a script to cast utamo vita and exit when the number of X monsters is visible on screen that would be perfect.

    In my words its

    Monster name =
    Creature count = 5+

    do utamo vita
    do exit

  2. #2
    Moderator shadowart's Avatar
    Join Date
    Dec 2014
    Location
    Sweden
    Posts
    1,985
    Mentioned
    225 Post(s)
    Tagged
    3 Thread(s)
    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)
    Last edited by shadowart; 08-26-2016 at 09:24 AM.

  3. #3
    Mageq's Avatar
    Join Date
    Aug 2012
    Posts
    396
    Mentioned
    19 Post(s)
    Tagged
    0 Thread(s)
    works perfectly man, thanks @shadowart you could add this to your lua script

    edit - any chance you could also write a script which exits after a stand time of 60 seconds?

    <3
    Last edited by Mageq; 08-26-2016 at 08:49 AM.

  4. #4
    Moderator shadowart's Avatar
    Join Date
    Dec 2014
    Location
    Sweden
    Posts
    1,985
    Mentioned
    225 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Mageq View Post
    works perfectly man, thanks @shadowart you could add this to your lua script

    edit - any chance you could also write a script which exits after a stand time of 60 seconds?

    <3
    Updated the previous script. The stand time condition will not trigger inside a pz zone.

  5. #5
    Mageq's Avatar
    Join Date
    Aug 2012
    Posts
    396
    Mentioned
    19 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shadowart View Post
    Updated the previous script. The stand time condition will not trigger inside a pz zone.
    Monster count and exit works fine, however the exit after 60 seconds does not work, I've tested it in multiple ways such as:

    Standing in pz - leaving pz = will exit, even though I moved a second ago, but I was standing in PZ for 60+ seconds.
    AFK for 3+ minutes outside of PZ = nothing

  6. #6
    Moderator shadowart's Avatar
    Join Date
    Dec 2014
    Location
    Sweden
    Posts
    1,985
    Mentioned
    225 Post(s)
    Tagged
    3 Thread(s)
    lasttrigger isn't getting updated. It should be updated to the current value of os.time() on each invocation of the module.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •