Any way to change all instances/uses of a variable in an event at once?

I can't figure out a way to do this, it's not critical to my game but it would save me a lot of time if there is a way.

I have a very long event that comprises most of my custom action battle code within the enemy event itself rather than a common event for various reasons, the downside is that each enemy needs their own variable, and each enemy variable has a minimum of 75 uses in the code in each enemy event, and potentially up to 300 if I do exactly what I want to do in terms of complexity (but the current 75 is still good, I could still live with that.)

I can go through each enemy event manually changing 75 uses of the variable to each new enemy variable without too much trouble, probably within a few minutes for each one with double checking, but I plan to have likely hundreds of enemies, and I'd prefer to not re-use variables. Also my code is long and finding every variable for hundreds of enemies without making a few mistakes isn't likely, bug fixing could be a nightmare.

So is there an easy way to replace all instances of use of variable 1 in an event to variable 2 for example?

Something like if variable 1 is used at all in any type of code or conditional branch, etc, then substitute variable 2 for all instances of it like with a batch command.

Rather than me manually changing all 75 per new enemy? (or even 300.)

Possibly achievable with a plugin?

Any help is much appreciated.
Are these variables being changed within the event, or just referred to? If the latter, you could use a common event and use a 'common' variable, and prior to calling the common event, set the 'common' variable to the same value as the enemy's variable.

Otherwise, if you don't want to do it manually, you're looking at either a plugin or setting one up the way you want, then copying it & doing a search/replace on the json file. Could be messy.
I think the best way to handle this would be to look for a plugin that provides a self-variable function to events.

If you do that, the plugin would create variables per event, and you would be able to use a common event with the script functions to access the self-variables - done correctly that should save you a lot of work, although you'll need to learn how to use the plugins script function to access the self-variable instead of the control variable command.
Ugh! You just reminded me of a plugin I started writing but haven't finished yet! It would do EXACTLY this!
Many thanks Shaz and Andar, I'm definitely leaning towards using a plugin as it's not so much the hard work I'm worried about, but more so human error.

My real life profession requires a strong attention to detail but with at least 75 instances of the variable to change for each event, there's going to be a few % margin of error, I'd have to be a robot to not make a mistake, on each one.

If I do end up doing it manually I'll need to write text comment reminders in bold colours to denote where each variable is as it's currently in different commands such as conditional branches and simple variable increases as it's so easy to miss them currently.

I definitely couldn't write this plugin myself, but I am learning how to read the basics of Javascript, if not write it, and I already use script conditional branches for my stamina system, etc, as TP isn't recognised fully as HP and MP is, so I could I could definitely understand how to configure one.

In the goal of reducing the real work and margin for error, surely a system that checks an event number and then changes all instances of that variable use to a different specific variable should be possible?

EG:

If event 14 uses variable number 1, then change all instances of Event 14's variable number 1 to variable number 2.

I wish it was as simple as just typing that sentence out!

In terms of variable use in my event, I only use the variable in conditional branches or to add to that variable. (My enemies' health variable doesn't reduce, it actually starts from 0 and increases due to the standard Event page triggers only allowing for if a variable is = or above, and not below. When the variable hits their max HP number, the page switches and they 'die' to a blank page with that variable limit set. (There's a lot more to it that that but that's the basic gist of it.)

If anyone thinks a plugin could be done and they have the time and inclination to make it, then I would be eternally grateful.
there are already existing self-variable plugins, that's why I mentioned them - don't write a new one, simply check the existing ones for compatibility and usefullness.
OK thanks, I watched Yanfly's self switches and variables tutorial and I think that would do it.

The self variable effectively makes a single variable have extra configurations according to each event and to only effect that individual event, seems like just what I need.

I think all I'd have to do according to my system and Yanfly's plugin is to name my battle event variable to have 'Self Var' in its name, and then it effectively will be classed as different variables according to each event.

Seems too good to be true if that actually works as I won't even need a common event either.

Will update post after testing.

EDIT:

Now that's what I'm talking about!

One variable to control them all.

I added Self Var to my single battle event variable, and then just copied the entire battle event on my map. I only did it once but logic dictates it work for any number of them that the game engine can handle.

They now function as entirely different events! I could almost shed a tear of happiness, I don't even have to change a single line of my battle event code except enemy damage to the player which is an absolute piece of cake!

300 variable reference per event here I come, a complex ranged system to go with my already 15 weapon type melee system here I come!

I love this forum, in less than 30 posts my game has advanced beyond all my capabilities thanks to it.

Original thread: https://forums.rpgmakerweb.com/threads/any-way-to-change-all-instances-uses-of-a-variable-in-an-event-at-once.79953/