Hello!
So, in my game the party is comprised of a single hero with 6 accessories able to be equipped. For balance reasons, the player is only able to earn 3 of any accessory in the game.
For the following example, for ease, I'll simply call the accessory "Ribbon."
My ribbon has the note tag <Max Item: 3>
The notetag works perfectly in shops, only allowing me to buy 3 Ribbons.
HOWEVER, if I equip all 3 Ribbons, and go back into the store, I can buy another 3 Ribbons.
I understand this is likely due to the plugin not including equipment when considering max items.
I found another thread with a similar issue, and the proposed code was as follows:
Game_Party.prototype.numItems = function(item)
{
var container = this.itemContainer(item);
let numHeld = container ? container[item.id] || 0 : 0;
if (container == this._weapons)
$gameActors._data.forEach(actor =>
{
if (actor)
actor.weapons().forEach(weapon => {if (weapon.id == item.id || weapon.baseItemId && weapon.baseItemId == item.id) numHeld++;});
});
else if (container == this._armors)
$gameActors._data.forEach(actor =>
{
if (actor)
actor.armors().forEach(armor=> {if (armor.id == item.id || armor.baseItemId && armor.baseItemId == item.id) numHeld++;});
});
return numHeld;
};
Whilst this code works in the shop preventing me from owning more than 3, it presents a new unique issue - it resulted in infinite ribbons. If I equipped one, my number of ribbons would actually go up, which makes sense looking at the code. If I had 3 ribbons equipped, and 3 in my inventory, my total ribbons in my inventory would appear as 6, essentially giving me 9 ribbons.
My question is essentially, how can I make the shop follow the max item cap including the equipment my actor has equipped? Or is there a way to modify this code to ONLY be considered when inside the shop?
Any suggestions at all would be immensely appreciated, thank you!
So, in my game the party is comprised of a single hero with 6 accessories able to be equipped. For balance reasons, the player is only able to earn 3 of any accessory in the game.
For the following example, for ease, I'll simply call the accessory "Ribbon."
My ribbon has the note tag <Max Item: 3>
The notetag works perfectly in shops, only allowing me to buy 3 Ribbons.
HOWEVER, if I equip all 3 Ribbons, and go back into the store, I can buy another 3 Ribbons.
I understand this is likely due to the plugin not including equipment when considering max items.
I found another thread with a similar issue, and the proposed code was as follows:
Game_Party.prototype.numItems = function(item)
{
var container = this.itemContainer(item);
let numHeld = container ? container[item.id] || 0 : 0;
if (container == this._weapons)
$gameActors._data.forEach(actor =>
{
if (actor)
actor.weapons().forEach(weapon => {if (weapon.id == item.id || weapon.baseItemId && weapon.baseItemId == item.id) numHeld++;});
});
else if (container == this._armors)
$gameActors._data.forEach(actor =>
{
if (actor)
actor.armors().forEach(armor=> {if (armor.id == item.id || armor.baseItemId && armor.baseItemId == item.id) numHeld++;});
});
return numHeld;
};
Whilst this code works in the shop preventing me from owning more than 3, it presents a new unique issue - it resulted in infinite ribbons. If I equipped one, my number of ribbons would actually go up, which makes sense looking at the code. If I had 3 ribbons equipped, and 3 in my inventory, my total ribbons in my inventory would appear as 6, essentially giving me 9 ribbons.
My question is essentially, how can I make the shop follow the max item cap including the equipment my actor has equipped? Or is there a way to modify this code to ONLY be considered when inside the shop?
Any suggestions at all would be immensely appreciated, thank you!