Hi!
(I know the title is confusing, but I couldn't find a better way to summarize it)
The thing is:
ChatGPT has created a script for my game to retain party equipment when removing/adding members. So, when I remove a member from the party temporarily and this member returns later, their equipment is still with them (this can't seem to be done without this script).
The problem is that during the early stage of development, I used this to solve another issue:
Without removing and re-adding the protagonist first, when I added a new character, it would become the main character (the first in the party order). I just wanted to avoid that and this was an easy way to do it.
Now that I have this new script, a player noticed that error when playing the first moment when a new character is added to the party like that. Here is the error:
rpg_managers.js:1949 TypeError: item.object is not a function
at rpg_objects.js:3600
at Array.map (<anonymous>)
at Game_Actor.equips (rpg_objects.js:3599)
at Game_Actor.equips (YEP_EquipCore.js:469)
at Game_Actor.traitObjects (rpg_objects.js:3810)
at Game_Actor.Game_BattlerBase.allTraits (rpg_objects.js:2375)
at Game_Actor.Game_BattlerBase.traits (rpg_objects.js:2381)
at Game_Actor.Game_BattlerBase.traitsSet (rpg_objects.js:2411)
at Game_Actor.Game_BattlerBase.slotType (rpg_objects.js:2539)
at Game_Actor.Game_BattlerBase.isDualWield (rpg_objects.js:2544)
SceneManager.catchException @ rpg_managers.js:1949
Here is the script I created with ChatGPT (it can't seem to solve the issue, even after adding extra checks):
Just adding/removing members doesn't cause the error. It only occurs when the party is empty. Disabling the script solves the issue. Here is the game's full plugin list:
My questions are:
Can this plugin be edited to work without causing this error when there are no members in the party? This is a recurrent instance in my game and having to remember all moments when that happens would be a headache at this point.
Is there an existing plugin that prevents equipment removal on member removal? That would help too.
I can provide any other information necessary. Thanks in advance!
(I know the title is confusing, but I couldn't find a better way to summarize it)
The thing is:
ChatGPT has created a script for my game to retain party equipment when removing/adding members. So, when I remove a member from the party temporarily and this member returns later, their equipment is still with them (this can't seem to be done without this script).
The problem is that during the early stage of development, I used this to solve another issue:
Without removing and re-adding the protagonist first, when I added a new character, it would become the main character (the first in the party order). I just wanted to avoid that and this was an easy way to do it.
Now that I have this new script, a player noticed that error when playing the first moment when a new character is added to the party like that. Here is the error:
rpg_managers.js:1949 TypeError: item.object is not a function
at rpg_objects.js:3600
at Array.map (<anonymous>)
at Game_Actor.equips (rpg_objects.js:3599)
at Game_Actor.equips (YEP_EquipCore.js:469)
at Game_Actor.traitObjects (rpg_objects.js:3810)
at Game_Actor.Game_BattlerBase.allTraits (rpg_objects.js:2375)
at Game_Actor.Game_BattlerBase.traits (rpg_objects.js:2381)
at Game_Actor.Game_BattlerBase.traitsSet (rpg_objects.js:2411)
at Game_Actor.Game_BattlerBase.slotType (rpg_objects.js:2539)
at Game_Actor.Game_BattlerBase.isDualWield (rpg_objects.js:2544)
SceneManager.catchException @ rpg_managers.js:1949
Here is the script I created with ChatGPT (it can't seem to solve the issue, even after adding extra checks):
JavaScript:
//=============================================================================
// ZOE_RetainEquipment.js
//=============================================================================
/*:
* @plugindesc Retain equipment for actors when removed from the party and added again.
* Also provides options to control functionality through plugin commands, parameters, and notetags.
*
* <RetainEquipment>
* @param Initial Plugin Status
* @desc Initial status of the plugin functions. Set to 'true' to enable by default, 'false' to disable. Default: true
* @default true
*
* @help ZOE_RetainEquipment.js
* Version: 1.0
* Credits to ZoeZero (Zoe Miranda)
* Free for both commercial and non-commercial use.
*
* This plugin ensures that equipment is not automatically unequipped from
* an actor when they are removed from the party. They will have the same
* equipment when added back to the party again unless specified otherwise.
*
* Plugin Commands:
* EnableRetainEquipment - Enable the plugin functions.
* DisableRetainEquipment - Disable the plugin functions.
* EnableNotetagFunctions - Enable only the notetag-related functions.
* DisableNotetagFunctions - Disable only the notetag-related functions.
*
* Script Calls:
* $gameSystem.enableRetainEquipment() - Enable the plugin functions.
* $gameSystem.disableRetainEquipment() - Disable the plugin functions.
* $gameSystem.enableNotetagFunctions() - Enable only the notetag-related functions.
* $gameSystem.disableNotetagFunctions() - Disable only the notetag-related functions.
*
* Notetags:
* <RetainEquipment> - Add this notetag to actors, equipment, weapons, classes, or states to retain equipment for them.
* <DisableRetainEquipment> - Add this notetag to actors, equipment, weapons, classes, or states to disable equipment retention for them.
*/
(function() {
var parameters = PluginManager.parameters('ZOE_RetainEquipment');
var initialStatus = parameters['Initial Plugin Status'] === 'true';
var retainEquipmentEnabled = initialStatus;
var notetagFunctionsEnabled = initialStatus;
var pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
pluginCommand.call(this, command, args);
if (command === 'EnableRetainEquipment') {
retainEquipmentEnabled = true;
} else if (command === 'DisableRetainEquipment') {
retainEquipmentEnabled = false;
} else if (command === 'EnableNotetagFunctions') {
notetagFunctionsEnabled = true;
} else if (command === 'DisableNotetagFunctions') {
notetagFunctionsEnabled = false;
}
};
var _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_Game_System_initialize.call(this);
this._retainEquipmentEnabled = initialStatus;
this._notetagFunctionsEnabled = initialStatus;
};
Game_System.prototype.enableRetainEquipment = function() {
this._retainEquipmentEnabled = true;
};
Game_System.prototype.disableRetainEquipment = function() {
this._retainEquipmentEnabled = false;
};
Game_System.prototype.enableNotetagFunctions = function() {
this._notetagFunctionsEnabled = true;
};
Game_System.prototype.disableNotetagFunctions = function() {
this._notetagFunctionsEnabled = false;
};
var _Game_Party_removeActor = Game_Party.prototype.removeActor;
Game_Party.prototype.removeActor = function(actorId) {
if ($gameSystem._retainEquipmentEnabled && this._actors.includes(actorId)) {
var actor = $gameActors.actor(actorId);
if (actor) { // Ensure actor exists
actor._lastEquipments = JSON.parse(JSON.stringify(actor._equips));
}
}
_Game_Party_removeActor.call(this, actorId);
};
var _Game_Party_addActor = Game_Party.prototype.addActor;
Game_Party.prototype.addActor = function(actorId) {
_Game_Party_addActor.call(this, actorId);
if (!$gameSystem._retainEquipmentEnabled) return;
var actor = $gameActors.actor(actorId);
if (actor && actor._lastEquipments) { // Ensure actor exists and has saved equipment
actor._equips = JSON.parse(JSON.stringify(actor._lastEquipments));
actor.refresh();
}
if (actor) actor._lastEquipments = null; // Reset saved equipment only if actor exists
};
var _Game_Actor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function(actorId) {
_Game_Actor_setup.call(this, actorId);
if ($gameSystem._notetagFunctionsEnabled) {
this.checkRetainEquipmentNotetag();
}
};
Game_Actor.prototype.checkRetainEquipmentNotetag = function() {
var actor = this.actor();
var classData = this.currentClass();
var equips = [actor].concat(this.equips()).concat(this.weapons()).concat(this.armors()).concat(classData);
equips.forEach(function(data) {
if (data && data.meta) {
if (data.meta.RetainEquipment) {
this._lastEquipments = JSON.parse(JSON.stringify(this._equips));
} else if (data.meta.DisableRetainEquipment) {
this._lastEquipments = null;
}
}
}, this);
};
})();
Just adding/removing members doesn't cause the error. It only occurs when the party is empty. Disabling the script solves the issue. Here is the game's full plugin list:
My questions are:
Can this plugin be edited to work without causing this error when there are no members in the party? This is a recurrent instance in my game and having to remember all moments when that happens would be a headache at this point.
Is there an existing plugin that prevents equipment removal on member removal? That would help too.
I can provide any other information necessary. Thanks in advance!