[SOLVED]Yanfly absorption barrier

How do you make it such that when you use a skill that grants barrier points, it erases existing barrier points first?
I’m not 100% sure this will work. But you can try. Change “value” to the formula you’re using to give the amount of barrier you want to add.


target.gainBarrier(-(target.barrierPoints(-1)))
target.gainBarrier(value)
I’m not 100% sure this will work. But you can try. Change “value” to the formula you’re using to give the amount of barrier you want to add.


target.gainBarrier(-(target.barrierPoints(-1)))
target.gainBarrier(value)
Dude it worked, thanks! I tried using the one at the button whilst having the value set to zero. How'd you figure out the top line?
I use the plugin so I was just familiar with it.

barrierPoints(-1) is used to call upon the current barrier points something has.

I believe it’s near the bottom of the plugin help.

Out of curiosity, why do you want to remove the old barrier points when adding new ones?
I use the plugin so I was just familiar with it.

barrierPoints(-1) is used to call upon the current barrier points something has.

I believe it’s near the bottom of the plugin help.

Out of curiosity, why do you want to remove the old barrier points when adding new ones?

Now I see it ~_~.....

That's to prevent barrier stacking so that the barrier skills I have in game cannot be abused.
Ah, yea. I ran into the same issue, but I added a cap that would work independently of the formula for the amount of barrier added. Although, I am struggling to make it work with barrier regen right now.


One potential issue I see with your method is that the player could replace a large barrier with a smaller barrier (Ex, remove 500 barrier points to place 300). That may work as your intended use, though.
But, I see it an a potential issue because it is hard for the player to judge exactly how many barrier points they have as it doesn't show as a numerical value on screen (which I would like to see for my game).

One way you could fix this, if you wanted to, may be

var amount = formula
if (amount > target.barrierPoints(-1)) {
target.gainBarrier(amount - target.barrierPoints(-1));
}

