setDefaultTab("Heal")

--2x healing spell
--2x healing rune
--utani hur
--mana shield
--anti paralyze
--4x equip

UI.Label("Hp Healing")

-- Configuração para o HP
if type(storage.healing1) ~= "table" then
  storage.healing1 = {on=false, title="HP%", text="exura", min=51, max=90}
end

-- Criar o painel de cura para HP
local healingmacro = macro(20, function()
  local hp = player:getHealthPercent()

  -- Verificar se a porcentagem de HP está dentro dos limites para usar a magia
  if storage.healing1.max >= hp and hp >= storage.healing1.min then
    if TargetBot then
      TargetBot.saySpell(storage.healing1.text) -- Sincroniza o feitiço com o TargetBot, se disponível
    else
      say(storage.healing1.text) -- Usa a magia diretamente
    end
  end
end)
healingmacro.setOn(storage.healing1.on)

-- Interface para o painel de configuração
UI.DualScrollPanel(storage.healing1, function(widget, newParams) 
  storage.healing1 = newParams
  healingmacro.setOn(storage.healing1.on)
end)

UI.Label("Mp Healing")
if type(storage.manaTrain) ~= "table" then
  storage.manaTrain = {on=false, title="MP%", text="utevo lux", min=80, max=100}
end

local manatrainmacro = macro(20, function()
  if TargetBot and TargetBot.isActive() then return end -- pause when attacking
  local mana = math.min(100, math.floor(100 * (player:getMana() / player:getMaxMana())))
  if storage.manaTrain.max >= mana and mana >= storage.manaTrain.min then
    say(storage.manaTrain.text)
  end
end)
manatrainmacro.setOn(storage.manaTrain.on)

UI.DualScrollPanel(storage.manaTrain, function(widget, newParams) 
  storage.manaTrain = newParams
  manatrainmacro.setOn(storage.manaTrain.on)
end)


UI.Separator()

UI.Label("Mana shield spell:")
UI.TextEdit(storage.manaShield or "utamo vita", function(widget, newText)
  storage.manaShield = newText
end)

local lastManaShield = 0
macro(20, "mana shield", function() 
  if hasManaShield() or lastManaShield + 90000 > now then return end
  if TargetBot then 
    TargetBot.saySpell(storage.manaShield) -- sync spell with targetbot if available
  else
    say(storage.manaShield)
  end
end)

UI.Label("Haste spell:")
UI.TextEdit(storage.hasteSpell or "utani hur", function(widget, newText)
  storage.hasteSpell = newText
end)

macro(500, "haste", function() 
  if hasHaste() then return end
  if TargetBot then 
    TargetBot.saySpell(storage.hasteSpell) -- sync spell with targetbot if available
  else
    say(storage.hasteSpell)
  end
end)

UI.Label("Anti paralyze spell:")
UI.TextEdit(storage.antiParalyze or "utani hur", function(widget, newText)
  storage.antiParalyze = newText
end)

macro(100, "anti paralyze", function() 
  if not isParalyzed() then return end
  if TargetBot then 
    TargetBot.saySpell(storage.antiParalyze) -- sync spell with targetbot if available
  else
    say(storage.antiParalyze)
  end
end)

UI.Separator()
