RMMV How to make a DOT state effect that works on both Barrier & HP

Joined
Jul 23, 2021
Messages
5
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello, long time lurker here with a question regarding the extended custom regeneration effects formula and how to make a DOT effect hurt both HP and Barrier depending on the situation.
How can I go about making it so that the DOT effect inflicts barrier damage when the target has barrier but inflict direct HP damage when the barrier is out?
I can easily make it affect one or the other but I was wondering if there was a way to make the damage formula affect either HP or Barrier as needed? Attached below is what I've got as the current (non functioning) formula, as well as other notes I have in that state.
 

Attachments

  • Damage Formua Poison.PNG
    Damage Formua Poison.PNG
    36.6 KB · Views: 4
  • Poison Other Info.PNG
    Poison Other Info.PNG
    9.1 KB · Views: 4

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,882
Reaction score
980
First Language
English
Primarily Uses
RMMV
When you're asking questions that involve plugins, it's important to tell us (and provide links for reference) which plugins you're using. I'm assuming you're using Yanfly's Absorption Barrier, because it's the one I've heard of, but if it's someone else, the functionality would be different.

For example, if it's Yanfly's, I don't know why you have the question - the default behavior for that plugin is exactly what you describe, that all damage goes to the barrier first - that's the whole point of the system.

And, so, the second part of asking a question - you need to tell us what isn't working. Rather than just slapping out a few screens of code and saying it's non-functional, you need to describe what is wrong with it, how it's functioning differently from what you want. No one wants to read through your code without knowing what they're looking for :wink:
 
Joined
Jul 23, 2021
Messages
5
Reaction score
0
First Language
English
Primarily Uses
RMMV
Right, my apologies. To clarify yes I'm using Yanfly's Absorbtion Barrier Plugin and Extended DOT plugins. In fact most of my Plugins are from Yanfly. I've attached a complete list of all the Plugins I'm using, and what order they are in.

As for the damage formula, what's happening in my broken one is there is no damage tick for some reason. Whenever a turn ends nothing happens, not even a damage tick of zero. There are two separate versions of the damage formula that do work, one for affecting only barriers and one for affecting HP directly. I'll go ahead and attach those as well. It's just than when I attempt to combine them in an "if" statement it doesn't even do damage anymore.
Here's the full version of the formula again for reference, slightly modified but still not doing any damage:

<Custom Apply Effect>
// Calculate the damage to be dealt by the formula.
target._mercuryPoison = Math.ceil(origin.mat);
</Custom Apply Effect>

<Custom Remove Effect>
// Remove the damage effect.
target._mercuryPoison = undefined;
</Custom Remove Effect>

<Custom Regenerate Effect>
//Check to see if the target has any barrier points
if (target.barrierPoints() > 0) {
// Default the DoT formula.
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
// Play an animation on the target.
target.startAnimation(67);
// Reduce the target's HP
target.loseBarrier(target._mercuryPoison);
// Start the damage popup.
target.startDamagePopup();
// Check if the target is dead.
if (target.isDead()) {
// Make the target collapse.
target.performCollapse();
}
// Clear the target's results.
target.clearResult();
}
Else {
// Default the DoT formula.
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
// Play an animation on the target.
target.startAnimation(12);
// Reduce the target's HP
target.gainHp(-target._mercuryPoison);
// Start the damage popup.
target.startDamagePopup();
// Check if the target is dead.
if (target.isDead()) {
// Make the target collapse.
target.performCollapse();
}
// Clear the target's results.
target.clearResult();
}
</Custom Regenerate Effect>

As for it being default, Any time I've tried to use DOT effects, custom or not it just directly damages HP.

Also, thanks for getting back to me so quickly.
 

Attachments

  • Plugins1.PNG
    Plugins1.PNG
    293.8 KB · Views: 1
  • Plugins2.PNG
    Plugins2.PNG
    322.2 KB · Views: 1
  • Plugins3.PNG
    Plugins3.PNG
    301.8 KB · Views: 0
  • Plugins4.PNG
    Plugins4.PNG
    286.7 KB · Views: 0
  • Plugins5.PNG
    Plugins5.PNG
    284.8 KB · Views: 0
  • Plugins6.PNG
    Plugins6.PNG
    284.6 KB · Views: 0
  • Plugins7.PNG
    Plugins7.PNG
    298.8 KB · Views: 0
  • Plugins8.PNG
    Plugins8.PNG
    301.7 KB · Views: 0
  • Plugins9.PNG
    Plugins9.PNG
    124.3 KB · Views: 0
  • HP DOT.PNG
    HP DOT.PNG
    25.7 KB · Views: 0
  • BarrierDOT.PNG
    BarrierDOT.PNG
    26.6 KB · Views: 1
