MV how to modify +counter rate only when in-state?

Related to YEP_counter control
Modify counter rate

when actor Guard, apply guard state that has flag Guard & +25% counter rate.
On counter, deal dmg & apply state that stun & increase target dmg taken.
(counter only available when on guard, or use certain weapon/class. default all 0% counter)

Boss has deadly attack, must: dodge the attack, or block/parry the attack. (that's only the beginning)

Set a boss skill that can only be blocked by countering it
<Target Counter: +80%>
With that tag, almost guarantee counter.

But I want the counter+ only to apply if the actor has a state guard.
If the actor doesn't have state Guard, then the +counter will not take effect.

Can help?

Tried with this, but a no
can counter be peformed while in the middle of continuous attack?
<Custom Target Counter Rate>
if (b.isStateAffected(2))
{ <Target Counter: +80%>; }
</Custom Target Counter Rate>
Use the Ex-Paramater "Counter Attack + 80%" in the Traits section, on the top right of the State window.
Use the Ex-Paramater "Counter Attack + 80%" in the Traits section, on the top right of the State window.
Yeah, but
I want the counter+ only to apply if the actor has a state guard.
If the actor doesn't have state Guard, then the +counter will not take effect.
IF add b.addstates in the formula, or add state in the effects, then guard or not the +rate will still increase.
that can be bypass with the IF state condition.

some actor cannot counter, can apply with the <Target Counter: 0%> either the actor, or weapon.

actor use like dagger, or rapier, less counter rate than sword, axe, etc.
can't give them the same 80% rate+
---
I move to use the <Target Counter: X%>.
use +-/flat number, can go to 0, or minus if keep receiving that attack.
<Custom Target Counter Rate>
if (b.isStateAffected(2))
{ <Target Counter: +80%>; }
</Custom Target Counter Rate>
You can't put notetags inside of code. They're not JavaScript, they're something that RPG Maker interprets.

A correct example is included in the documentation for Counter Control:
Code:
<Custom Target Counter Rate>
   rate -= user.hpRate();
</Custom Target Counter Rate>

So yours would be:
Code:
<Custom Target Counter Rate>
if (b.isStateAffected(2))
    rate+=.8;
</Custom Target Counter Rate>
So yours would be:
Code:
<Custom Target Counter Rate>
if (b.isStateAffected(2))
    rate+=.8;
</Custom Target Counter Rate>
0.8 , no?
anyway. yes, this can work.
Thanks for the help
0.8 , no?
I don't understand the question: .8 and 0.8 are the same number. Just like 1 and 01 are the same number...leading zeroes don't affect a value.
0.8 , no?
You're right @tyranzero. 👋 You should use 0.8 instead.
Even though 0.8 === .8 evaluates to true, it's easy to confuse .8 with 8.

FYI, leading zeroes CAN affect values in javascript.
Question: If you run the code below through Event Commands > Advanced > Script, what should be the resulting value of Control Variables: #0001?
JavaScript:
$gameVariables.setValue(1, 10 == 010);
Note: Using the loose equality (==) operator is deliberate.
Is the answer... true? 😮‍💨
Edit: Answer
FYI, leading zeroes CAN affect values in javascript.
Yes, if you put them before digits on the left side of a decimal it will be interpreted as an octal value, but that's really not relevant to the ".8" that I typed in my post 🤣 (it is relevant to the 01 example that I said later, but that was in the context of math, not code. I can see how you misunderstood me)

In that case, the answer to tyranzero's question is no, it should not be 0.8 - it can be, but there's no necessity to it. If he copied and pasted what I typed for him, it would work correctly.
Huh? That entire post, including the part about leading zeroes, was intended for tyranzero. Not you.

But since you mistakenly believe you're the intended recipient of that post...
Just like 1 and 01 are the same number...leading zeroes don't affect a value.
Yes, if you put them before digits on the left side of a decimal it will be interpreted as an octal value
Sure, concocting excuses is par for the course for you... Your Infallible Holiness.🤣 You weren't talking about octals with regards to leading zeroes until I pointed it out.
"...leading zeroes don't affect a value."

It should be interesting to hear what excuse you have conceived after improperly using the splice() method here and then nonchalantly using them properly here AFTER your mistake was pointed out to you.

You are leading tyranzero (and other newbies like him) astray with your insistence on brevity at the expense of readability.
Code:
<Custom Target Counter Rate>
if (b.isStateAffected(2))
    rate+=.8;
</Custom Target Counter Rate>
At least tyranzero is smart enough not to take your advice at face value, questioning the use of .8 rather than 0.8. Think of all the mistakes newbies can possibly make if you continually "advise" them to code in this unreadable, downright ugly, manner.

Unless of course your goal is to "encourage" newbies to make their code as unreadable as possible so they're more likely to make coding mistakes so you can in turn "help" them some more.
@tyranzero: hi, is your question solved?
is your question solved?
Yes, has been solved.

and thanks above for the additional script info

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-modify-counter-rate-only-when-in-state.146754/