Easier way to award XP to discovered party members only?

RPGMaker MV latest version.
I have several CEs set up to award experience to the party, CEs which are called from events completing quests. Each CE awards a different amount of experience: 100, 200 etc to 1000.
I want every party member currently discovered in the game to get the experience (you start out solo, and gain up to five allies as you explore the world).

I tried just using
Code:
$gameParty.gainExp(1000);
but that doesn't do anything.

I tried using
Code:
$gameActors.actor(1).gainExp(1000);
$gameActors.actor(2).gainExp(1000);
$gameActors.actor(3).gainExp(1000);
$gameActors.actor(4).gainExp(1000);
$gameActors.actor(5).gainExp(1000);
$gameActors.actor(6).gainExp(1000);
but that gives the XP to all six possible party members, by name when the level up message is displayed, even if you haven't discovered them yet.

So I've gone with what's in the following screenshot (character names redacted):

LvlUp_CE.png


Surely there's a better way?

Also, is there a library of MV scripts anywhere? That would be really helpful!

Cheers

~M~
Surely there's a better way?
why not use the command that was designed for this:
partyexp.png
>600 hours with MV and I NEVER KNEW the entire party option was on that list!
I NEVER KNEW the entire party option was on that list!
it's there for every command where it is possible, only very few change commands that need a specific actor (like change equipment) don't have an "entire party" option.
Also if the amount gained is variable (depends of your CE) you can use $gameVariables.value(x) instead of 1000.

To use the command as a script call, it should be :
$gameParty.members().forEach(function(actor) { actor.gainExp($gameVariables.value(x)); });
where x is the variable ID. then you'll only need to set the variable to "1000", "200" or anything and it'll give the number of XP you've set it to.
you can use $gameVariables.value(x) instead of 1000.
no need for a script there either, the event command "change EXP" also supports the use of variables.

people should really learn to check the event commands BEFORE looking for a scripted solution, all functions needed for basic RPGs are directly (and often better) handled with event commands.
no need for a script there either, the event command "change EXP" also supports the use of variables.
Did not know, since I never needed something like this in +3000 hours, ahah.

But still, if OP was to make multiple common events of the same action, just giving a different value, there's a way to optimize this by using a variable, and setting the value of the variable before calling the common event.
no need for a script there either, the event command "change EXP" also supports the use of variables.

people should really learn to check the event commands BEFORE looking for a scripted solution, all functions needed for basic RPGs are directly (and often better) handled with event commands.
We're always learning. Things might not be as intuitive to others 🙂

Original thread: https://forums.rpgmakerweb.com/threads/easier-way-to-award-xp-to-discovered-party-members-only.143900/