Increase a characteristic during a very specific condition (Resolved)

Hello,

I want to create two rather unusual status changes, and I'm pretty sure this will require some JavaScript knowledge (which I don't have).

The first state should increase an actor's critical hit chance by X%, but ONLY if they attack a poisoned or bleeding target, so it depends on other states that an enemy (the target) might have.

The second state should increase an actor's chance to dodge a physical attack by X% and a magic attack by Y%, but ONLY if the enemy has made a multi-target attack.

I think these states can be achieved using tools like <Custom Select Effect> and <Custom Deselect Effect>, but I'm not very good with JavaScript.
I have many Yanfly plugins, so that shouldn't be a problem.

What I'm asking may be a bit complicated, I'm sorry. Thanks to anyone who can help me.

(translation done by Google, please ask me to rephrase if necessary)
Hi,

I did something similar to second state in the past using Custom Select Effect. But it did require javascript.
Here is a shield that has 100% evade against skills marked as projectiles:
JavaScript:
<Custom Select Effect>
  var item = this._item;
  if(this.isSkill()) {
    const isProjectile = item.hasCategory('PROJECTILE');
    if(isProjectile) {
      state.traits.push({code: 22, dataId: 1, value: 1.0});
    }
  }
</Custom Select Effect>
<Custom Conclude Effect>
  state.traits.pop();
</Custom Conclude Effect>

Give me some time and I can figure out how to do yours.
Here is what I got so far:
In order to do dodge physical and magical you need to add traits to the state:
1741811720344.png

code 22 means Ex-Parameter
dataId 1 is Evasion Rate
dataId 4 is Magic Evasion
and the numbers is the percentage, so in your case you would need to put X instead 0.05 and Y instead 0.04

To check multi-target you need to check used skill/item scope:
1741812862742.png

if (this.checkItemScope([2, 4, 5, 6])) { //All Enemies, 2,3,4 Random Enemies }
So I think the final code for this state would be:
JavaScript:
<Custom Select Effect>
    if(this.checkItemScope([2, 4, 5, 6])) {
        state.traits.push({code: 22, dataId: 1, value: 0.30});
        state.traits.push({code: 22, dataId: 4, value: 0.20});
    }
</Custom Select Effect>
<Custom Deselect Effect>
    state.traits.pop();
    state.traits.pop();
</Custom Deselect Effect>

EDIT: Fixed Custom Conlude -> Custom Deselect , sorry for the confusion
Hello,

Thank you very much for taking the time to help me. I tried your solution this morning (unfortunately, I don't have much time outside of weekends).

I think we're close to the solution, but it's not quite there yet.
After running some tests, I realize that the actor's dodge is indeed increased during multi-target attacks, but it isn't decreased at the end of the attack. I tested by setting 100% dodge (so 1 for the value), and the actor only dodges multi-target attacks. But the problem is that after dodging one, he also dodges single-target attacks.
I don't think the dodge is decreased. Shouldn't "deselect" be used instead of "conclud"? I haven't had time to try it.

Another thing, does your solution increase dodge by X? Or does it fix dodge to X?
Because I thought of an alternative to your solution, which involves adding an intermediate state that increases dodge. Specifically, state A uses <custom> tags to add and remove state B in the event of a multi-target attack. State B simply increases dodge by the desired amount.

But if you tell me that your solution actually increases dodge by X without locking it to X, then that's fine with me. ^^
Shouldn't "deselect" be used instead of "conclud"? I haven't had time to try it.
yes. the idea was that the state traits would be removed at the very end of the process. they meant deselect rather than conclude. as it is now, the traits would only be removed as the battler with the state acts rather than when theyre acted upon.

Another thing, does your solution increase dodge by X? Or does it fix dodge to X?
it would increase eva by x. you would need a separate plugin to allow a state to fix a battler's eva to some number as a battler's eva is the sum of all their eva traits
Thank you very much for your reply. In that case, I'll try it tomorrow morning with "deselect," and it should be perfect.
I'll keep you posted ^^
If anyone has an idea for the other condition I asked for (the one that increases the critical hit value only if the target is bleeding or poisoned), please let me know.
I assume the script should be similar to Rakanishoo's. But maybe that's impossible since there's a possibility that the actor will perform an attack that hits two enemies where only one bleeds. In the worst case, I'll simply reword the condition.
I'll try to post a solution to the first state. The idea is similar, just use Initiate and Conclude to add a trait to the state and remove it, but this time instead of checking item scope, check the target states.

EDIT: Here you go, try this:
JavaScript:
<Custom Initiate Effect>
  if(defender.hasState(4) || defender.hasState(5)) {
    state.traits.push({ code: 22, dataId: 2, value: 1.00 });
  }
</Custom Initiate Effect>
<Custom Conclude Effect>
  if(defender.hasState(4) || defender.hasState(5)) {
    state.traits.pop();
  }
</Custom Conclude Effect>
Where value 1.00 would be 100% critical chance so decrease it as you will,
and 4 and 5 are ids of states for poison and bleed so change them as well.
Hello,
I just tried the dodge state after the fix, as well as the state that increases critical hit chance. Both seem to work perfectly. Thank you so much ^^

Edit : For those who are interested, for the state that concerns critical hits, if the actor performs a multi-target attack, the solution given perfectly differentiates between enemies who are affected by a state (here bleeding) and those who are not affected.
This thread is closed due to being marked solved. Report the next one so it’s easier to find! If you need this one reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/increase-a-characteristic-during-a-very-specific-condition-resolved.176168/