I need an action who do:

When my life is 'X' and i have 'X' < Life Potion and 'X' < Mana Potion; the cavebot Stops and use one spell (if have mana to do).. When my life recovered until 80% (or 'X' life), the cavebot continue

Exemple:
Code:
My life gets 450, and i have 60 HP and 40 MP (to 'economize' the potions); so the cavebot stop (my character stop to walk).. and wait the mana to recover until 75.. when the mana get's 75 the character use the spell 'utura' (this spell make my char recover 600life point, but need 1minute to do this..) when the character recover life until 90% or Xlife the bot continue (the character continue to walk)..