(made a few minor edits to try to be more clear)
Plugins that I'm using relevant to what I'm trying to code:
Yanfly's battle core
Auto passive states:
Buffs and states core
Common troop events
Hime's end phase triggers (though it doesn't seem to work or maybe it has to do with the code I put in).
Okay, so I had a bug once upon a time. Most of the people here helped me get it working, then I discovered there was stuff missed the first time around and here we are. So I'm going to try explaining again and stating where I think the issue is.
So my game is based around character moods. I'm trying to implement a mechanic where if one character dies in battle, the variable for the other 2 characters' "sadness" moods increase, and then a common troop event plays where the character reacts to it.This is the code I have currently. I have an idea on where the problem is coming from I think, but I'm not sure what I need to change to fix it. I've bolded the areas I think are possibly suspect, and I'll give an outline on what I'm trying to make the code do, lol. Each of the three main characters has a similar hidden passive state with slightly different variables.
<Custom Battle Effect>
if (user.isDead() {
user.sadHit = true;
}
else {
user.sadHit = false;
}
//this is setting the flag so that if the user of the state is already
dead, it doesn't automatically trigger it.//
</Custom Battle Effect>
<Custom Respond Effect>
//If target is dead (from enemy attack), and target doesn't have sadHit, and target is actor 1//
if (target.isDead() && !target.sadHit && target.actorId()==1)
{
// turn on sadHit, variables 77 and 83 are sadness variables for actors 2 and 3. Switch 101 turns on the common troop event where the characters cry out at the loss of their companion.//
target.sadHit = true;
$gameVariables.setValue(77,
$gameVariables.value(77) + 20);
$gameVariables.setValue(83,
$gameVariables.value(83) + 20);
$gameSwitches.setValue(101, true);
}
else if (!user.isDead() && target.sadHit)
{
target.sadHit = false;
$gameSwitches.setValue(101, false);
}
</Custom Respond Effect>
<Custom Regenerate Effect>
if (user.isDead() && !user.sadHit && target.actorId()==1)
{
user.sadHit = true;
$gameVariables.setValue(77,
$gameVariables.value(77) + 20);
$gameVariables.setValue(83,
$gameVariables.value(83) + 20);
$gameSwitches.setValue(101, true);
}
else if (!user.isDead() || user.sadHit)
{
user.sadHit = false;
$gameSwitches.setValue(101, false);
}
</Custom Regenerate Effect>
So what I want the code to do is each time a character is killed in battle, the other two characters get the sadness variable to go up, then it plays the common troop event where they're all "NO WHYYYY" or what have you.
The respond effect portion is working great as far as I can tell. They die, they get sad, event triggers, all good.
The Regenerate effect is there to make sure it covers for things like, if a character dies from poison, or a character sacrifices themself, or dies from a global attack since it's not targeted etc.
But the bug(s) are, 1) If a character dies before that regenerate effect is triggered and the character is still dead the next battle, it will trigger next regen round on the battle after the current. In fact, as long as the character stays dead, it triggers once every battle afterwards. Bringing the character to life does prevent the regen from triggering, but otherwise the characters are mourning their dead cohort once every battle. I tried to set the sadHit object at the beginning of the battle to prevent this, but the Regenerate effect kicks in no matter what.
2) If the last enemy in a troop is killed at the same time a character dies, the battle ends before the mouring can trigger. This isn't that big of deal, except it leads to more instances of bug 1. I tried fixing this with a Hime plugin (end phase triggers I think) but I didn't see any change.
As a note, bug 1 only happens if the character is dead when the regen trigger hits. If you have a character die from a self destruct ability, then heal them, then start a new battle, it doesn't trigger. So hope that helps. Let me know what I'm missing.
To summarize the challenge is getting the death reaction to trigger each time a character is killed in battle but not to trigger if they're already dead. Ideally I want it to also work where if a character is killed, revived and killed again, the animation variable and troop event triggers each time.
Plugins that I'm using relevant to what I'm trying to code:
Yanfly's battle core
Auto passive states:
Buffs and states core
Common troop events
Hime's end phase triggers (though it doesn't seem to work or maybe it has to do with the code I put in).
Okay, so I had a bug once upon a time. Most of the people here helped me get it working, then I discovered there was stuff missed the first time around and here we are. So I'm going to try explaining again and stating where I think the issue is.
So my game is based around character moods. I'm trying to implement a mechanic where if one character dies in battle, the variable for the other 2 characters' "sadness" moods increase, and then a common troop event plays where the character reacts to it.This is the code I have currently. I have an idea on where the problem is coming from I think, but I'm not sure what I need to change to fix it. I've bolded the areas I think are possibly suspect, and I'll give an outline on what I'm trying to make the code do, lol. Each of the three main characters has a similar hidden passive state with slightly different variables.
<Custom Battle Effect>
if (user.isDead() {
user.sadHit = true;
}
else {
user.sadHit = false;
}
//this is setting the flag so that if the user of the state is already
dead, it doesn't automatically trigger it.//
</Custom Battle Effect>
<Custom Respond Effect>
//If target is dead (from enemy attack), and target doesn't have sadHit, and target is actor 1//
if (target.isDead() && !target.sadHit && target.actorId()==1)
{
// turn on sadHit, variables 77 and 83 are sadness variables for actors 2 and 3. Switch 101 turns on the common troop event where the characters cry out at the loss of their companion.//
target.sadHit = true;
$gameVariables.setValue(77,
$gameVariables.value(77) + 20);
$gameVariables.setValue(83,
$gameVariables.value(83) + 20);
$gameSwitches.setValue(101, true);
}
else if (!user.isDead() && target.sadHit)
{
target.sadHit = false;
$gameSwitches.setValue(101, false);
}
</Custom Respond Effect>
<Custom Regenerate Effect>
if (user.isDead() && !user.sadHit && target.actorId()==1)
{
user.sadHit = true;
$gameVariables.setValue(77,
$gameVariables.value(77) + 20);
$gameVariables.setValue(83,
$gameVariables.value(83) + 20);
$gameSwitches.setValue(101, true);
}
else if (!user.isDead() || user.sadHit)
{
user.sadHit = false;
$gameSwitches.setValue(101, false);
}
</Custom Regenerate Effect>
So what I want the code to do is each time a character is killed in battle, the other two characters get the sadness variable to go up, then it plays the common troop event where they're all "NO WHYYYY" or what have you.
The respond effect portion is working great as far as I can tell. They die, they get sad, event triggers, all good.
The Regenerate effect is there to make sure it covers for things like, if a character dies from poison, or a character sacrifices themself, or dies from a global attack since it's not targeted etc.
But the bug(s) are, 1) If a character dies before that regenerate effect is triggered and the character is still dead the next battle, it will trigger next regen round on the battle after the current. In fact, as long as the character stays dead, it triggers once every battle afterwards. Bringing the character to life does prevent the regen from triggering, but otherwise the characters are mourning their dead cohort once every battle. I tried to set the sadHit object at the beginning of the battle to prevent this, but the Regenerate effect kicks in no matter what.
2) If the last enemy in a troop is killed at the same time a character dies, the battle ends before the mouring can trigger. This isn't that big of deal, except it leads to more instances of bug 1. I tried fixing this with a Hime plugin (end phase triggers I think) but I didn't see any change.
As a note, bug 1 only happens if the character is dead when the regen trigger hits. If you have a character die from a self destruct ability, then heal them, then start a new battle, it doesn't trigger. So hope that helps. Let me know what I'm missing.
To summarize the challenge is getting the death reaction to trigger each time a character is killed in battle but not to trigger if they're already dead. Ideally I want it to also work where if a character is killed, revived and killed again, the animation variable and troop event triggers each time.