[RMMV] How to change an event's sprites permanently without self switches

Is there a way to change an event’s sprites permanently (or until an event/switch/whatever else changes them again) without using self switches? The set movement route “change image” option would be good, but those changes don’t stay if you leave the map. “Change actor images” would be perfect if I could somehow apply it to events, but as far as I can tell that isn’t possible.

My goal is to randomize the visual appearances of the NPCs in an area. Making separate graphics and implementing randomization aren’t issues; I just need a way to change the sprites of the events. I’d use self switches but for all of the possible appearances I want and variations I plan on adding, they just don’t seem like a viable option. If I can’t find a way to do this I’ll probably do something like make separate events for all of them and randomize which ones show up, but I thought I’d see if anyone knows a way to just change the images first.
You can use variables. Creating a variables for each npc and make the values random, or use this plugin
Edit: oh, I was wrong, that plugin saves the location of the event, but i'm not sure if it also saves the appearance.
You can use variables. Creating a variables for each npc and make the values random, or use this plugin
Edit: oh, I was wrong, that plugin saves the location of the event, but i'm not sure if it also saves the appearance.
Could you elaborate a bit on the variables? I know I can use them to pick a random npc but can they be used to put that npc's sprite on the map? I'll try the plugin though.
The data regarding which sprite an event uses is saved in the data file for the specific map that the event is on. The game re-loads that file each time you enter the map in game. This is why you're having a hard time permanently changing the NPC's sprite image (without using a new page for each sprite).

Because of that, it's best to handle this type of situation with a plugin. There are some plugin-less ways to do it, but they're a bit clunky (IMO). However, I have demonstrated a plugin-less way to do it once upon a time, and you're free to check out that post, if you're interested. The system I made in that post was also doing some other stuff, so you probably don't want to copy what I did verbatim, but you might be able to pick out the parts that are relevant to whatever you're trying to do.
Could you elaborate a bit on the variables? I know I can use them to pick a random npc but can they be used to put that npc's sprite on the map? I'll try the plugin though.

I apologize if I'm not understanding exactly what you need, but you could do a "Control Variable..." to randomize each variable of any number of NPCs. Say you have four NPCs, so you could randomly generate a value for each variable this way, and create a separate Event page for each appearance you want on any given NPC. Assuming they all say or do the same things since you only want to change the image, you would only have to copy and paste the pages and change the relevant value in its Conditions.

I'm not fully proficient with JavaScript but from looking through rpg_objects.js I couldn't find a function to do what you need.
I apologize if I'm not understanding exactly what you need, but you could do a "Control Variable..." to randomize each variable of any number of NPCs. Say you have four NPCs, so you could randomly generate a value for each variable this way, and create a separate Event page for each appearance you want on any given NPC. Assuming they all say or do the same things since you only want to change the image, you would only have to copy and paste the pages and change the relevant value in its Conditions.

I'm not fully proficient with JavaScript but from looking through rpg_objects.js I couldn't find a function to do what you need.
My bad, I should've specified that I don't want to use multiple event pages for the different images. Thank you anyway though
The data regarding which sprite an event uses is saved in the data file for the specific map that the event is on. The game re-loads that file each time you enter the map in game. This is why you're having a hard time permanently changing the NPC's sprite image (without using a new page for each sprite).

Because of that, it's best to handle this type of situation with a plugin. There are some plugin-less ways to do it, but they're a bit clunky (IMO). However, I have demonstrated a plugin-less way to do it once upon a time, and you're free to check out that post, if you're interested. The system I made in that post was also doing some other stuff, so you probably don't want to copy what I did verbatim, but you might be able to pick out the parts that are relevant to whatever you're trying to do.
I’m glad it’s possible! I’ve been trying to implement your method, but I’m not very good with script, so I have a couple things I want to ask about if that’s alright. The first is that, while I’m pretty sure I put everything in exactly (to see if I can get it to work initially before changing anything), I’m getting “SyntaxError Unexpected Token .” I looked everything over but without fully understanding what I’m doing, I don’t think I have any hope of knowing what to change.

