The official VisuStella notetag help thread

● ARCHIVED · READ-ONLY
Started by Trihan 1458 posts Page 53 of 73 View original ↗
  1. Kes said:
    I have an accessory which adds to the ordinary attack a chance to inflict state 65. It looks like this:
    Code:
    <JS Post-Damage as User>
    if (!target.isDead() && Math.random()<.4)
        target.addState(65);
    </JS Post-Damage as User>
    It works fine and does what I want.

    However, I have discovered that it does more than I want.
    At the moment it is equipped to Actor 4, but it could be anyone. Actor 4 has a self-heal skill. Its setup is bog standard, but I include it here in case it's needed.
    View attachment 289215

    I have just noticed that using this skill she can inflict herself with state 65. I don't understand how something that is designated to add a state via Attack can do it with a heal skill, but if that's the way things work, I need to amend the notetag so as to exclude the user as target.

    Can anyone help me out?
    Thank you.
    I'm not at home currently but when I get back I'll have a look at this if you haven't had an answer yet. I need to go through the thread at some point and find any unanswered questions, too.
  2. Kes said:
    !target.isDead()
    I'm not sure this is actually needed as target.isDead seems to only be correctly calculated much later than post-damage
  3. Kes said:
    I have an accessory which adds to the ordinary attack a chance to inflict state 65. It looks like this:
    Code:
    <JS Post-Damage as User>
    if (!target.isDead() && Math.random()<.4)
        target.addState(65);
    </JS Post-Damage as User>
    It works fine and does what I want.

    However, I have discovered that it does more than I want.
    At the moment it is equipped to Actor 4, but it could be anyone. Actor 4 has a self-heal skill. Its setup is bog standard, but I include it here in case it's needed.
    View attachment 289215

    I have just noticed that using this skill she can inflict herself with state 65. I don't understand how something that is designated to add a state via Attack can do it with a heal skill, but if that's the way things work, I need to amend the notetag so as to exclude the user as target.

    Can anyone help me out?
    Thank you.

    Hmmm, it says that notetag just runs code after the executedamage function. So doesn't it add that to all your stuff? The way I understand it is that it uses that function for gaining hp too, it just changes the sign of the value depending what the damage type is (disclaimer: I might be wrong LOL).

    If you want it only to work with normal attack, I think it's:
    this.item().id === 1
    If you want it to work with hp damage causing skills, I think it's:
    this.item().damage.type === 1
  4. Dark_Ansem said:
    I'm not sure this is actually needed as target.isDead seems to only be correctly calculated much later than post-damage
    I don't understand your point.
    The code - which is
    Code:
    !target.isDead
    and not
    Code:
    target.isDead
    is making sure that the target is alive before determining if the random roll is going to inflict the state. There is no other time for that to happen, as far as I am aware.

    @rpgLord69 The honest answer to your question is: I don't know. The intention for this item is that the chance to inflict state 65 was only applied to the straightforward attack skill. This is the first time that the state has turned up with another skill.
  5. Kes said:
    The code...is making sure that the target is alive before determining if the random roll is going to inflict the state. There is no other time for that to happen, as far as I am aware.
    That's not correct. The isDead() method checks for the target to be affected with the death state.

    That doesn't happen until the entire skill has finished resolving and the target battler is refreshed - this will never return true unless you manually applied state 1 someplace else.

    If you look at Yanfly's Tips & Tricks, or any of the threads on the forum with skill/state notetags, what you want to check for is target.hp<=0 e.g. the target will die.

    Kes said:
    The intention for this item is that the chance to inflict state 65 was only applied to the straightforward attack skill.
    So there's nothing in the description of the notetag you're using (JS Post-Damage as User) that says it only is evaluated when the attack skill is used. I'm not sure where you got that impression.

    The plugin documentation says:
    1703381151420.png

    which is the function that every skill with anything entered in the damage formula will call.

    If you want to check the target is dead:
    Code:
    target.hp<=0

    To check that it is an attack skill (targets an enemy):
    Code:
    this.isForOpponent()

    If you only want it to function with the user's Attack skill:
    Code:
    this.isAttack()
  6. @ATT_Turan Thank you for explaining that in a way that I can understand.
    I assume that in this instance, as I will be specifying that the skill is Attack, I don't also need to check that this is an enemy. The only time Attack might be used against an ally is if the user has Confusion, and then it is logical that the ally might get inflicted as well.

    Putting it all together I came up with this:

    <JS Post-Damage as User>
    if (target.hp<=0 && this.isAttack() && Math.random()<.4)
    target.addState(65);
    </JS Post-Damage as User>

    Should I split the 3 conditions into separate lines?
    Testing these doesn't produce a crash, but neither has State 65 been inflicted. This is difficult to test for, because it's only a 40% chance, but in 10 fights it's not come up once. Even putting it to 90% it didn't happen.
  7. @Kes

    I believe to fix it you need to put a ! in front of 'target.hp' so that it's

    Code:
    !target.hp<=0

    Because right now it's only going to activate if the target has 0 or less, and I assume you want the opposite when it's still alive, correct? Which will explain why nothing is triggering right now.
  8. @FrigidGaze How right you are. Enemy now being nicely splatted with the state.
    Thank you.
  9. @Kes Right, that's just a mathematical operator. HP is less than or equal to zero - so you were only trying to do it when your target was dead.

    You can reverse it as @FrigidGaze showed, with the NOT operator, or just reverse the math - target.hp > 0, is greater than zero, is still alive.

    I did word it confusingly in my prior post.
  10. posted in the wrong thread before so:

    I’m using Visustella MZ and is there a way to create a passive state that prevents other states from expiring?

    For example, if the actor has that passive state, a buff that last only 3 turns would never expire, nor would an ailment that lasted 4 turns.

    Bonus points if it could only apply to certain state categories!
  11. Hey all,

    For STB Turn Display. Is there a way to have a gap between non subjects? I hate how on top of each other each frame is.
  12. Lonewulf123 said:
    posted in the wrong thread before so:

    I’m using Visustella MZ and is there a way to create a passive state that prevents other states from expiring?

    For example, if the actor has that passive state, a buff that last only 3 turns would never expire, nor would an ailment that lasted 4 turns.

    Bonus points if it could only apply to certain state categories!
    You could give it a turn/action end tag that loops through states, checks for category X, and adds 1 to the duration of each one that meets the condition.
  13. Trihan said:
    You could give it a turn/action end tag that loops through states, checks for category X, and adds 1 to the duration of each one that meets the condition.

    I actually figured out a little snippet that prevents the state turn from incrementing when that state was applied:

    JavaScript:
    Game_BattlerBase.prototype.updateStateTurns = function() {
        for (const stateId of this._states) {
            if (!this.isStateAffected(149)){
            if (this._stateTurns[stateId] > 0) {
                this._stateTurns[stateId]--;
            }
        }
        }
    };

    It's been working so far.
  14. A quick question (hopefully)


    Do i have to alter anything to have Action Sequences accepts variables in place of numbers? I want to set motions and just do something like actor ID $gameVariables.value(20) here:

    1704754047647.png
  15. Puppet Knight said:
    I want to set motions and just do something like actor ID $gameVariables.value(20) here:
    Unless the documentation explicitly says someplace you can do that, there's no way that would work.

    You can't just provide anything code-related - whether it's a script call or a plugin command that interfaces with one - something different from what it's written to work with.
  16. ATT_Turan said:
    You can't just provide anything code-related - whether it's a script call or a plugin command that interfaces with one - something different from what it's written to work with.
    Good call. Actually dawned on me after that any Summoned Pet (since I'm only using one at a time) would be "friend index 4" (basically party index 4) in action sequences. So I can just use that.
  17. Hi there, I'm scratching my head over something that should be simple... I want to swap out sprite sheets based on the weapon equipped, and to prototype this I have the following note in the state 'EqShortSword':

    JavaScript:
    <JS On Add State>
    console.log('short sword equipped');
    target.setBattlerImage('acSjorgeShortSword');
    target.refresh();
    </JS On Add State>

    The console.log entry I added because it didn't seem to do anything, and lo and behold, no log is being added. The state itself is applied correctly when equipping a Short Sword, but it seems to ignore the note? I suspect I'm overlooking something very basic here, but need a second set of eyes...

    EDIT: for clarification, the icon for the passive state (in this case EqShortSword and EqLongSword) are showing up in the actor status menu correctly. It just seems like the whole <JS On Add State> notetag is ignored.
  18. @werzaque Passive states are neither added nor removed, they are only toggled on and off. This is in the plugin documentation:
    1705770099252.png
  19. Thanks, you are absolutely correct. However, now I'm a little puzzled how to implement this mechanic... I saw that the MV-equivalent of these plugins did allow for sprite sheet swapping through this mechanic. But if passive states are not states, I'd need a something to add a "normal" state upon equipping...

    Will try asking their discord for clarification.
  20. werzaque said:
    I saw that the MV-equivalent of these plugins did allow for sprite sheet swapping through this mechanic.
    Maybe you can link to what you're looking at, because that's not correct. I can't think of any combination of Yanfly plugins/notetags that would let you change an actor's spritesheet by equipping a weapon.

    I would've used waynee95's On Equip Eval, which runs code when you equip and unequip items (in fact, that is what I'm using in my project).

    You could check, see if that plugin is compatible with MZ - the equip/unequip methods may well be the same between engines.