2Qs: Yanfly Stacking DoT damage element and Random Skill item.

First question: I'm using Yanfly's code for Stacking Damage over time. It works as intended. I want to create multiple types of stacking DoTs that deal different kinds of elemental damage, eg: poison, burning, drowning. Dunno how to accomplish this. Yanfly has a script that lets you establish what kind of damage a dot state does (using <DoT Element: x> in notes), but so far I haven't been able to mesh the two effects together. Can anyone offer any advice?

Second question: I want to make an item that performs a random skill from a list of possible skills. My plan--and this seems to be the common way to do this--was to call a common event that assigns a random variable, then run through a list of conditional branches until the variable is hit. I ran into a problem right away: because it's an item, any actor can use it. And because any actor can use it, there's no way to use the Force Action event, since that requires a specific actor. Is there a workaround to this?


Code:
<Custom Apply Effect>

// Make sure the stack count exists.

target._stackingDrowning = target._stackingDrowning || 0;

// Increase the stack count.

target._stackingDrowning += 1;

</Custom Apply Effect>



<Custom Remove Effect>

// Reset the stack count.

target._stackingDrowning = 0;

</Custom Remove Effect>



<Custom Regenerate Effect>

// Make sure the stack count exists.

target._stackingDrowning = target._stackingDrowning || 1;

// Sets the maximum amount of stacks to 5.

var stacks = Math.min(5, target._stackingDrowning);

// The damage formula used per tick.

var damage = stacks * origin.mat * 2;

// Play Drowning animation on the target.

target.startAnimation(1);

// Target takes HP damage.

target.gainHp(-damage);

// Play the popup.

target.startDamagePopup();

// Clear the results.

target.clearResult();

// Check if the target is dead.

if (target.isDead()) {

  // If the target is dead, make it collapse.

  target.performCollapse();

}

</Custom Regenerate Effect>
You could use yanflys item requirement plugin. That way only the specified actor can use the item.



I have a skill called 'burn' that literally does just that, it adds fire damage over time and stacks nicely.

<Category: Ailment>
<DoT Formula: a.mat * 2 * (100/(100+b.mdf))>
<DoT Animation: 67>
<DoT Variance: 5%>
<DoT Element: 2> <--- 2 is the id of my fire element

<Help Description>
: Unit takes \c[18]Fire Magic Damage\c[0] per turn.
</Help Description>

This is how I set it up, maybe that helps.
You could use yanflys item requirement plugin. That way only the specified actor can use the item.


Unfortunately, that doesn't fit my needs. I need the item to be usable by everyone.

Code:
I have a skill called 'burn' that literally does just that, it adds fire damage over time and stacks nicely.

<Category: Ailment>
<DoT Formula: a.mat * 2 * (100/(100+b.mdf))>
<DoT Animation: 67>
<DoT Variance: 5%>
<DoT Element: 2>     <--- 2 is the id of my fire element

<Help Description>
: Unit takes \c[18]Fire Magic Damage\c[0] per turn.
</Help Description>

This is similar how I set it up, maybe that helps.


This is how I set up my own DoTs prior to attempting DoT stacks. It's a great utility, but if I'm reading it right, not quite what I'm looking for. The stacking DoTs would mean every time you re-use the skill, the amount of damage dealt each turn increases. So, for example, the code in the OP would make the state apply 200 damage per turn if used by a character with 100 M.ATK. If they applied the state a second time, it would apply 400 damage per turn. At the given maximum of 5 stacks, it would do 1000 damage per turn until the state expires.

The script in the OP was lifted from Yanfly's site with minimal alteration and works as intended. The only thing it's missing is
First question: I'm using Yanfly's code for Stacking Damage over time. It works as intended. I want to create multiple types of stacking DoTs that deal different kinds of elemental damage, eg: poison, burning, drowning. Dunno how to accomplish this. Yanfly has a script that lets you establish what kind of damage a dot state does (using <DoT Element: x> in notes), but so far I haven't been able to mesh the two effects together. Can anyone offer any advice?
So just to be clear - you have already made these different states, each with their own DoT formula and element, and...what exactly happens instead? Does the damage get converted into a different element? Do only some of the states happen? We don't know what "not able to mesh the two effects together" means.
because it's an item, any actor can use it. And because any actor can use it, there's no way to use the Force Action event, since that requires a specific actor. Is there a workaround to this?
Sure. Googling "RPG Maker MV Force Action script call" we get:
Code:
battler.forceAction(skillId, targetIndex);
BattleManager.forceAction(battler);

We can then put that anyplace that will take JavaScript. So you could do it using Yanfly's Skill Core:
Code:
<After Eval>
if (!target.isDead())
{
    var skill=Math.randomInt([1, 2, 3, 4, 5].length);
    // Where I listed 1, 2, 3, 4, 5, put as many different skill IDs as you like, separated by commas

    user.forceAction(skill, $gameTroop.members().indexOf(target));
    BattleManager.forceAction(user);
}
</After Eval>

