Improve YEA - Enemy Death Transform

I am using YEA - Enemy Death Transform
It provides one way only.It reads the note in database to decide which enemy will be transformed.
I want to transform enemy according to a variable.Just like the below.

In game,enemy 1 is Slime,enemy 2 is Spider,enemy 3 is Dragon.
Before a battle,I set that $game_variables[x] = 2

During the battle,Slime will transform to Spider when Slime die.
At the same time,I set that $game_variables[x] = 3

And then,Spider will transform to Dragon when Spider die.
At the same time,I set that $game_variables[x] = 0
Finally,Dragon die and win the battle.

Can any friend help me please?
I don't want to use event.Please help me by script.Thank you.

p.s. English is not my first language .So that my grammer is not good.Forgive me.
Try this patch, below the script.
Code:
class RPG::Enemy
  def death_transform
    unless @transform_var 
      @transform_var = 0
      if note =~ /<transform var:\s*(\d+)>/i
        @transform_var = $1.to_s
      end
    end
    return $game_variables[@transform_var] if @transform_var > 0
    return @death_transform
  end
end
To use, simply put <transform var: ID> as notetag. Replace ID with the variable ID. Untested. Theoretically should work, but eh.
Try this patch, below the script.
Code:
class RPG::Enemy
  def death_transform
    unless @transform_var
      @transform_var = 0
      if note =~ /<transform var:\s*(\d+)>/i
        @transform_var = $1.to_s
      end
    end
    return $game_variables[@transform_var] if @transform_var > 0
    return @death_transform
  end
end
To use, simply put <transform var: ID> as notetag. Replace ID with the variable ID. Untested. Theoretically should work, but eh.

Unbelievables! A famous author was invited by me.
I have used your script for a long time. Thanks for your help from past to present .
Moved to: RGSSx Script Support

Original thread: https://forums.rpgmakerweb.com/threads/improve-yea-enemy-death-transform.119614/