Elemental Armor State

Discussion in 'Javascript/Plugin Support' started by killdude, Aug 3, 2019.

  1. killdude

    killdude RPD Officer Veteran

    Messages:
    56
    Likes Received:
    12
    Location:
    Raccoon City
    First Language:
    Turkish
    Primarily Uses:
    RMMV
    Hi.İm making a passive state for my final boss but i ve got a issue with that.Im using Yanfly's Adapting Armor Tip.

    http://www.yanfly.moe/wiki/Adapting_Armor_(MV_Plugin_Tips_&_Tricks)
    When the user takes damage from an elemental attack, the user will gain a buff that grants a massive resistance(%90) to the elemental damage received. İts really cool but I want to make some changes.I want to make it to gain resistance to last element it receives.For example if it receives fire damage it gains resistane to fire element.And then if it receives poison damage the fire resistance buff is erased and gain poison resistance buff.For example if it receives ice damage then posion resistance buff will be erased too and it gains ice resistance buff.Hope i can explain.İt can gain only 1 element resistance at time.İn this code element resistance buffs are stacking hope somebody help me with this.

    <Custom Respond Effect>
    // Check if the target received HP damage.
    if (target.result().hpDamage > 0) {
    // Get all of the elements used for this attack.
    var elements = this.getItemElements();
    // Loop through all the elements.
    while (elements.length > 0) {
    // Get the current element.
    var element = elements.shift();
    // Set the default state.
    var state = 0;
    // If the current element ID is 7...
    if (element === 7) {
    // ...then apply state 121.
    state = 121;
    // If the current element ID is 8...
    } else if (element === 8) {
    // ...then apply state 122.
    state = 122;
    // If the current element ID is 9...
    } else if (element === 9) {
    // ...then apply state 123.
    state = 123;
    // If the current element ID is 10...
    } else if (element === 10) {
    // ...then apply state 124.
    state = 124;
    // If the current element ID is 11...
    } else if (element === 11) {
    // ...then apply state 125.
    state = 125;
    // If the current element ID is 12...
    } else if (element === 12) {
    // ...then apply state 126.
    state = 126;
    // If the current element ID is 13...
    } else if (element === 13) {
    // ...then apply state 127.
    state = 127;
    // If the current element ID is 14...
    } else if (element === 14) {
    // ...then apply state 128.
    state = 128;
    // If the current element ID is 15...
    } else if (element === 15) {
    // ...then apply state 129.
    state = 129;
    // If the current element ID is 16...
    } else if (element === 16) {
    // ...then apply state 130.
    state = 130;
    }
    // If the state is a positive number...
    if (state) {
    // ...then add the state to the target.
    target.addState(state);
    // And play an animation on the target.
    target.startAnimation(53);
    }
    }
    }
    </Custom Respond Effect>
     
    Last edited by a moderator: Aug 3, 2019
    #1
  2. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,255
    Likes Received:
    3,569
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.


    Additionally, I inserted the extremely long notetag in a Spoiler tag so the post is more easily readable. In the future, if you post code or notetags that are longer than ~20 lines, please insert them into a Spoiler tag (it's under the "Insert..." icon above where you type your message).

    What you will need to do is make sure that the "Adaptive Resistance" states are exclusive to this armor and any other "Only resist the Last Element" effects (e.g. if a character uses a simple skill that increases an ally's Ice Resistance by 50% for 5 turns, that needs to be a separate state from the Adaptive Ice Resistance state that this armor would add).

    Then, in your notetag, immediately before the line "target.addState(state);", you will need to add a line for every Adaptive Resistance State to remove it. For example:
    target.removeState(121);
    target.removeState(122);
    target.removeState(123);
    and so on for every Adaptive Resistance State this armor can add to a character.

    This will allow the existing state to be cleared if (and only if) a new state is about to be added by the armor, which sounds like the effect you are looking for.
     
    #2
  3. killdude

    killdude RPD Officer Veteran

    Messages:
    56
    Likes Received:
    12
    Location:
    Raccoon City
    First Language:
    Turkish
    Primarily Uses:
    RMMV
    Thank you for your help but have a question too.Where should i put the codes written by you should i make multipl state for this?Im very lacking on java script so can you make an example for that?
     
    #3
  4. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,255
    Likes Received:
    3,569
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Put them directly above the "addstate" line. So if you have four elements, and your Adaptive Resist states are 121, 122, 123, and 124, your notetag would look like this:

    <Custom Respond Effect>
    // Check if the target received HP damage.
    if (target.result().hpDamage > 0) {
    // Get all of the elements used for this attack.
    var elements = this.getItemElements();
    // Loop through all the elements.
    while (elements.length > 0) {
    // Get the current element.
    var element = elements.shift();
    // Set the default state.
    var state = 0;
    // If the current element ID is 7...
    if (element === 7) {
    // ...then apply state 121.
    state = 121;
    // If the current element ID is 8...
    } else if (element === 8) {
    // ...then apply state 122.
    state = 122;
    // If the current element ID is 9...
    } else if (element === 9) {
    // ...then apply state 123.
    state = 123;
    // If the current element ID is 10...
    } else if (element === 10) {
    // ...then apply state 124.
    state = 124;
    }
    // If the state is a positive number...
    if (state) {
    // ...first remove existing Adapative Resist states...
    target.removeState(121);
    target.removeState(122);
    target.removeState(123);
    target.removeState(124);

    // ...then add the state to the target.
    target.addState(state);
    // And play an animation on the target.
    target.startAnimation(53);
    }
    }
    }
    </Custom Respond Effect>
     
    #4
    SoSick. likes this.
  5. killdude

    killdude RPD Officer Veteran

    Messages:
    56
    Likes Received:
    12
    Location:
    Raccoon City
    First Language:
    Turkish
    Primarily Uses:
    RMMV
    Thank you very much!It worked and my game has gained a cool state.
     
    #5

Share This Page