You could also do it using Action Sequences.
So just to be clear - you have already made these different states, each with their own DoT formula and element, and...what exactly happens instead? Does the damage get converted into a different element? Do only some of the states happen? We don't know what "not able to mesh the two effects together" means.

Sorry, I'll try to be more specific.

I've made elemental DoT states before, using scripting similar to what You Clod has suggested. Recently, I've tried making stacking DoTs using scripts provided by Yanfly. By default, Yanfly's stacking DoT script does not include an element for the damage, at least inasmuch as I can deduce. I have been unable to add one. Put as simply as possible, I don't know how to add an element to the OP script.
We can then put that anyplace that will take JavaScript. So you could do it using Yanfly's Skill Core:

I used the formula you provided and tested it. It resulted in the actor using skill ID 1-4, or doing nothing. So pretty close to perfect. I then substituted the skill IDs for mine, and it resulted in the actor using skill ID 1-4, or doing nothing. I don't know how to account for that. Just in case it needs saying, I haven't altered Skills 1-5, and do indeed have skills made for 80-84.

Code:
<After Eval>

if (!target.isDead())

{

    var skill=Math.randomInt([80, 81, 82, 83, 84].length);

    user.forceAction(skill, $gameTroop.members().indexOf(target));

    BattleManager.forceAction(user);

}

</After Eval>
Sorry, I'll try to be more specific.

I've made elemental DoT states before, using scripting similar to what You Clod has suggested. Recently, I've tried making stacking DoTs using scripts provided by Yanfly. By default, Yanfly's stacking DoT script does not include an element for the damage, at least inasmuch as I can deduce. I have been unable to add one. Put as simply as possible, I don't know how to add an element to the OP script.
I would use the Custom Regenerate Effect and have on the same skill a DoT Element notetag. Are you saying that doesn't work?
I used the formula you provided and tested it. It resulted in the actor using skill ID 1-4, or doing nothing. So pretty close to perfect. I then substituted the skill IDs for mine, and it resulted in the actor using skill ID 1-4, or doing nothing. I don't know how to account for that. Just in case it needs saying, I haven't altered Skills 1-5, and do indeed have skills made for 80-84.
I was in a hurry and did the array wrong. It should be:
Code:
var skill=[80, 81, 82, 83, 84][Math.randomInt(5)];

If you add more skills to the list, just make sure to make the number in parentheses reflect how many you have listed.
If you add more skills to the list, just make sure to make the number in parentheses reflect how many you have listed.
That works as intended. Thank you very much. That required more scripting than I thought it would, and I'm very grateful that you were willing to write it out.

I would use the Custom Regenerate Effect and have on the same skill a DoT Element notetag. Are you saying that doesn't work?

Not in any way I've been able to figure out. I tried the code below. It goes without saying, but I don't know anything about scripting. I assume // designates a space for notes and has no effect on the script, so I apologize if they're important and require specific wording and I'm making a fool of myself. Adding DoT element near the damage formula in the <Custom Regenerate Effect> causes the state to do nothing. Adding it outside of the categories won't impair the code, but it has no effect on the damage being dealt. I've tested the state against enemies with immunity to Element 5, but they still take full damage.

Code:
<Custom Apply Effect>
// Make sure the stack count exists.
target._stackingDrowning = target._stackingDrowning || 0;
// Increase the stack count.
target._stackingDrowning += 1;
</Custom Apply Effect>

<Custom Remove Effect>
// Reset the stack count.
target._stackingDrowning = 0;
</Custom Remove Effect>

<Custom Regenerate Effect>
// Make sure the stack count exists.
target._stackingDrowning = target._stackingDrowning || 1;
// Sets the maximum amount of stacks to 5.
var stacks = Math.min(5, target._stackingDrowning);
// The damage formula used per tick.
var damage = stacks * origin.mat * 2
// The element of the damage.
DoT Element: 5
// Play Drowning animation on the target.
target.startAnimation(1);
// Target takes HP damage.
target.gainHp(-damage);
// Play the popup.
target.startDamagePopup();
// Clear the results.
target.clearResult();
// Check if the target is dead.
if (target.isDead()) {
  // If the target is dead, make it collapse.
  target.performCollapse();
}
</Custom Regenerate Effect>
I tried the code below.
Notetags aren't code, and they can never be nested inside each other or combined. Each one must be its own entry. So you would do:
Code:
<DoT Element: 5>
<Custom Apply Effect>
...
</Custom Apply Effect>
<Custom Remove Effect>
...
</Custom Remove Effect>
<Custom Regenerate Effect>
...
</Custom Regenerate Effect>

That being said, I think it's not working because you're combining a tag designed to work with the Extended Damage Over Time stuff with a generic "this happens in the regeneration phase" tag.

