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.
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:
First I created the skill Agility. It will call a common event, also known as Agility
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.
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.