Cool. Will do. Take care. Have a great day.
Thank you very much for all your help as well. It is really appreciated. It's working now. Take care and have a great day.
Cool. Will do. Take care. Have a great day.
Thank you very much for all your help as well. It is really appreciated. It's working now. Take care and have a great day.
I don't understand the purpose of this. Where is the game variable supposed to be set, and if it's being set, why check for it to be 0, and set it to 1 whether or not that's the main actor being used? Just check which of the possible actors is actually in the party, no need for an external variable.
var mainCharVarId=$gameParty.members().includes($gameActors.actor(1)) ? 1 : 2;var mainChar=$gameParty.members().includes($gameActors.actor(1)) ? $gameActors.actor(1) : $gameActors.actor(2);You could save yourself several lines of code by just using the built-in member:
var members=$gameParty.aliveMembers();if (members.length)No biggie. 😅
Oh, I was rushing the code at that time. It's for the case the variable value has not been set. Force of habit. 👋 That line can be removed.
The OP did not mention if the presence of actor 1 in the party precludes the presence of actor 2 or if they can be in the party at the same time. The code previously provided will work in either case.
var mainCharVarId=$gameParty.members().includes($gameActors.actor(1)) ? 1 : 2;
Since the OP is not yet proficient with scripting I wanted the code to be as easy for him to modify as possible. I made the code so that he only needs to modify three figures in total in the the first three lines. Your code will force him to modify three figures within a single line alone.
var members=$gameParty.aliveMembers();
if (members.length)
if (members.length === 0)
$gameParty.aliveMembers().length === 0.He did previously in the thread, you're choosing one of the two protagonists 😉
So you're both right and wrong. You're correct that if we let all of the party be dead before the item goes off, it'll hit a game over. However, the code you provided does exactly the same thing. The
else if (hasReviveAll) triggers if no actors in the party were alive, so...we would already have hit the game over.That's...just wrong. In every C-adjacent language, 0 is considered to be false (or, in JavaScript, falsey). Saying
if (X>0) is exactly the same as saying if (X)I don't understand what you think the difference is. If any actor was brought to 0 HP by an effect, they would already have had the death state applied at the same time. Under what circumstances would they have the death state and not 0 HP? Or vice versa?
The OP did not mention anything of the sort when I asked him about the desired mechanics of his revival items so I based my coding decision on that. The code will work in either case. The code will also still work if he tags other actors as the main character. So you can't criticize my decision to code as I did since I based my coding decision on the information I had been given. And the code is flexible enough to accommodate different scenarios.
Actually, you're wrong. There's a difference.
Okay. You got me there.
I don't understand why you don't think there's a difference. Do you even test your codes before assuming what they actually do? Damage is applied BEFORE the deselect phase. The death state is applied AFTER the deselect phase. The hp is checked for the last actor who is about to die DURING the deselect phase when the death state hasn't yet been applied; this is the time when the revival state is triggered.
$gameParty.aliveMembers().length?Actually, my code had already achieved everything the OP wanted without using any Custom Confirm Effect notetags.
If the code is working for the OP and not for you then you have to start your own thread since as far as the OP is concerned his problem had already been solved. This is his thread, not yours.
$gameParty.aliveMembers().length works just as well as a conditional is because you haven't actually tested the code. I did. I tested the original conditional plus this suggested one you kept insisting. Mine works; yours doesn't.As far as the OP is concerned we had already solved this problem without doing any of the sort. There are many ways for this effect to be achieved. It doesn't have to be my way. You could have spent your time preparing your code for the OP's benefit. Instead you much preferred spending that time nitpicking every imaginable flaw you could find in the code made by someone who solved the OP's problem before you did (after spending the better part of the week working with the OP to little avail). To be clear, as of posting, you still haven't yet provided your own solution that actually works as the OP requests, merely insinuating that your solution is the only one that works.
You need to please calm down. You're being very defensive at this point. I did not criticize you, I offered ways to streamline what you had coded. He may not have stated it to you specifically, but it was said earlier in this thread. I didn't insult you for not reading the entire thread that carefully, but I did point out it was a fact.
Where do you see this? In Buffs & States, the deselect code is called by:
Yanfly.BSC.Game_Action_apply.call(this, target);
this.onDeselectStateEffects(target);
I've reopened the thread at OP's request.
<Custom Apply Effect>
// SETUP START
// replace the following as necessary
var reviveOneId = 12; // Item ID of the Revive One item
var reviveAllId = 13; // Item ID of the Revive All item
// SETUP END
if (target.isActor()) {
var hasReviveAll = $gameParty.hasItem($dataItems[reviveAllId]);
var hasReviveOne = $gameParty.hasItem($dataItems[reviveOneId]);
if ((hasReviveAll || hasReviveOne) && $gameParty.isAllDead()) {
var members = $gameParty.members();
var heal;
if (hasReviveOne) {
$gameParty.loseItem($dataItems[reviveOneId], 1);
var mainCharActorId = members.contains($gameActors.actor(1)) ? 1 : 2;
var mainChar = $gameActors.actor(mainCharActorId);
mainChar.startAnimation(49);
heal = mainChar.mhp;
mainChar.gainHp(heal);
mainChar.startDamagePopup();
} else if (hasReviveAll) {
$gameParty.loseItem($dataItems[reviveAllId], 1);
members.forEach(function (member) {
member.startAnimation(49);
heal = member.mhp;
member.gainHp(heal);
member.startDamagePopup();
});
}
}
}
</Custom Apply Effect>
Thank you for posting in the revival item thread. The post is very clear and easy to understand and is very much appreciated! You've been a tremendous help. I have been very fortunate to have the forum to turn to and to find people like you. Thank you. ^_^
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/revival-item.144454/