Created: 6 months ago on 05/20/2025, 03:37:16 PM
-- Helper function for mediation
function Meditate()
    Journal.Clear()
    Skills.Use('Meditation')
    Pause(700)
    if Journal.Contains('You cannot focus your concentration') then
        Pause(10000)
        Meditate()
    elseif Journal.Contains('You must wait a few moments to use another skill') then
        Pause(1000)
        Meditate()
    elseif Journal.Contains('You stop meditation') then
        Pause(1000)
        Meditate()
    elseif Journal.Contains('You are at peace') then
        Pause(1000)
        return
    elseif Journal.Contains('You enter a meditative trance') then
        while Player.Mana < Player.MaxMana do
            Pause(100)
        end
        return
    end
end
-- =============
-- MAIN ROUTINE
-- =============
while Skills.GetValue('Magery') < 100 do
    Pause(50)
    if Journal.Contains('insufficient mana') then
        Meditate()
    end
    
    currentMagery = Skills.GetValue('Magery')
    
    if currentMagery >= 70 then
        Spells.Cast('ManaVampire')
    elseif currentMagery >= 62 then
        Spells.Cast('Invisibility')
    elseif currentMagery >= 50 then
        Spells.Cast('ManaDrain')
    elseif currentMagery < 50 then
        Messages.Overhead('You need at least 50 Magery to start the training.', Player.Serial)
        break
    end
    if Targeting.WaitForTarget(5000) then
        Targeting.Target(Player.Serial)
        Pause(800)
    end
end