UI.Separator() local trainingDummy = { 28565, 28558, 28559, 28560 } --// Training Dummy IDs local paladinId = 35288 --// Excercise Bow ID local knightId = 35285 --// Exercise Melee ID local mageId = 28556 --// Exercise Magic ID local distanceDummy = 4 --// Self-distance from the dummy local iconid = 35288 function startTrain() for _, tile in ipairs(g_map.getTiles(posz())) do --// Checks distance within character and tile if getDistanceBetween(pos(), tile:getPosition()) <= distanceDummy then --// Get items on top of the floor local item = tile:getTopUseThing() --// Checks if the item has the same ID as our table. if item and table.find(trainingDummy, item:getId()) then --// Checks our vocation, in this case if paladin then use exercise bow. if voc() == 2 or voc() == 12 then --tile:setText("Dummy Found RP") item:setMarked("#2eb9ff") --autoWalk(item:getPosition(), 20, { -- ignoreNonPathable = true, -- precision = 0, -- marginMin = 1, -- marginMax = 1 --}) g_game.useInventoryItemWith(paladinId, item) return true end --// Checks our vocation, in this case if knight then use melee exercise weapon. if voc() == 1 or voc() == 11 then --tile:setText("Dummy Found EK") item:setMarked("#2eb9ff") autoWalk(item:getPosition(), 20, { ignoreNonPathable = true, precision = 0, marginMin = 1, marginMax = 1 }) schedule(2000, function() g_game.useInventoryItemWith(knightId, item) end) end --// Checks our vocation, in this case if mage then use wand or rod weapon. if voc() == 3 or voc() == 13 or voc() == 4 or voc() == 14 then --tile:setText("Dummy Found Mage") item:setMarked("#2eb9ff") --autoWalk(item:getPosition(), 20, { -- ignoreNonPathable = true, -- precision = 0, -- marginMin = 1, -- marginMax = 1 --}) g_game.useInventoryItemWith(mageId, item) return true end end end end end UI.Button("Exercise Items", function() startTrain() end) onTextMessage(function(mode, text) if string.match(text, "You have changed position. Training has stopped.") then print("[Error] "..text) schedule(5000, function() startTrain() end) end if string.match(text, "This exercise dummy can only be used after a 20 second cooldown.") then print("[Error] "..text) startTrain() end if string.match(text, "Your training weapon has disappeared.") then print("[Error] "..text) startTrain() end end) UI.Separator()