I'm creating a script and I'm wondering if it's possible to set tergetting or to write an action for iBot to wait until monster becomes visible again?

Because it's kinda annoying.

My char is attacking a monster and when it becomes invisible, my char just walk away and lure a lot of monsters. It's a waste of time, pots and I might even die because of it..

Can anybody help me out with this?