So, to put this briefly, I have an Idea for a randomized rougelike, and one thing that is going to be randomized is Party Members. You can find random party members, but if you die, you're sent back to the starting room with no party members. Is there a way to remove All the Party members with one command rather than listing each individual one in every battle's lose code?
How to Remove ALL party members?
RPG Maker MV SupportYes, there is.
Could you perhaps.... tell me where I could find it, please? I only know of the "Change Party Member" command to remove them.
Of course I can! You had but to ask. (sorry, I have this thing I do where if someone just asks if there's a way to do something, my initial response will just be "yes" because that's the question they asked XD)
Use the "script" command:
$gameParty._actors = [];
That's if you want to completely empty the party. If you want to keep a "main character" there, do
$gameParty._actors = [x];
where x is the ID of that actor.
Hey, you don't know that! Maybe it's a game where everything is nearly a shade of red. 😛
Thank you. You just saved me hours of copy and pasting.
This just makes me mad at everyone I talk to on a daily basis who never corrected me lol. I'll remember that.
I'm sorry to bother you once again, but it doesn't seem to work for me. No party members get removed no matter what I do. Is this the correct way to use it?
That should be it. Can I see the rest of that event?
That's all there is. Apart from a text to make sure the event was running. I just put it into the game quickly to test it and it doesn't do anything.
I mean the rest of the event editor. I need to see the whole thing to see what the potential problem is.
Oh alright. Here.
Oh, I'm guessing you think it hasn't worked because your on-map character is the same. After that put
$gamePlayer.refresh();
That worked! Tysm!
Hi there!
I know you had your answer, but maybe you should consider using the proper method to do it. Just to be safe in case you may use any plugin that performs some stuff when removing an actor from the party or who knows what more ^^''
This is the script call to use. It will always leave one actor, the party leader.
(If you don't want to keep the party leader, remove the > 1)
Just for reference, here is the function that removes the actor:
You will run the refresh methods more than once though, but don't think is a thing to worry about.
I know you had your answer, but maybe you should consider using the proper method to do it. Just to be safe in case you may use any plugin that performs some stuff when removing an actor from the party or who knows what more ^^''
This is the script call to use. It will always leave one actor, the party leader.
(If you don't want to keep the party leader, remove the > 1)
JavaScript:
while($gameParty.members().length > 1){
const actorId = $gameParty._actors.pop()
$gameParty.removeActor(actorId)
}
Just for reference, here is the function that removes the actor:
JavaScript:
Game_Party.prototype.removeActor = function(actorId) {
if (this._actors.includes(actorId)) {
const actor = $gameActors.actor(actorId);
const wasBattleMember = this.battleMembers().includes(actor);
this._actors.remove(actorId);
$gamePlayer.refresh();
$gameMap.requestRefresh();
$gameTemp.requestBattleRefresh();
if (this.inBattle() && wasBattleMember) {
actor.onBattleEnd();
}
}
};
You will run the refresh methods more than once though, but don't think is a thing to worry about.
That's a fair point. Assuming you're using anything that has code dealing with removing actors from the party, Eli's method is far safer.
I agree that it's best to go through the proper method. However, there is a small problem with the script call that you posted. You're popping the value from the
$gameParty._actors array before you call the $gameParty.removeActor method, which means that the value is no longer in the array by the time the method is executed. This means that the if (this._actors.includes(actorId)) check will always fail, and none of the code inside the method will be executed (so the refresh methods will not get called).Something like this would solve the issue:
JavaScript:
while ($gameParty.members().length > 1) {
const actorId = $gameParty._actors[$gameParty._actors.length - 1];
$gameParty.removeActor(actorId);
}
Oh yeah, indeed!
Nice catch!
Original thread: https://forums.rpgmakerweb.com/threads/how-to-remove-all-party-members.157574/