YEP's Buffs & States Core state custom effect help

Discussion in 'Javascript/Plugin Support' started by thepsyche, Jun 18, 2019.

  1. thepsyche

    thepsyche Veteran Veteran

    Messages:
    223
    Likes Received:
    58
    Location:
    NZ
    First Language:
    English
    Hi all,

    I'm looking to create a state, presumably using Lunatic Mode in YEP's Buffs & States Core that inflicts elemental damage during the HP regeneration window of each turn. Disclaimer: I don't know / understand javascript, but I try to and figure it out as much as possible.

    The formula I want the damage to use is - in layman's terms:

    5% of affected actor's Total HP = Value of elemental damage to inflict. However, once that initial value is determined, I want that to be treated as if it were an incoming attack of that element, so that the actor's resistance, or lack thereof, will change the amount of damage they receive.

    The second part of this state, is that I want this same effect to occur to the actors in the slots adjacent to this actor. So if the actor was in slot 2, I would want this effect to occur on the actors in slots 1 and 3, even though they actually aren't afflicted by the state themselves.

    Thanks for any help you can give me.

    EDIT: I think it's worth mentioning I'd like an animation to play at the point where the damage occurs too, just to call attention to itself.

    EDIT AGAIN: It's also worth mentioning that I'll need variants of this type that deal damage to all party members, as opposed to just those next to the afflicted actor.
     
    Last edited: Jun 18, 2019
    #1
  2. caethyril

    caethyril ^_^ Veteran

    Messages:
    952
    Likes Received:
    590
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    For damage to neighbouring members, you could try:
    Code:
    <Custom Regenerate Effect>
    var animId = 59;    // animation ID
    var elemId = 6;     // damage element ID
    var ix = user.index();
    var allies = user.friendsUnit().members();
    [ix-1, ix, ix+1].forEach(function(n) {
      var ally = allies[n];
      if (ally && ally.isAlive()) {
        var dmg = ally.mhp * 0.05; // 5% max HP
        dmg *= ally.elementRate(elemId);
        ally.startAnimation(animId);
        ally.gainHp(-Math.round(dmg));
        ally.startDamagePopup();
        ally.clearResult();
      }
    });
    </Custom Regenerate Effect>
    For damage to all (living) allies, maybe something like this instead:
    Code:
    <Custom Regenerate Effect>
    var animId = 59;    // animation ID
    var elemId = 6;     // damage element ID
    var allies = user.friendsUnit().aliveMembers();
    allies.forEach(function(ally) {
      var dmg = ally.mhp * 0.05; // 5% max HP
      dmg *= ally.elementRate(elemId);
      ally.startAnimation(animId);
      ally.gainHp(-Math.round(dmg));
      ally.startDamagePopup();
      ally.clearResult();
    });
    </Custom Regenerate Effect>
    Just edit the values on the "// commented" lines as appropriate~ :kaothx:

    After a brief test, I'd suggest using Yanfly's Battle Engine Core plugin to make the damage numbers show up. :kaoslp:

    (Also, if by "total" HP you meant "current" HP, just replace mhp with hp. :kaoswt:)
     
    #2
  3. thepsyche

    thepsyche Veteran Veteran

    Messages:
    223
    Likes Received:
    58
    Location:
    NZ
    First Language:
    English
    Thanks so much for this @caethyril !

    I'm having some trouble getting it to work, but I think that may be due to other plugins I am using. Once I figure that out, I'll test it right away!
     
    #3
  4. caethyril

    caethyril ^_^ Veteran

    Messages:
    952
    Likes Received:
    590
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Since you mention Yanfly's plugins, maybe double-check you have them up-to-date and in the recommended order in the Plugin Manager. Recommended order can be found here: http://yanfly.moe/yep/

    Hope it works out! :kaothx:
     
    #4

Share This Page