How do I...make a skill that requires all party members to be alive, with no statuses?

I want to give 1 of my party members an "All-Together" Skill.

The idea is that as long as all party members are alive, and all party members do not have a status inflicted on them (like, no poison, no death/KO statuses), then all the party members come together and unleash a beating on all the enemies.

If those conditions are not met, the move fails.

-------

My idea so far is to make a skill that links to a Common Event, but I'm just not really sure what the Common Event should have in it to "check" for those lack of status effects/KO, and how to check if all party members are still present.

How do I go about making something like this?
I don't see how you'd do this with a Common Event, unless the skill doesn't behave like a skill at all.

The Common Event is run after the skill is performed, so it can't do anything to stop you from using the skill if you don't meet your requirements.

You could do this pretty easily with Yanfly's Skill Core, using the following notetag:
Code:
<Custom Requirement>
value=true;

for (var i=0; i<$gameParty.battleMembers().length; i++)
{
    if ($gameParty.battleMembers()[i].isDead() || $gameParty.battleMembers()[i].states().length)
        value=false;
}
</Custom Requirement>

Note that this will make sure they're all alive and have no states. If you want to allow beneficial states but disallow negative ones, then you'll need to account for that with individual state IDs, or something like Yanfly's State Categories.
I don't see how you'd do this with a Common Event, unless the skill doesn't behave like a skill at all.

The Common Event is run after the skill is performed, so it can't do anything to stop you from using the skill if you don't meet your requirements.

You could do this pretty easily with Yanfly's Skill Core, using the following notetag:
Code:
<Custom Requirement>
value=true;

for (var i=0; i<$gameParty.battleMembers().length; i++)
{
    if ($gameParty.battleMembers()[i].isDead() || $gameParty.battleMembers()[i].states().length)
        value=false;
}
</Custom Requirement>

Note that this will make sure they're all alive and have no states. If you want to allow beneficial states but disallow negative ones, then you'll need to account for that with individual state IDs, or something like Yanfly's State Categories.

Ahh, does this include stuff like buffs/debuffs as well?
Buffs and debuffs are not states, and you didn't specify it before, so no.

You can add the condition
Code:
|| $gameParty.battleMembers()[i]._buffs.filter(buff => buff<0).length

and it should exclude any party member with a debuff.
Buffs and debuffs are not states, and you didn't specify it before, so no.

You can add the condition
Code:
|| $gameParty.battleMembers()[i]._buffs.filter(buff => buff<0).length

and it should exclude any party member with a debuff.

Oh! No, I don't want to incorporate buffs/debuffs as a "neutral" state or anything like that.
I just meant things like no poison, no KO state, etc. As long as they are alive and "normal", the skill should be able work.



Also, how should I go about the damage formula?

My current plan is that when I execute the damage formula, it will be a sum all of the party members's attack powers together, multiplied by 2.
(And that of course includes the debuffs/buffs).

