MV Help with Skill using YEP BuffsAndStatsCore

Hello everyone, I’m trying to create a Skill that applies a buff to the user with a certain chance each time the skill is used, but I’m running into two issues. (I'm using YEP BuffsAndStatsCore).


1)
Everything is working as expected, except for how the buff duration (turn count) is displayed. With the current code, when the monster uses the skill it immediately gains the buff with a duration of 5 turns. However, instead of starting the count at 5, it immediately drops to 4 in the same moment the buff is applied. In other words, the turn in which the buff is applied is already being counted as one of the buff turns, which is not what I want.


I tried modifying the code so that it remains at 5 even after the turn passes, but then the number 6 briefly appears and then drops to 5. This isn’t terrible, but it could confuse the player about the actual duration of the buff.


The strange part is that sometimes it works correctly, with the buff starting at 5 turns as intended.

The Code:
JavaScript:
<After Eval>
var chance = 0.40; // 40%

function applyStackingBuffs(buffList){
  buffList.forEach(function(paramId){
    if (Math.random() < chance) { // verifica a chance
      if (!user.isBuffAffected(paramId)) {
        user.addBuff(paramId, 5);
        user._buffTurns[paramId] += 1; // compensa Action End
      } else {
        if (user._buffs[paramId] < 4) { // limite de stack
          user._buffs[paramId]++;
          user.refresh();
        }
      }
    }
  });
}
applyStackingBuffs([2]);
</After Eval>

2)
There is a line in the code that allows me to apply buffs to multiple stats, but visually only one stat appears as buffed. I checked the console using F8, and the stats are indeed being buffed in the backend, but not all of then an the visual indicators in the UI do not reflect this.
Is there a way to make these buffs appear separately instead of being grouped together visually and also make all of then being abble to be applied at the same time?

The Skill Settings:
1773617001413.png


The Console:
1773617114557.png

In this example I use: applyStackingBuffs([2,3,4,5,6]);

Could anyone help me with this?
when the monster uses the skill it immediately gains the buff with a duration of 5 turns. However, instead of starting the count at 5, it immediately drops to 4 in the same moment the buff is applied
and theyre not acting last in the turn order? buffs should only tick down on turn end, not action end. you likely have a plugin that's the cause if the turns are decreasing without the turn ending.

There is a line in the code that allows me to apply buffs to multiple stats, but visually only one stat appears as buffed. I checked the console using F8, and the stats are indeed being buffed in the backend, but not all of then an the visual indicators in the UI do not reflect this.
try to refresh() the battler afterwards. Yanfly's buffs and states caches parameter rates to cut down on the need to fully recalculate them. refreshing should clear it.

Is there a way to make these buffs appear separately instead of being grouped together visually and also make all of then being abble to be applied at the same time?
im not certain of what youre asking here

function applyStackingBuffs(buffList){
also theres no need to declare a function in a notetag that is only meant to be used immediately after. it wouldnt be accessible outside of the tag and if it was, its not tied to a battler in a way that'd make sure it could function elsewhere
and theyre not acting last in the turn order? buffs should only tick down on turn end, not action end. you likely have a plugin that's the cause if the turns are decreasing without the turn ending.
I’m not sure if I fully understood your question, but I’ll try to clarify what’s happening.


Right after the skill is used, the buff is applied immediately and the counter shows 5 turns, which is what I expect. However, when the turn actually ends, the counter immediately drops to 4.


What I believe should happen is this: the skill is executed, the character’s turn ends, and then the counter should display 5 turns. Right now, the skill execution itself is already being counted as if one buff tick had been consumed.


To illustrate:


In this first moment, the attack has just been executed. You can tell because the damage popup appears (it’s currently zero since this is just a test skill). As soon as the skill is used, the counter already appears while the action is still being executed.
1773670495845.png


It currently shows 6 because I tried to work around the issue by manually adding one extra turn to the buff, so it would effectively stay at 5, since the counter was decreasing anyway.


Then, once the action is fully completed and the turn actually ends, the counter drops to 5, as if one turn of the buff had already been used. If I hadn’t tried to compensate for this in the code, the value would go from 5 to 4 instead.
1773670536746.png


This explanation might be a bit confusing, and I might be using some incorrect terminology. I also don’t really have a programming background, I actually found this code somewhere and tried to adapt it for what I needed, but it seems the solution didn’t work as well as I hoped.

im not certain of what youre asking here
Never mind, I'll try to solve one problem at a time, hahaha. This isn't a priority right now.
Then, once the action is fully completed and the turn actually ends, the counter drops to 5, as if one turn of the buff had already been used.
are you using a battle system plugin or some other plugin that affects how turns are counted? as ive mentioned, the buff counter normally only decreases at the end of the turn, not at the end of actions. If the enemy was the last person to act in a turn then it would have to as the turn ends after they act, but if youre using the default battle system then the buff turns shouldnt immediately decrease from use.

buff.gif


ive copied exactly what you have provided in the first post and using the skill doesnt cause the timers to decrease immediately. the turn ending does, which is why the 2nd enemy to use the skill shows 6 turns for a second and then 5 after, but the first enemy shows 6 all the way to the end of the turn and then 5 after.
I'm using Yanfly's CTB plugin; besides that, I don't have any other plugins that affect turns.
Bump
I'm using Yanfly's CTB plugin
Nothing comes to mind immediately on how to go about it without editing the plugin. It seems that it sets what counts as being the end of the turn to the end of their action, so the easiest way of applying it after then doesn't really work. I'd have to take a look into it, but I haven't really had the free time lately to be able to.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-skill-using-yep-buffsandstatscore.182889/