Why don't you put the actual formula for damage into one of the notetags from the Extended DoT plugin, which should then work properly with its own DoT Element tag?
im lost in all of this... ive never used DoT plugin; ive made my own DoT formulas...

in the state:
Code:
<Custom Apply Effect>
   target._stackingDmg = target._stackingDmg || 0;
   target._stackingDmg += 1;
</Custom Apply Effect>

<Custom Remove Effect>
   target._stackingDmg = 0;
</Custom Remove Effect>

<Custom Regenerate Effect>
   target._stackingDmg = target._stackingDmg || 1;

   //set max 3 stacks. rplace 3 with your number:
   var stacks = Math.min(3, target._stackingDmg);

   //damage calculation:
   var damage = Math.min((target.mhp * 0.1) * stacks);
  
   //apply the element to the damage. replace Y with the element id:  
   damage = Math.floor(damage * target.elementRate(Y));

   //play animation here. got the animation number "1" from your example:
   target.startAnimation(1);

   //make them suffer:
   target.gainHp(-damage);
   target.startDamagePopup();
   target.clearResult();
</Custom Regenerate Effect>
im lost in all of this... ive never used DoT plugin; ive made my own DoT formulas...
The thing is, doing it that way (manually adjusting the damage by the target's element rate) doesn't actually give the damage that element type. So if the OP is using any of Yanfly's other element-related plugins for elemental absorption or things like that, it won't interact as desired.

If you know your game and none of that is necessary, then that's absolutely a way to do it.

I think it will work just fine when the OP tests putting it into the Custom DoT Formula notetag.
[...]So if the OP is using any of Yanfly's other element-related plugins for elemental absorption or things like that, it won't interact as desired.

If you know your game and none of that is necessary, then that's absolutely a way to do it.[...]

i agree. one must know its own game and see if that would fit.
That being said, I think it's not working because you're combining a tag designed to work with the Extended Damage Over Time stuff with a generic "this happens in the regeneration phase" tag.

Why don't you put the actual formula for damage into one of the notetags from the Extended DoT plugin, which should then work properly with its own DoT Element tag?

Do you mean in addition to the Stacking DoT notetags? Likely unsurprisingly, the game considers this too separate instances of damage: one DoT that has an element but doesn't stack, and one that stacks but doesn't have an element. I had the instinct to put the whole thing in a <Custom DoT Formula>, but you said notetags can't be combined or house in each other so I'm guessing that wouldn't work.

Code:
<DoT Element: 4>

<DoT Formula: a.mat * 2>



<Custom Apply Effect>

// Make sure the stack count exists.

target._stackingDrowning = target._stackingDrowning || 0;

// Increase the stack count.

target._stackingDrowning += 1;

</Custom Apply Effect>



<Custom Remove Effect>

// Reset the stack count.

target._stackingDrowning = 0;

</Custom Remove Effect>



<Custom Regenerate Effect>

// Make sure the stack count exists.

target._stackingDrowning = target._stackingDrowning || 1;

// Sets the maximum amount of stacks to 5.

var stacks = Math.min(5, target._stackingDrowning);

// The damage formula used per tick.

var damage = stacks * origin.mat * 2

// Play Drowning animation on the target.

target.startAnimation(1);

// Target takes HP damage.

target.gainHp(-damage);

// Play the popup.

target.startDamagePopup();

// Clear the results.

target.clearResult();

// Check if the target is dead.

if (target.isDead()) {

  // If the target is dead, make it collapse.

  target.performCollapse();

}

</Custom Regenerate Effect>
Do you mean in addition to the Stacking DoT notetags?
I don't know what that means. Did you look up the notetag when I suggested it? In the instructions, it provides a value variable that will be what the DoT hits for and an element variable that determines what the element of the damage will be.

So, as I said, you get rid of the Custom Regenerate Effect and fill out the Custom DoT Formula.

Code:
<Custom Apply Effect>
// Use existing stacks or set initial value
target._stackingDrowning = target._stackingDrowning || 0;

// Increase the stack count with a maximum of 5
if (target._stackingDrowning<5)
    target._stackingDrowning++;
</Custom Apply Effect>

<Custom Remove Effect>
// Reset the stack count.
target._stackingDrowning = 0;
</Custom Remove Effect>

<Custom DoT Formula>
// The damage formula used per tick.
value = target._stackingDrowning * origin.mat * 2;

// No variance, per your original formula
variance=0;

// Element 4, per your original notetag
element=4;

// Play Drowning animation on the target.
target.startAnimation(1);

</Custom DoT Formula>
I see. So you meant to replace the <Custom Regenerate Effect> completely with the DoT formula. I apologize for misunderstanding, and that you had to do so much heavy lifting. Thank you very much for the help.

Original thread: https://forums.rpgmakerweb.com/threads/2qs-yanfly-stacking-dot-damage-element-and-random-skill-item.149560/