Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Hireling Dialog
- local hireling_settings = {
- dish_name = "Carrion Casserole",
- dish_id = 29414,
- dish_amount = 10,
- hireling_name = "Otclient"
- }
- function get_item_count(itemId)
- local count = 0
- for _, container in pairs(g_game.getContainers()) do
- for _, item in ipairs(container:getItems()) do
- if item:getId() == itemId then
- count = count + item:getCount()
- end
- end
- end
- for _, item in ipairs(player:getItems()) do
- if item:getId() == itemId then
- count = count + item:getCount()
- end
- end
- return count
- end
- function check_purse()
- local purse = getContainerByName("Store inbox")
- if not purse then
- g_game.use(g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse))
- end
- end
- function talk_hireling()
- check_purse()
- CaveBot.Conversation("hi")
- schedule(200, function()
- check_purse()
- CaveBot.Conversation("food")
- end)
- schedule(400, function()
- check_purse()
- CaveBot.Conversation("specific")
- end)
- schedule(800, function()
- check_purse()
- CaveBot.Conversation(hireling_settings.dish_name)
- end)
- schedule(1200, function()
- check_purse()
- CaveBot.Conversation("yes")
- end)
- schedule(1600, function()
- if get_item_count(hireling_settings.dish_id) < hireling_settings.dish_amount then
- check_and_buy()
- end
- end)
- end
- function buy_hireling()
- local hireling = getCreatureByName(hireling_settings.hireling_name)
- if not hireling then
- print("CaveBot[follow]: can't find hireling to follow")
- return
- end
- local hireling_pos = hireling:getPosition()
- local pos = pos()
- if getDistanceBetween(hireling_pos, pos) > 2 then
- follow(hireling)
- schedule(1000, buy_hireling)
- return
- end
- g_game.cancelFollow()
- talk_hireling()
- end
- function check_and_buy()
- check_purse()
- if get_item_count(hireling_settings.dish_id) < hireling_settings.dish_amount then
- buy_hireling()
- end
- end
- check_and_buy()
- return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement