Yanfly Buffs & States: Joint Penalty help

ruin lance

Villager
Member
Joined
Aug 20, 2017
Messages
7
Reaction score
2
First Language
English
Primarily Uses
RMMV
Currently I am using this code from one of Yanfly's tips and tricks videos. (Joint Penalty)
<Custom React Effect>
<Custom React Effect>
// Check if the damage is positive.
if (value > 0) {
// Get the living members of the same party.
var members = target.friendsUnit().aliveMembers();
// Make an empty group to list affected members.
var affected = [];
// We'll go through each member to check them.
for (var i = 0; i < members.length; ++i) {
// Getting the individual member.
var member = members;
// Does the member exist and is the member affected by state 91 (the Joint Penalty state)?
if (member && member.isStateAffected(91)) {
// If the member is affected, add it to the affected group.
affected.push(member);
}
}
// Divide up the damage by how many members are affected.
value = Math.ceil(value / affected.length);
// We'll go through each of the affected members now.
for (var i = 0; i < affected.length; ++i) {
// Getting the individual affected member.
var member = affected;
// Ignore the effect if the member is the target of attack.
if (member !== target) {
// The affected member takes damage.
member.gainHp(-value);
// We'll have the affected member reveal a damage popup.
member.startDamagePopup();
// Clear the results of the effect.
member.clearResult();
// Next, check to see if the member is dead.
if (member.isDead()) {
// If the member is dead, we'll make it collapse.
member.performCollapse();
}
}
}
}
</Custom React Effect>


</Custom React Effect>
What this does is make it so that everyone with the affected state disperses their damage they take between each other based on how many characters have that status.

What I want to do is add some extra effects to this, namely:

1. The damage taken by the characters who have the state take element rates into consideration. (for instance, a character with 200% physical element rate would take double damage from the damage-dispersed attack but everyone else with the state who have 100% physical rate would take normal damage from it.)

2. The damage taken by the characters who have the state take defense into consideration.

3. The characters sharing damage also get any states that were inflicted on the target from the attack.

4. The damage taken by the characters who have the state take Yanfly's absorption barriers into consideration.

I've spent a few hours trying to figure this out myself with no luck. I've found a workaround for the second effect but it is a hassle.

I hope this made sense and if you need any clarifications I'd be happy to elaborate. Thanks in advance.

Edit: added a 4th thing I'd like it to do.
 
Last edited:

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
132
Reaction score
71
First Language
French
Primarily Uses
RMMV
Hello! I changed your script a bit:
Code:
<Custom React Effect>
  if (value > 0) {
    var members = target.friendsUnit().aliveMembers();
    var affected = [];
    for (var i = 0; i < members.length; ++i) {
      var member = members[i];
      if (member.isStateAffected(39)) {
        affected.push(member);     
      }
    }
    value = Math.ceil(value / affected.length);
    for (var i = 0; i < affected.length; ++i) {
      var member = affected[i];
      var dam = value - member.def
      if (dam < 0) {dam = 0};
      if (member !== target) {     
        if (this.item().damage.elementId < 0) {
          dam *= this.elementsMaxRate(member, this.subject().attackElements());
        } else {
          dam *= member.elementRate(this.item().damage.elementId);
        }
        member.gainHp(-Math.round(dam));
        member.startDamagePopup()
        member.clearResult();
        if (member.isDead()) {
          member.performCollapse();
        }
      } else {
        if (this.item().damage.elementId < 0) {
          value *= this.elementsMaxRate(member, this.subject().attackElements());
        } else {
          value *= member.elementRate(this.item().damage.elementId);
        }
      }
    }
  }
</Custom React Effect>
1. The damage taken by the characters who have the state take element rates into consideration. (for instance, a character with 200% physical element rate would take double damage from the damage-dispersed attack but everyone else with the state who have 100% physical rate would take normal damage from it.)
This is what I did in the above script; it should now take account of elemental rate.

2. The damage taken by the characters who have the state take defense into consideration.
You want def to affected the value with what formula ?
(I used 'value - def' in the script above)

3. The characters sharing damage also get any states that were inflicted on the target from the attack.
If the target is inflicted a state, you want that state to be automaticaly applied to others or you need to check for state rate?

4. The damage taken by the characters who have the state take Yanfly's absorption barriers into consideration.
I'm currently checking for this...

EDIT: @ruin lance *note that I changed the state Id to 39 for testing (yours was 91)...

