Making an "AoE Cover skill"

Discussion in 'Javascript/Plugin Support' started by kkiittuuss, Aug 4, 2019.

  1. kkiittuuss

    kkiittuuss Villager Member

    Messages:
    9
    Likes Received:
    2
    First Language:
    Spanish
    Hello people,

    So the idea is as it follows. This skill shouldn't be a normal "cover" skill where the actor gets all the blows from the enemy, as such effect could be easily recreated with Yanfly's "Taunt" plugin.
    The effect of this skill would be to block the incoming damage of an enemy's AoE skill for the "covered" battlers and transfer that negated damage to the battler covering.

    I've been searching for a while, and I've found a guy using Yanfly's "Buffs states core". He made a custom effect for the cover skill, writing this costume formula on the state's notebox.


    <Custom Respond Effect>
    if (this.isHpEffect() && value > 0){
    origin.gainHp(-value);
    origin.startDamagePopup();
    target.gainHp(value);
    target.startDamagePopup();
    target.clearResult();
    }
    </Custom Respond Effect>

    This formula works pretty close as the idea intended, but instead of blocking damage to the "covered" allies, it heals them. The damage gets redirected to the "tank" just fine, so that far it works.

    If you try to change this line:

    target.gainHp(value); to -----> target.gainHp(0);

    It appears as "0" damage displayed, but actually the battlers lose HP anyways.

    So what im asking you guys is if you could think of a way to modify the formula for the intended results, or instead, if you have any other ideas that could work, id also like to hear them.

    Thanks.
     
    Last edited: Aug 4, 2019
    #1
    JtheDuelist likes this.
  2. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,766
    Likes Received:
    10,578
    First Language:
    English
    Primarily Uses:
    RMVXA
    @kkiittuuss Could you please edit your post to include a link to the particular web page where you got that plugin. That way if anyone needs to check something before offering a suggestion, they won't need to go hunting.

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

     
    #2
  3. kkiittuuss

    kkiittuuss Villager Member

    Messages:
    9
    Likes Received:
    2
    First Language:
    Spanish
    Done, thank you so much.
     
    #3
  4. JtheDuelist

    JtheDuelist Just a dev who actually got a game finished Veteran

    Messages:
    1,160
    Likes Received:
    1,423
    Location:
    RMW Forums, Granvia, or Askr
    First Language:
    English
    Primarily Uses:
    RMMV
    Sounds like you want to recreate a skill I had in Downfall FES Re:Boot, Devoted Sacrifice (Effect: "The user takes all damage that was intended for all allies this turn. The user will automatically revive if HP hits 0 this turn.")

    First, you'll need Yanfly's Passive Aura Effects.

    Next you'll need to make three states (two if you do not want the auto-revive)- one being the aura origin:
    upload_2019-8-3_16-17-32.png
    Set the origin like this. Replace the 16 with the state ID of the next state, the aura effect state.

    Then to make the actual aura effect:
    upload_2019-8-3_16-18-44.png
    This is the actual aura effect. The notetag you want to make is:
    Code:
    <Custom React Effect>
    
    // Check if the action dealt HP damage
    
    if (this.isHpEffect() && value > 0) {
    
    // Get the target's allies
    
    var members = target.friendsUnit().aliveMembers();
    
    // Get the Aura's Origin State ID
    
    var auraOriginId = X;
    
    // Make the origin user undefined
    
    var auraOriginUser = undefined;
    
    // Loop through each member
    
    for (var i = 0; i < members.length; ++i) {
    
    // Get the currently looped member
    
    var member = members[i];
    
    // Check if the member exists, isn't the target, and is the aura holder
    
    if (member && member !== target && member.isStateAffected(auraOriginId)) {
    
    // Set the origin user to that member
    
    auraOriginUser = member;
    
    // Break the loop
    
    break;
    
    }
    
    }
    
    // Check if the origin user exists
    
    if (auraOriginUser) {
    
    // Calculate the amount of reduction
    
    var reduction = Math.ceil(0 * value);
    
    // Set the damage to the target to 0.
    
    value = 0;
    
    // Make the origin user take damage instead.
    
    auraOriginUser.gainHp(-reduction);
    
    // Display an animation on the origin user.
    
    auraOriginUser.startAnimation(53);
    
    // Make the origin user display a damage popup.
    
    auraOriginUser.startDamagePopup();
    
    // Check if the origin user is dead
    
    if (auraOriginUser.isDead()) {
    
    // Collapse the origin user if dead
    
    auraOriginUser.performCollapse();
    
    }
    
    // Clear the origin user's results
    
    auraOriginUser.clearResult();
    
    }
    
    }
    
    </Custom React Effect>
    
    Replace the X in "var auraOriginId = X;" to the state ID of the origin state.

    If you want the added auto-revive effect, make a third state like this:
    upload_2019-8-3_16-19-16.png
    The notetag:
    Code:
    <Custom React Effect>
    
    // Check to see if the party is in battle.
    
    if ($gameParty.inBattle()) {
    
    // Sets the flag if the target has more than 1 HP at the time of death.
    
    target._secondChance = target.hp > 0;
    
    }
    
    </Custom React Effect>
    
    
    
    <Custom Respond Effect>
    
    // Check to see if the party is in battle, has the Second Chance flag, and if the target is dead with 0 HP.
    
    if ($gameParty.inBattle() && target._secondChance && target.hp <= 0) {
    
    // Play the revival animation.
    
    target.startAnimation(49);
    
    // Set the target's HP to 1.
    
    target.setHp(1);
    
    }
    
    </Custom Respond Effect>
    

    Once you have those states, Make your skill like this:
    upload_2019-8-3_16-19-57.png
    If you don't want the auto-revive, just have the skill Add State the origin state and you are good to go. If you want the auto-revive, also include Add State the resurrection state.

    I hope that helped, @kkiittuuss.
     
    #4
    SoSick. likes this.
  5. kkiittuuss

    kkiittuuss Villager Member

    Messages:
    9
    Likes Received:
    2
    First Language:
    Spanish
    Hello, first of all thanks for replying to my question.

    I've followed all your steps and it kinda worked but with an "strange" effect. I've read the formula and it looks like once you set the damage for the allies to "0", the damage that they "transfer" to the user of the cover skill is also "0". Did it work fine for you? This is what i am getting.

    This when receiving AoE damage.

    This when receiving ST damage.

    Hope that make sense to you and you can imagine what happens because your code really looks spot on.

    Thanks again!


    EDIT: Okay solved it! I prayed and it worked (I know like zero coding).

    The issue was in this line:

    // Calculate the amount of reduction

    var reduction = Math.ceil(0 * value);

    0 * value is 0, thats why!


    Once more, thank you so much for your help, you are a life saver!
     
    Last edited: Aug 4, 2019
    #5
    JtheDuelist likes this.
  6. JtheDuelist

    JtheDuelist Just a dev who actually got a game finished Veteran

    Messages:
    1,160
    Likes Received:
    1,423
    Location:
    RMW Forums, Granvia, or Askr
    First Language:
    English
    Primarily Uses:
    RMMV
    @kkiittuuss No problem. The skill actually makes the user take all of the hits that turn, regardless if the damage is AoE, directed, or random. It was actually a replica of the skill it took its name from, Devoted Sacrifice, which was a Rook skill in Unison League.
     
    #6

Share This Page