Joined
Jul 23, 2021
Messages
5
Reaction score
0
First Language
English
Primarily Uses
RMMV
When you're asking questions that involve plugins, it's important to tell us (and provide links for reference) which plugins you're using. I'm assuming you're using Yanfly's Absorption Barrier, because it's the one I've heard of, but if it's someone else, the functionality would be different.

For example, if it's Yanfly's, I don't know why you have the question - the default behavior for that plugin is exactly what you describe, that all damage goes to the barrier first - that's the whole point of the system.

And, so, the second part of asking a question - you need to tell us what isn't working. Rather than just slapping out a few screens of code and saying it's non-functional, you need to describe what is wrong with it, how it's functioning differently from what you want. No one wants to read through your code without knowing what they're looking for :wink:
Sorry about that, I thought I posted as a reply to your post, but I didn't.

I've posted the entire formula above, as well as listed all Plugin's I've got in attachments.
As for what is broken in it, the formula I have doesn't seem to even register any damage, even ticks of 0. Every round no damage of any kind occurs.
Here's that formula again:
<Custom Apply Effect>
// Calculate the damage to be dealt by the formula.
target._mercuryPoison = Math.ceil(origin.mat);
</Custom Apply Effect>

<Custom Remove Effect>
// Remove the damage effect.
target._mercuryPoison = undefined;
</Custom Remove Effect>

<Custom Regenerate Effect>
//Check to see if the target has any barrier points
if (target.barrierPoints() > 0) {
// Default the DoT formula.
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
// Play an animation on the target.
target.startAnimation(67);
// Reduce the target's HP
target.loseBarrier(target._mercuryPoison);
// Start the damage popup.
target.startDamagePopup();
// Check if the target is dead.
if (target.isDead()) {
// Make the target collapse.
target.performCollapse();
}
// Clear the target's results.
target.clearResult();
}
Else {
// Default the DoT formula.
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
// Play an animation on the target.
target.startAnimation(12);
// Reduce the target's HP
target.gainHp(-target._mercuryPoison);
// Start the damage popup.
target.startDamagePopup();
// Check if the target is dead.
if (target.isDead()) {
// Make the target collapse.
target.performCollapse();
}
// Clear the target's results.
target.clearResult();
}
</Custom Regenerate Effect>


As for DOT affecting barriers by default, Any time I've tried to use DOT effects, custom or not, it just directly damages HP.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,882
Reaction score
980
First Language
English
Primarily Uses
RMMV
So I haven't looked into the plugin code, but I believe your problem is relying on the Custom Regenerate Effect. The description of that notetag says "This effect will run whenever the battler would regenerate HP, MP, or TP." Your skill isn't doing anything that innately causes the battler to regenerate anything (and no one regenerates anything at the end of a turn by default), so there isn't an event to trigger the custom effect.

I think you might want to look into the Yanfly+Tigress Extended Damage Over Time plugin, this actually makes states inflict damage at the end of each turn, with the option of using custom formulae. Or replace it with a Custom Turn End Effect using your existing plugins.

As far as the barrier bit...I'm not sure what to say there. The plugin description says all damage should go to the barrier first unless it's given the penetrating notetag. Aside from the above changes to make this skill work, can you post a screenshot of an effect that does damage which ignores barriers?

P.S. I don't know how you have everything typed out in your note boxes, but if you use the code tag in your posts (the rightmost icon on top), it will preserve indented lines and be easier to read.
 
Joined
Jul 23, 2021
Messages
5
Reaction score
0
First Language
English
Primarily Uses
RMMV
So I haven't looked into the plugin code, but I believe your problem is relying on the Custom Regenerate Effect. The description of that notetag says "This effect will run whenever the battler would regenerate HP, MP, or TP." Your skill isn't doing anything that innately causes the battler to regenerate anything (and no one regenerates anything at the end of a turn by default), so there isn't an event to trigger the custom effect.

I think you might want to look into the Yanfly+Tigress Extended Damage Over Time plugin, this actually makes states inflict damage at the end of each turn, with the option of using custom formulae. Or replace it with a Custom Turn End Effect using your existing plugins.

