Stunning A Target Based On Last Enemy Countered

For an enemy boss, the idea is that the boss has a counter that stuns the character who hit them infinitely. However, if another character were to hit the boss, the boss would remove the stun from the previous character (or all characters with that unique stun), and apply the infinite stun to the new character.

For context, the stun will kill the character affected after it decays (So infinite in the sense it will last until they die). And decay in the terms (Let expire, not removed)

I probably have implemented and used plugins wrong, and I have not gotten much of it to work. Below is my current progress and the work I have done so far. After, is the results of my work.

1700542799495.png

(The attempted adding of stun (Victim is the name of the stun) and removal of other "Victim" stuns.)

1700542928896.png

(The attempt at making the infinite stun)
The custom leave effect for the kill after decay is: (taken from a Doom state created by Yanfly)

<Custom Leave Effect>

// Get the death state for the user.

var deathState = user.deathStateId();

// Check if the user is not immune to death nor resistant to it.

if (user.stateRate(deathState) > 0.01 && !user.isStateResist(deathState)) {

// Play animation on the user.

user.startAnimation(65);

// Set the user's HP to 0.

user.setHp(0);

// Check if the user is dead.

if (user.isDead()) {

// Make the user collapse.

user.performCollapse();

}

}

</Custom Leave Effect>

1700543087854.png

The boss is supposed to be able to counter infinitely and with a guaranteed chance given the high values. Its default counter is the removal and addition of the stun (Stare)

In conclusion, what I am struggling with is that the removal of the stuns is non-existent, and the character does not die when the stun expires. What works is that it will counter with the stun. What ends up happening is that everyone is getting stunned for 1 turn if they attack, and no one dies to decay.

Will try to provide additional screenshots and info if needed!
As a tip, you should put code in the CODE tag (the </> on the edit bar). That will preserve indentation and make brackets display correctly.

the removal of the stuns is non-existent
Your syntax is incorrect. "battler" doesn't mean anything, it just signifies that the function can be called on "a battler" - e.g. an enemy or actor.

I'm also not certain why you're using a state category for this when you say it's a unique state. Just use its ID.

If you want to remove the state from the entire party, you'd do:
Code:
$gameParty.aliveMembers().forEach(actor => actor.removeState(ID));
No leading zeros on the ID.

Code:
<Custom Leave Effect>
// Get the death state for the user.
var deathState = user.deathStateId();
There's no real reason to go through declaring a variable and calling this function and stuff...unless you've done some significant, extensive re-coding of MV's engine, the death state is 1 for all battlers.

Aside from that, this looks like it should work. If you're saying the state decays and nothing happens to the actor's HP (and they're not Immortal or something), then you should do some plugin troubleshooting.

Primarily, double check the order of your plugins on the Yanfly Engine Plugins Web site to make sure they're in that exact order in your plugin manager.
As a tip, you should put code in the CODE tag (the </> on the edit bar). That will preserve indentation and make brackets display correctly.


Your syntax is incorrect. "battler" doesn't mean anything, it just signifies that the function can be called on "a battler" - e.g. an enemy or actor.

I'm also not certain why you're using a state category for this when you say it's a unique state. Just use its ID.

If you want to remove the state from the entire party, you'd do:
Code:
$gameParty.aliveMembers().forEach(actor => actor.removeState(ID));
No leading zeros on the ID.


There's no real reason to go through declaring a variable and calling this function and stuff...unless you've done some significant, extensive re-coding of MV's engine, the death state is 1 for all battlers.

Aside from that, this looks like it should work. If you're saying the state decays and nothing happens to the actor's HP (and they're not Immortal or something), then you should do some plugin troubleshooting.

Primarily, double check the order of your plugins on the Yanfly Engine Plugins Web site to make sure they're in that exact order in your plugin manager.
Thanks for the help! Your code managed to get the removal working! I checked the plugins and plugin order, and everything seems fine, yet the decay part of the state still isn't working. I'll try to mess with the code a bit and see if it works. If it does, then I will let you know.
yet the decay part of the state still isn't working. I'll try to mess with the code a bit and see if it works. If it does, then I will let you know.
Have you changed anything ever since you updated it to what you have above? it didnt look wrong, but I copied it anyways and tried it exactly as you wrote it. it did what it was supposed to.
maybe try using user.die() or user.addState(1) instead of setting their hp to 0?
@Robro33 That's why I was asking about plugin troubleshooting, to see if there could be a problem that was preventing the notetag from running at all.
@Robro33 That's why I was asking about plugin troubleshooting, to see if there could be a problem that was preventing the notetag from running at all.
I tried looking through more examples on how to implement the "Doom" part of the stun as well as trying to find any order for plugins. I used this


as the basis of the ability but from what I see it just mentions required plugins and nothing about order.

Below is my list of plugins, it is quite the mess so conflicting plugins might be the root of the problem
1700631226264.png

1700631242261.png

maybe you guys might have a better eye for this?
It was recommended before and you said you checked your plugin order, but I can see right off the bat your Yanfly plugins are not in the order they're listed on the Yanfly Engine Plugins Web page.
It was recommended before and you said you checked your plugin order, but I can see right off the bat your Yanfly plugins are not in the order they're listed on the Yanfly Engine Plugins Web page.
Pardon my ignorance; I thought it was there was just a specific order between the plugins involved. However, after I fixed it, it still would not work. After messing with the state for a while, I think I know the problem. The doom effect works after I removed the stun. In the above "victim" state, I made a restriction that they "cannot move" (a stun). However, just removing that part makes the doom effect work. Is there another way to implement the stun, because it seems a character that "cannot move" can not be affected by doom?
You seem kind of overly fixated on the whole "doom" thing - code inside the Custom Leave Effect runs or it doesn't.

But if it's not running when the state has the Cannot Move restriction, then that would be a bug.

Are you using the default battle system or a plugin?
You seem kind of overly fixated on the whole "doom" thing - code inside the Custom Leave Effect runs or it doesn't.

But if it's not running when the state has the Cannot Move restriction, then that would be a bug.

Are you using the default battle system or a plugin?
Sorry about the wait have been a little busy; I am using the YEP charge battle system.
If you read through the instructions/introduction to that plugin, it's discontinued and not all plugin features fully support it.

That's one of a few battle systems that do away with the concept of turns entirely for a time-based system. So other plugins that rely on turns and sometimes even actions don't work properly with it. There are numerous threads from people trying to figure their way through Cannot Move working with that system.
If you read through the instructions/introduction to that plugin, it's discontinued and not all plugin features fully support it.

That's one of a few battle systems that do away with the concept of turns entirely for a time-based system. So other plugins that rely on turns and sometimes even actions don't work properly with it. There are numerous threads from people trying to figure their way through Cannot Move working with that system.
I see; thanks for the help! I'll look for some workarounds or other options! If I do ever find a solution I'll post it here.

Original thread: https://forums.rpgmakerweb.com/threads/stunning-a-target-based-on-last-enemy-countered.163124/