Enemy Dynamic Max HP

Teabone

Veteran
Veteran
Joined
Mar 26, 2019
Messages
31
Reaction score
1
First Language
English
Primarily Uses
RMXP
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
 
Last edited:

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
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.
 

Teabone

Veteran
Veteran
Joined
Mar 26, 2019
Messages
31
Reaction score
1
First Language
English
Primarily Uses
RMXP
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.
 
Last edited:

Teabone

Veteran
Veteran
Joined
Mar 26, 2019
Messages
31
Reaction score
1
First Language
English
Primarily Uses
RMXP
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.
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top