common event checking enemy HP?

How can I edit the common event script so that it can allow for checking the total HP of the enemy party? I want to try a complex common event idea i had to see if it might make a decent game mechanic
To check the total hp of the currently alive enemy troop members...

Put something like this as the script call option of a conditional branch check (or whatever)

Code:
$game_troop.members.compact.select{|i| i.alive? }.inject(0) { |r,i| r += i.hp }

Original thread: https://forums.rpgmakerweb.com/threads/common-event-checking-enemy-hp.38170/