Leech skill misdirecting

What is supposed to happen is this:

At turn 0, the state 'Leech' is inflicted on the boss, who is enemy #8

Each turn, 5% of the entire party's HP is taken and absorbed by the boss, using this scriptlet in the troop event

a=0

$game_party.members.each{|actor|

  #if actor.state?(77)

    b=(actor.hp*5/100)

    actor.hp-=b

    a+=b

  #end

}

$game_troop.members[0].hp += a

 

I know that the state is being successfully applied, because there is a text announcement and the boss has the icon showing on it.

However, the HP is being absorbed by enemy #1

I know this because it keeps resurrecting.

 

Obviously I need to be more specific in that bit of coding about which enemy is to benefit, but I cannot see where and how.  Could anyone help out?

 

Thank you.
$game_troop.members[0] would give you the first enemy... You could possibly iterate all enemies, then look for the one that has the leech state

instead of

$game_troop.members[0].hp += ayou'd do

$game_troop.members.each {|ene| ene.hp += a if ene.state?(leech_ID)} or if it's a specific enemy, just use his number...

if it's enemy 8, try 

Code:
$game_troop.members[7].hp += a
That's done the trick. thank you very much.

Original thread: https://forums.rpgmakerweb.com/threads/leech-skill-misdirecting.35609/