MV Help: Allaister's Blocking Plugin - Making skills and items affect block rate.

Hey. I want to make a skill that affects block rate, just like you can with critical rate.

AP_Blocking Plugin and Desc

My end goal is to make blocking and critical hitting polar opposites, one doubles damage, one halves damage.

Skills and Items will be able to affect the rate of all moves being blocked by a percentile increase or decrease.

I am just getting familiar with notetags, but by reading the values given in the AP_Blocking's description, there is only <Ignore blocking> in it. Is there still a way to achieve this within the skill database notetags?

RPGMaker MV latest.
untested, but it looks like for the block rate parameters you can do something like
Code:
(user.def + user.agi) * 0.05 * user.stateRate(20)
and then reserve state 20 (or any state you want) to be the "block rate" state. that way you can make any state, gear, etc. affect your block chance by giving it a state rate trait for that state
This assumes I know what exactly a state is... you're referring to states like Poison, Knockout, Sleep, etc, correct?

What is state 20?

Also, sounds a bit messy if you ask me, having to call a bunch of states. Is there a limit on how many states I can have, and how much they can stack (if they can?)

In my efforts, I want to use X skill twice. X Skill will increase the stack by 1 each time (while Y skill will increase the stack by 2, and so forth...) Each stack increase will in turn add to the multiplier of the user's block rate
This assumes I know what exactly a state is... you're referring to states like Poison, Knockout, Sleep, etc, correct?
yes. the same terminology the engine uses to reduce the odds of a misunderstanding 😉

What is state 20?
the 20th state in the states section of the database. but as i said, it could be any state.

Also, sounds a bit messy if you ask me, having to call a bunch of states.
when you said
Skills and Items will be able to affect the rate of all moves being blocked by a percentile increase or decrease.
i assumed you meant that these skills and items would be adding states to battlers to adjust their block rates the same way it works for critical hits, but as a percentage increase. The way the crit rate is changed is by crit rate/evasion traits. skills/items do it by adding states with those traits to battlers. Especially since said states have durations to signify when such effects should end.

Is there a limit on how many states I can have, and how much they can stack (if they can?)
there is no limit, and states do not stack. plugins can change both.

In my efforts, I want to use X skill twice. X Skill will increase the stack by 1 each time (while Y skill will increase the stack by 2, and so forth...) Each stack increase will in turn add to the multiplier of the user's block rate
you can do that with yanfly's skill core plugin. change the parameter to
Code:
(user.def + user.agi) * 0.05 + (user._blockBoost/20 || 0)
and give the skills the notetag
Code:
<After Eval>
var stacks = 1;
user._blockBoost = (user._blockBoost + stacks) || stacks;
</After Eval>
change the 1 in the first line to the number of stacks the skill should give. each stack will add a flat +5%.
I did a very peculiar method of simply creating separate states, each state will be accessed by a common event, is this a good method? I could do your method, but vars are limited afaik (since XP), and I need lots of them.

Screenshot 2025-04-28 093241.png
I did a very peculiar method of simply creating separate states, each state will be accessed by a common event, is this a good method?
if it works for you, it works for you.

but vars are limited afaik (since XP), and I need lots of them.
i dont understand what you mean by the JS vars being limited (especially in a way that states are not).
Ok, so, how do I make sure that var "stacks" or "agility level" or whatever does not interfere between objects? Say, my character does agility, and then the opponent does something that also changes agility. The counter will reset or change based on who did the move. How do I get around this?

I was thinking of making a local var within the state or object, but after searching the internet for some tutorials, nothing's coming up.
I was thinking of making a local var within the state or object, but after searching the internet for some tutorials, nothing's coming up.
the code within yanfly's JS notetags is in most cases ran in an eval() within a method of an existing object. there are usually predefined variables by yanfly that refer to specific objects (i.e. "user" within <after eval> is the user of the skill) and all declared variables within both that method and the eval are disposed of once that method has completed. JS lets you write properties directly onto specific objects after their creation without the need of having them defined as attributes within the class. Those are what remain (i.e. user._blockBoost).

