UO Sagas: Updated JaseOwns script to also use a heal pot when below 70 health

Created: 13 days ago on 06/06/2025, 08:05:15 AM
Size: 10452

Description: this is jaseowns heal script i just added a heal pot to it.

-- Bandage Loop by JaseOwns -- Version: 1.4 (Corrected) -- Created: 2025-05-24 -- Server: UO Sagas -- Last Updated: 2025-05-25 local config = { potions = { refreshPotion = { enabled = true, stamDiffThreshold = 30, overheadMissing = { enabled = false, message = "No refresh potion found", color = 34, } }, HEAL_POTION = { enabled = true, HitsDiffThreshold = 30, overheadMissing = { enabled = false, message = "No health potion found", color = 34, } }, curePotion = { enabled = true, overheadMissing = { enabled = false, message = "No cure potion found", color = 34, } }, }, 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 _, item in ipairs(items) do if item.RootContainer == Player.Serial and item ~= nil then return item end end return nil end function GetBandage() return GetBackpackItem(0x0E21) end function GetCurePotion() return GetBackpackItem(0x0F07) end function GetRefreshPotion() return GetBackpackItem(0x0F0B) end function GetHealPotion() return GetBackpackItem(0x0F0C) end local bandage = GetBandage() local curePotion = GetCurePotion() local refreshPotion = GetRefreshPotion() local HEAL_POTION = GetHealPotion() 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 ApplyBandage() if not Bandaging() and Journal.Contains("you begin applying") then Messages.Overhead("Bandage started", 89, Player.Serial) Bandaging(true) end if not Bandaging() then 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 then bandage = GetBandage() end if bandage then 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 _, 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 then while Items.FindByLayer(2) do Messages.Overhead("Clearing right hand", 34, Player.Serial) Player.ClearHands("right") Pause(650) end end while curePotion and curePotion.Serial and Player.IsPoisoned do Player.UseObject(curePotion.Serial) curePotion = GetCurePotion() Pause(650) end if righthand then while not Items.FindByLayer(2) do Player.Equip(righthand.Serial) Pause(650) end end end elseif Player.IsPoisoned then curePotion = GetCurePotion() if (not curePotion or not curePotion.Serial) 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 UseHealPotionIfNeeded() if HEAL_POTION and HEAL_POTION.Serial and config.potions.HEAL_POTION.enabled then if Player.Hits < 70 then if Skills.GetValue("Alchemy") >= 80 then Player.UseObject(HEAL_POTION.Serial) HEAL_POTION = GetHealPotion() Pause(650) else local righthand = Items.FindByLayer(2) if righthand then while Items.FindByLayer(2) do Messages.Overhead("Clearing right hand", 34, Player.Serial) Player.ClearHands("right") Pause(650) end end Player.UseObject(HEAL_POTION.Serial) HEAL_POTION = GetHealPotion() Pause(650) if righthand then while not Items.FindByLayer(2) do Player.Equip(righthand.Serial) Pause(650) end end end end end end function UseRefreshPotionIfNeeded() if refreshPotion and refreshPotion.Serial 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 then while Items.FindByLayer(2) 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 then while not Items.FindByLayer(2) do Player.Equip(righthand.Serial) Pause(650) end end end end else refreshPotion = GetRefreshPotion() if (not refreshPotion or not refreshPotion.Serial) and config.potions.refreshPotion.overheadMissing.enabled then Messages.Overhead(config.potions.refreshPotion.overheadMissing.message, config.potions.refreshPotion.overheadMissing.color, Player.Serial) end end end Journal.Clear() while not Player.IsDead do while Player.IsHidden do Pause(100) end printEverySecond() Scavanger() CurePoisonWithPotionIfNeeded() UseHealPotionIfNeeded() UseRefreshPotionIfNeeded() if Journal.Contains("Error in script") then 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 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 not bandage or not bandage.Name then bandage = GetBandage() end if bandage and bandage.Name then if Player.Hits < Player.HitsMax 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.