I'm waiting for CompSci class to start right now but in the meantime I can give you some general info. Computer AI is not an easy area. What I use for AI is a mood setter. You do a check to see what "mood" the enemy is in. This can check such stats as HP, PlayerHP, Ratio HP, MP Distance from party and almost anything really. After analyzing what "mood" they are in you need to set the script for their actions based on their mood whether it may be running away, melee attacking, etc..
Superfluous correlations through Pavlovian conditioning cause cerebral captivity for all of us.