[RPG Maker MV] Plugin to switch the character below/above the current one with a command. (on map)

Hello,

I was looking for a plugin which would allow me to switch the character above or below in the charsheet just with a plugin command.
Example :


This plugin would provide one command for the below character, and another one for the above character.

I didn't find such plugin on the internet, so I was wondering if someone would be able to create this plugin?

Many thanks.
Are you talking about the player or an event?

You can use this to change the image of an actor:
Code:
var actor = $gameActors.actor(id);
actor.setCharacterImage(actor.characterName(), actor.characterIndex() + 4)

Or this to change the image of an event:
Code:
var actor = this.character(id);
actor.setImage(actor.characterName(), actor.characterIndex() + 4)

These commands select the image below the current one. Replace + 4 with - 4 to make it select the image above the current one.

The change is not permanent for events - if you leave the map and come back, it will revert. To make it permanent, don't use these commands - use multiple event pages with conditions that indicate which image will be used.
You can do that with event commands. If the character is an event:
-Go to the second tab and select "Adjust movement routes" (or something like that my game is in spanish).
-Select the event you want the graphics change and at the right click "Change graphics"
-Select the new graphic you want for that event.
If its for an actor:
-Go to the 3rd tab and select "Change actor graphics"
-There, select the actor you wanna change and select the graphics to be changed.
Hope this works for you!
Hello Shaz and Danitinkis. Thank you for your answers.

Danitinkis, thank you for the help, but I'm affraid the problem is quite more complex : the thing is I want to avoid this kind of process and create a common event for ALL the characters change. As it has to affect any kind of event, I cannot use this command because it has to be for specific characters. (I don't know if I'm clear enough)

I will illustrate my problem with the below picture :



Blue : Stand
Green : talking
Red : Walking

I always build my charsheet around this structure. So right now, I'm using exactly the process you just described :


And it works! However, as I want to work more smartly, I was thinking it would be way better to create 2 common events :
_ One which would switch for the character just below (for talking)
_ Another one for to switch back to the character above (for getting back to standing)





Shaz, thank you for the help, I see you totally understand the problem.
However, this code, do I have to activate it free the command "script"?
Also, I see there is this passage :
actor(id)
which means, (I guess) I have to specify the concerned event? This is what I'm trying to avoid.
I think you understand now that I suck (or more like "doesn't understand anything) at coding, unfortunately.
Based on what I explained to Danitinkis, would it be possible to, instead of specify the event ID, just "detect" which character is currently used by the event, and then switch to the below (or above) character?
If you use this command:
Code:
var actor = this.character(id);

and specify 0 as the id, it will apply the change to the event that's running the command.

However, based on your explanation of your character sheet structure, I don't think + 4 or -4 is going to be a good approach. What if they're currently walking and then change immediately to talking? That would set it to the block of tiles below your red and to the right of your green. I think you would be better off specifying the index directly - 0 for stand, 1 for walk, 4 for talk. You can still use the rest of the script to apply it to "this event" without having to specify which event it is, and to keep the same character sheet.

I'd set up one common event for each index (stand, talk, walk, etc), add those commands to the common event, and then make each event call the common event at the appropriate time.
I mean, you don't even need to do that much. Just so under System in the Event Commands and change Actor Image. Walla!

Hint: It's on the Third page.
the OP is changing event images, not actor images, and doesn't want to have to select the sprite, as it's going to be done to many events. They just want a way to say "use the same sprite sheet (without having to select it), but a different index)
What if they're currently walking and then change immediately to talking?

Solid point, I think I should add a fourth character which would be talking + walking at the same tome. That would be ok, right?

You're idea of making a common event for each state is really interesting, I would like to try it.
However, I don't entirely understand how to proceed.
I don't even know for the code you gave me if I have to use the "Plugin command" or "Script" in the third page to make it work?
I understand that 0 would refer to stand, 1 to walk and 4 to talk, but yet I don't even know where to put those numbers...

I am really sorry but I don't usually use code on anything I do...
I do this in my game. I have a walking sprite for each character, a swimming sprite and a riding sprite for those who could be in the party at those times.

I have one common event called 'reset sprites', one called 'swimming sprites' and one called 'riding sprites' and at the time I want to change from one to the other, I just have the map event call the appropriate common event. In the common event I do a Change Actor Images to set each one to the appropriate sprite.

The difference with yours is that it would use the script call (not a plugin command) rather than an event command, so you don't have to select the image, and it would do a single event (using this.character(0)) rather than a group, and you would specify the appropriate index for that pose/action.

You would put the numbers (0 for stand, 1 for walk, 4 for talk) as the second argument in the script call, rather than use actor.currentIndex() + 4

So your common event to change to the standing sprite would just have a script call:
Code:
var actor = this.character(0);
actor.setImage(actor.characterName(), 0);

and your common event to change to the walking sprite would be:
Code:
var actor = this.character(0);
actor.setImage(actor.characterName(), 1);

then in your event, you'll just call the common event at the time you want it to change.


Note my earlier warning though - this will only apply while you remain on the map - if you leave the map and return, they will all be reset to their original images. If you don't want that to happen - if you want them to stay that way if you leave the map and return, you can't do it this way - you have to use multiple event pages with a different image on each page, and conditions to dictate which one is active.
Perfect!

This works perfectly!

Thank you so much man!
And don't worry for the "this will only apply while you remain on the map", the "speaking" common event will always be followed by the "not speaking" common event, so I don't think this will be a problem.

Anyway, this is exactly what I was looking for. And this isn't even a plugin so it's even better.

Thank you so much.

EDIT : yeah you were right about the "talking to a moving event" : in that case, it doesn't work. But I just put a "wait 20 frames" before your code and it seems to work. So, I guess it's fine.
Hello again,

I'm trying to do literally the same thing, but on an actor. Any help? Here is what I tried until now :

This is the script I use for EVENTS : (which works)
upload_2019-11-27_15-50-29.png


And here is what I tried to do for actors : (which doesn't work, I couldn't know why)
upload_2019-11-27_15-50-5.png

If I put "0" instead of "1", the game crashes. So far, with THIS script, nothing happens.

Many thanks in advance.
The id for the actor is the actor id in the database. There is no Actor 0, which is why you get an error.

What do you mean by "trying to do it on an actor"? Do you mean followers? You might need to add a command to refresh the map afterwards. I don't have MV with me so I can't look it up, but it might be something like $gameMap.requestRefresh() or $gameMap.need_refresh = true or $gameMap.needs_refresh = true

I would think asking for a character image change should automatically refresh the map though, so maybe that's not it. Or maybe the refresh is done within Game_Interpreter and not Game_Character...

At this stage, because I can't actually look at anything, I'm just guessing.
Hello Shaz and thank you for your prompt answer. Indeed, excuse me, I should have been more precise.

For example, if I want to switch the character in a same charsheet for an EVENT, here is the code you showed me I have to use :
upload_2019-11-28_2-25-32.png


You know, for this kind of change :
upload_2019-11-28_2-26-13.png



But now, I would like to apply the change for the actor. Not the follower, but the player only. As far as I know, I do not need to refresh this between maps. (There is a few chance I will need for the follower also, but.... not for now.)
Bump
Code:
var actor = $gameActors.actor(1);
actor.setCharacterImage(actor.characterName(), 4);
$gamePlayer.refresh()
Aaaah, sorry, I didn't understand that the GamePlayer.refresh was the missing thing, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/rpg-maker-mv-plugin-to-switch-the-character-below-above-the-current-one-with-a-command-on-map.103814/