STARFALL

Core of the Stars
Veteran
Joined
Jul 6, 2020
Messages
195
Reaction score
49
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
298
Reaction score
219
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
195
Reaction score
49
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
677
Reaction score
357
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
195
Reaction score
49
First Language
spanish
Primarily Uses
RMMV
I managed to do something combining your advice, thanks
 

Latest Threads

Latest Posts

Latest Profile Posts

Squashing some bugs before releasing plugin :LZScool:The testing phase is taking more time than what I expected...
On cloud 9. My latest game got a 4/5 review today :)

Forum statistics

Threads
110,322
Messages
1,052,328
Members
143,359
Latest member
bananas
Top