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,691
Reaction score
15,295
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

While was working on one of the monsters that will appear in my horor game I may have made harold a Lovecraftian monster. (I used his head to keep things aligned.)
Finally got my website fixed and the security sorted so it's been a productive day. Can I go to sleep now? I mean... I don't need to work right?
It's always a good idea to refresh yourself on what your plugins do. I'm working on a map with opening walls, and I was about to tear my hair out over how much image editing and hand-constructing of autotiles I'd have to do, when I looked again and saw @Shaz 's Tile Changer could copy areas from another map.
"sorry it took me so long to respond" - can we please agree not to say that anymore unless it actually took a long time?! (Like 36hrs at least) I mean, I'm running out of funny responses here xD
Ugh... 4:53AM over here and I can't sleep so why not just game make.

Forum statistics

Threads
115,923
Messages
1,094,046
Members
151,176
Latest member
yoshikosai
Top