I’m also wondering if it’s possible to use this method with actors instead of enemies by omitting part of the script, or if it would have to be reworked. If I can easily skip the troop step I might want to do that, but if too much would need to be changed I’m totally fine with leaving it as is.
Well that error message means that somewhere in your code you have a "." character where there shouldn't be one. However looking at the original post that is a lot of code and that dot could be hidden anywhere.

So your first step should be to check in which area of code this error occurs. You can add the following commands to the script you already have:
console.log('Step 1');
Do this at the start of each script event command (of course while replacing the number after 'Step' with the next one).

Your console output should then look something like this:
Code:
Step 1
Step 2
Syntax Error
Step 3
So now you know between which log-commands the error must be. Maybe this hint is already enough to spot the error. If not, don't worry. You can simply apply the above method more granularly to pinpoint the exact line of the error of necessary.
However inserting these logs after every line is pretty tedious, so it makes sense to rule out large parts of the code with less granular steps before getting more detailed.
Well that error message means that somewhere in your code you have a "." character where there shouldn't be one. However looking at the original post that is a lot of code and that dot could be hidden anywhere.

So your first step should be to check in which area of code this error occurs. You can add the following commands to the script you already have:
console.log('Step 1');
Do this at the start of each script event command (of course while replacing the number after 'Step' with the next one).

Your console output should then look something like this:
Code:
Step 1
Step 2
Syntax Error
Step 3
So now you know between which log-commands the error must be. Maybe this hint is already enough to spot the error. If not, don't worry. You can simply apply the above method more granularly to pinpoint the exact line of the error of necessary.
However inserting these logs after every line is pretty tedious, so it makes sense to rule out large parts of the code with less granular steps before getting more detailed.
Sorry, where will this show up? It doesn't appear on the error screen; I may be looking in the wrong place.
Here is my Solution for the first Post, sorry did not have Time to read the rest deeply.
Breaktime is nearly over.

An Event that runs one time each time the map is entered.
It changes the Graphics and than erases itself until map is reloaded.
Maybe this helps in this case?
npcmapoutfit01515.png

Edit: I made an Error i forgot to change the Moveroute target for NPC 2.
Not EV001 it should be another Event Id.
I figured it out! There may be a better/more efficient way to do it but what I have now is definitely working.

I set up the randomization alone on one event, then have it turn itself off so it doesn't set different npcs when you leave the map and come back. On a different event, I set the actual images based on the variables that the first event chose, then erase that event. That way, it not only sets the random images initially, but every time the map is reentered, it checks to see what those images were and sets the same ones again.

I'm honestly surprised I didn't think of this sooner. I may change it a bit here and there as I go, and hopefully when it's done on a larger scale there are no issues. Feel free to let me know if there's anything I'm overlooking. Otherwise, thank you to everyone who commented and helped me figure this out! (I'll definitely also check out the Save Event Position plugin; I wouldn't've thought to look for that.)
Here is my Solution for the first Post, sorry did not have Time to read the rest deeply.
Breaktime is nearly over.

An Event that runs one time each time the map is entered.
It changes the Graphics and than erases itself until map is reloaded.
Maybe this helps in this case?
View attachment 236672
Edit: I made an Error i forgot to change the Moveroute target for NPC 2.
Not EV001 it should be another Event Id.
The only thing is I need it to remember the npcs. This method choses different ones when you leave the map and come back. I think it works if I only have it choose the npcs once and then keep setting the images based on those same variables though. Thank you for the input!
Sorry, where will this show up? It doesn't appear on the error screen; I may be looking in the wrong place.
You can view the console output through pressing F8. Be aware though, the window that will open has several tabs. The console is not necessarily the one you start on.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-how-to-change-an-events-sprites-permanently-without-self-switches.150020/