As far as the barrier bit...I'm not sure what to say there. The plugin description says all damage should go to the barrier first unless it's given the penetrating notetag. Aside from the above changes to make this skill work, can you post a screenshot of an effect that does damage which ignores barriers?

P.S. I don't know how you have everything typed out in your note boxes, but if you use the code tag in your posts (the rightmost icon on top), it will preserve indented lines and be easier to read.

Well, that tag might not be the best in the long run so I'll have to update but the custom regenerate tag honestly works fine. I have two formulas for either a Barrier DOT or a regular DOT that directly damages HP and by themselves they work fine. And as for the Extended DOT I've tried switching it up and using the tags from that plugin and same issues: the DOT doesn't seem to trigger at all, no damage ticks, even of 0.

Here's the formula, this time using the custom DOT tags from Yanfly+Tigress Extended Damage Over Time plugin
Code:
<Custom DoT Formula>

//Check to see if the target has any barrier points

if (target.barrierPoints() > 0) {

// Default the DoT formula.

target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);

// Play an animation on the target.

target.startAnimation(67);

// Reduce the target's HP

target.loseBarrier(target._mercuryPoison);

// Start the damage popup.

target.startDamagePopup();

// Check if the target is dead.

if (target.isDead()) {

  // Make the target collapse.

  target.performCollapse();

}

// Clear the target's results.

target.clearResult();

}

Else {

// Default the DoT formula.

target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);

// Play an animation on the target.

target.startAnimation(12);

// Reduce the target's HP

target.gainHp(-target._mercuryPoison);

// Start the damage popup.

target.startDamagePopup();

// Check if the target is dead.

if (target.isDead()) {

  // Make the target collapse.

  target.performCollapse();

}

// Clear the target's results.

target.clearResult();

}

</Custom DoT Formula>


Also I attached two states that deal damage, that always ignore Barriers and directly damage HP. One is a pretty vanilla poison effect that uses the standard -HP regen stat and the other uses Yanfly's DOT plugin to give a custom but simple DOT damage formula. It also deals direct HP damage.

I've also attached the Barrier DOT effect I made, which works but as expected is only good for damaging Barriers only.

Ps: Thanks for pointing out the code button, I literally would never have even seen it.
 

Attachments

  • Basic Poison.PNG
    Basic Poison.PNG
    236.4 KB · Views: 1
  • Custom DOT Poison.PNG
    Custom DOT Poison.PNG
    207 KB · Views: 1
  • BarrierDOT.PNG
    BarrierDOT.PNG
    26.6 KB · Views: 1

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,882
Reaction score
980
First Language
English
Primarily Uses
RMMV
Well, that tag might not be the best in the long run so I'll have to update but the custom regenerate tag honestly works fine. I have two formulas for either a Barrier DOT or a regular DOT that directly damages HP and by themselves they work fine.
I wouldn't have thought that would function, but I'll take your word for it!
And as for the Extended DOT I've tried switching it up and using the tags from that plugin and same issues: the DOT doesn't seem to trigger at all, no damage ticks, even of 0.
Yeah, you have some flaws in your code.
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
I'm not sure exactly what you want this line to do, but you're setting mercuryPoison equal to the result of an evaluation. When you say "this equals this or this," the result will be true or false. In this case, it will always be true because Math.ceil() will always provide you with an integer value, and thus be true. So after this line of code, target._mercuryPoison has no numerical value, it will be equal to "true."
target.loseBarrier(target._mercuryPoison);
That means this won't do anything because you're telling it to damage the barrier by an amount of "true." I'm surprised this doesn't pop any kind of error in your console, but JavaScript is overly forgiving for my tastes.
target.startDamagePopup();
And then I wouldn't expect this to do anything, because nothing is taking damage.
target.gainHp(-target._mercuryPoison);
The same happens when you get all the way down here, you're telling the target to gain negative "true" HP.

So if you fix that line to more accurately do what you want (and if you're not sure how, just tell me what you're trying to achieve), I think it should do what you want.
Also I attached two states that deal damage, that always ignore Barriers and directly damage HP. One is a pretty vanilla poison effect that uses the standard -HP regen stat and the other uses Yanfly's DOT plugin to give a custom but simple DOT damage formula. It also deals direct HP damage.
I was able to duplicate this. This, to me, is undesirable behavior, so I'll see if I can't work up a snippet for you to make all of this coding unnecessary, as I would also want DoTs to hit the barrier.