Ok, so, how do I make sure that var "stacks" or "agility level" or whatever does not interfere between objects?
the stacks variable cant interfere with anything because it doesnt exist at any point besides when its being used. your agility level is a state. its affect on the battler's agi only affects that battler's agi. that _blockBoost property only exists on that battler. if you make another on another battler, thats an entirely independent one on another battler with a different value

Say, my character does agility, and then the opponent does something that also changes agility. The counter will reset or change based on who did the move. How do I get around this?
Youre being unclear. youll have to explain what you want, explain you tried doing, and show what you did in that common event.

if agility a skill that your actor is using to give themself an "agility level" state with your common event, by "the opponent does something that also changes agility" you meant the enemy is able to lower your actor's agility level through that same common event, and the common event has the logic within it to dispense the correct versions of the state while removing the others, then yes. wouldnt that have been the point of them trying to lower your agility?

Or did you mean the enemy does something to raise their own agility and its affecting the actor's? because that would mean your common event doesnt have the logic to apply the agility level to specific battlers.
the code within yanfly's JS notetags is in most cases ran in an eval() within a method of an existing object. there are usually predefined variables by yanfly that refer to specific objects (i.e. "user" within <after eval> is the user of the skill) and all declared variables within both that method and the eval are disposed of once that method has completed. JS lets you write properties directly onto specific objects after their creation without the need of having them defined as attributes within the class. Those are what remain (i.e. user._blockBoost).
So, your saying that I can eval() the user, whether it's an actor or enemy? Cause if so, that would really help! For instance, how to determine if the attacker is an actor or enemy... and how to script it. (Again, I've looked into the internet for a tut or code, but I couldn't find one for MV specifically, only VXAce or MZ... I'm still learning how to script my own code myself, but it's a VERY slow process...)

the stacks variable cant interfere with anything because it doesnt exist at any point besides when its being used. your agility level is a state. its affect on the battler's agi only affects that battler's agi. that _blockBoost property only exists on that battler. if you make another on another battler, thats an entirely independent one on another battler with a different value
No, that's not what I mean, and your correct, stacks cannot interfere because they exist only on the object. However, a common engine based variable, or a pointer to actor or enemy, will cause conflicts if used in multiple places, if you understand what I mean.

Screenshot 2025-04-29 232201.png


Here in this image, you have a state that points to a single actor (or the party.)

There's a similar case for enemies.

If you make an event that must check for which actor or enemy used a previous skill to change their state, you will run into a scoping problem using the engine's base editor (not scripting)

Youre being unclear. youll have to explain what you want, explain you tried doing, and show what you did in that common event.

if agility a skill that your actor is using to give themself an "agility level" state with your common event, by "the opponent does something that also changes agility" you meant the enemy is able to lower your actor's agility level through that same common event, and the common event has the logic within it to dispense the correct versions of the state while removing the others, then yes. wouldnt that have been the point of them trying to lower your agility?
No, that is not what I meant.

Or did you mean the enemy does something to raise their own agility and its affecting the actor's? because that would mean your common event doesnt have the logic to apply the agility level to specific battlers.
This.

This is the tutorial I'm following:

Creating a Stacking Buff System (YEP)

And this is what I'm doing:

Screenshot 2025-04-29 230334.png


First I created the skill Agility. It will call a common event, also known as Agility


Screenshot 2025-04-29 230558.png


This will increase the variable 0003, known as agility level, by 1. What I think this does is raise the agility level state.

then I call the agility level manager common event.

Screenshot 2025-04-29 224507.png

What this does, in full, is change states of Agility Level to the state that the variable of the level is at.

This mostly mimics the tutorial given. However, we run into a problem: Scoping

by default, we cannot check if the attacker/caster is an enemy or an ally. This will create problems if "Agility" was used by a different player, or even an enemy. If I give, say, both "Reid" and "Marcus" the skill "Agility", and change the state for Reid, then if marcus executes the skill, reid will get the buff! The same can be said for enemies!

