Yanfly buff/state core counter questions

Bleh

Warper
Member
Joined
May 3, 2019
Messages
2
Reaction score
1
First Language
french
Primarily Uses
RMMV
Hello !

I'm trying to make a skill that hits harder every time you hit the same target, and decreases in power every turn you don't hit the target with the skill.

So I was thinking it'd be easiest to use yanfly's buff&state core as I remembered it had a state counter fonctionality which would be perfect for the job, though i don't have much experience with custom notetag formulas and such, and as expected i can't get it to work yet :kaocry:


So far, i set it up like so :

The 'low-kick' skill :

Damage formula : a.atk*0.5*(1+b.getStateCounter(21))*(a.atk/b.def).clamp(1/3,3)/2
The "*a.atk * (a.atk/b.def).clamp(1/3,3)/2" part is part of the standard damage formula i use, the part thats specific to this skill is the ".5* (1+b.getStateCounter(21))" which is supposed to multiply the damage by 0.5 times th state's counter +1.

In effect, the skill adds the LegBreak state (21).

And in notebox :
<Custom Establish Effect>
b.addStateCounter(21,1);
</Custom Establish Effect>

As I understand it should increase the target's state's counter by 1 every time the skill hits a target.


The 'LegBreak' state:

No specefic effect or restrictions, no removal parameters.
Notetag :
<Custom Turn Start Effect>
this.clampStateCounter(21, 0, 4); // just to be sure the counter values clamps, didn't know where to put it
this.addStateCounter(21, -1);
if (this.getStateCounter(21) == 0)
{this.removeState(21)};
</Custom Turn Start Effect>

Here i wanted the state to substract 1 counter every turn, and remove itself when counter reaches 0.


And up to now, pretty much nothing works.
-> The skill always does 0 damage, even though i tested it in conditions when it guaranted damage even at lowest damage output (atk 20 -> def 5), so I guess i messed up the formula.
-> The state applies on the target, but no counter is shown on it (i made sure to set show ennemy state counter to true in plugin settings).
-> The state never automatically removes itself.

What i suppose is that i probably got off the mark regarding how to use the script commands provided, and i'm quite clueless as to how to actually make it work, so if someone cares to help that would be nice :kaoluv:
 
Last edited:

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
399
Reaction score
221
First Language
English
Primarily Uses
RMMV
In future it would be useful to provide a link to the plugin you're using - it saves people trying to help having to google their way to it.

I don't use this plugin, but I would imagine that the reason nothing is happening is because "getStateCounter" is returning undefined or NaN. When applying the state you should use "setStateCounter", this will change the value from undefined to a number which you can then do maths on such as addition or subtraction. I would try something along these lines:

JavaScript:
if (!b.getStateCounter(21)) {
    b.setStateCounter(21, 1);
} else {
    b.addStateCounter(21, 1);
}
As another thought, I'm not convinced Yanfly uses "b" when referring to the target of a skill so it may be worth replacing "b" with "target" or reading the plugin description for the proper reference.

Additionally, the "Establish" notetags appear to be for states, but you're using them for skills. It might be the case that you need to find a separate plugin that has notetags that will allow you to add custom javascript to skills, possibly Yanfly's skill core?

If the state counter being undefined is the issue you'll also need to adjust your damage formula to handle instances where the enemy doesn't have a state counter.

JavaScript:
a.atk * 0.5 * (1 + ( b.getStateCounter(21) ? b.getStateCounter(21) : 0)) * (a.atk / b.def).clamp(1/3, 3) / 2;
// using ternary operator

if (b.getStateCounter(21)) {a.atk * 0.5 * (1 + b.getStateCounter(21)) * (a.atk / b.def).clamp(1/3, 3) / 2} else {a.atk * 0.5 * (a.atk / b.def).clamp(1/3,3) / 2};
// using if statement
 

Bleh

Warper
Member
Joined
May 3, 2019
Messages
2
Reaction score
1
First Language
french
Primarily Uses
RMMV
In future it would be useful to provide a link to the plugin you're using - it saves people trying to help having to google their way to it.
I'll keep that in mind for next time, for now i edited my post to contain a link to the script (including it's description).

Anyway thanks a lot for your help, with it and a little sniffing out other stuff i managed to make it work.
Here's a little more explanations for other peeps :

I don't use this plugin, but I would imagine that the reason nothing is happening is because "getStateCounter" is returning undefined or NaN.
This was indeed one of the issues, in particular in the damage formula, as you suggested. To add more details, getStateCounter actually does initializes the counter, but doesn't assign a value, so it's pretty much the same regarding the damage formula. So the no-damage was resolved by using what you suggested (0.5 * (1 + ( b.getStateCounter(21) ? b.getStateCounter(21) : 0)), or the if statement alternative).

Your were also right that the establish notetag i was using was not meant for skills. Yanfly does have a notetag for skills in his skillCore script, though i didn't manage to make that part work, but found a simpler alternative. Most probably because, as you mentionned, using b to refer to the target doesn't work in the skill's notetag (it does in the damage formula of course). However target didn't work either and i couldn't find what term to use in the script's descrition. Though the workaround i found is both simpler and doesn't need another script, so it's not a big deal.

What i used in the end is this in the state's notetag :

JavaScript:
<Custom Apply Effect>
  user.addStateCounter(21, 2);
  user.clampStateCounter(21, 0, 4);
</Custom Apply Effect>
addStateCounter actually does initialize the counter and gives it a default value of 0 if none was set. This notetag makes the code run each time you apply the state, even if the state is already applied, so, in my case, each time your skill lands. Also, need to increment by 2 each time, otherwise the value would never go up as it is reduced by 1 each turn. I don't get why, but putting clampStateCounter() first prevents addStateCounter() to function in this situation.

and this :
JavaScript:
<Custom Turn End Effect>
  user.addStateCounter(21, -1);
  if (user.getStateCounter(21) < 1) {
    user.removeState(21)
  };
</Custom Turn End Effect>
Changed custom turn start to custom turn end, as the other would make the state value to drop right after your command input. So, in some cases, you take your actions while the state was still active, but it would disapear before the actions actually happen.

So, problem solved i guess.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you have an audio you want me to animate? If so send me the youtube link and I’ll animate it.
Okay, so I'm working on Draft 2 of my game's script.
Will try to keep you guys posted, if you're interested!

This is vid of my new game, Crystalgazers. A demo is available on my Gamejolt

I just thought of the best achievement for my game: "'I Didn't Know You Were a Developer!' Find and enter one or more dev room(s)."
I made this animation to apply to a job, what do you think?

Forum statistics

Threads
105,589
Messages
1,014,830
Members
137,253
Latest member
Koshibari
Top