Copy this and save it as a .js file in your plugins folders, then add it into your plugin manager beneath the Absorption Barrier.
Code:
Game_Battler.prototype.gainHp = function(value) {
    var blocked=false;
    if (value<0 && !BattleManager._subject && this.barrierPoints()>0)
    {
        var damage=-value;
        damage = this.loseBarrier(damage, 1, 0);
        if (!damage)
            blocked=true;
        else
            value=-damage;
    }
    if (!blocked)
    {
        this._result.hpDamage = -value;
        this._result.hpAffected = true;
        this.setHp(this.hp + value);
    }
};

This should cause all sources of damage, even outside of direct damage from a skill, to get absorbed by the barrier. It should not interfere with the normal functioning of barriers, or cause them to get double hit or anything.

The limitation is that outside of using a skill/item, the game doesn't know where the damage came from. So you can't modify your DoTs with the barrier penetration tags or anything like that. But this should eliminate the need for most of your code in your state...just directly call gainHp() with the calculation you want.
 
Last edited:
Joined
Jul 23, 2021
Messages
5
Reaction score
0
First Language
English
Primarily Uses
RMMV
I wouldn't have thought that would function, but I'll take your word for it!

Yeah, you have some flaws in your code.

I'm not sure exactly what you want this line to do, but you're setting mercuryPoison equal to the result of an evaluation. When you say "this equals this or this," the result will be true or false. In this case, it will always be true because Math.ceil() will always provide you with an integer value, and thus be true. So after this line of code, target._mercuryPoison has no numerical value, it will be equal to "true."

That means this won't do anything because you're telling it to damage the barrier by an amount of "true." I'm surprised this doesn't pop any kind of error in your console, but JavaScript is overly forgiving for my tastes.

And then I wouldn't expect this to do anything, because nothing is taking damage.

The same happens when you get all the way down here, you're telling the target to gain negative "true" HP.

So if you fix that line to more accurately do what you want (and if you're not sure how, just tell me what you're trying to achieve), I think it should do what you want.

I was able to duplicate this. This, to me, is undesirable behavior, so I'll see if I can't work up a snippet for you to make all of this coding unnecessary, as I would also want DoTs to hit the barrier.

Copy this and save it as a .js file in your plugins folders, then add it into your plugin manager beneath the Absorption Barrier.
Code:
Game_Battler.prototype.gainHp = function(value) {
    var blocked=false;
    if (value<0 && !BattleManager._subject && this.barrierPoints()>0)
    {
        var damage=-value;
        damage = this.loseBarrier(damage, 1, 0);
        if (!damage)
            blocked=true;
        else
            value=-damage;
    }
    if (!blocked)
    {
        this._result.hpDamage = -value;
        this._result.hpAffected = true;
        this.setHp(this.hp + value);
    }
};

This should cause all sources of damage, even outside of direct damage from a skill, to get absorbed by the barrier. It should not interfere with the normal functioning of barriers, or cause them to get double hit or anything.

The limitation is that outside of using a skill/item, the game doesn't know where the damage came from. So you can't modify your DoTs with the barrier penetration tags or anything like that. But this should eliminate the need for most of your code in your state...just directly call gainHp() with the calculation you want.

Oh geez, upon looking at
Code:
target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.mat * 0.50);
I can see that it is plainly busted. The original line from my previous game worked fine, I must've butchered it somewhere down the line without realizing it. I'm also pretty surprised it never threw an error.

I'll see about fixing that line for more complicated DOT's but either way thanks' a million! The code you gave me works like a charm. I put that into plugins and put it right underneath the Absorption Barrier plugin and all DOT effects work wonders now.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,435
Reaction score
15,227
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Thank you.

 

Latest Threads

Latest Profile Posts

Just released a new trailer for Manafinder! It's the TGS trailer! :D I'm very happy with the result!
sooo... im gonna go ahead and release all my game ideas on android as Beta. Everyone will be nice right? cause its Beta... right?...

AABS traps and heals (detail is below the YTB desc)
 I may actually have something I can put into the Boss Battle Build Bout by the time it’s due. It won’t be anything spectacular (or even great (and maybe not even good (I have no idea how to do combat (yay for nested parentheses)))), but I might have a submission none the less.
Today's my first login since Jan 2020. Time sure flies. Sorry to everyone's messages i missed.

Forum statistics

Threads
115,407
Messages
1,089,632
Members
150,147
Latest member
Arnard
Top