Activate when PM = 0 (in combat)

Sorry for my bad English.

I try to start an event in the middle of a fight (when the MPs reach 0) but I can't get it to work properly.

The resulting event works, but it does not activate correctly. I have problems with the "CONDITION" that activate it and the "LAPSO" (I don't know if I have translated them correctly).

1590757659663.png

I would like that at the exact moment that the character has PM = 0 (or PM <1) the planned event is activated, and not when starting a new turn (for example).

Again, sorry my english.

Thank you.
If you set no condition, then the troop event will never be executed. You have to set a condition for a trigger to work.
If what you want to check isn't available as a condition, then you have to run the troop event every turn and check your other conditions in conditional branches.


The span determines how often and when the condition is checked. "Battle" means once per battle, "Turn" means once per turn and "moment" means once per action/skill.

In your case I would probably set the condition to actor HP <= 100% and Moment, with one troop event for each actor in your party.
Thanks, but this dont help me.

Yeah, i can set the condition "actor HP <= 100%" and "Moment", but the battle even can't start. Probably something of the event i create genere this, but is in spanish. I'll try to translate.

1590759813910.png


Control Variable: "Variable" = PM of character
If "Variable" <1
Something happens (I put a message just for test)
then you need to start bughunting your game.

And if the battle doesn't even start, then the problem is not in this troop event - troop events can only be processed after the battle has started.

How did you start the battle? Is it an evented battle or a random troop? Is the actor (El) in the party when the battle is started?
Evented battle. And yes, El is in the party.
Well, the battle start, but no the turns. It stays like this forever.

1590761469486.png


If i use the span "Turn", the battle and the event works. When the MP (in this case, "Valor") reaches 0, the event start, but only if i start other turn.
And what I'm looking for is to activate it in the exact moment.

Any idea?
Actually, the span of a troop event only determines how often the event can run. All events have their conditions checked pretty much every frame of battle (unless it's busy doing something else, e.g. running another event). Battle span lets it run once per battle, Turn lets it run once per turn, and Moment is no restriction, i.e. it can run every frame and lock up the battle. 😅

Unless you're OK with checking once per turn (Turn span and Turn 1*X condition), I think you'll need a plugin for this. I think you could use Yanfly's Buffs & States Core plugin for this (there may be a simpler option):
With that, you can make a state and put this into that state's notebox:
Code:
<Custom Deselect Effect>
if (user.mp === 0) {
  $gameSwitches.setValue(1, true);
}
</Custom Deselect Effect>
This notetag should trigger its code just after the battler with the state (the "user") gets hit. The code says "if the battler with this state has zero MP right now, turn on switch 1". You could then set up a troop event with Condition: Switch 1 is on and a suitable span. Then just be sure to turn off switch 1 at the end of that troop event, so the event only runs once. 😮‍💨

Then add the state to your actor(s) and I think it should work! 😤

Oh, and you can use a different switch if you like, of course; I just used switch 1 as an example. 🙏

[Edit: span, not scope. 😴]
[Edit2: the notetag has an error, see my follow-up post! 👋]
I will download the plugin, although I don't know if I will know how to configure what I want to do well.

Tomorrow I can tell you if I have made it work or not.
Hope it works out! 😂 Yanfly's plugins are usually relatively easy to use, but if you have problems then maybe someone else has some ideas~
Well, I have already tried the plugin and I have not managed to make it work.

As you suggested, I used the code that you showed me and it turned out like this:

1590827675084.png

Unfortunately the event never starts. I have tried setting the event in the same combat and even with "Common events" (I think it translates like this), but nothing ever happens.

What could I have done wrong?
Oh, user is a variable defined by the plugin, you don't have to replace it. Or...well, actually I found out it should be target instead, because when this notetag triggers, the one with the state is the target of the action. 😴

Long story short, copy this for your state's notetag, no edits:
Code:
<Custom Deselect Effect>
if (target.mp === 0) {
  $gameSwitches.setValue(53, true);
}
</Custom Deselect Effect>
Then make sure the state is added to the character. It should then run the code every time someone with this state is the target of an action. I tested it this time, it works for me! 🙏

I just realised that if you have negative MRG (MP regeneration) then that could make MP = 0 at the end of the turn. If you want to catch this, you could have a second notetag on that state (again, no edits needed):
Code:
<Custom Turn End Effect>
if (user.mp === 0) {
  $gameSwitches.setValue(53, true);
}
</Custom Turn End Effect>
I.e. do exactly the same check at the end of every turn as well. (It really is user for this notetag, I've tested to make sure. 😅)

I think that covers everything, sorry if it seems a bit clunky. 🙂
Still nothing. I have copied and pasted the code, but still nothing.

I'm going to try to show everything I have to see if I do something that prevents it from working.

PLUGIN:
1590832324783.png

NOTETAG:
1590832166802.png

"VALOR" is switch 53
1590832241638.png

(I put a message just for test and never shows)
  1. Did you save your project after adding the plugin?
    Plugin Manager changes aren't applied unless you save your project. It's a common mistake! 🙏

  2. Did you remember to add the state to the appropriate actor(s)?
    If they don't have the state, none of the state's properties (e.g. its notetag) apply to them. 😊

  3. Do you have any other plugins active?
    If so, try turning them off (select all, right-click > turn off), save the project, and test. If that "fixes" it, the problem might be a plugin conflict (possibly due to bad load order). In this case, a screenshot of your Plugin Manager, showing the list of all your plugins, might be helpful. 🙂
You could test if the notetag is running at all by replacing your notetag with this:
Code:
<Custom Deselect Effect>
alert('Test! Target ' + target.name() + ' was deselected.');
</Custom Deselect Effect>
This will show a very obvious popup message if/when the notetag's code runs. As mentioned, the Deselect notetag should run whenever a battler with the state is the target of an action, e.g. when they get attacked. If no message displays, double-check the list above.

Otherwise I'm not sure what else to suggest... 😅
I use the new code for test and doesn't runs.

1590834571497.png


1590834713468.png
Oh, I see! The notetag should be in the notebox of a State ("Estado"?), not the notebox of an Actor. You're on the wrong tab in the database. 😛
1590853472193.png


Ok so I... wel... I'll start form 0. I'll make sure I do all u said before and i'll info with the update.

[Edit]
The event works!! I did't know that i must create a new State (a invisible one) to make it works. Now, when 1 of the character have 0 Valor (0 MP) fall in TERROR, just when i wanted.

Thanks for all your help and patient!!!

1590854456327.png
Yea, I probably should have emphasised that part more. 😴

Good you've got it working now, though! Happy RPG Making~ 😂

Original thread: https://forums.rpgmakerweb.com/threads/activate-when-pm-0-in-combat.122193/