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.
The official VisuStella notetag help thread
RPG Maker MZ Supportoh, I do want those but have no idea how to make them work, could you please step in?
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);
}
};
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.
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>
<JS Pre-Apply>
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>
@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).
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.
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.
@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?
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.
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? 🤣
I'll do in 4 hours or so, thanks!
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?
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>
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.
Original thread: https://forums.rpgmakerweb.com/threads/the-official-visustella-notetag-help-thread.125717/