Sorry for the late post, I was busy trying to debug this myself and doing other stuff.

EDIT 1: I looked over your piece of code, and just realized that this will work, but only for the blocking formula. I haven't been able to replicate this to much success with other stats, like critical, evasion, hp, etc.


In my efforts, I want to use X skill twice. X Skill will increase the stack by 1 each time (while Y skill will increase the stack by 2, and so forth...) Each stack increase will in turn add to the multiplier of the user's block rate


you can do that with yanfly's skill core plugin. change the parameter to


JavaScript:
(user.def + user.agi) * 0.05 + (user._blockBoost/20 || 0)

and give the skills the notetag


JavaScript:
<After Eval>
var stacks = 1;
user._blockBoost = (user._blockBoost + stacks) || stacks;
</After Eval>
change the 1 in the first line to the number of stacks the skill should give. each stack will add a flat +5%.
I think I may have to change the formulas that are hardcoded or in plugins to change the rates, correct?

and please tell me, how do I reduce the stacks below zero? By just removing the "|| 0" part? I want block to be lowest of -6 stack stages, and highest of 6 stack stages. Maybe do something like "|| -6".

Also, I don't know if we're on the same page of the term "Stacks"... we are referring to a single stack of 6 boosts, correct? Not like 1 stack of x boosts, then another stack of x boosts. Cause from my tinkering and understanding, Yanfly already implements multiple "boosts".

My goal I'm trying to accomplish is boosting or reducing the stats, to a low of -6 reductions, and a high of +6 boosts. For Block and Crit Rate ONLY, increases and decreases in stats are by an additive of 5%, so, +/-0.05%, +/-0.10%, +/-0.15%, etc. For the rest of the stats, increases and decreases are by a multiplier of 25% increments or decriments, so, (Reduction) *40%, *44.4%, *50%, 57.1% *66.6%, *80%, (Boosts) *125%, *150%, *175%, *200%, *225%, *250%. I don't know of a formula that can quickly calculate that, so I was going to do it through states and common events.


Sorry for all the questions, I'm still learning as I go.
So, your saying that I can eval() the user, whether it's an actor or enemy? Cause if so, that would really help!
in short, yes. the user variable within the after eval notetag will always refer to the user of the skill, regardless of if theyre an enemy or an actor.
For instance, how to determine if the attacker is an actor or enemy... and how to script it. (Again, I've looked into the internet for a tut or code, but I couldn't find one for MV specifically, only VXAce or MZ... I'm still learning how to script my own code myself, but it's a VERY slow process...)
isActor() and isEnemy() are methods that both actors and enemies will have thatll return true or false based on what kind of battler they are. past that website, the only other resource i can give for mv specific code is to look into the js files of your project. i know you said you had some degree of familiarity with ruby, but id recommend learning js and its specific quirks before then.

However, a common engine based variable, or a pointer to actor or enemy, will cause conflicts if used in multiple places, if you understand what I mean... you will run into a scoping problem using the engine's base editor (not scripting)
i never suggested to use a common event for a number of reasons - the main one being that its much easier using yanflys notetags to reference battlers such as "the one currently acting" and "the one being targeted"
If I give, say, both "Reid" and "Marcus" the skill "Agility", and change the state for Reid, then if marcus executes the skill, reid will get the buff! The same can be said for enemies!
which is exactly why i suggested using the after eval notetag and the user reference in the first place.

I looked over your piece of code, and just realized that this will work, but only for the blocking formula. I haven't been able to replicate this to much success with other stats, like critical, evasion, hp, etc.
I think I may have to change the formulas that are hardcoded or in plugins to change the rates, correct?
yes. it was intended for the blocking formula. you never mentioned wanting it to work for anything else other than that blocking formula by the time i gave it to you. the base engine parameters operate differently and you'd need a plugin to change how they act to be able to make it work the same way.

