Yanfly Questions

Hey all, I have two questions regarding two different Yanfly plugins.

1. Instant Cast

The documentation for the plugin has this line:

Note that if your actors can perform multiple actions, the instant cast will only occur if it is the very first action selected and not a subsequent one.

This seems to suggest that you can only use an instant cast once per turn and that it has to be the first action. However, testing it out, I'm able to use multiple instant casts in a turn. This is good because it's what I want to happen, but the line above has me worried that maybe it can cause me problems later. So, am I misunderstanding this line or...?

2. Absorption Barrier

I had the idea that a battler losing their barrier would trigger an effect like what you can do with a "Custom Leave Effect" added by BuffStateCore. Reading the documentation for Absorption Barrier, this doesn't seem possible with the notetags added by the plugin. However, I think it may still be possible by using a state. For example, a state that is added together with the barrier points and checks if the actor has any barrier points left, executing the effect and then removing itself. Thing is, I'm not really sure how to go about doing this. Any help/guidance is very much welcome!
Hey all, I have two questions regarding two different Yanfly plugins.

1. Instant Cast

The documentation for the plugin has this line:



This seems to suggest that you can only use an instant cast once per turn and that it has to be the first action. However, testing it out, I'm able to use multiple instant casts in a turn. This is good because it's what I want to happen, but the line above has me worried that maybe it can cause me problems later. So, am I misunderstanding this line or...?

2. Absorption Barrier

I had the idea that a battler losing their barrier would trigger an effect like what you can do with a "Custom Leave Effect" added by BuffStateCore. Reading the documentation for Absorption Barrier, this doesn't seem possible with the notetags added by the plugin. However, I think it may still be possible by using a state. For example, a state that is added together with the barrier points and checks if the actor has any barrier points left, executing the effect and then removing itself. Thing is, I'm not really sure how to go about doing this. Any help/guidance is very much welcome!
1. I believe it just means the moment you take a normal action (non instant) the turn concludes as normal. At least that's how I remember it working when I messed with it back in the day. The multiple actions mentioned I think is more as if you were lining up attacks somehow, maybe based off another of Yanfly's plugins. In that scenario Yanfly may mean that if an instant attack is meant to be part of this chain of attacks it needs to occur first. Though someone may need to correct me as it's been a while since I've messed with yanfly's stuff. I assume all is well since there is mention of using a skill restriction script with it as well, which I would assume attempts to mitigate the overuse of instant cast skills, such as cooldowns and such.

2. I never think I used absorption barrier but looking at it you can assign barrier points through states as well as regenerate them. If that is the case you should be able to still use buffs and states core in that manner. <Custom Remove Effect> or <Custom Leave Effect> should still work if the barrier itself functions as a state. If not then your idea of applying a state along side it could work. It could look something like this ...

Code:
<Custom Remove Effect>
if (user.battler.barrierPoints() === 0 && user.isAlive()) {
    // Check that user's barrier points are 0 and user is alive
    var skill = 3; // Set skill to 3
    var target = -1; // Set target to -1
    BattleManager.queueForceAction(user, skill, target); // Queue skill
   } else if (user.isAlive()) {
    // If user is alive (checking again for the case that actor is not dead and barrier points are not 0)
    user.addState(3); // Add state 3
};
</Custom Remove Effect>

....where it calls a skill to be activated if it detects that barrier points are 0 and the one the barrier just wore off of is still alive. Afterwards, it then removes the state. If it detects that barrier points are not 0 then it would reapply the state so it can check again once it expires once more. You'd put this in the state notebox that you want to track the barrier points with and set it to 1 turnand you'd replace the 3 with whatever skill ID needs to be called in var skill and the 3 in addstate to whatever the ID of this state is.

The var target = -1 is stating that our target is going to be set to a random selection out of available targets you set the scope of the skill to (ally or enemy) . If you stick -2 there it'll go after the last target.

My syntax may not be correct however, user.battler.barrierPoints() may need to be user.battler().barrerPoints() if it can even be accessed in that manner. I'm drawing from faded memories and a little instruction on Yanfly's site for absorbtion barrier so the actual implementation may be a bit dodgy. However, this should at least point you in a general direction to where you can start to toy around with it and see what works and what doesn't. There is a lot of documentation for yanfly's systems out there so it will probably relatively simple to find info on the snippets of code you need to achieve what you are aiming for. Hopefully, if my memory has failed me at some point in that someone will correct me on it. Anyhow, have a good one.
This seems to suggest that you can only use an instant cast once per turn and that it has to be the first action.
No - the line you quoted says "if they can perform multiple actions." Having access to instant cast skills doesn't mean the battler can perform multiple actions, it means you're using a plugin that ignores some of them.

Natively, battlers can have multiple actions by use of the Action Times+ trait. So that line is saying that in that scenario, instant cast will only be instant if it's the first action chosen.

I had the idea that a battler losing their barrier would trigger an effect like what you can do with a "Custom Leave Effect" added by BuffStateCore...However, I think it may still be possible by using a state. For example, a state that is added together with the barrier points and checks if the actor has any barrier points left, executing the effect and then removing itself.
You could do something like what you're suggesting and @kalian19 provided, but it's really more complicated than it has to be.

