MV [Solved]Referencing Absorption Barrier points as a 'counter' in a state.

Hello!

I'm trying to do exactly as the title states.
Whenever a battler uses a skill that gives a barrier, I also give the battler a state that has this:

Code:
<Custom Apply Effect>
var points = user.barrierPoints();
// Update the state counter by barrierpoints
   user.setStateCounter(stateId, points);
</Custom Apply Effect>

I'm not sure why it's only showing 0 in the counter of the state.
I've moved this thread from JS Plugin Releases to Javascript/Plugin Support. Releases is for completed plugins that you're publishing here on the forums. Thank you!
Okay thank you!
We'd have to see your skill in the database to know how you set up your skill. But if you're just adding the state using the Effects list, absorption barrier notetags don't resolve until after that, which is why your state is correctly picking up 0 points.

To get the order of operations as necessary, you'd have to apply the barrier points earlier using a Skill Core notetag (e.g. Before Eval).

Also, note that that counter will not track the user's barrier points. It will display however many they had when you applied the state, but it won't change as they get hit and lose them.
We'd have to see your skill in the database to know how you set up your skill. But if you're just adding the state using the Effects list, absorption barrier notetags don't resolve until after that, which is why your state is correctly picking up 0 points.

To get the order of operations as necessary, you'd have to apply the barrier points earlier using a Skill Core notetag (e.g. Before Eval).

Also, note that that counter will not track the user's barrier points. It will display however many they had when you applied the state, but it won't change as they get hit and lose them.

I see, so basically for it to ‘update’ I need to set up another state that is going to replace the first state with the original barrier points after the battler gets damaged?
I see, so basically for it to ‘update’ I need to set up another state that is going to replace the first state with the original barrier points after the battler gets damaged?
I would submit that's an inefficient approach. You could simply give this state a Custom Respond Effect that recalculates the counter.

You know you don't need to have the putting the state on inside your skill, right? The very first plugin parameter in Absorption Barrier is the ID of a state to automatically apply when the battler gets any barrier points.

Have you looked at any other display options? There's the gauge on the battle status window that comes included with the plugin. Then there are existing plugins to add a barrier gauge to the battler, like this:
I would submit that's an inefficient approach. You could simply give this state a Custom Respond Effect that recalculates the counter.

You know you don't need to have the putting the state on inside your skill, right? The very first plugin parameter in Absorption Barrier is the ID of a state to automatically apply when the battler gets any barrier points.

Have you looked at any other display options? There's the gauge on the battle status window that comes included with the plugin. Then there are existing plugins to add a barrier gauge to the battler, like this:
Yes, unfortunately I already tried that plugin and it’s incompatible with the other plugins I’m using. I also thought if it looks like a state counter than a gauge like for HP/MP, it would look better.

Unfortunately I don’t quite understand your second statement, my english is failing me.
Screenshot 2023-06-25 144733.png
Screenshot 2023-06-25 144824.png
Oh right, yes thank you for pointing that out, I wasn't using that because I thought it would be bad if I make everyone that has a barrier point have the same states.
I tried using these state tags:

Code:
<Custom Apply Effect>
var points = user.barrierPoints();
user.setStateCounter(stateId, points);
</Custom Apply Effect>

<Custom Respond Effect>
var points = user.barrierPoints();
user.setStateCounter(stateId, points);
</Custom Respond Effect>
 - - - - - - - - - -
<Custom Apply Effect>
user.setStateCounter(stateId, user.barrierPoints());
</Custom Apply Effect>

<Custom Respond Effect>
user.setStateCounter(stateId, user.barrierPoints());
</Custom Respond Effect>

And the skill:

Code:
Add Barrier Before State
<Before Eval>
user.gainBarrier(12, 1)
</Before Eval>


Neither works.
The barrier was applied, I tried damaging the enemy and the barrier damage numbers show up which means they have the barrier with the correct amount(12).
The state also was applied, but there was no counter.
Do you have displaying the counter enabled in the plugin parameters for Buffs & States?

If you're applying the state through the Absorption Barrier plugin parameter now, it doesn't matter how you put the barrier on. You could use the Before Eval or the normal Absorption Barrier notetags.

Edit: Okay, there's what I'd say is a bug in Absorption Barrier. When you have a state in that plugin parameter, it does not call any Custom Apply Effect. I guess it's treated like a passive state that's just toggled on and off.

So you have to go back to applying the state through the skill, then using Before Eval to put the barrier on first. This works in my test game.
Screenshot 2023-06-25 154159.png
Screenshot 2023-06-25 154036.png
Do you have displaying the counter enabled in the plugin parameters for Buffs & States?

If you're applying the state through the Absorption Barrier plugin parameter now, it doesn't matter how you put the barrier on. You could use the Before Eval or the normal Absorption Barrier notetags.
Yes they are on.
I am seeing the counters on my other states that are working properly.

I attached 3 images that show how it is at the moment.
As you can see, the shield icon which was the state that's supposed to count how much barrier the user has is there, but there's no number on it.

After I attacked it once, another state appeared which has a counter on top of it, so I know that the counter does work on other states, and the purple damage number indicates that the barrier was applied properly.
See the edit in my post above.
See the edit in my post above.
The counter works as soon as the state is applied now, with the appropriate value and the barrier does work as well.

Only thing that's missing is for it to update when the barrier value changes.

I've tried these:
Code:
<Custom Respond Effect>
user.removeStateCounter(stateId)
user.setStateCounter(stateId, user.barrierPoints());
</Custom Respond Effect>

- - - - - - - - - -

<Custom Respond Effect>
user.getStateCounter(stateId)
</Custom Respond Effect>

But they both don't do anything from what I saw.
I'm not sure what the point of the second notetag is, just getting the current counter number and not doing anything it...wouldn't do anything.

The first one should work, I should think. I don't see any reason you'd need the first line, removing the counter, just the second line.

It could be another example of the timing being wrong, maybe the Custom Respond happens before damage is subtracted from the barrier. Have you tried putting it into a Custom Deselect Effect?
Respond effect is for when you are the target of an action, so try replacing user with target?
I'm not sure what the point of the second notetag is, just getting the current counter number and not doing anything it...wouldn't do anything.

The first one should work, I should think. I don't see any reason you'd need the first line, removing the counter, just the second line.

It could be another example of the timing being wrong, maybe the Custom Respond happens before damage is subtracted from the barrier. Have you tried putting it into a Custom Deselect Effect?

Oh sorry there's a confusion.
I was trying to show that I used the first notetag, and then when that didn't work, I tried the notetag below that. I did not use them both at the same time.

Yes I tried Deselect as well and it doesn't register.

I was thinking maybe the actor would have a passive state so that all the damaging skills would apply another state on the enemy which removes the state that sets the counter, and then replace it with a new counter with the current remaining barrier points. But it sounds so complicated, there must be another way..
Respond effect is for when you are the target of an action, so try replacing user with target?
It worked when I changed user into target.

I'm not sure what the point of the second notetag is, just getting the current counter number and not doing anything it...wouldn't do anything.

The first one should work, I should think. I don't see any reason you'd need the first line, removing the counter, just the second line.

It could be another example of the timing being wrong, maybe the Custom Respond happens before damage is subtracted from the barrier. Have you tried putting it into a Custom Deselect Effect?

You're both lifesavers. Thank you for helping me.
I still have a long way to go, but I appreciate all the help I'll keep on learning.
Thank you very much, sorry for the troubles.

Original thread: https://forums.rpgmakerweb.com/threads/solved-referencing-absorption-barrier-points-as-a-counter-in-a-state.158682/