XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 5 of 5

Thread: Dont attack other peoples monsters

  1. #1

    Join Date
    Jun 2012
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dont attack other peoples monsters

    an option to ignore other peoples monsters would be very useful. its one of the most important thing a bot needs and i dont get why its not added yet

  2. #2
    Daemon's Avatar
    Join Date
    Jun 2012
    Posts
    236
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It can be done with a Lua script

  3. #3
    Daemon's Avatar
    Join Date
    Jun 2012
    Posts
    236
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @Syntax ,@DarkstaR, @Spectrus ~ I got this for a friend a while back so I am not sure who to credit the anti ks script to; but thanks to all of you for everything as well.

    PHP Code:
    dofile("Forgee.lua"
    ---------------------
    while (
    true) do 
        if (
    playersAround(7) == 0) or (Self.TargetID() ~= 0) or ((monstersAround(1) > 1) and (playersAround(1) == 0)) or ((monstersAround(1) > 0) and (playersAround(3) == 0)) then 
            setTargetingEnabled
    (true)
            
    wait(500)
        else
            
    setTargetingEnabled(false)
            
    wait(500)
        
    end 
    end 
    @drullitos, you will also need the below lua saved as Forgee.lua in your scripts folder though there is no need for actually executing it. Thanks to @Forgee for his library.


    PHP Code:
    --[[
    Mini library by ForgeeLast updated 23/3/12.
    To 
    use these functions pastedofile("Forgee.lua")
    at the top of the script.
    ]]
    -- 
    getMonstersAround(4"Frost Dragon""Frost Dragon Hatchling")
    function 
    getMonstersAround(radius, ...)
        
    local t = {...}
        
    local monsters = {}
        for 
    CREATURES_LOWCREATURES_HIGH do
            
    local creature Creature.GetFromIndex(i) -- Let's find us a creature //TODO: Find a way to read additional info correctly (hp, speed, outfit etc).
            if (creature:isValid()) and creature:ID() ~= Self.ID() then -- Make sure it'
    s valid and don't count ourselves.
                if (creature:isOnScreen() and creature:isVisible() and creature:isAlive()) then -- We want to see the creature.
                    if not creature:isPlayer() then -- And it must not be a player, aren'
    t we picky?
                        
    local name creature:Name()
                        if (
    creature:DistanceFromSelf() <= radiusthen -- Is the creature close enough to be considered?
                            if (
    #t > 0 and table.contains(t, name)) or (#t == 0) then -- If we have a monster list, we look for our creature there.
                                
    table.insert(monsterscreature)
                            
    end
                        end
                    end
                end
            end
        end
        
    return monsters
    end
    --[[
    Example use for exori: (NoteAdded exori() function to library.)

    dofile("Forgee.lua")
    local radius -- Radius to consider
    local min 
    -- Minimum number of monsters to hit.
    local spell "exori" -- Spell to cast.
    local mana 120 -- Minimum mana to cast spell.
    local monsters = {"Frost Dragon""Frost Dragon Hatchling"}
    function 
    exori()
        
    local m getMonstersAround(radiusunpack(monsters))
        if 
    #m >= min then
            
    Self.Cast(spellmana)
            
    wait(11001800)
        
    end
    end

    while (true) do
        
    exori()
    end
    ]]

    -- 
    getPlayersAround(7"DarkstaR""Syntax")
    function 
    getPlayersAround(radius, ...)
        
    local t = {...}
        
    local players = {}
        if (
    radius == 0then
            radius 
    8
        end
        
    for CREATURES_LOWCREATURES_HIGH do
            
    local creature Creature.GetFromIndex(i)
            if (
    creature:isValid()) and creature:ID() ~= Self.ID() then
                
    if (creature:isOnScreen() and creature:isVisible() and creature:isAlive()) then
                    
    if creature:isPlayer() then
                        local name 
    creature:Name()
                        if (
    creature:DistanceFromSelf() <= radiusthen
                            
    if (not table.contains(tname)) then -- If we have a white list, we look for the player there.
                                
    table.insert(playerscreature)
                            
    end
                        end
                    end
                end
            end
        end
        
    return players
    end
    --[[
    Usage:
    We can find all info the bot can get about a creature.
    If 
    you enter names after the radius it will work as "whitelist".

    players getPlayersAround(8"DarkstaR""Syntax")
    if 
    #players > 0 then
        
    for #players do
            
    creature players[i]
            if 
    creature:HealthPercent() < 60 then
                
    ~do something
            end
        end
    end
    ]]

    -- 
    Same as getPlayersAroundbut gets players from other floors too.
    -- 
    xrayPlayersAround(6)
    function 
    xrayPlayersAround(radius, ...)
        
    local t = {...}
        
    local players = {}
        if (
    radius == 0then
            radius 
    8
        end
        
    for CREATURES_LOWCREATURES_HIGH do
            
    local creature Creature.GetFromIndex(i)
            if (
    creature:isValid()) and creature:ID() ~= Self.ID() then
                
    if creature:isVisible() and creature:isAlive() then
                    
    if creature:isPlayer() then
                        local name 
    creature:Name()
                        
    local selfpos Self.Position()
                        
    local creaturepos creature:Position()
                        
    local distance math.max(math.abs(selfpos.creaturepos.x), math.abs(selfpos.creaturepos.y))
                        if (
    distance <= radiusthen
                            
    if not table.contains(tnamethen
                                table
    .insert(playerscreature)
                            
    end
                        end
                    end
                end
            end
        end
        
    return players
    end


    function monstersAround(radius, ...) -- Count monsters aroundmonstersAround(5"Frost Dragon"will count only Frost Dragons within a 5 sqm radius.
        if 
    getMonstersAround(radius, ...) then
            
    return #getMonstersAround(radius, ...)
        
    else
            return 
    0
        end
    end

    function playersAround(radius, ...) -- Count players aroundNames are excluded from the count.
        if 
    getPlayersAround(radius, ...) then
            
    return #getPlayersAround(radius, ...)
        
    else
            return 
    0
        end
    end

    --teleportWalker(32111331067labelName"Teleport1" "PassedTeleport1")
    -- 
    Please do not omit labelName (exactly like it is) as it is needed for the function to know which label the walker is on.
    function 
    teleportWalker(xyzlabelNamelabel1label2)
        if 
    not label1 then
            label1 
    "Teleport"
        
    end
        
    if not label2 then
            label2 
    "PassedTeleport"
        
    end
        
    if labelName == label1 then
            wait
    (2000)
            
    gotoLabel(label2)
        elseif 
    labelName == label2 then
            delayWalker
    (2000)
            if 
    Self.Position().~= or Self.Position().~= or Self.Position().~= z then
                gotoLabel
    (label1)
            
    end
        end
    end


    -- Can be used for any circular aoe spell such as UEDivine Calderaetc.
    -- 
    exori(13"exori"120false"Frost Dragon""Frost Dragon Hatchling")
    function 
    exori(radiusnumspellmanahitPlayers, ...)
        
    local monsters = {...}
        if 
    monstersAround(radiusunpack(monsters)) >= num then
            
    if not hitPlayers then
                
    if playersAround(radius 1) == 0 then
                    Self
    .Cast(spellmana)
                
    end
            
    else
                
    Self.Cast(spellmana)
            
    end
            wait
    (11001800)
        
    end
        wait
    (200,500)
    end
    --[[Example Script ] --
    dofile("Forgee.lua")
    local radius -- Radius to consider
    local num 
    -- Minimum number of monsters to hit.
    local spell "exori" -- Spell to cast.
    local mana 120 -- Minimum mana to cast spell.
    local monsters = {"Frost Dragon""Frost Dragon Hatchling"}
    local hitPlayers false -- false will not cast the spell if there are players in the affected nearby (radius+1). true will execute regardless of other playersonly recommended for Optional pvp.

    while (
    true) do
        
    exori(radiusnumspellmanahitPlayersmonsters) -- All waiting is handled by the main function.
    end
    ]]

    --[[
    Backpacks inside one another should be the same kind.
    closeBackpacks() -- optional id of cascaded backapacks
    ]]
    function 
    closeBackpacks(...)
        
    local tmpBP Container.GetFirst() 
        
    local cascaded = {...}
        while 
    tmpBP:isOpen() do
            for 
    spot 0tmpBP:ItemCount() do
                
    local item tmpBP:GetItemData(spot)
                if 
    item.id == tmpBP:ID() then
                    table
    .insert(cascadedtmpBP:ID())
                    
    tmpBP tmpBP:GetNext()
                
    end
            end
            tmpBP 
    Container.GetFirst()
            if 
    not table.contains(cascadedtmpBP:ID()) or tmpBP:ItemCount() == 0 then -- Backpack is main or last cascadedClosing...
                
    Self.UseItem(tmpBP:ID())
                
    wait(500900)
            
    end
            
    if #cascaded > 0 then -- Any cascaded backpacks?
                
    for 1#cascaded do
                    
    if tmpBP:ID() == cascaded[ithen -- Found cascaded backpack.
                        if 
    tmpBP:ItemCount() > 0 then -- Backpack contains atleast one itemcheck for anoter bp.
                            for 
    spot 0tmpBP:ItemCount() do
                                
    local item tmpBP:GetItemData(spot)
                                if 
    item.id == tmpBP:ID() then -- Found anoter cascade bpopening...
                                    
    tmpBP:UseItem(spot)
                                    break
                                
    end
                            end
                        end
                    end
                end
            end
            wait
    (500900)
            
    tmpBP Container.GetFirst() -- Get a new bp to check.
            if 
    tmpBP:ID() == 0 then -- No more open backpacks.
                print(
    "All backpacks were successfully closed.")
            
    end
        end
        
    return true
    end

    -- openbackpacks(id[, {"Parent Name"id})
    -- 
    openBackpacks() -- Will open the bp in your backpack slot.
    -- 
    openBackpacks({"Backpack"9602}) -- Will open an orange bp (9602inside a Backpack.
    -- 
    openBackpacks(9602, {"Orange Backpack"8860}) -- Will first open an orage bp inside the first container/main bpThen opens a Brocade Backpack inside the Orange Backpack.
    function 
    openBackpacks(...)
        
    local backpacks = {...}
        
    Self.UseItem(Self.Backpack().id) -- Open main backpack.
        
    wait(500900)
        
    main Container.GetFirst()
        if 
    #backpacks > 0 then
            
    for 1#backpacks do
                
    if type(backpacks[i]) == 'table' then -- Is parent container specified?
                    
    tmpBP Container.GetByName(backpacks[i][1])
                    for 
    spot 0tmpBP:ItemCount() do
                        
    item tmpBP:GetItemData(spot)
                        if 
    item.id == backpacks[i][2then
                            tmpBP
    :UseItem(spot)
                            print(
    "Opening backpack from list. " .. backpacks[i][1] .. ", " .. backpacks[i][2])
                            
    wait(300700)
                        
    end
                    end
                
    else -- If there is no parent specified we will use the main bp.
                    for 
    spot 0main:ItemCount() do
                        
    item main:GetItemData(spot)
                        if 
    item.id == backpacks[ithen
                            main
    :UseItem(spot)
                            print(
    "Opening backpack from list. Default, " .. backpacks[i])
                            
    wait(300,700)
                        
    end
                    end
                end
            end
            indexes 
    Container.GetIndexes()
            if 
    #indexes == #backpacks then
                
    print("All backpacks were successfully opened.")
            
    end
        end
    end
    --[[
    Returns a table containing the ids of opened backpacks in order.
    open getOpenBackpacks()
    open[1] -> first backpack
    open
    [2] -> second backpacketc.
    ]]
    function 
    getOpenBackpacks()
        
    local indexes Container.GetIndexes() -- Find index for all open backpacks
        local open 
    = {} -- Create a place to store our open backpacks
        
    for 1#indexes do -- Search all open backpacks
            
    tmpBP Container.GetFromIndex(indexes[i])
            
    table.insert(opentmpBP:ID()) -- Store this backpack
        end
        
    return open -- Return found backpacks
    end

    --[[
    Id of cascaded bps can be multiple {28698860}
    Openid or {"Parent Name"id}
    closeBackpacks(28698860)
    openBackpacks(2869, {"Backpack"8860})
    or
    resetBackpacks({28698860}, 2869, {"Backpack"8860})
    Note the brackets {28698860in reset.
    ]]
    function 
    resetBackpacks()
        
    setBotEnabled(false)
        
    open getOpenBackpacks()
        
    wait(700,1300)
        
    closeBackpacks()
        
    wait(900,1800)
        
    openBackpacks(unpack(open))
        
    setBotEnabled(true)
    end

    -- getSpotByID(id[, container]) Container name/index is optional.
    function 
    getSpotByID(idcontainer)
        if 
    container then
            
    if type(container) == "string" then
                cont 
    Container.GetByName(container)
            elseif 
    type(container) == "number" then
                cont 
    Container.GetFromIndex(container)
            
    end
        
    else
            
    cont Container.GetFirst()
        
    end
        
    while cont:isOpen() do
            for 
    spot 0cont:ItemCount() do
                
    item cont:GetItemData(spot)
                if 
    item.id == id then
                    
    return spot
                end
            end
            
    if container then
                
    return false
            
    else
                
    cont cont:GetNext()
            
    end
        end
        
    return false
    end

    function getItemFromSpot(spotcontainer)
        
    cont Container.GetByName(container)
        
    item cont:GetItemData(spot)
        return 
    item.id
    end

    -- [ In collaboration with Spectrus ] --
    -- 
    openDoor(NORTH5250)
    -- 
    openDoor({123412347}, 5250)
    function 
    openDoor(dirkeyid)
        if 
    not dir then --[[assume doorpos is 1sqm ahead in the direction the char is facing]]
            
    pos Self.LookPos(1)
        elseif 
    type(dir) == "table" then
            pos 
    = {
            [
    "x"] = dir[1],
            [
    "y"] = dir[2],
            [
    "z"] = dir[3]
            }
        else
            
    pos getPositionFromDirection(Self.Position(), dir1)
        
    end
        
    if keyid then
            door 
    Self.UseItemWithGround(keyidpos.xpos.ypos.z)
            
    wait(6001200)
            while 
    not table.contains(OPENED_DOORSdoor) do -- until we know the door was open
                door 
    Self.UseItemWithGround(keyidpos.xpos.ypos.z)
                
    wait(6001200)
            
    end
            Self
    .UseItemWithGround(keyidpos.xpos.ypos.z) -- then open it again
        
    else 
            
    door Self.UseItemFromGround(pos.xpos.ypos.z)
            if 
    table.contains(OPENED_DOORSdoorthen -- door was open
                door 
    Self.UseItemFromGround(pos.xpos.ypos.z)
                
    wait(6001200)
            
    end
        end
        
    return true
    end

    Self
    .BuyItemsUpTo = function(itemcount)
        
    amount Self.ItemCount(item)
        
    needed math.abs(count amount)
        if 
    type(item) ~= "number" then
            
    print("BuyItemsUpTo: Item must be specified by id.")
            return 
    0
        end
        
    if amount count then
            
    if needed 100 then
                repeat
                    Self
    .ShopBuyItem(item100)
                    
    amount Self.ItemCount(item)
                    
    needed math.abs(count amount)
                    
    wait(500,1500)
                
    until needed 100
            end
            
    return Self.ShopBuyItem(itemneeded)
        else
            return 
    1
        end
    end

    Self
    .SellItemsDownTo = function(itemcount)
        
    amount Self.ItemCount(item)
        
    sell math.abs(amount count)
        if 
    type(item) ~= "number" then
            
    print("SellItemsDownTo: Item must be specified by id.")
            return 
    0
        end
        
    while amount count do
            
    Self.ShopSellItem(itemsell)
            
    amount Self.ItemCount(item)
            
    sell math.abs(amount count)
        
    end
        
    return 1
    end

    Self
    .ShopBuyItemsUpTo Self.BuyItemsUpTo
    Self
    .ShopSellItemsDownTo Self.SellItemsDownTo

    -------------------------------------------------------------
    -----------------------[ 
    War tools ]-------------------------
    -------------------------------------------------------------
    -- [
    NOT TESTED] --
    function 
    warEnemies(range)
        
    getPlayersAround(range)
        
    enemies = {}
        for 
    1#p do
            
    if p[i]:isWarEnemy() then
                table
    .insert(enemiesp[i])
            
    end
        end
        
    return #enemies
    end

    function warAllies(range)
        
    getPlayersAround(range)
        
    allies = {}
        for 
    1#p do
            
    if p[i]:isWarAlly() then
                table
    .insert(alliesp[i])
            
    end
        end
        
    return #allies
    end

    function getWarAllies(range)
        
    getPlayersAround(range)
        
    allies = {}
        for 
    1#p do
            
    if p[i]:isWarAlly() then
                table
    .insert(alliesp[i])
            
    end
        end
        
    if #allies > 0 then
            
    return allies
        
    else
            return 
    false
        end
    end

    function getWarEnemies(range)
        
    getPlayersAround(range)
        
    enemies = {}
        for 
    1#p do
            
    local player p[i]
            if 
    player:isWarEnemy() then
                table
    .insert(enemiesplayer)
            
    end
        end
        
    if #enemies > 0 then
            
    return enemies
        
    else
            return 
    false
        end
    end 
    Last edited by Daemon; 08-20-2012 at 11:27 PM.

  4. #4
    Administrator
    Join Date
    Dec 2010
    Posts
    2,565
    Mentioned
    228 Post(s)
    Tagged
    1 Thread(s)
    That anti-ks script was written by @LukeFisher

  5. #5

    Join Date
    Feb 2016
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wher do i post the first script?
    The second one goes in the folder script with the name forge but where does the first script go

Posting Permissions

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