So here's what I'm trying to accomplish. I want to have two slots for my Accessory equipment type, where any Accessory can go into both slots. As it stands though, all I've done is just make a second slot that does nothing because there's nothing in that equipment type. So yeah... how do I allow players to equip 2 of the same equipment type at once?
How can I have 2 accessory slots that share the same equipment type?
RPG Maker MZ SupportSo here's what I'm trying to accomplish. I want to have two slots for my Accessory equipment type, where any Accessory can go into both slots. As it stands though, all I've done is just make a second slot that does nothing because there's nothing in that equipment type. So yeah... how do I allow players to equip 2 of the same equipment type at once?
I wrote this a couple of weeks ago, did a little testing and it seems to work OK for me:
Or you could look for an established plugin that does it, e.g. VisuStella probably has something~
Edit - here's an updated, slightly more efficient version:
JavaScript:
/*:
* @target MZ
* @plugindesc Allow more than 1 slot per equip type.
* @help Blank equip type names count as previous non-blank equip type.
* E.g. "Weapon", "Shield", "Ring", "", "Amulet" - defines 2 ring slots.
*
* Free to use and/or modify for any project, no credit required.
*/
// M06) Blank equip type names count as previous non-blank equip type.
void (() => {
'use strict';
// E.g. "Weapon", "Shield", "Ring", "", "Amulet" - defines 2 ring slots.
/**
* Tracks duplicate equip types.
* @type {Map<number,number[]>}
*/
const dupeTypes = new Map();
/** Initialises `dupeTypes`. */
const initDupeTypes = function() {
const E = $dataSystem.equipTypes;
const L = E.length;
let root = 1;
dupeTypes.clear();
// blank equip type names count as preceding non-blank equip type ID
for (let n = 1; ++n < L;)
if (!E[n]) {
if (dupeTypes.has(root))
dupeTypes.get(root).push(n);
else
dupeTypes.set(root, [n]);
} else
root = n;
};
/**
* Maps duplicate slots to their root equip type ID.
* @param {number} etypeId input equip type ID
* @param {number} n source index
* @param {number[]} arr source array
* @returns {number} output equip type ID
*/
const dupeSlot = function(etypeId) {
for (const [k, v] of dupeTypes.entries())
if (v.contains(etypeId))
return k;
return etypeId;
};
// Initialise dupe types.
void (alias => {
Scene_Boot.prototype.start = function() {
initDupeTypes();
alias.apply(this, arguments);
};
})(Scene_Boot.prototype.start);
// Map equip slots to their root type ID as appropriate.
void (alias => {
Game_Actor.prototype.equipSlots = function() {
return alias.apply(this, arguments).map(n => dupeSlot(n));
};
})(Game_Actor.prototype.equipSlots);
})();
Edit - here's an updated, slightly more efficient version:
JavaScript:
/*:
* @target MZ
* @plugindesc Allow more than 1 slot per equip type.
* @help Blank equip type names count as previous non-blank equip type.
* E.g. "Weapon", "Shield", "Ring", "", "Amulet" - defines 2 ring slots.
*
* Free to use and/or modify for any project, no credit required.
*/
// M06) Blank equip type names count as previous non-blank equip type.
void (() => {
'use strict';
// E.g. "Weapon", "Shield", "Ring", "", "Amulet" - defines 2 ring slots.
/** Array of root values for each equip type ID. */
const types = [];
/** Initialises {@linkcode types}. */
const initDupeTypes = function() {
const E = $dataSystem.equipTypes;
const L = E.length;
let root = types[0] = 1;
for (let n = 1; ++n < L;)
types[n - 1] = E[n] ? root = n : root;
};
/**
* Maps given equip type ID to its root type ID.
* @param {number} eTypeId input equip type ID
* @returns {number} "real" equip type ID.
*/
const dupeSlot = function(eTypeId) {
return types[eTypeId - 1];
};
// Initialise dupe types on game boot.
void (alias => {
Scene_Boot.prototype.start = function() {
initDupeTypes();
alias.apply(this, arguments);
};
})(Scene_Boot.prototype.start);
// Map equip slots to their root type ID as appropriate.
void (alias => {
Game_Actor.prototype.equipSlots = function() {
return alias.apply(this, arguments).map(n => dupeSlot(n));
};
})(Game_Actor.prototype.equipSlots);
})();
Their Items and Equip Core does this, but I'd recommend OP try yours first because there's no telling how the VS plugin will react with whatever is being used to make the menus look like NES Dragon Quest.
Ah, yeah, I actually tried the Items and Equips Core before, but it forces a bunch of mandatory stuff that you can't toggle off that I don't like, so I didn't want to use that. I'll try the script posted above and report back!
Great! Happy RPG Making~ 😂
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-have-2-accessory-slots-that-share-the-same-equipment-type.153639/