STARFALL

Core of the Stars
Veteran
Joined
Jul 6, 2020
Messages
190
Reaction score
46
First Language
spanish
Primarily Uses
RMMV
I am looking for how to know when a state is added to a player, basically I want to make a state that detects when the states of the same category were to be added to the same user. I use the majority of yep plugins.
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
297
Reaction score
217
First Language
English
Primarily Uses
RMMZ
The default function to check for a state on a battler is:

Game_BattlerBase.prototype.isStateAffected = function(stateId)

You can use that to check for a state on any battler, such as:

target.isStateAffected(x) $gameActors.actor(1).isStateAffected(x)

I'm not sure what you mean by "category." Is that a parameter added by a plugin you're using? Or just a mechanic you have in mind?

If it's the former, checking the state's category would depend on how the plugin handles that.

If it's the latter and you wanted to just handle it manually, you could add a notetag to your state like so:

<Category:Debuff>

And then check the if the battler both has the state and if it's a specific category:

var state = x; if (target.isStateAffected(x) && $dataStates[x].meta.Category === 'Debuff') { console.log('Do something.'); }

In terms of doing all of this stuff at the moment that a state is added to a battler versus at any arbitrary time, there's a function for that too.

Game_Battler.prototype.addState = function(stateId) { if (this.isStateAddable(stateId)) { if (!this.isStateAffected(stateId)) { this.addNewState(stateId); this.refresh(); } this.resetStateCounts(stateId); this._result.pushAddedState(stateId); } };

Which you can alias. Here's a quick example:

_Game_Battler_addState = Game_Battler.prototype.addState; Game_Battler.prototype.addState = function(stateId) { _Game_Battler_addState.call(this, stateId); console.log('Do something.'); }

I do know that the YEP plugins will allow you to perform some of these checks via notetags, so you may want to reference that if you would prefer to do it that way.

Not sure if that answers your question, but maybe it'll get you started.
 

STARFALL

Core of the Stars
Veteran
Joined
Jul 6, 2020
Messages
190
Reaction score
46
First Language
spanish
Primarily Uses
RMMV
that was absolutely wonderful and useful, you have opened a world of possibilities for me.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
670
Reaction score
353
First Language
English
Primarily Uses
RMMV
Just a couple of other things, in case they're helpful. Since you have the Yanfly plugins, you can give a state a <Custom Apply Effect> per the Buffs and State core, to give it code that will execute when it's applied to a battler.

That plugin also has a "counter" function, so if you're looking for some kind of stacking effect (you were non-specific as to what exactly you want to do), you can use that to track and manipulate how many times someone has received a given state.
 

STARFALL

Core of the Stars
Veteran
Joined
Jul 6, 2020
Messages
190
Reaction score
46
First Language
spanish
Primarily Uses
RMMV
I managed to do something combining your advice, thanks
 

Latest Threads

Latest Posts

Latest Profile Posts

Doing RPG Maker News for 10th April, 2021. :LZScheeze: (Improving on the thumbnails, by using assets from the day's news.)
Just discovering the forum.
Since Final Fantasy VII has been trending today, decided to make a series of my favorite bars in the OG game! Check it out:

At 2021, we are now farther from the 1980's than they were from the 1950's. Consider that the next time you long for a 1980's song, when you thought your grandpa's taste for 1950's music was "outdated".
no, not my duct tape, anything but my duct tape!

Forum statistics

Threads
110,293
Messages
1,052,037
Members
143,323
Latest member
earthium
Top