Do you think this would be easier if it was just scripted the whole way or most of the way? If so would you happen to know a script that would work this way? Or maybe there's a plug in that can already do this?
Revival Item
RPG Maker MV SupportNo - as I said above, I already can't figure out the correct functions to make this act the way you want.
The alternative would be to use Yanfly's Buffs & States and Auto Passive States...don't give the party members immortal, but instead adjust the incoming damage if all the circumstances are met. That would get around this current issue.
Just for the sake of correct terminology, you appear to be asking the same thing twice - RPG Maker MV doesn't use scripts, only plugins. An individual reference to a function is sometimes called a script call, like when I gave you a single line to fill into the Script box to check two actors at once.
Ah ok. I do have the Yanfly plugins already installed into the game just not quite sure how to adjust the incoming damage. Would it still be controlled from the troop event?
Do you have YEP Auto Passive States installed? Copy and paste the code below into your actor passive state's notebox (you can delete the comment lines if you want):
There's no need for any revival item yet. You just want to test the effect. Now, do a playtest, NOT a battle test, and get some enemies to kill your actors and see if they revive after fatal hits. To make things faster give your enemies 999 ATK or something. If you like the effect we can proceed with revival items.
JavaScript:
<Custom Deselect Effect>
// Check if the target's HP is 0 or is currently in the death state.
if (target.hp <= 0 || target.isDead()) {
// Play the auto-life animation on target.
target.startAnimation(49);
// Set the amount of HP recovered to 10%.
var rate = 0.10;
// Calculate the HP healed.
var heal = Math.floor(target.mhp * rate);
// Heal the target.
target.gainHp(heal);
// Make the damage popup show for the heal.
target.startDamagePopup();
// Clear the target's results.
target.clearResult();
}
</Custom Deselect Effect>
There's no need for any revival item yet. You just want to test the effect. Now, do a playtest, NOT a battle test, and get some enemies to kill your actors and see if they revive after fatal hits. To make things faster give your enemies 999 ATK or something. If you like the effect we can proceed with revival items.
Which one is the actor passive state's notebox? Is it the notebox in the specific actor's settings or is it the notebox in a state that I would have to make?
Hi. You have to make a state first. Any state would do. Just make a new state. Let's call this state Actor Global Passive.
Then in your YEP_AutoPassiveStates plugin parameters, to the right you will see ---Basic--- > Actor Passives List. Double click or right click > edit then find your new state Actor Global Passive in the drop down menu. Now you have a passive state on all actors.
Once you do that, you copy and paste that code into the notetag of your state Actor Global Passive.
Ok so I copied and pasted the code into the notetag of the state and followed your instructions, but in the play test it doesn't seem to revive the actor once they are knocked out. After they are knocked out it shows the normal screen outside of battle for a split second then goes to gameover.
Can you try this below?
JavaScript:
Custom Deselect Effect>
// Check if the target's HP is 0 or is currently in the death state.
if (target.hp <= 0 || target.isDead()) {
// Play the auto-life animation on target.
target.startAnimation(49);
// Set the amount of HP recovered to 10%.
var rate = 0.10;
// Calculate the HP healed.
var heal = Math.floor(target.mhp * rate);
// Heal the target.
target.gainHp(heal);
// Make the damage popup show for the heal.
target.startDamagePopup();
// Clear the target's results.
target.clearResult();
}
</Custom Deselect Effect>
Same thing.
Oh right! My bad. I omitted the < in Custom Deselect Effect> 😢
replace the first line from
Custom Deselect Effect>
to
<Custom Deselect Effect>
I'm using the exact same code above in my device and it's reviving my single actor over and over.
replace the first line from
Custom Deselect Effect>
to
<Custom Deselect Effect>
JavaScript:
<Custom Deselect Effect>
if (target.hp <= 0 || target.isDead()) {
target.startAnimation(49);
var rate = 0.10;
var heal = Math.floor(target.mhp * rate);
target.gainHp(heal);
target.startDamagePopup();
target.clearResult();
}
</Custom Deselect Effect>
I'm using the exact same code above in my device and it's reviving my single actor over and over.
@V-DeLuna
Check my previous message. We're missing the left bracket < in Custom Deselect Effect. My bad. Sorry about that. 😩
Gotcha. No problem. It worked this time. It kept reviving the actor back to 50hp.
@V-DeLuna Whew! 😮
Can you describe more details about how you want this revive one and revive all items to work?
1. Are these revive items equipped items or just regular consumable items?
2. If the party has both items how would you like to handle that?
3. How much hp do you want to gain upon revival? Full hp, percentage of something, 1 hp?
4. Will the main character always be in the party?
5. Any other feature you'd like?
Can you describe more details about how you want this revive one and revive all items to work?
1. Are these revive items equipped items or just regular consumable items?
2. If the party has both items how would you like to handle that?
3. How much hp do you want to gain upon revival? Full hp, percentage of something, 1 hp?
4. Will the main character always be in the party?
5. Any other feature you'd like?
1. Just consumable items.
2. If the party has both items then priority of use should go to Revive 1 rune and it should bring either actor 1 or actor 2 back depending on who is in the party.
3. Was wanting full hp back.
4. In the beginning of the game the player gets to choose between actor 1 or actor 2 as the main character for the game. From that point on the chosen actor stays in the party for the rest of the game.
5. None that I can think of off the top of my head. Thank you.
Here's the tentative code. You will need to setup a bit. Just a little bit. Promise. 😀
1. You will first need to store the actor id of the main character inside a control variable. Any would do.
2. Then you will need to modify the numbers (just numbers) in the setup section of the code below.
You can delete the comments later if you want. Just tell me all the bugs that may arise.
1. You will first need to store the actor id of the main character inside a control variable. Any would do.
2. Then you will need to modify the numbers (just numbers) in the setup section of the code below.
JavaScript:
<Custom Deselect Effect>
// SETUP START
// replace the following as necessary
var mainCharVarId = 1; // Control Variable ID that will hold the main character actor ID
var reviveOneId = 12; // Item ID of the Revive One item
var reviveAllId = 13; // Item ID of the Revive All item
// SETUP END
var mainCharActorId = $gameVariables.value(mainCharVarId);
if (mainCharActorId === 0) mainCharActorId = 1;
var members = $gameParty.members();
var hasReviveAll = $gameParty.hasItem($dataItems[reviveAllId]);
var hasReviveOne = $gameParty.hasItem($dataItems[reviveOneId]);
var heal;
if (hasReviveAll || hasReviveOne) {
var isAnyAlive = members.some(function(actor) {return actor.hp > 0 && !actor.isDead();});
if (!isAnyAlive) {
if (hasReviveOne) {
$gameParty.loseItem($dataItems[reviveOneId], 1);
var mainChar = $gameActors.actor(mainCharActorId);
heal = mainChar.mhp;
mainChar.startAnimation(49);
mainChar.gainHp(heal);
mainChar.startDamagePopup();
mainChar.clearResult();
} else if (hasReviveAll) {
$gameParty.loseItem($dataItems[reviveAllId], 1);
members.forEach(function (member) {
heal = member.mhp;
member.startAnimation(49);
member.gainHp(heal);
member.startDamagePopup();
member.clearResult();
});
}
}
}
</Custom Deselect Effect>
Brilliant. Thank you very much for all your help! It is greatly appreciated! Everything worked the way it was supposed to.
Glad to help! 😂 I still think you may have issues later on as we've seen earlier thanks to my boo boos. 😢
But if you're satisfied with the results you can report your first post and tell a moderator to close this thread. You can always reopen this thread later on if you so desire.
Good night!
Original thread: https://forums.rpgmakerweb.com/threads/revival-item.144454/