The official VisuStella notetag help thread

● ARCHIVED · READ-ONLY
Started by Trihan 1458 posts Page 48 of 73 View original ↗
  1. Dark_Ansem said:
    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.
  2. Trihan said:
    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?
  3. 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);
        }
    };
  4. oh, I am using the whole visustella thing including their accuracy formula, so that would change?
  5. Dark_Ansem said:
    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.
  6. 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>
  7. @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).
  8. ATT_Turan said:
    @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.
  9. Dark_Ansem said:
    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?
  10. ATT_Turan said:
    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.
  11. @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.
  12. ATT_Turan said:
    @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?
  13. Dark_Ansem said:
    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;
  14. ATT_Turan said:
    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.
  15. Dark_Ansem said:
    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:
  16. ATT_Turan said:
    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!
  17. ATT_Turan said:
    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?
  18. Dark_Ansem said:
    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;
  19. ATT_Turan said:
    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>
  20. 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.