Disperse Damage through allies

miyanke

Veteran
Veteran
Joined
Dec 2, 2015
Messages
73
Reaction score
12
First Language
Spanish
Primarily Uses
RMMZ
Hi people!!


I'm here again to see if you can answer me a hard question and find a solution.

I'd like to create a state in wich if you are damaged then the damage is spread proportionally through your allies.

I thought Yanfly did something similar but I couldn't find it.


Thank you in advance.
 

miyanke

Veteran
Veteran
Joined
Dec 2, 2015
Messages
73
Reaction score
12
First Language
Spanish
Primarily Uses
RMMZ
Yes, As I am looking for all damage to be spread the code I should take should be this:

<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) {
// Let's play animation 12 on the affected member.
member.startAnimation(12);
// 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>




But I need not to check if they have the state, just the party.
 


I tried this but it doesn't work:
 

<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;
}
// 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) {
// Let's play animation 12 on the affected member.
member.startAnimation(12);
// 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>




I'm VERY bad on scripting, can you help me?
 
Last edited by a moderator:

beenbaba

Slowly getting there
Veteran
Joined
Apr 28, 2015
Messages
289
Reaction score
159
First Language
English
I'm not sure what you are asking for :/


When the state is on more than one character, any damage they take will be dispersed between those affected. Is that not what you want?
 
Last edited by a moderator:

miyanke

Veteran
Veteran
Joined
Dec 2, 2015
Messages
73
Reaction score
12
First Language
Spanish
Primarily Uses
RMMZ
I'm not sure what you are asking for :/


When the state is on more than one character, any damage they take will be dispersed between those affected. Is that not what you want?
No.

Sorry if I didn't explained it correctly.

What I want is that if the mage is hitted and he has the state "damage dispersion", the damage suffered by the mage is divided between the members of the party.
Then, if the hit is -100HP and there are 4 members, then each member will suffer -25HP.
 

beenbaba

Slowly getting there
Veteran
Joined
Apr 28, 2015
Messages
289
Reaction score
159
First Language
English
Ah now I get it. I've just gone out but I'm pretty sure I know how to do it. If no one else has answered by the time I get back I'll get it working for you


EDIT: So this should work, all I've done is taken away the if that checks for the state on the members and instead if a character has the state on them and gets attacked it will disperse the damage. Just edit the number for what animation to play if needed.

<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 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) {
      // Let's play animation 12 on the affected member.
      member.startAnimation(12);
      // 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>
 
Last edited by a moderator:

miyanke

Veteran
Veteran
Joined
Dec 2, 2015
Messages
73
Reaction score
12
First Language
Spanish
Primarily Uses
RMMZ
Thank you!!!


An error appears that say "undefined is not a function".
 

miyanke

Veteran
Veteran
Joined
Dec 2, 2015
Messages
73
Reaction score
12
First Language
Spanish
Primarily Uses
RMMZ
Thank you!!!


An error appears that say "undefined is not a function".
I cleaned the formula to see if there were something wrong,
Did it works with you Beenbaba?

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;
      affected.push(member);
    }
  value = Math.ceil(value / affected.length);
  for (var i = 0; i < affected.length; ++i) {
    var member = affected;
    if (member !== target) {
      member.startAnimation(12);
      member.gainHp(-value);
      member.startDamagePopup();
      member.clearResult();
      if (member.isDead()) {
        member.performCollapse();
      }
    }
  }
}
</Custom React Effect>
 

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

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top