EDIT 2: @ruin lance *will now consider Barriers:
Code:
<Custom React Effect>
  if (value > 0) {
    var members = target.friendsUnit().aliveMembers();
    var affected = [];
    for (var i = 0; i < members.length; ++i) {
      var member = members[i];
      if (member.isStateAffected(39)) {
        affected.push(member);       
      }
    }
    value = Math.ceil(value / affected.length); 
    for (var i = 0; i < affected.length; ++i) {
      var member = affected[i];
      var dam = value - member.def
      if (dam < 0) {dam = 0};
      if (member !== target) {       
        if (this.item().damage.elementId < 0) {
          dam *= this.elementsMaxRate(member, this.subject().attackElements());
        } else {
          dam *= member.elementRate(this.item().damage.elementId);
        }
        var bar = $gameActors.actor(member.actorId())._permBarrier
        if (bar > 0) {
          let dif = bar - dam
          bar -= (dif >= 0) ? dam:dam + dif;
          if (dif < 0) {dam = -dif};
          member.loseBarrier(bar);
          member.startBarrierAnimation();
        }
        member.gainHp(-Math.round(dam));
        member.startDamagePopup()
        member.clearResult();
        if (member.isDead()) {
          member.performCollapse();
        }
      } else {
        if (this.item().damage.elementId < 0) {
          value *= this.elementsMaxRate(member, this.subject().attackElements());
        } else {
          value *= member.elementRate(this.item().damage.elementId);
        }
      }
    }
  }
</Custom React Effect>
 
Last edited:

ruin lance

Villager
Member
Joined
Aug 20, 2017
Messages
7
Reaction score
2
First Language
English
Primarily Uses
RMMV
@TSR
This is what I did in the above script; it should now take account of elemental rate.
This doesn't seem to work. From my test it seems like it only takes into account the person being targeted by the attack and causes the attack to calculate the elemental rate twice. Character A had 200% element rate. Character A and B both have the status with your script. The attack deals 10 damage. If the attack targeted Character A, they would both take 20 damage for a total of 40(not counting the defense bonus). If the attack targeted Character B, they would both take 5 for a total of 10(again, not counting the defense bonus).

Looking back on it I didn't do a very good job of explaining what I'd like this part to do and I'm sorry to waste your time like that. I guess I am actually asking for two separate effects, which I will try to explain the best I can.

1. Let's say Character A has 200% element rate. Character B has 100% element rate. Characters A and B both have the Joint Penalty status. Character A gets targeted by the attack that deals 10 damage. Character A takes 10 damage and Character B takes 5 damage. That way, it does not interfere with the next effect.

2. Character A has 100% element rate. Character B has 300% element rate. Characters A and B both have the Joint Penalty status. Character A gets targeted by the attack that deals 10 damage. Character A takes 5 damage and Character B takes 15 damage.

Once again both of these examples are not taking into account the defenses just for clarity.

If you need me to elaborate on either of those at all just say the word. I totally understand if this is confusing lol

You want def to affected the value with what formula ?
(I used 'value - def' in the script above)
This works almost perfectly but if at all possible I would like the original target to also be affected by this part. Right now it only affects the non-targets with the Joint Penalty status. If not then it's no big deal because I am already asking for a lot.

If the target is inflicted a state, you want that state to be automaticaly applied to others or you need to check for state rate?
I would like it to check for state rate.

Thank you so much for your help so far man. I appreciate it a lot.
 

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
132
Reaction score
71
First Language
French
Primarily Uses
RMMV
@TSR
...and causes the attack to calculate the elemental rate twice.
I see... I checked in the plugins file and the <Custom React Effect> take place just before damage calculation, hence elemental rate applied twice on the target... I used both <Custom React Effect> and <Custom Respond Effect> for this. See if it work:
Code:
<Custom React Effect>
  var members = target.friendsUnit().aliveMembers();
  var affected = [];
  for (var i = 0; i < members.length; ++i) {
    var member = members[i];
    if (member.isStateAffected(91)) {
      affected.push(member);       
    }
  }
  value = Math.ceil(value / affected.length); 