This should only add barrier points if the current barrier is weaker than the one being cast. And would only add the difference of the skill strength and the current barrier. (I haven't tested it, though, so again not 100% sure this iteration would work).

Ex1, The target has 500 barrier points and your skill strength gives 300 points. The skill would do nothing. The 500 points would remain.
Ex2, The target has 500 barrier points and your skill strength gives 700 points. The skill would only add 200 additional points.


One thing I'm now thinking of adding is
target.startDamagePopup();

So that it displays how many barrier points are being added. But, I'd want to make the font color match the color of the barrier bar, which I am not sure how to do off the top of my head.
Ah, yea. I ran into the same issue, but I added a cap that would work independently of the formula for the amount of barrier added. Although, I am struggling to make it work with barrier regen right now.


One potential issue I see with your method is that the player could replace a large barrier with a smaller barrier (Ex, remove 500 barrier points to place 300). That may work as your intended use, though.
But, I see it an a potential issue because it is hard for the player to judge exactly how many barrier points they have as it doesn't show as a numerical value on screen (which I would like to see for my game).

One way you could fix this, if you wanted to, may be

var amount = formula
if (amount > target.barrierPoints(-1)) {
target.gainBarrier(amount - target.barrierPoints(-1));
}

This should only add barrier points if the current barrier is weaker than the one being cast. And would only add the difference of the skill strength and the current barrier. (I haven't tested it, though, so again not 100% sure this iteration would work).

Ex1, The target has 500 barrier points and your skill strength gives 300 points. The skill would do nothing. The 500 points would remain.
Ex2, The target has 500 barrier points and your skill strength gives 700 points. The skill would only add 200 additional points.


One thing I'm now thinking of adding is
target.startDamagePopup();

So that it displays how many barrier points are being added. But, I'd want to make the font color match the color of the barrier bar, which I am not sure how to do off the top of my head.

That's pretty cool dude, I think sumrnddude has a script to draw a separate bar for absorption barrier so you can try that and see if it works, otherwise, you might have to write in a separate script for it and place it below in the plugin manager.
It turns out target.startDamagePopup(); doesn't work to show the barrier being added.

I don't suppose you know of a similar script that might work in this case?


Also, I figured out why my regen spell wasn't working. I guess you can't reference "target" from a state. I changed everything to "user" and it works fine. Might be useful if you plan on using regen barriers.
You have to change your damage popup to this:

var result = target._damagePopup[x];

or just

target._damagePopup[x];

Where x is the label of the damage popup. To get this, I'm currently scouting through the script to find out what label Yanfly uses for that.

EDIT: This is from my rough script understanding btw.

EDIT 2:
Tried to make it so that it'd show the barrier points popup when the skill was used but no effect. Going to try a different approach.
<Custom User Barrier>

z = user.barrierPoints;

user.gainBarrier(-(user.barrierPoints(-1)));

user.gainBarrier(user.mp/4);

user._damagePopup [z];

</Custom User Barrier>
target._damagePopup[barrierHP];

This doesn't show an error for me, although it doesn't work either. But, I feel like it might be close..

Note:
My spell is cast on a target, whereas yours is only user.
And barrierHP is saved as a variable for how much barrier I gain.
target._damagePopup[barrierHP];

This doesn't show an error for me, although it doesn't work either. But, I feel like it might be close..

Note:
My spell is cast on a target, whereas yours is only user.
And barrierHP is saved as a variable for how much barrier I gain.

Is there a simple script call for damage/heal popup?

EDIT: More efficient way to clear barriers

user.clearAbsorptionBarrier();

change user to target and you're good.
I was hoping you knew the script call to bring up the damage.

It looks like the damage popup info built into the absorbtion plugin is used for taking damage, not so much applying the barriers.

I'm sure there must be a way, but it seems it's above my javascript knowledge. I pretty much work with trial and error. Haha.
I was hoping you knew the script call to bring up the damage.

It looks like the damage popup info built into the absorbtion plugin is used for taking damage, not so much applying the barriers.

I'm sure there must be a way, but it seems it's above my javascript knowledge. I pretty much work with trial and error. Haha.
I can do something with the battle log maybe but that'd be useless and very lacking. Hopefully someone answers my other thread.

EDIT: Got it.

<Custom User Barrier>

user.clearAbsorptionBarrier();

user.gainBarrier(user.mp/4);

user._result.hpDamage = -user.mp/4;

</Custom User Barrier>

Can't believe it was so simple :-/ A few things might need to be edited but that's it.
Hmm. That's not working for me. Even if I copy/ paste your code into a new skill.

Strange.

Edit: Even when turning off all plugins except yanfly's absorbtion barrier..
What is strange is that I can make the barrier number show up through console.log();

Well that's easy, you have no damage type to show so it won't show any damage popup. Change the damage type to HP recovery, MP Recovery, HP Damage or MP Damage for the script to work.

Using HP types may be best, haven't tested with MP yet.
Oh wow.. I feel stupid.. Perfect. Thanks for your help!

Now, I gotta look into how I go about changing the color of a popup for a specific skill. Not sure if that's even possible.

Making all my barriers a "barrier" element and finding how to change the popup for a specific element seems more likely to be possible.

Would you know how this is done, by chance? If not, I'll try to look around later.
Oh wow.. I feel stupid.. Perfect. Thanks for your help!

Now, I gotta look into how I go about changing the color of a popup for a specific skill. Not sure if that's even possible.

Making all my barriers a "barrier" element and finding how to change the popup for a specific element seems more likely to be possible.

Would you know how this is done, by chance? If not, I'll try to look around later.
An elemental barrier huh... well the first thing to do would be to change to popup color before implementing the barrier point change. You can do this from manipulating the core components that influence color from the script.

The only thing from the script that I can see with four color variables is at the window base right now and looking through the script is going to take me a while so I'll probably get back to this later.

But for now, nope, no clue how to do that.
I thought there would be a plugin that allows you to make all fire spell popup be red, all ice spells popup be blue and so on.

If there were one, I would make all my barrier spells a "barrier" element. But, it would be hidden from the player, and would operate in the exact same way as normal. It's only use would be to isolate the popup numbers to be changed color. I found no such plugin, though..

I did find 2 imperfect solutions. Both using SRD's Battle Popup Customizer.
http://sumrndm.site/battle-popup-customizer/

Solution 1:
I tried to play around with adding a custom popup.
I added user._result.gainBarrier = -user.mp/4; to the end of my code, which seemingly does nothing.
But, by adding result.gainBarrier > 0 in the custom condition box, it let me add a text to the popup.
However, changing the other paramaters of the custom popup only affect the text added.
The color of the number popup will always be the same as HP damage.


Solution 2:
This is a niche solution that should work well with my game because of way I intend to use TP. (I may have issues down the road, but I'll try to find a better solution if any issues come up).

I replaced the user._result.hpDamage = -user.mp/4; in the code with user._result.tpDamage = -user.mp/4;
(changed hp to tp)
Then in the TP Heal section of the popup plugin, I can add text to the line, and use all the other paramters to change the color for both the numbers and the text.
However, this means I won't be able to use the popup information for TP in my game, which I doubt I will.

Original thread: https://forums.rpgmakerweb.com/threads/solved-yanfly-absorption-barrier.87318/