Passive help ;-;

So below are some passive abilities i need help with cause im still confused with lunatic mode and the ones i made dont work. (I have all YEP plugins btw).

Spoiler: Abilities
1. A passive that increases damage the lower the actors health is. SOLVED

2. A passive that guarantees crit if opponent is inflicted by a status eff.

3. A passive that increases crit damage

4. A passive that increases all allies defence when the actor with the passive successfully inflicts a status

All help would be greatly appreciated also credit will be given in game
Well, i can help you with the first one.
Code:
<Custom Confirm Effect>
// Check if the damage dealt deals physical HP damage.
if (this.isCertainHit() && this.isHpEffect() && value > 0) {
  // Base the bonus damage off of the user's HP rate.
  value *= 2.00 - user.hpRate();
  // Add bonus damage equal to the user's missing HP.
  value += (user.mhp - user.hp) * 0.50;
  // Round up the calculations.
  value = Math.ceil(value);
}
</Custom Confirm Effect>
It's commented since it's actually from Yanfly's Tips & Tricks.
You might find the others in its wiki: here
Well, i can help you with the first one.
Code:
<Custom Confirm Effect>
// Check if the damage dealt deals physical HP damage.
if (this.isCertainHit() && this.isHpEffect() && value > 0) {
  // Base the bonus damage off of the user's HP rate.
  value *= 2.00 - user.hpRate();
  // Add bonus damage equal to the user's missing HP.
  value += (user.mhp - user.hp) * 0.50;
  // Round up the calculations.
  value = Math.ceil(value);
}
</Custom Confirm Effect>
It's commented since it's actually from Yanfly's Tips & Tricks.
You might find the others in its wiki: here
thanks rifty, so this increases damage when low right? Also forgot bout the tips and tricks xd, defo gon check it out.
Yes, although it only works for Physical Hit skills only. You can tweak it more to do the same when using Magical and Certain.
Yes, although it only works for Physical Hit skills only. You can tweak it more to do the same when using Magical and Certain.
nah it's good the character using this will be a physical damage dealer anyway. thanks
Hey,

I've not worked with Yanflys passive states so far, so there may be better options without the downsides, but two ways to do number 2 (and potentially 3):

Code:
<custom confirm effect>
  // If the target has more than 0 states and...
  // ...the action is able to produce critical hits and...
  // ...the action is not already a critical hit...
  if (target.states().length > 0 &&
      this.item().damage.critical &&
      !target.result().critical) {
    // ...flag the result as a critical hit
    // ...modify the damage value:
    target.result().critical = true;
    value = Math.round(this.applyCritical(value));
  }
</custom confirm effect>
This should guarantee a critical hit against targets affected by any state.
For alternatives replace target.states().length > 0 with...
target.isStateAffected(17) to check for a specific state (#17 in this case),
target.states().some(s => s.iconIndex > 0) to check for any state not invisible,
target.states().some(s => s.meta["valid state"]) to check for any state with a <valid state> tag in its notebox.

The downside of this variant would be that the critical effect is only added later, so if you have other effects that check if the attack is a critical hit, make sure that they are checked after (have a lower state priority).


An alternative could be to give the attacker a state (#17 in this case) for this attack only in order to buff their critical hit chance:
Code:
<custom initiate effect>
  if (target.states.length() > 0) {
    user.result().clear();
    user.addState(17);
  }
</custom initiate effect>
<custom conclude effect>
  user.removeState(17);
</custom conclude effect>
The conclude effect is only triggered if the attacker still has the passive state when the attack ends (i.e. has not died or lost the passive through some other effects)


Edit:
I forgot about the other cases, but number 4 could look like this:
Code:
<custom conclude effect>
  if (target.result().addedStates.length > 0) {
    let group = user.friendsUnit().members();
    group.forEach(m => m.addState(16));
  }
</custom conclude effect>
Haven't tested this at all, but similarly you can replace the condition with
target.result().addedStates.includes(17) ...to check for a specific added state
target.result().addedStatesObjects().some(s => s.iconIndex > 0)
target.result().addedStatesObjects().some(s => s.meta["valid state"]) ...to check for visibility or a custom note tag.

Edit: Misremembered a function name
Hey,

I've not worked with Yanflys passive states so far, so there may be better options without the downsides, but two ways to do number 2 (and potentially 3):

Code:
<custom confirm effect>
  // If the target has more than 0 states and...
  // ...the action is able to produce critical hits and...
  // ...the action is not already a critical hit...
  if (target.states().length > 0 &&
      this.item().damage.critical &&
      !target.result().critical) {
    // ...flag the result as a critical hit
    // ...modify the damage value:
    target.result().critical = true;
    value = Math.round(this.applyCritical(value));
  }
</custom confirm effect>
This should guarantee a critical hit against targets affected by any state.
For alternatives replace target.states().length > 0 with...
target.isStateAffected(17) to check for a specific state (#17 in this case),
target.states().some(s => s.iconIndex > 0) to check for any state not invisible,
target.states().some(s => s.meta["valid state"]) to check for any state with a <valid state> tag in its notebox.

The downside of this variant would be that the critical effect is only added later, so if you have other effects that check if the attack is a critical hit, make sure that they are checked after (have a lower state priority).


An alternative could be to give the attacker a state (#17 in this case) for this attack only in order to buff their critical hit chance:
Code:
<custom initiate effect>
  if (target.states.length() > 0) {
    user.result().clear();
    user.addState(17);
  }
</custom initiate effect>
<custom conclude effect>
  user.removeState(17);
</custom conclude effect>
The conclude effect is only triggered if the attacker still has the passive state when the attack ends (i.e. has not died or lost the passive through some other effects)


Edit:
I forgot about the other cases, but number 4 could look like this:
Code:
<custom conclude effect>
  if (target.result().addedStates.length > 0) {
    let group = user.friendsUnit().members();
    group.forEach(m => m.addState(16));
  }
</custom conclude effect>
Haven't tested this at all, but similarly you can replace the condition with
target.result().addedStates.contain(17) ...to check for a specific added state
target.result().addedStatesObjects().some(s => s.iconIndex > 0)
target.result().addedStatesObjects().some(s => s.meta["valid state"]) ...to check for visibility or a custom note tag.
ooooh w i can work with this thanks again xd

Original thread: https://forums.rpgmakerweb.com/threads/passive-help.160917/