The very first plugin parameter in Absorption Barrier is for the ID of a state that's automatically present IFF a battler has any barrier points.

So you don't need the state to check for barrier points or remove itself, just assign a state ID there and define a Custom Remove Effect from Yanfly's Buffs & States.

Code:
if (user.battler.barrierPoints() === 0 && user.isAlive()) {
This isn't correct syntax. Neither actors nor enemies have a battler property. The word battler in Yanfly's plugin documentation indicates you can use the supplied barrier methods with any kind of battler, actors or enemies, and you need to supply your own reference.

So it would just be user.barrierPoints() == 0
No - the line you quoted says "if they can perform multiple actions." Having access to instant cast skills doesn't mean the battler can perform multiple actions, it means you're using a plugin that ignores some of them.

Natively, battlers can have multiple actions by use of the Action Times+ trait. So that line is saying that in that scenario, instant cast will only be instant if it's the first action chosen.


You could do something like what you're suggesting and @kalian19 provided, but it's really more complicated than it has to be.

The very first plugin parameter in Absorption Barrier is for the ID of a state that's automatically present IFF a battler has any barrier points.

So you don't need the state to check for barrier points or remove itself, just assign a state ID there and define a Custom Remove Effect from Yanfly's Buffs & States.


This isn't correct syntax. Neither actors nor enemies have a battler property. The word battler in Yanfly's plugin documentation indicates you can use the supplied barrier methods with any kind of battler, actors or enemies, and you need to supply your own reference.

So it would just be user.barrierPoints() == 0
Appreciate the clarification @ATT_Turan. 🙂 Been a minute since I messed around with all that and never really touched the absorption plugin before so I figured some corrections would probably be needed. @Nox_Aeternae, gl with your creation!
Thanks for the replies.

@ATT_Turan

I've done as you've suggested and created a state for the plugin, and added this as the custom remove effect:

JavaScript:
<Custom Remove Effect>
var int = ($gameVariables.value(12));
$gameVariables.setValue(12, int + 1);
</Custom Remove Effect>

However, having the barrier broken and thus the state removed doesn't increase the variable. Maybe I'm missing something obvious but haven't been able to figure this out yet.

Edit: I've done some more googling and stumbled onto this thread where Caethryl (Who I think I've also seen on this forum) says the plugin doesn't actually apply the state. If that is true, I would assume it doesn't actually get removed too, thus not triggering the custom remove effect. I've opened up the plugin to check if this is how it worked but admittedly the code was too advanced for me so I decided to give up on that route and make my own state.


JavaScript:
<Custom Respond Effect>
if (target.barrierPoints() == 0)  {
 target.removeState(30);
} 
</Custom Respond Effect>


<Custom Remove Effect>
var int = ($gameVariables.value(12));
$gameVariables.setValue(12, int + 1);
</Custom Remove Effect>

Having this for the state worked perfectly, I just have to remember to add the state whenever barriers are applied.
Edit: I've done some more googling and stumbled onto this thread where Caethryl (Who I think I've also seen on this forum) says the plugin doesn't actually apply the state.
Annoyingly, that's true. It's added behind the scenes when looking at the list of states the battler has, it's not added and removed when the barrier is.

I was just checking it out and returned to the thread to see your edit.

Having this for the state worked perfectly, I just have to remember to add the state whenever barriers are applied.
Another option would be to give the actor a passive state with the notetags:
Code:
<Custom Select Effect>
target.hadBarrier = target.barrierPoints() > 0;
</Custom Select Effect>

<Custom Respond Effect>
if (target.hadBarrier && !target.barrierPoints())
    $gameVariables.setValue(12, $gameVariables.value(12) + 1);
</Custom Respond Effect>

That will go off whenever they get hit by a skill that removes the last of their barrier, and you can just leave it on them.
@ATT_Turan

That seems like a more elegant solution than mine but the first part confuses me a bit. I've only ever used "=" to assign a value to a variable but it seems like you're using it to assign a conditional to the variable and then later checking that. Is my understanding correct?

Additionally, as far as I know, Auto Passive states cannot be removed and can only be disabled. I'm wondering if that could potentially cause issues like the effect triggering when it's not supposed to.
the first part confuses me a bit. I've only ever used "=" to assign a value to a variable but it seems like you're using it to assign a conditional to the variable and then later checking that.
It is assigning a value - any conditional statement produces the value true or false.

When it's checked in the second notetag, if (target.hadBarrier) is a shorter way of saying if (target.hadBarrier == true)

Additionally, as far as I know, Auto Passive states cannot be removed and can only be disabled. I'm wondering if that could potentially cause issues like the effect triggering when it's not supposed to.
I'm not sure what you mean. The code I gave you checks whether the target had barrier points before the attack resolves and does not have any left after the attack resolves - to my logic, that means the attack removed the last of the barrier.

What other circumstances could cause those conditions to be true?
@ATT_Turan

Ah, that makes perfect sense. And you're right, I can't think of any scenario that would cause the same conditions to be true. Thanks a bunch for the help!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-questions.168290/