Activate when PM = 0 (in combat)

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,278
Reaction score
7,147
First Language
German
Primarily Uses
RMMV
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.
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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)
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,278
Reaction score
7,147
First Language
German
Primarily Uses
RMMV
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?
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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?
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
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. :kaoswt:

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. :kaophew:

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

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

[Edit: span, not scope. :kaoslp:]
[Edit2: the notetag has an error, see my follow-up post! :kaoback:]
 
Last edited:

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
Hope it works out! :kaojoy: Yanfly's plugins are usually relatively easy to use, but if you have problems then maybe someone else has some ideas~
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
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. :kaoslp:

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! :kaothx:

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. :kaoswt:)

I think that covers everything, sorry if it seems a bit clunky. :)
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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)
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
  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! :kaothx:

  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. :kaoblush:

  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... :kaoswt:
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
I use the new code for test and doesn't runs.

1590834571497.png

1590834713468.png
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
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. :p
 

Urosawa

Villager
Member
Joined
May 25, 2020
Messages
10
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,663
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
Yea, I probably should have emphasised that part more. :kaoslp:

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

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Imagine having a different opinion on the internet.
Crazy.
Here's the one that flee from no foe, the brave Sir Kiwival! Also protagonist of my current project.

This is the cover art of new game, "Primordial Essence".
I'm amazed at the performance increase I saw in just going through and rescoping the variables in other people's plugins that I'm using. You know what that means? :LZSexcite:
//Tosses more absurd stuff onto the game of "Jenga" that is his RM project.
:rheh:
Browsing through Steam's Curator Connect, it seems the vast majority of curators haven't curated in months. I'm guessing people finally got tired of reviewing games for free. Can't blame them.

Forum statistics

Threads
99,672
Messages
967,890
Members
131,351
Latest member
Makual
Top