<\Custom React Effect>
<Custom Respond Effect>
  if (value > 0) {
    var members = target.friendsUnit().aliveMembers();
    var affected = [];
    for (var i = 0; i < members.length; ++i) {
      var member = members[i];
      if (member.isStateAffected(91)) {
        affected.push(member);       
      }
    }
    for (var i = 0; i < affected.length; ++i) {
      var member = affected[i];
      var dam = value - member.def
      if (dam < 0) {dam = 0};
      if (member !== target) {       
        if (this.item().damage.elementId < 0) {
          dam *= this.elementsMaxRate(member, this.subject().attackElements());
        } else {
          dam *= member.elementRate(this.item().damage.elementId);
        }
        var bar = $gameActors.actor(member.actorId())._permBarrier
        if (bar > 0) {
          let dif = bar - dam
          bar -= (dif >= 0) ? dam:dam + dif;
          if (dif < 0) {dam = -dif};
          member.loseBarrier(bar);
          member.startBarrierAnimation();
        }
        member.gainHp(-Math.round(dam));
        member.startDamagePopup()
        member.clearResult();
        if (member.isDead()) {
          member.performCollapse();
        }
      }
    }
  }
</Custom Respond Effect>
 

ruin lance

Villager
Member
Joined
Aug 20, 2017
Messages
7
Reaction score
2
First Language
English
Primarily Uses
RMMV
Doesn't seem to work. Here are my crash logs:

CUSTOM STATE 88 CODE ERROR
YEP_BattleAICore.js:1661 var members = target.friendsUnit().aliveMembers();
var affected = [];
for (var i = 0; i < members.length; ++i) {
var member = members;
if (member.isStateAffected(88)) {
affected.push(member);
}
}
value = Math.ceil(value / affected.length);
<\Custom React Effect>

YEP_BattleAICore.js:1662 SyntaxError: Unexpected token <
at Game_Action.customEffectEval (YEP_BuffsStatesCore.js:1696)
at Game_Action.reactStateEffects (YEP_BuffsStatesCore.js:1797)
at Game_Action.onReactStateEffects (YEP_BuffsStatesCore.js:1791)
at Game_Action.executeDamage (YEP_BuffsStatesCore.js:1763)
at Game_Action.apply (rpg_objects.js:1659)
at Game_Action.apply (YEP_BattleEngineCore.js:3273)
at Game_Action.apply (YEP_SkillCore.js:1041)
at Game_Action.apply (Olivia_OctoBattle.js:2507)
at Game_Action.apply (YEP_BuffsStatesCore.js:1676)
at Game_Action.apply (YEP_BattleAICore.js:795)
Yanfly.Util.displayError @ YEP_BattleAICore.js:1662
rpg_managers.js:1949 TypeError: require(...).Window.get(...).isDevToolsOpen is not a function
at Object.Yanfly.Util.displayError (YEP_BattleAICore.js:1664)
at Game_Action.customEffectEval (YEP_BuffsStatesCore.js:1698)
at Game_Action.reactStateEffects (YEP_BuffsStatesCore.js:1797)
at Game_Action.onReactStateEffects (YEP_BuffsStatesCore.js:1791)
at Game_Action.executeDamage (YEP_BuffsStatesCore.js:1763)
at Game_Action.apply (rpg_objects.js:1659)
at Game_Action.apply (YEP_BattleEngineCore.js:3273)
at Game_Action.apply (YEP_SkillCore.js:1041)
at Game_Action.apply (Olivia_OctoBattle.js:2507)
at Game_Action.apply (YEP_BuffsStatesCore.js:1676)
The barriers don't seem to be taken into account on either of the scripts. Originally I thought it was because I was using temporary barrier points but I tried changing permBarrier to turnBarrier and barrierPoints and it also did not work.
 

Attachments

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
132
Reaction score
71
First Language
French
Primarily Uses
RMMV
It is probably because you're using turn barriers, as I design it for permanent barriers and it's how I tested it in my project... You could replace _permBarrier by _turnBarrier[turn] but I'm not too sure what it is expecting as the turn argument... :dizzy:
It's an array so I guess you could try index 0:
$gameActors.actor(member.actorId())._turnBarrier[0]
 

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

Latest Threads

Latest Posts

Latest Profile Posts

There a thread out there that tells us the best way to open an RPG that isn't 'the protag gets out of bed'?
Updated my state Stacker Script on itch.io, github is down for some reason (probs just me).
Wife watching Locke and Key. This show is so bad!! You can't just acclimate to discovering magic or magical worlds in less than 60 seconds.
I think I still prefer RPG Maker over Dreams. Been playing around with it, and the controls are really the biggest flaw for me.

Forum statistics

Threads
94,332
Messages
919,996
Members
124,087
Latest member
OrdinaryOne
Top