Now, I'm not sure how similar zmud scripting is with tintin++, but this is what I came up with (and it works as far as I can tell):
You need to have a prompt like this: <%h/%Hhp %mmn %vmv : %thour %Xtnl> %n%p
And as a trigger or .. #act, in tintin++:
#ACTION {<%1/%2hp %3 %4 %5 %6 %7 %8 [%9]}={#math divvar {%2/%1};#if {"$divvar" >= "2" && "%9" <= 100 } {#showme
HP below 50 PERCENT!;flee} {#nop %9 Fine}}
Not sure with zmud, but tintin+ doesn't let you show non-integers with the #math function, so you have to reverse it. Anything at 2 or above (your max hp / min hp) will force you to flee. It also checks %9 (which is the percentage of whoever is fighting) to prove you're in combat. If it's not there, then you're not in combat and it doesn't trigger. Also, whoever is fighting should be at 100% or below. If for some reason they're 101 (happens with lifedrain and vamp touch, energy drain, etc) it won't trigger either.