The official VisuStella notetag help thread

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,526
Reaction score
7,033
First Language
English
Primarily Uses
RMMZ
ah I see, thanks. So, I should just ignore the engine options to inflict the state.

JavaScript:
<JS Pre-Apply>
  if (Math.random() < 0.85 * target.stateRate(99)) { // 0.85 is the basic infliction rate, 99 is the state ID
    let turns = Math.randomInt(10) + 3; // Generates a random integer between 3 and 12
    target.addState(99, turns);
  }
</JS Pre-Apply>
That would work. The default engine also factors in attack state rate of the user and luck effect, but if you don't want those that should be sufficient.
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
That would work. The default engine also factors in attack state rate of the user and luck effect, but if you don't want those that should be sufficient.
oh, I do want those but have no idea how to make them work, could you please step in?
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,526
Reaction score
7,033
First Language
English
Primarily Uses
RMMZ
This is how the default engine does it:

JavaScript:
Game_Action.prototype.itemEffectAddAttackState = function(target, effect) {
    for (const stateId of this.subject().attackStates()) {
        let chance = effect.value1;
        chance *= target.stateRate(stateId);
        chance *= this.subject().attackStatesRate(stateId);
        chance *= this.lukEffectRate(target);
        if (Math.random() < chance) {
            target.addState(stateId);
            this.makeSuccess(target);
        }
    }
};
Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
    let chance = effect.value1;
    if (!this.isCertainHit()) {
        chance *= target.stateRate(effect.dataId);
        chance *= this.lukEffectRate(target);
    }
    if (Math.random() < chance) {
        target.addState(effect.dataId);
        this.makeSuccess(target);
    }
};
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
oh, I am using the whole visustella thing including their accuracy formula, so that would change?
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,526
Reaction score
7,033
First Language
English
Primarily Uses
RMMZ
oh, I am using the whole visustella thing including their accuracy formula, so that would change?
You should still be able to call the rate functions.
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
so, shamelessly taking after several cues from your Tips thread... I came up with these two

<JS Pre-Apply>
if (Math.random() < item.successRate * 0.01 * target.stateRate(99)) { // item.successRate is the skill's success? rate
let turns = Math.randomInt(10) + 3;
target.addState(99, turns);
}
</JS Pre-Apply>

Goddamit success refers to the skill success not the state infliction success.

<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(99)) {
let turns = Math.randomInt(10) + 3;
target.addState(99, turns);
}
</JS Pre-Apply>

EDIT: this is the best I can think of, but I wonder if the immunity check is redundant

<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(99) && !target.isStateResist(99)) {
let turns = Math.randomInt(10) + 3;
target.addState(99, turns);
}
</JS Pre-Apply>
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
@Dark_Ansem Did you make your own version of addState() for this? Or is that a modified one provided by one of the VisuStella plugins?

In the default code, addState() can't take a second argument for the number of turns. That's determined by what you type in the state's entry in the database. You'd have to apply the state then modify its turns afterward (although I don't see why you'd need to, just put 3 and 12 in the database).
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
@Dark_Ansem Did you make your own version of addState() for this? Or is that a modified one provided by one of the VisuStella plugins?

In the default code, addState() can't take a second argument for the number of turns. That's determined by what you type in the state's entry in the database. You'd have to apply the state then modify its turns afterward (although I don't see why you'd need to, just put 3 and 12 in the database).
I think it is altered in some way by VS because some of their plugins allow this sort of functioning (like the cool down one), but I could always be wrong, so if you could show me how to apply the state then modify turn afterward it would be much appreciated.

The reason for the custom duration being that normally the stun state is supposed to expire after 1 turn, but this enemy ability is more powerful.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
if (state.id === 99) { // this is where the STUN ID is supposed to go, yes?
I don't see the point of this. You're typing this notetag into state 99, so why check whether it's state 99?
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
I don't see the point of this. You're typing this notetag into state 99, so why check whether it's state 99?
See, I'm wrong again, I clearly need lunch, I got carried away and it needs to go in the skill.

<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(99) && !target.isStateResist(99)) {
let turns = Math.randomInt(10) + 3;
target.addState(99);
target.setStateTurns(99, turns);
}
</JS Pre-Apply>

As I said, I'd appreciate if you provided your solution.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
@Dark_Ansem That looks fine to me. You don't need to bother checking for the state resist, that's already done below - addState() won't work on a target with resist.
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
@Dark_Ansem That looks fine to me. You don't need to bother checking for the state resist, that's already done below - addState() won't work on a target with resist.
That's great, thanks. Skill only inflicts the state, doesn't do any damage, which is why picking notetag is a bit tricky.

So this is how it's supposed to work?
<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(99)) {
let turns = Math.randomInt(10) + 3;
target.addState(99);
target.setStateTurns(99, turns);
}
</JS Pre-Apply>

just to be sure, is setStateTurns a MZ function?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
just to be sure, is setStateTurns a MZ function?
No, it's a Yanfly Buffs & States function.