and please tell me, how do I reduce the stacks below zero? By just removing the "|| 0" part? I want block to be lowest of -6 stack stages, and highest of 6 stack stages. Maybe do something like "|| -6".
the || 0 is just a safety net against an undefined value. theres nothing stopping you from using a negative value in the skill code i gave to you.

Also, I don't know if we're on the same page of the term "Stacks"... we are referring to a single stack of 6 boosts, correct? Not like 1 stack of x boosts, then another stack of x boosts. Cause from my tinkering and understanding, Yanfly already implements multiple "boosts".
what i gave you was a single value that could be incremented and decremented that factors into the formula. im not sure of the distinction youre drawing or what you mean by yanfly's boosts.

or the rest of the stats, increases and decreases are by a multiplier of 25% increments or decriments, so, (Reduction) *40%, *44.4%, *50%, 57.1% *66.6%, *80%, (Boosts) *125%, *150%, *175%, *200%, *225%, *250%. I don't know of a formula that can quickly calculate that, so I was going to do it through states and common events.
the buffs and states core already lets you do that through its plugin parameters for buffs and debuffs. you wouldnt be able to use it for the the x and s params since those dont have buffs, but the base params all could have just used that. the other params would require rewriting how they work. you could look for a plugin that lets states stack and then use that to handle it, but youll have to put together the checks to change from from positive to negative and vice versa
Ok, thank you for this info.

in short, yes. the user variable within the after eval notetag will always refer to the user of the skill, regardless of if theyre an enemy or an actor.
I see. Thanks for the info.
isActor() and isEnemy() are methods that both actors and enemies will have thatll return true or false based on what kind of battler they are. past that website, the only other resource i can give for mv specific code is to look into the js files of your project. i know you said you had some degree of familiarity with ruby, but id recommend learning js and its specific quirks before then.
That's good to know! And yes, I looked into the js files, it's really complex.
i never suggested to use a common event for a number of reasons - the main one being that its much easier using yanflys notetags to reference battlers such as "the one currently acting" and "the one being targeted"

which is exactly why i suggested using the after eval notetag and the user reference in the first place.
If I use the eval notetag to apply a "Var" state for the buff stack, I won't be able to display an icon that shows the user has been buffed or debuffed, or change the icon based on buff and debuff level (say, -1 - -3 shows a small stack, while -4 - -6 shows a large stack.
yes. it was intended for the blocking formula. you never mentioned wanting it to work for anything else other than that blocking formula by the time i gave it to you. the base engine parameters operate differently and you'd need a plugin to change how they act to be able to make it work the same way.
Yeah, that's what I thought.
the || 0 is just a safety net against an undefined value. theres nothing stopping you from using a negative value in the skill code i gave to you.
Ah ok!
what i gave you was a single value that could be incremented and decremented that factors into the formula. im not sure of the distinction youre drawing or what you mean by yanfly's boosts.
Yanfly has it's own set of boosts, I believe, and they somewhat stack. I have yet to fully test the stack states, but I believe it's hardcoded into the plugin (Buffs & States Core)
the buffs and states core already lets you do that through its plugin parameters for buffs and debuffs. you wouldnt be able to use it for the the x and s params since those dont have buffs, but the base params all could have just used that. the other params would require rewriting how they work. you could look for a plugin that lets states stack and then use that to handle it, but youll have to put together the checks to change from from positive to negative and vice versa
I looked for a plugin for that specific purpose. But I didn't find anything via google search or rpgmaker website search. v.v

I wonder why they didn't add buffs for x and s parameters (the engine devs)? Seems like a wasted opportunity to me.

I don't currently have enough Javascript knowledge to rewrite the parameter or creating a plugin from scratch. Hell, I couldn't even do that for ruby or c! Scripting is hard and takes intelligence and problem solving (and I don't have problem solving skills, unfortunately).

I could open a plugin request, but I don't know if anyone has the time to write a plugin for an old program.

Original thread: https://forums.rpgmakerweb.com/threads/help-allaisters-blocking-plugin-making-skills-and-items-affect-block-rate.177287/