garret95

Pokémon Breeder
Member
Joined
Mar 15, 2017
Messages
17
Reaction score
4
First Language
Spanish
Primarily Uses
RMMV
Hi, I'm in the middle of making a summoning skill (kind of) and I needed to remove all actors but the first four, then add them back. I've made this test event that works just fine (there's a second page where I add them back in the same order and, again, works like I charm. I can show it if needed but it's just a bunch of conditional branches).

Sin nombre.png

The problem comes when I try to do the same in battle, where the game gives me a Type Error when using a skill that calls a common event just like the event above. I think the error has something to do with the variables, but I just don't know how to fix it or work around it.

Code:
$gameParty.members()[4]._actorId
YEP_EnhancedTP.js:4035 TypeError: Cannot read property '_actorId' of undefined
    at eval (eval at Game_Interpreter.command122 (YEP_CoreEngine.js:1540), <anonymous>:1:24)
    at Game_Interpreter.command122 (YEP_CoreEngine.js:1540)
    at Game_Interpreter.executeCommand (rpg_objects.js:8930)
    at Game_Interpreter.update (rpg_objects.js:8838)
    at Game_Troop.updateInterpreter (rpg_objects.js:5226)
    at Function.BattleManager.updateEventMain (rpg_managers.js:2281)
    at Function.BattleManager.updateEvent (YEP_BattleEngineCore.js:1948)
    at Function.BattleManager.update (YEP_BattleEngineCore.js:1906)
    at Scene_Battle.updateBattleProcess (rpg_scenes.js:2265)
    at Scene_Battle.update (rpg_scenes.js:2257)
rpg_managers.js:1949 TypeError: require(...).Window.get(...).isDevToolsOpen is not a function
    at Object.Yanfly.Util.displayError (YEP_EnhancedTP.js:4037)
    at Game_Interpreter.command122 (YEP_CoreEngine.js:1542)
    at Game_Interpreter.executeCommand (rpg_objects.js:8930)
    at Game_Interpreter.update (rpg_objects.js:8838)
    at Game_Troop.updateInterpreter (rpg_objects.js:5226)
    at Function.BattleManager.updateEventMain (rpg_managers.js:2281)
    at Function.BattleManager.updateEvent (YEP_BattleEngineCore.js:1948)
    at Function.BattleManager.update (YEP_BattleEngineCore.js:1906)
    at Scene_Battle.updateBattleProcess (rpg_scenes.js:2265)
    at Scene_Battle.update (rpg_scenes.js:2257)

I'd appreciate any help I can get. I'm sure there are details I'm not telling so if you need any info please ask away. I've been searching for a few days now and I feel I'm really close to finally finishing.
 

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
First Language
English
Primarily Uses
RMMZ
According to the stack trace, it can't grab the actor id of $gameParty.members()[4] because that points to something undefined, with no properties.

I think the problem may be the index number you're using. Programming indexes are zero-based, which means the first member of your party is actually index 0. If you don't have 5 members in your party, $gameParty.members()[4] equals nothing.

Edit: Think I tracked down the real culprit. $gameParty.members() has different behavior in battle.

JavaScript:
Game_Party.prototype.members = function() {
    return this.inBattle() ? this.battleMembers() : this.allMembers();
};

So outside battle, it will use everyone in the party, but in battle, only those in the battle group, which defaults to the first 4 members of your party. It never sees the others.
 
Last edited:

garret95

Pokémon Breeder
Member
Joined
Mar 15, 2017
Messages
17
Reaction score
4
First Language
Spanish
Primarily Uses
RMMV
I see, I was beginning to suspect as much.

Is there any way at all of temporarily removing all actors that are not fighting in a battle?
 

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
First Language
English
Primarily Uses
RMMZ
I see, I was beginning to suspect as much.

Is there any way at all of temporarily removing all actors that are not fighting in a battle?
You seem to be at least aware enough of scripting to use javascript, so the easiest method is to grab all actors from allMembers() instead of members() when removing. Since you're storing their actor ids already, you can use them to add the actors back in later in the proper order(I assuming you're already doing it that way, hence the variable use in the beginning of your event).

One potential note: I'm not sure if the actor switching would preserve any of their turn information, so you may need to account for that. It's possible that when they come back they'll "lose" their chance to act until the next turn.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,745
Reaction score
15,312
First Language
English
Primarily Uses
RMMV
When you're in battle, $gameParty.members() will only give you your battlers.
When you're out of battle, $gameParty.members() will give you all of your party.

So, as above, use $gameParty.allMembers() if you want to access reserve members during battle.
 

garret95

Pokémon Breeder
Member
Joined
Mar 15, 2017
Messages
17
Reaction score
4
First Language
Spanish
Primarily Uses
RMMV
Thank you for your replies, I'll look into into it later when I arrive home.

As Drakkonis said, I'm.... aware enough of sripting with java. Nothing less, nothing more, so I kind of headbutt my way while understanding how things work.

Only problem I see (and correct me if I'm wrong) is remembering where the actors were when adding them back.

Edit: Sorry, I don't understand what to do with this new information. How can I implement $gameParty.allMembers() to remove reserve characters and later add them back?
I've tried to use it on a variable and it gives me (objet, Object) for each member (battlers included).
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

I'm so annoyed with myself...I can't get this code to work so it looks like I'm going the plugin route for a problem I should be able to do myself :kaolivid:Great. Now I get to murder save file compatibility. Again.
Can't believe my code from four years ago is still working! Did some expansions, and...
1635194553179.png
In related news, I may have an update for my old Extra status window plugin ready. That is, once I manage to sit down and update the documentation... and the demo project... :kaoswt:
How does one pronounce Godot? I've heard it pronounced a couple of different ways, and I genuinely don't know the proper way.
March 2020 ...
1635188823939.jpeg
... vs October 2021
You look like you had a rough day...Here, have a Baby Panda!

Forum statistics

Threads
116,077
Messages
1,095,555
Members
151,443
Latest member
Xtvback
Top