For stuff like that, you can just search the contents of your files. Depending on what operating system you're running, most Windows you can just go to the js folder and type setstateturns into the search bar and it will search the contents of the js files for it.

In Windows 11, many have had a hard time getting that functionality to work, so I have a program called DocFetcher that does the search. I didn't know the answer off the top of my head, either.

You'd just do target._stateTurns[99]=turns;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
No, it's a Yanfly Buffs & States function.

For stuff like that, you can just search the contents of your files. Depending on what operating system you're running, most Windows you can just go to the js folder and type setstateturns into the search bar and it will search the contents of the js files for it.

In Windows 11, many have had a hard time getting that functionality to work, so I have a program called DocFetcher that does the search. I didn't know the answer off the top of my head, either.

You'd just do target._stateTurns[99]=turns;
But it should still work within the VS framework, as I think I saw it in the tips and tricks thread.

Thanks for the doctfetcher suggestion. I'm still on 10, wondering if it is worth to upgrade to 11 at all.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
But it should still work within the VS framework, as I think I saw it in the tips and tricks thread.
I can't speak to that, can only answer whether it's an MZ function. It costs you only a few seconds to test it, if your game crashes with an error, it's not in VisuStella, right? :guffaw:
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
I can't speak to that, can only answer whether it's an MZ function. It costs you only a few seconds to test it, if your game crashes with an error, it's not in VisuStella, right? :guffaw:
I'll do in 4 hours or so, thanks!
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
I can't speak to that, can only answer whether it's an MZ function. It costs you only a few seconds to test it, if your game crashes with an error, it's not in VisuStella, right? :guffaw:
All right, so, this works, except that if I use the skill twice in a row, instead of following VS Skills and State Core plugin settings reapply rules (add) it simply applies a new duration overwriting the existing one. I am assuming that is to be expected but I was wondering if it could be fixed.

JavaScript:
<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(13)) {
let turns = Math.randomInt(10) + 3;
target.addState(13);
target.setStateTurns(13, turns);
}
</JS Pre-Apply>

I was thinking of using <Reapply Rules: Add> but it only works for states. Is there a quick n dirty command to tell the notetag to obey plugin parameter settings?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,000
Reaction score
8,882
First Language
English
Primarily Uses
RMMV
I am assuming that is to be expected but I was wondering if it could be fixed.
Use an if statement to see if the target already has the state before you apply it? If yes, add their existing turns to what you're setting.
Code:
let turns = Math.randomInt(10) + 3 + target.isStateAffected(13) ? target._stateTurns[13] : 0;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
592
Reaction score
144
First Language
English
Primarily Uses
RMMZ
Use an if statement to see if the target already has the state before you apply it? If yes, add their existing turns to what you're setting.
Code:
let turns = Math.randomInt(10) + 3 + target.isStateAffected(13) ? target._stateTurns[13] : 0;
I actually thought about this one


JavaScript:
<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(13)) {
  let turns = Math.randomInt(10) + 3;
  if (target.isStateAffected(13)) {
    let currentTurns = target.stateTurns(13);
    target.setStateTurns(13, currentTurns + turns);
  } else {
    target.addState(13);
    target.setStateTurns(13, turns);
  }
}
</JS Pre-Apply>

Which works, but the minimalist in me wanted a solution which could handle different rule sets. Then again, it's not like the players can change them mid-game... and of course your single-line fix is much better so thanks!

EDIT: It is indeed very fun to keep the enemy stunlocked with this

JavaScript:
<JS Pre-Apply>
if (Math.random() < 0.85 * target.stateRate(13)) {
  let turns = Math.randomInt(10) + 3 + (target.isStateAffected(13) ? target.stateTurns(13) : 0);
  target.addState(13);
  target.setStateTurns(13, turns);
}
</JS Pre-Apply>
 
Last edited:

weaselout1

Warper
Member
Joined
Jun 15, 2014
Messages
2
Reaction score
0
First Language
English
Primarily Uses
How do you reference self switches in the show/hide choices notetags for Message Core? I tried <Hide Switch: A> but it didn't work.
 

Latest Threads

Latest Posts

Latest Profile Posts

Well, if anyone has a funny, simple, easy RM game they want me to playtest/review, I would love it.
Someone close to me straight up told me they didn't think my relationship with my girlfriend would last. No lead up, very bluntly. Like it's obvious or something. Trying not to let it get to my head, but it's hard.
The distraction would be a life saver.
QuestMZPlugin.png

My first foray into a plugin that I plan to release. Working on something for those who want to set up a Dragon Quest style battle HUD with minimal fuss. Includes the ability to round the battleback corners to fit your windowskin and, of course, front-view animations.

QuestMZPLugin_CustomWindow.png
Do you ever wonder where the heck everyone is going at 9:00 at night? Like... guys, go home! Get some sleep! Me? Oh, I'm out to get pizza 'cause I decided supper time was 9:30 tonight.
Updated my map with new terrain, improved the water and added some fishes, also added a beautiful rainbow!

Forum statistics

Threads
134,754
Messages
1,250,332
Members
177,515
Latest member
CJMZ
Top