STARFALL

Core of the Stars
Veteran
Joined
Jul 6, 2020
Messages
199
Reaction score
52
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
220
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
199
Reaction score
52
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
708
Reaction score
378
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
199
Reaction score
52
First Language
spanish
Primarily Uses
RMMV
I managed to do something combining your advice, thanks
 

Latest Threads

Latest Posts

Latest Profile Posts

I've decided "Attack on Equestria" should be released first... hence this new ARG channel! https://www.youtube.com/channel/UClKiUI8xOVx9dsF4kRXUmxw
Check it out, and subscribe! The ARG will lead up to the video game. It's not a creepy game, but I just thought it should follow ARG standards.
For anyone interested in my project M - i finally made a gamethread about it :D

Yay. I turned 39 today. Another year older, another year closer to the grave.
I'm sure the latest post/thread in the sidebar used to have 5 posts. Was it always been like this?

Made it to the 10th video doing this! :kaocry:

renderTimingPixel.png

Forum statistics

Threads
110,407
Messages
1,053,065
Members
143,469
Latest member
ClementPanchout
Top