[Yanfly] JS Code Question(s) >>EASY<<

Hey Folks,
Another newbie question from RetroBoy.


If I place this into the notebox of a skill, will it add a State prior to attacking and then remove the state after the attack is concluded, will that work?

I want to make a skill that has a higher critical chance. So, I have made a state which raises your critical chance. Will this work or is there a problem with it because of the code or a timing for when criticals are determined or something?

Code:
<Custom Pre-Damage Eval>
a.addState(161)
</Custom Pre-Damage Eval>


<Custom Post-Damage Eval>
a.removeState(161)
</Custom Post-Damage Eval>

Bonus Question: If I want to see if a Defender has one of the following states, is this how I do it?

Code:
<Select Conditions>
State: 84
State: 85
State: 86
</Select Conditions>

Or, would that mean to activate the skill the Defender would need to be afflicted with State 84, 85 and 86?

Sorry for asking all this stupid stuff but I am still learning.
For the first question, yes, your code is correct and do as you explained, but you used the wrong tags. You used <Custom Pre-Damage Eval> and <Custom Post-Damage Eval>, whereas the correct tags are <Pre-Damage Eval> and <Post-Damage Eval>

Code:
<Pre-Damage Eval>
a.addState(161);
</Pre-Damage Eval>


<Post-Damage Eval>
a.removeState(161);
</Post-Damage Eval>

Also, you do not need to apply a higher crit rate state just to have a skill have a higher chance of critically striking. The YEP_X_CriticalControl plugin has notetags that allow you to do just that.

On the skill notebox, you can use the following:

<Critical Rate: x%>

To set the critical rate to a flat value for that skill. If you want to use a formula instead (example taken from the plugin's help file):

<Critical Rate Formula>
rate = user.cri + 0.2;
rate -= 1 - target.cev;
</Critical Rate Formula>

The 'rate' variable that is returned will be the critical rate for that skill.


For the next question, that notetag will allow you to target an enemy only if they have all 3 states (84, 85 and 86). If you want to be able to target the enemy if they have any of the 3 states, you would use:

Code:
<Custom Select Condition>
var state1 = target.isStateAffected(84);
var state2 = target.isStateAffected(85);
var state3 = target.isStateAffected(86);
if (state1 || state2 || state3) {
  condition = true;
} else {
  condition = false;
}
</Custom Select Condition>
Thanks Champ. Youre always helping. Its really kind of you.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-js-code-question-s-easy.80407/