• 01-04.05.2026 - DOUBLE EXP / SKILL EVENT!

[Development] Fully functional Bot system

Status
Zamknięty.

Avento

New User
Zarejestrowany
Dołączył
Kwiecień 26, 2010
Posty
8
Liczba reakcji
3
TESTED AND WORKING IN 0.3.4PL1

Features
Added:
-Bot Info (!bot)
-Auto Eat (!bot startfood/stopfood)
-Full Light (!bot light)
-Auto Heal (!bot startheal/stopheal)
-Auto Magic (!bot startmagic/stopmagic)

To be added:
-Auto Attack
-Auto Target
-Auto Loot
-Auto Stack
-Cavebot


Kod:
  local eat =  {}
local heal = {}
local magic = {}
local foods = {
        {8, "Crunch.", 2362},
        {15, "Munch.", 2666},
        {12, "Munch.", 2667},
        {10, "Mmmm.", 2668},
        {17, "Munch.", 2669},
        {4, "Gulp.", 2670},
        {30, "Chomp.", 2671},
        {60, "Chomp.", 2672},
        {5, "Yum.", 2673},
        {6, "Yum.", 2674},
        {13, "Yum.", 2675},
        {8, "Yum.", 2676},
        {1, "Yum.", 2677},
        {18, "Slurp.", 2678},
        {1, "Yum.", 2679},
        {2, "Yum.", 2680},
        {9, "Yum.", 2681},
        {20, "Yum.", 2682},
        {17, "Munch.", 2683},
        {8, "Crunch.", 2684},
        {6, "Munch.", 2685},
        {9, "Crunch.", 2686},
        {2, "Crunch.", 2687},
        {9, "Munch.", 2688},
        {10, "Crunch.", 2689},
        {3, "Crunch.", 2690},
        {8, "Crunch.", 2691},
        {6, "Munch.", 2792},
        {9, "Munch.", 2793},
        {6, "Gulp.", 2695},
        {9, "Smack.", 2696},
        {9, "Munch.", 2787},
        {4, "Munch.", 2788},
        {22, "Munch.", 2789},
        {30, "Munch.", 2790},
        {30, "Munch.", 2791},
        {6, "Munch.", 2792},
        {3, "Munch.", 2794},
        {36, "Munch.", 2795},
        {5, "Munch.", 2796},
        {9, "Munch.", 2793},
        {4, "Yum.", 5097},
        {8, "Gulp.", 6125},
        {10, "Mmmm.", 6278},
        {15, "Mmmm.", 6279},
        {12, "Mmmm.", 6393},
        {15, "Mmmm.", 6394},
        {20, "Mmmm.", 6501},
        {6, "Gulp.", 6541},
        {6, "Gulp.", 6542},
        {6, "Gulp.", 6543},
        {6, "Gulp.", 6544},
        {6, "Gulp.", 6545},
        {1, "Mmmm.", 6569},
        {4, "Mmmm.", 6574},
        {15, "Munch.", 7158},
        {13, "Munch.", 7159},
        {7, "Yum.", 7372},
        {7, "Yum.", 7373},
        {7, "Yum.", 7374},
        {7, "Yum.", 7375},
        {7, "Yum.", 7376},
        {7, "Yum.", 7377},
        {4, "Crunch.", 7909},
        {7, "Gulp.", 8838},
        {5, "Yum.", 8839},
        {2, "Yum.", 8840},
        {3, "Urgh.", 8841},
        {3, "Munch.", 8842},
        {3, "Crunch.", 8843},
        {3, "Gulp.", 8844},
        {2, "Munch.", 8845},
        {11, "Yum.", 8447}
}

function botInfo(cid)
        doPlayerPopupFYI(cid, "Bot System by Aziz\n" ..
        "--Tools--\n" ..
        "!bot startfood/stopfood   (Auto Eat)\n" ..
        "!bot light  (Full Light)\n\n" ..
        "--Auto Heal--\n" ..
        "!bot startheal, spellname, healthneeded, mananeeded\n" ..
        "(example !bot startheal, exura, 500, 20)\n" ..
        "!bot stopheal\n\n" ..
        "--Auto Magic--\n" ..
        "!bot startmagic, spellname, mananeeded\n" ..
        "(example !bot startmagic, utevo lux, 84)\n" ..
        "!bot stopmagic\n" ..
        ""
        )
end

function botEat(cid)
        local food = nil
        for _, v in ipairs(foods) do
                if getPlayerItemCount(cid, v[3]) > 0 then
                        food = v
                        break
                end
        end

        if food ~= nil then
                if((getPlayerFood(cid) + food[1]) >= 400) then
                        doPlayerSendCancel(cid, "You are full.")
                        eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
                        return
                end
                doPlayerFeed(cid, food[1] * 4)
                doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
                doPlayerRemoveItem(cid, food[3], 1)
        end
        eat[getPlayerGUID(cid)] = addEvent(botEat, 20000, cid)
        return true
end

function botLoot(cid, itemid)
        if not isItemStackable(itemid) then
                return false
        end

        local count = getPlayerItemCount(cid, itemid)
        if count > 100 then
                count = count - math.floor(count / 100) * 100
        end
       
        local newCount = count
        if count ~= 0 then
                doRemoveItem(getPlayerItemById(cid, true, itemid, count).uid)
        end
        doPlayerAddItem(cid, itemid, newCount)
end

function botMoneyLoot(cid)
        local count = getPlayerItemCount(cid, 2148)
        if count > 100 then
                count = count - math.floor(count / 100) * 100
        end
        if count ~= 0 then
                doPlayerRemoveItem(cid, 2148, count)
        end
        doPlayerAddItem(cid, 2148, count)
end

function botHeal(params)
        if getCreatureMana(params[1]) < tonumber(params[4]) then
                heal[getPlayerGUID(params[1])] = addEvent(botHeal, 100, params)
                return true
        elseif getCreatureHealth(params[1]) < tonumber(params[3]) then
                doPlayerCastSpell(params[1], params[2])
                heal[getPlayerGUID(params[1])] = addEvent(botHeal, 100, params)
                return true
        end
        heal[getPlayerGUID(params[1])] = addEvent(botHeal, 100, params)
        return true
end

function botMagic(params)
        if getCreatureMana(params[1]) < tonumber(params[3]) then
                magic[getPlayerGUID(params[1])] = addEvent(botMagic, 100, params)
                return true
        else
                doPlayerCastSpell(params[1], params[2])
                magic[getPlayerGUID(params[1])] = addEvent(botMagic, 100, params)
                return true
        end
end

function onSay(cid, words, param, channel)
        if param == "" then
                botInfo(cid)
        end

     local params = string.explode(param, ",")
     if params[1] == "startfood" then
          eat[getPlayerGUID(cid)] = addEvent(botEat, 100, cid)
     elseif params[1] == "stopfood" then
          stopEvent(eat[getPlayerGUID(cid)])
     elseif params[1] == "light" then
          doSetCreatureLight(cid, 100, 215, -1)
     elseif (params[1] == "startheal" and #params == 4) then
          botHeal({cid, params[2], params[3], params[4]})
     elseif (params[1] == "stopheal") then
                stopEvent(heal[getPlayerGUID(cid)])
        elseif (params[1] == "startmagic" and #params == 3) then
                botMagic({cid, params[2], params[3]})
        elseif (params[1] == "stopmagic") then
                stopEvent(magic[getPlayerGUID(cid)])
     end    
     return true
end

Credit:
Idea - Me
Script - Me and Nahruto
doPlayerCast - Evil Hero

Comments/Suggestions.
 
Status
Zamknięty.
Back
Do góry