UO Sagas: Jase Owns Bandage Loop

Created: 21 days ago on 05/24/2025, 03:24:31 PMUpdated: 5 days ago on 06/09/2025, 05:27:24 PM
FileType: LUA
Size: 12280
Category: Healing
Skills: Healing
Hotkey: 1

Description: We are learning LUA and making a bandage script similar to the dex bot from Outlands. We added refresh and cure pots.

-- Bandage Loop by JaseOwns -- Version: 1.5 -- Created: 2025-05-24 -- Server: UO Sagas -- Last Updated: 2025-06-09 --================== -- Add HP check for applying bandage -- Skip logic if hidden -- Updated config to easily customize the script -- Added a check to see if the player has a refresh potion and if the player's stam is low enough to drink it -- Added Scavanger to pick up items from the ground -- Added a check to see if the player is poisoned (and has a cure potion) --================= local config = { -- bandaging bandage = { applyIfMissingHealthValue = 1, }, -- Potion options potions = { healthPotion = { enabled = true, healthDiffThreshold = 30, overheadMissing = { enabled = false, message = "No health potion found", color = 34, } }, refreshPotion = { enabled = true, stamDiffThreshold = 30, overheadMissing = { enabled = false, message = "No refresh potion found", color = 34, } }, curePotion = { enabled = true, overheadMissing = { enabled = false, message = "No cure potion found", color = 34, } }, }, -- Scavanger options scavanger = { enabled = true, items = { 0x0F3F, -- Arrow 0x0f7a, -- Black Pearl 0x0f7b, -- Blood Moss 0x0f86, -- Mandrake Root 0x0f84, -- Garlic 0x0f85, -- Ginseng 0x0f88, -- Nightshade 0x0f8d, -- Spider's Silk 0x0f8c, -- Sulphurous Ash } } } local drinkRefreshPotionStamDiffThreshold = config.potions.refreshPotion.stamDiffThreshold local scavangerEnabled = config.scavanger.enabled local scavangerItems = config.scavanger.items function GetBackpackItem(graphic) local items = Items.FindByFilter( { graphics = { graphic } } ) for index, item in ipairs(items) do if item.RootContainer == Player.Backpack.RootContainer then if item ~= nil and item then return item end end end return nil end function GetBandage() return GetBackpackItem(0x0E21) end function GetCurePotion() return GetBackpackItem(0x0F07) end function GetHealthPotion() return GetBackpackItem(0x0F0C) end function GetRefreshPotion() return GetBackpackItem(0x0F0B) end local bandage = GetBandage() local curePotion = GetCurePotion() local healthPotion = GetHealthPotion() local refreshPotion = GetRefreshPotion() local applyingBandage = false if bandage == nil or bandage.Name == nil then Messages.Overhead("No bandages found", 34, Player.Serial) return else Messages.Overhead("Bandage loop starting", 89, Player.Serial) end local lastPrint = os.clock() local ticks = 0 function printEverySecond() if applyingBandage then local now = os.clock() if now - lastPrint >= 1 then ticks = ticks + 1 Messages.Overhead(string.format("%d bandaging", ticks), 89, Player.Serial) lastPrint = now end end end function Bandaging(applying) if applying ~= nil then applyingBandage = applying if applying then ticks = 0 end end return applyingBandage end function DiffHits() local diff = Player.HitsMax - Player.Hits if diff > 0 then return diff else return 0 end end function ApplyBandage() if not Bandaging() and Journal.Contains("you begin applying") then Messages.Overhead("Bandage started", 89, Player.Serial) Bandaging(true) end if Bandaging() then -- waiting for bandage to be applied else if Targeting.WaitForTarget(100) then Messages.Overhead("We already got a target", 34, Player.Serial) Pause(200) else if bandage == nil or bandage.Name == nil or bandage.Serial == nil or not Items.FindBySerial(bandage.Serial) then bandage = GetBandage() else Player.UseObject(bandage.Serial) if Targeting.WaitForTarget(500) then Targeting.TargetSelf() Pause(200) if Journal.Contains("you begin applying") then Messages.Overhead("Bandage started", 89, Player.Serial) Bandaging(true) end end end end end end function Scavanger() if scavangerEnabled then local filter = {onground=true, rangemax=2, graphics=scavangerItems} local list = Items.FindByFilter(filter) for index, item in ipairs(list) do Player.PickUp(item.Serial, 1000) Player.DropInBackpack() Pause(100) end end end function CurePoisonWithPotionIfNeeded() if Player.IsPoisoned and curePotion ~= nil and curePotion.Serial ~= nil then Messages.Overhead("Poisoned", 34, Player.Serial) if Skills.GetValue("Alchemy") >= 80 then Player.UseObject(curePotion.Serial) curePotion = GetCurePotion() Pause(100) else local righthand = Items.FindByLayer(2) if righthand ~= nil then while Items.FindByLayer(2) ~= nil do Messages.Overhead("Clearing right hand", 34, Player.Serial) Player.ClearHands("right") Pause(650) end end while curePotion ~= nil and curePotion.Serial ~= nil and Player.IsPoisoned do Player.UseObject(curePotion.Serial) curePotion = GetCurePotion() Pause(650) end if righthand ~= nil then while Items.FindByLayer(2) == nil do Player.Equip(righthand.Serial) Pause(650) end end end elseif Player.IsPoisoned then curePotion = GetCurePotion() if (curePotion == nil or curePotion.Serial == nil) and config.potions.curePotion.overheadMissing.enabled then Messages.Overhead(config.potions.curePotion.overheadMissing.message, config.potions.curePotion.overheadMissing.color, Player.Serial) end end end function UseRefreshPotionIfNeeded() if refreshPotion ~= nil and refreshPotion.Serial ~= nil and config.potions.refreshPotion.enabled then local stamDiff = Player.MaxStam - Player.Stam if stamDiff >= drinkRefreshPotionStamDiffThreshold then if Skills.GetValue("Alchemy") >= 80 then Player.UseObject(refreshPotion.Serial) refreshPotion = GetRefreshPotion() Pause(650) else local righthand = Items.FindByLayer(2) if righthand ~= nil then while Items.FindByLayer(2) ~= nil do Messages.Overhead("Clearing right hand", 34, Player.Serial) Player.ClearHands("right") Pause(650) end end Player.UseObject(refreshPotion.Serial) refreshPotion = GetRefreshPotion() Pause(650) if righthand ~= nil then while Items.FindByLayer(2) == nil do Player.Equip(righthand.Serial) Pause(650) end end end end else refreshPotion = GetRefreshPotion() if (refreshPotion == nil or refreshPotion.Serial == nil) and config.potions.refreshPotion.overheadMissing.enabled then Messages.Overhead(config.potions.refreshPotion.overheadMissing.message, config.potions.refreshPotion.overheadMissing.color, Player.Serial) end end end local healthPotHelper = { lastPrint = os.clock(), ticks = 0, ready = true, } function UseHealthPotionIfNeeded() if healthPotHelper.ready == false then local now = os.clock() if now - healthPotHelper.lastPrint >= 10 then healthPotHelper.ready = true else return end end if healthPotHelper.ready then if healthPotion ~= nil and healthPotion.Serial ~= nil and config.potions.healthPotion.enabled then if DiffHits() >= config.potions.healthPotion.healthDiffThreshold then Player.UseObject(healthPotion.Serial) healthPotion = GetHealthPotion() healthPotHelper.lastPrint = os.clock() healthPotHelper.ready = false Pause(650) end elseif (healthPotion == nil or healthPotion.Serial == nil) and config.potions.healthPotion.overheadMissing.enabled then Messages.Overhead(config.potions.healthPotion.overheadMissing.message, config.potions.healthPotion.overheadMissing.color, Player.Serial) healthPotion = GetHealthPotion() end end end Journal.Clear() while Player.IsDead == false do while Player.IsHidden do Pause(100) end printEverySecond() Scavanger() CurePoisonWithPotionIfNeeded() UseRefreshPotionIfNeeded() UseHealthPotionIfNeeded() if Journal.Contains("Error in script") then Messages.Overhead("OMG THE SCRIPT IS BROKEN", 34, Player.Serial) Messages.Overhead("OMG THE SCRIPT IS BROKEN", 34, Player.Serial) Messages.Overhead("This should fix it, maybe?", 89, Player.Serial) Journal.Clear() bandage = nil Bandaging(false) end --Messages.Print(string.format("applyingBandage: %s", applyingBandage)) if Journal.Contains("you finish applying") or Journal.Contains("You apply the bandages, but they barely help.") or Journal.Contains("You did not stay close enough to heal your patient!") or Journal.Contains("You heal what little damage your patient had.") or Journal.Contains("You fail to resurrect") or Journal.Contains("You are able to resurrect") then Journal.Clear() Messages.Overhead("Bandage finished.", 89, Player.Serial) Bandaging(false) end if not Bandaging() and Journal.Contains("you begin applying") then Messages.Overhead("Bandage started", 89, Player.Serial) Bandaging(true) end if bandage == nil or bandage.Name == nil or bandage.Serial == nil or not Items.FindBySerial(bandage.Serial) then bandage = GetBandage() end if bandage ~= nil and bandage.Name ~= nil then if DiffHits() >= config.bandage.applyIfMissingHealthValue or Player.IsPoisoned then ApplyBandage() end else Messages.Overhead("Out of aids", 34, Player.Serial) end Pause(100) end
View list of scripts
Disclaimer: This is a fan made site and is not directly associated with Ultima Online or UO staff.