Replacing enemy parameter by variable

Is it possible to replace the default parameter of an enemy by a variable?
Thank you.
only with a script
@Shaz Do you know of one, or a snippet? I assume it can't just be a script call.
What is it you're trying to do? What parameter(s), in what situation? Just an example will help me understand better.

It probably won't be as simple as a script call, if you're in battle, but it might be simple enough to write a little scriplet for you (I'm not aware of any existing, but then I'm out of the loop when it comes to what scripts are out there that will do stuff)
@Shaz Sorry for the delay in getting back to you, I was away from my computer for a while.

It's in battle, and ideally it would be any of the basic 8 stats (HP, MP, ATK etc.). It is so that I can make adjustments depending on when in the game a couple of bosses are faced, and who is in the party, that sort of thing.

And thank you for your generous offer.
I will see if I can take a crack at this tomorrow. About to shut down now.
Thank you.
If you only want to change an enemies parameters at specific points and don't have to completely tie it to a variable, you could maybe also use this script command for now (which would be the equivalent of the "grow" effect from items/skills):

enemy = $game_troop.members[ Index ]
enemy.add_param(
ParamIndex , Amount )

with
Index as the enemy position in the troop (0-7),
ParamIndex between 0 (=MHP) and 7 (=LUK) and
Amount being the parameter value to add (can be negative).
@Another Fen Thank you for this. I think there might be other occasions when I could use this script call, but for what I have in mind, I think I shall need the ability to tie it to a variable.

Once again, thank you for your suggestion.
@Kes try this in a new script slot:

Code:
class Game_Enemy < Game_Battler
  def mhp; enemy.note =~ /<mhpvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def mmp; enemy.note =~ /<mmpvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def atk; enemy.note =~ /<atkvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def def; enemy.note =~ /<defvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def mat; enemy.note =~ /<matvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def mdf; enemy.note =~ /<mdfvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def agi; enemy.note =~ /<agivar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
  def luk; enemy.note =~ /<lukvar\s*(\d+)>/i ? $game_variables[$1.to_i] : super; end;
end

and for any enemies where you want to use a variable for a stat, put <...var #> into their note box. Eg: linking MHP to variable 15 would be <mhpvar 15>

I only tested a part of this (pulling the variable ids by that method), not the final version. Hopefully there are no typos in there. If you have issues, post the error message and I'll take a look 🙂

btw - are you using any other scripts that affect battle or enemies? If you are, do a global search for def mhp and see how many definitions there are. If more than one (in Game_BattlerBase), there might be compatibility problems. Check for the other 7 as well.
@Shaz Tested this and it works just fine, no error messages, and I can achieve what I want with it. I checked out the definitions, and there aren't any extras, so no compatibility issues either.

Thank you very much for this, it's greatly appreciated.
Awesome! Enjoy 🙂
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/replacing-enemy-parameter-by-variable.83526/