Thing is, I'm not sure if my damage formula should in the form of...
(a.atk + b.atk + c.atk + d.atk)*2
...cause I know the lettering doesn't work like that. But I don't know how to add the other party member's attack power together.
But I don't know how to add the other party member's attack power together.
Store your other members' Attack stat into variables and use those in your damage formula.
You just check which characters are in the party, whether they're inflicted with Death and for every other status condition that matters. It's not complicated, it just requires setting up a bunch of conditional branches to run all of the checks.
If you run a Common Event at the end of each turn (which you should, even if you don't use it), then just swap between the 2 versions of the skill depending on whether it meets the requirements or not. If you're not running a Common Event at the end of each turn: When casting the Skill, link to a Common Event that checks for the skill conditions, and if the conditions aren't met, Force Action on the failed skill, otherwise Force Action on the successful skill.
Also, how should I go about the damage formula?
Something like this should work to get the sum of everyone's attack power:
JavaScript:
$gameParty.members().reduce((sum, actor) => sum + actor.param(0))
That requires the latest version of RPG Maker MV, and I haven't tested it so there may be minor syntax errors. Before using it, I would recommend pasting it into the game's developer console (either F8 or F12 while playing) to make sure it's correct.
Oh! No, I don't want to incorporate buffs/debuffs as a "neutral" state or anything like that.
I just meant things like no poison, no KO state, etc. As long as they are alive and "normal", the skill should be able work.
Sorry, I really am not sure what you're getting at now. It would help greatly if you kept your terminology accurate to how it's used by RPG Maker.

Buffs and Debuffs are a specific thing that skills can add via their Effects. You asked in post 3 if my code incorporated them, I gave you revised code, and now you're saying you don't want them.

Buffs/Debuffs are not States. States are not Debuffs. I don't know what "a neutral state" means. If you're saying the word "debuff" and meaning a State that has a negative effect, then I addressed that in post 2.
Note that this will make sure they're all alive and have no states. If you want to allow beneficial states but disallow negative ones, then you'll need to account for that with individual state IDs, or something like Yanfly's State Categories.
Something like this should work to get the sum of everyone's attack power:
JavaScript:
$gameParty.members().reduce((sum, actor) => sum + actor.param(0))
That requires the latest version of RPG Maker MV, and I haven't tested it so there may be minor syntax errors. Before using it, I would recommend pasting it into the game's developer console (either F8 or F12 while playing) to make sure it's correct.
actor.param(0) is actually max hp. I think you would want actor.param(2), though it'd be safer/easier to just use actor.atk.

You would also need to add one more argument to the reduce call, in order to define the initial value starting at 0. Putting it all together:
JavaScript:
$gameParty.members().reduce((sum, actor) => sum + actor.atk, 0)

@PoptartPresident
I recently made a "Combination Skills" plugin that I think might be sorta along the same vein as what you're trying to do, and the way I decided to handle the damage formula situation is I made a new set of properties that can be referenced from within the damage formula. So for example, in my damage formula, if I type Combo.atk, it will give me the combined attack power of all melee members participating in the combination skill. Combo.mat will give me the combined magic attack of all casters participating in the combination skill, etc.

If you're just making one such skill, then the code snippet mentioned above will be fine. But if you're planning on having a lot of combination skills, then it might be worth it to go ahead and create the new properties, so that you can keep your damage formulas neater and more readable. Here is an example of how you could make the properties (just copy and paste this into a new .js file and add it to the project through the plugin manager):

Spoiler: Property Code
JavaScript:
//-----------------------------------------------------------------------------
// Combo
//
// A static class used to obtain combined parameters for use in damage formulas

function Combo() {
    throw new Error("This is a static class");
}

Object.defineProperties(Combo, {
    // Hit Points
    hp: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.hp, 0) : 0;
        },
        configurable: true
    },
    // Magic Points
    mp: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mp, 0) : 0;
        },
        configurable: true
    },
    // Tactical Points
    tp: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.tp, 0) : 0;
        },
        configurable: true
    },
    // Maximum Hit Points
    mhp: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mhp, 0) : 0;
        },
        configurable: true
    },
    // Maximum Magic Points
    mmp: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mmp, 0) : 0;
        },
        configurable: true
    },
    // ATtacK power
    atk: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.atk, 0) : 0;
        },
        configurable: true
    },
    // DEFense power
    def: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.def, 0) : 0;
        },
        configurable: true
    },
    // Magic ATtack power of all combo members
    mat: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mat, 0) : 0;
        },
        configurable: true
    },
    // Magic DeFense power
    mdf: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mdf, 0) : 0;
        },
        configurable: true
    },
    // AGIlity
    agi: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.agi, 0) : 0;
        },
        configurable: true
    },
    // LUcK
    luk: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.luk, 0) : 0;
        },
        configurable: true
    },
    // HIT rate
    hit: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.hit, 0) : 0;
        },
        configurable: true
    },
    // EVAsion rate
    eva: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.eva, 0) : 0;
        },
        configurable: true
    },
    // CRItical rate
    cri: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.cri, 0) : 0;
        },
        configurable: true
    },
    // Critical EVasion rate
    cev: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.cev, 0) : 0;
        },
        configurable: true
    },
    // Magic EVasion rate
    mev: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mev, 0) : 0;
        },
        configurable: true
    },
    // Magic ReFlection rate
    mrf: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mrf, 0) : 0;
        },
        configurable: true
    },
    // CouNTer attack rate
    cnt: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.cnt, 0) : 0;
        },
        configurable: true
    },
    // Hp ReGeneration rate
    hrg: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.hrg, 0) : 0;
        },
        configurable: true
    },
    // Mp ReGeneration rate
    mrg: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mrg, 0) : 0;
        },
        configurable: true
    },
    // Tp ReGeneration rate
    trg: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.trg, 0) : 0;
        },
        configurable: true
    },
    // TarGet Rate
    tgr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.tgr, 0) : 0;
        },
        configurable: true
    },
    // GuaRD effect rate
    grd: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.grd, 0) : 0;
        },
        configurable: true
    },
    // RECovery effect rate
    rec: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.rec, 0) : 0;
        },
        configurable: true
    },
    // PHArmacology
    pha: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.pha, 0) : 0;
        },
        configurable: true
    },
    // Mp Cost Rate
    mcr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mcr, 0) : 0;
        },
        configurable: true
    },
    // Tp Charge Rate
    tcr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.tcr, 0) : 0;
        },
        configurable: true
    },
    // Physical Damage Rate
    pdr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.pdr, 0) : 0;
        },
        configurable: true
    },
    // Magic Damage Rate
    mdr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.mdr, 0) : 0;
        },
        configurable: true
    },
    // Floor Damage Rate
    fdr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.fdr, 0) : 0;
        },
        configurable: true
    },
    // EXperience Rate
    exr: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.exr, 0) : 0;
        },
        configurable: true
    },
    // level
    level: {
        get: function() {
            return $gameParty.members().length > 0 ? $gameParty.members().reduce((sum, actor) => sum + actor.level, 0) : 0;
        },
        configurable: true
    }
});

What I pasted to you just now is going to give you the combined values of *all* party members in the battle, rather than singling out the specific members that are participating in the skill, and it won't differentiate between melee/magic members. So you may need to fine-tune it to suit your needs better.
You would also need to add one more argument to the reduce call, in order to define the initial value starting at 0.
I omitted that in my example because it defaults to 0 if not provided.
I omitted that in my example because it defaults to 0 if not provided.
It doesn't quite work that way. If you omit an initial value, then it actually changes the behavior of the reduce method. It will cause it to use the first element of the array as the initial value, and the iteration will start with the second element instead.

The reason that's a problem is because the first element of the array is an object. So then you're trying to add an entire actor object with the atk value of another actor. I don't know if I explained that in a way that makes sense, so I'll just show you an example. I just now booted up a test game, and typed both scripts into the console (one with a default value, and one without). Here are the results:

1659905244418.png


As you can see, omitting the initial value yields a pretty wonky result. It's because the initial value is an entire actor object, rather than the atk property of that actor.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-skill-that-requires-all-party-members-to-be-alive-with-no-statuses.149917/