Enemy Dynamic Max HP

Hey all,

I've been trying to find a simple solution for creating a way for enemies during battle to have increased overall maximum health without effecting all instances of that enemy within the troop or in future battles. Is there a variable that people are aware of for something like this?

I'm also quite new to scripting and its been hard finding resources online still around for RPGXP around this sort of topic.

Using simple Event Commands dont seem to work as the max hp cap still applies even if you try to percent it over.

EDIT: Just noticed this can indeed be altered strictly in Control Variables. Though the scripting solutions are best. Thanks @KK20
Something as simple as this will suffice for your request. Paste below default scripts, above Main as usual.
Code:
class Game_Troop
  alias randomize_enemy_hp setup
  def setup(troop_id)
    randomize_enemy_hp(troop_id)
    @enemies.each do |enemy|
      # HP Variance of -10% to +20% base max HP
      enemy.maxhp += enemy.maxhp * ((rand(31) - 10) / 100.0)
      enemy.hp = enemy.maxhp
    end
  end
end
This changes each enemy's MaxHP to be -10% to +20% its database MaxHP value. If you want to be more creative, I'd need to know some specifics.
Fantastic intro here to Ruby scripting for me. Already makes sense. Its the existing database variables I need to become more familiar with.

This has helped me a lot. Thank you very much!

If you want to be more creative, I'd need to know some specifics.

Im playing around with some very basic enemy leveling systems which have been working okay so far. I like the ability to add some randomization in there its great.
Another question I have, is why can't i paste code into the script event commands script field? lol seems to not allow for pasting from the clipboard there.
Considering you posted this in the RGSS request board, you were given a snippet to place inside your script database, not in the event's script command. If you had placed the snippet in the database, the would would happen when the enemy troop is formed, which will be every battle, including bosses.

But if you do want to use the script command, if you had managed to squeeze that in there, the code wouldn't have worked what with the code designed to activate in a certain place and not as a line-per-line code. Instead, you would have done something like:
Code:
$game_troop.enemies.each do |enemy|
  enemy.maxhp += enemy.maxhp * ((rand(31) - 10) / 100.0)
  enemy.hp = enemy.maxhp
end

Original thread: https://forums.rpgmakerweb.com/threads/enemy-dynamic-max-hp.107382/