You know how in battle, the SV actor is at 25% HP, the damaged sprite shows? Can I replicate that in the overworld with the charset under the currently used one?
Damaged overworld sprite
RPG Maker MV SupportI'm actually using a parallel process to do something similar. You could accomplish what you want by...
1. Create an event, set it to parallel.
2. Set a variable 1 to be equal to the player's the max hp.
3. Divide variable 1 by whatever the percentage you want to be considered damaged. Such as by 10 if you want 10%.
4. Set variable 2 to be equal to the player's current hp.
5. Create a conditional statement to see variable 2 is less than or equal to variable 1. If it is, have it change the actor image to damaged (using "Change Actor Images". If it isn't then have it change the actor's graphics to the normal ones.
Edit:
I'm silly and left out to have it self switch to another page if it's above the amount to make certain it still is. If it isn't have it turn that switch off so it returns to the first page. Use a different switch/page if they're below the amount and have it switch off if they aren't. If you don't do this, it will keep running the change actor image command and likely lag your game. I forgot to do this with an animation running and it looked like the world ended. XD
1. Create an event, set it to parallel.
2. Set a variable 1 to be equal to the player's the max hp.
3. Divide variable 1 by whatever the percentage you want to be considered damaged. Such as by 10 if you want 10%.
4. Set variable 2 to be equal to the player's current hp.
5. Create a conditional statement to see variable 2 is less than or equal to variable 1. If it is, have it change the actor image to damaged (using "Change Actor Images". If it isn't then have it change the actor's graphics to the normal ones.
Edit:
I'm silly and left out to have it self switch to another page if it's above the amount to make certain it still is. If it isn't have it turn that switch off so it returns to the first page. Use a different switch/page if they're below the amount and have it switch off if they aren't. If you don't do this, it will keep running the change actor image command and likely lag your game. I forgot to do this with an animation running and it looked like the world ended. XD
That's going to be a lot of work for a lot of characters. Is there a more simple way to do it?
Not that I personally know of, but I'm new to this so there probably is. For what it's worth, you could just copy and paste the event with the variables/change actor image changed for each character. Or you could use Yanfly's Self Variables so you can copy and past everything except the actor image change. Personally I use Yanfly's Event Spawner to call the event into any map I need it, mostly to limit parallel processes... Also because I'm lazy and don't want to copy it for every map.
So, on one particular map, you want ALL party members to show a "healthy" sprite if their hp is > 25%, and a "damaged" sprite if it's 25% or under? And you have a spritesheet with 8 characters, where the top group is the "healthy" sprite but the bottom group is the "damaged" sprite?
Try this ... create an event set to parallel process, and add the following commands:
Then on any map you can go to from that particular map, also create an event set to parallel process, with the following commands:
which will make sure the images revert back to the correct form on every other map.
This is a little inefficient, as it's calling the function to change images even if they don't need to be changed. You could alter it to first check if it needs to be changed for each member, and only call the function if it does, and then to only refresh $gamePlayer if at least one was changed. But that'd be more complex scripting, and the above shouldn't really be a drag on performance.
Try this ... create an event set to parallel process, and add the following commands:
Code:
Wait 5 Frames
Script: $gameParty.members().forEach( function(actor) {
if (actor.hpRate() > 0.25) {
actor.setCharacterImage(actor._characterImage , actor._characterIndex.mod(4));
} else {
actor.setCharacterImage(actor._characterImage , actor._characterIndex.mod(4) + 4);
});
$gamePlayer.refresh();
Then on any map you can go to from that particular map, also create an event set to parallel process, with the following commands:
Code:
Script: $gameParty.members().forEach( function(actor) {
actor.setCharacterImage(actor._characterImage , actor._characterIndex.mod(4));
});
$gamePlayer.refresh();
Erase Event;
which will make sure the images revert back to the correct form on every other map.
This is a little inefficient, as it's calling the function to change images even if they don't need to be changed. You could alter it to first check if it needs to be changed for each member, and only call the function if it does, and then to only refresh $gamePlayer if at least one was changed. But that'd be more complex scripting, and the above shouldn't really be a drag on performance.
Can I do that for every map or something?
You said you only wanted to do it in the overworld. So the first event will only be in the overworld map. The second event needs to be on every map that the overworld leads to, to make sure the sprites are correct when they leave the overworld. You could do this by putting the second event into a common event (not parallel process), then make the event on the other maps do a Common Event command. That way if it's not quite right and you need to change it, you only have to change it in one place.
By overworld, I meant every map (the places where battles don't take place).
Where do the battles take place? How many maps are overworld maps and how many are battle maps?
(I thought "overworld" meant "world map", of which there's usually only one)
(I thought "overworld" meant "world map", of which there's usually only one)
Okay, let me get this straightened out. By overworld, I mean everything except in-battle.
Assuming battles take place on the battle screen and you don't have some kind of map/ATB battle system, you want this to happen on ALL maps then?
If that's the case ...
Create a Common Event with the first block of code I gave you. Set it to parallel process and give it a switch. At the very start of your game, turn the switch on.
If you don't have ANY maps where this process should not be run, then you don't need the second block of code at all.
Note - I haven't tested the above, so I don't know if there might be any errors in there. Give it a go, and if you have issues let me know. Also let me know if it causes any kind of lag, and I'll give you the more complicated version that only changes the sprites when absolutely necessary.
If that's the case ...
Create a Common Event with the first block of code I gave you. Set it to parallel process and give it a switch. At the very start of your game, turn the switch on.
If you don't have ANY maps where this process should not be run, then you don't need the second block of code at all.
Note - I haven't tested the above, so I don't know if there might be any errors in there. Give it a go, and if you have issues let me know. Also let me know if it causes any kind of lag, and I'll give you the more complicated version that only changes the sprites when absolutely necessary.
Can you please post a screenshot of your event?
I copypasted the script exactly as it is.
got it - I left out a }
Please copy/paste this instead, for the script call:
Please copy/paste this instead, for the script call:
Code:
Script: $gameParty.members().forEach( function(actor) {
if (actor.hpRate() > 0.25) {
actor.setCharacterImage(actor._characterImage , actor._characterIndex.mod(4));
} else {
actor.setCharacterImage(actor._characterImage , actor._characterIndex.mod(4) + 4);
}
});
$gamePlayer.refresh();
can you please post an image of the console? (F8 when that error happens, Console tab)
I'm sorry - it's the wrong variable name. Please try this instead:
Code:
Script: $gameParty.members().forEach( function(actor) {
if (actor.hpRate() > 0.25) {
actor.setCharacterImage(actor._characterName , actor._characterIndex.mod(4));
} else {
actor.setCharacterImage(actor._characterName , actor._characterIndex.mod(4) + 4);
}
});
$gamePlayer.refresh();
Up to 5 characters using Yanfly's party system (8 different characters)
They all have sprites assigned (Charset, Charset weak, Face, Battler)
Did not, just edited overtop of them, though you start with only 1
They all have sprites assigned (Charset, Charset weak, Face, Battler)
Did not, just edited overtop of them, though you start with only 1
Original thread: https://forums.rpgmakerweb.com/threads/damaged-overworld-sprite.113043/