MZ Learned skills limit, and forget skills option.

Hey everyone, I have a little request for (what I assume will be) a fairly simple plugin. If something like this already exists, please point me in the direction of where I can find it! If not... well, I'd really appreciate it if someone could help me out!

So here's the deal: I want to be able to limit how many skills my actors can learn. In my game, there are items which teach skills when used on an actor, and I want it to be impossible to have every single skilled learned at one time. I would need it where if you try and use a skill-teaching item on an actor who already has the maximum number of skills learned, it will play the error sound and refuse to teach them the skill, and not consume the item. But since there would be more skills than slots available, I would also need an option to be added to the skill menu, or accessible via button press, to forget a learned skill so that you could make way for new skills to be learned. I would also like to be able to choose via plugin options what sort of message is displayed when it asks you if you want to forget a skill, and of course, there should be a yes/no confirmation message before you forget one.

Additionally, I am using a short plugin that was made by @ATT_Turan in another thread that I made, which can be found here: https://forums.rpgmakerweb.com/inde...s-be-restricted-by-class.148995/#post-1284820

That plugin is what prohibits an actor from learning skills that they aren't allowed to (such as a Wizard not being allowed to learn healing spells), as well as prevents you from wasting the skill-teaching items on actors that already know the skill in question. So this new plugin would need to be compatible with that one. Other than that, I don't think I have any plugins currently that might cause any conflicts.

Also, I should probably mention that the plugin needs to be allowed for commercial use, since while I don't plan to outright charge for the game once it's done, I plan to use a "pay what you want with the option of free" model. I hope that's not a problem! Anyway, I hope someone here can help me out! I would really appreciate it!
Bump!
I made a mockup image showing what I need using Paint.

1658372668040.png


I really need this plugin in order to make my skill system work the way I want it to. The game pretty much can't function as intended without it 🙁
Bumping again. Guys, I reeeeeally need something like this in order to make my game function right 🙁
For the limited known skills bit, here's the snippet I made for you last time with a modification:
Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

return this.item().effects.some(effect =>
        effect.code==Game_Action.EFFECT_LEARN_SKILL ? 
        target.skills().length>=X :
        this.testItemEffect(target, effect)
    );
};

change X to the maximum number of skills per actor. That should prevent you from using a skill learn item if they already have X skills known.

As for the second one, I don't think it's so difficult that you need to pay a coder.

1 - Make an item for each skill that can be learned, of type Hidden Item

2 - Add to the items you use to learn skills a common event that gives the party the appropriate Hidden Item for that skill

3 - Make a usable item that calls a common event (or have an NPC, whatever) that uses the Select Item event command and chooses the Hidden Item category. Remove the skill based on the item chosen.

It's a bit of work to set up, but it's free.
For the limited known skills bit, here's the snippet I made for you last time with a modification:
Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

return this.item().effects.some(effect =>
        effect.code==Game_Action.EFFECT_LEARN_SKILL ?
        target.skills().length>=X :
        this.testItemEffect(target, effect)
    );
};

change X to the maximum number of skills per actor. That should prevent you from using a skill learn item if they already have X skills known.

As for the second one, I don't think it's so difficult that you need to pay a coder.

1 - Make an item for each skill that can be learned, of type Hidden Item

2 - Add to the items you use to learn skills a common event that gives the party the appropriate Hidden Item for that skill

3 - Make a usable item that calls a common event (or have an NPC, whatever) that uses the Select Item event command and chooses the Hidden Item category. Remove the skill based on the item chosen.

It's a bit of work to set up, but it's free.

I tried adding that plugin to my project, but... now it just seems to make it where nobody can learn any skills through the items. It just errors out every time. If I remove that plugin and go back to the old one you made for me, they can learn skills again. So... something seems to be wrong 😛

Second, your idea sounds like it could work in theory, BUT wouldn't that just give me a great big list of every single skill in the select item event? So even invalid skills that nobody currently knows would be listed there, right? Plus, how would doing it that way let the game know which actor to remove the skill from?

Does this seem like something that I would need to pay someone for? How much do you think it'd cost for a plugin like this? And where would be the appropriate place to ask for such a thing?
I tried adding that plugin to my project, but... now it just seems to make it where nobody can learn any skills through the items. It just errors out every time. If I remove that plugin and go back to the old one you made for me, they can learn skills again. So... something seems to be wrong 😛
What value did you put for X? And how many skills does the actor you're trying on already know?
Second, your idea sounds like it could work in theory, BUT wouldn't that just give me a great big list of every single skill in the select item event?
ATT_Turan said:
2 - Add to the items you use to learn skills a common event that gives the party the appropriate Hidden Item for that skill
So even invalid skills that nobody currently knows would be listed there, right?
If you're giving the hidden item when you use the item, I don't see how.
Plus, how would doing it that way let the game know which actor to remove the skill from?
Your question is backwards. The game knows because you have conditional branches checking the item ID of the hidden item the player selected.
For the player to know, you'd need to make a version of the item for each actor who can learn a given skill. So you activate your skill forgetting event and the player chooses from a list that looks something like:
Cure Light Wounds - Harold
Cure Light Wounds - Teresa
Fireball - Harold
Magic Missile - Lucius
etc.
Does this seem like something that I would need to pay someone for? How much do you think it'd cost for a plugin like this? And where would be the appropriate place to ask for such a thing?
Any time you want to do something non-trivial via JavaScript (like coding a custom scene/interface for this) that no one else has ever asked for, I would presume you'd need to commission it to be done. There's a dedicated Classifieds forum.
What value did you put for X? And how many skills does the actor you're trying on already know?



If you're giving the hidden item when you use the item, I don't see how.

Your question is backwards. The game knows because you have conditional branches checking the item ID of the hidden item the player selected.
For the player to know, you'd need to make a version of the item for each actor who can learn a given skill. So you activate your skill forgetting event and the player chooses from a list that looks something like:
Cure Light Wounds - Harold
Cure Light Wounds - Teresa
Fireball - Harold
Magic Missile - Lucius
etc.

Any time you want to do something non-trivial via JavaScript (like coding a custom scene/interface for this) that no one else has ever asked for, I would presume you'd need to commission it to be done. There's a dedicated Classifieds forum.

I put 16 for the X value. The actors knew 0-2 skills, definitely well under 16.

I'm... not sure if I understand what you mean. So like... I would have to have a separate hidden item for every single actor, for every single skill... but... when teaching the skill to a character, wouldn't it give every hidden item for each character related to that skill? So wouldn't the options to delete the skill from every character pop up after having used the item on just one actor? I... don't think I get it...

Also, I have 60 skills and 7 actors that can learn them (though some can only learn certain ones). That sounds like an enormous amount of work to set it up the way you suggested... at least, assuming I'm understanding what you mean...

So how does it work? Do I tell them what I want and they pitch me a price, or should I say "I have X amount of money to work with", or what?
I would have to have a separate hidden item for every single actor, for every single skill... but... when teaching the skill to a character, wouldn't it give every hidden item for each character related to that skill?
I'm not sure what the misunderstanding is here, if you just need to do some more basic eventing tutorials and projects to figure out how stuff works, perhaps. "It," meaning RPG Maker, doesn't do anything you don't tell it to. If you tell it to give the party Cure Light Wounds - Harold, it does. It doesn't also give the party Cure Light Wounds - Lucius unless you tell it to do that, too.
Also, I have 60 skills and 7 actors that can learn them (though some can only learn certain ones). That sounds like an enormous amount of work to set it up the way you suggested
I guess "enormous" is all a matter of perspective. To me, making an item and then copying and pasting it 6 times, then changing one word on each of those things takes a matter of seconds. And then in the events that give said items, it's again a matter of copying and pasting and changing one thing in each pasted part. So...I dunno. Your preference is your own, and if that sounds like an amount of work that is worth money for you to avoid, then that's a fine decision for you.
So how does it work? Do I tell them what I want and they pitch me a price, or should I say "I have X amount of money to work with", or what?
I'm sure there are pinned threads in the forum that give you the relevant rules. I've never posted there.

As far as the item using part, add the line I'm adding below. In the game, press F8, go to the console tab, show us what it says when you try to use the item.

Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

console.log("Skills length " + target.skills().length);

return this.item().effects.some(effect =>
        effect.code==Game_Action.EFFECT_LEARN_SKILL ? 
        target.skills().length>=X :
        this.testItemEffect(target, effect)
    );
};
Also, I have 60 skills and 7 actors that can learn them (though some can only learn certain ones). That sounds like an enormous amount of work to set it up the way you suggested
In my opinion, that's small potatoes. Not to say that you won't get someone to create a plugin for you to make things easier, but if spreading out only sixty skills among seven actors sounds like a lot of work, you've got a long road ahead of you, buddy.
I'm not sure what the misunderstanding is here, if you just need to do some more basic eventing tutorials and projects to figure out how stuff works, perhaps. "It," meaning RPG Maker, doesn't do anything you don't tell it to. If you tell it to give the party Cure Light Wounds - Harold, it does. It doesn't also give the party Cure Light Wounds - Lucius unless you tell it to do that, too.

I guess "enormous" is all a matter of perspective. To me, making an item and then copying and pasting it 6 times, then changing one word on each of those things takes a matter of seconds. And then in the events that give said items, it's again a matter of copying and pasting and changing one thing in each pasted part. So...I dunno. Your preference is your own, and if that sounds like an amount of work that is worth money for you to avoid, then that's a fine decision for you.

I'm sure there are pinned threads in the forum that give you the relevant rules. I've never posted there.

As far as the item using part, add the line I'm adding below. In the game, press F8, go to the console tab, show us what it says when you try to use the item.

Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

console.log("Skills length " + target.skills().length);

return this.item().effects.some(effect =>
        effect.code==Game_Action.EFFECT_LEARN_SKILL ?
        target.skills().length>=X :
        this.testItemEffect(target, effect)
    );
};

Right, I know that it won't give the skill to a non-specified actor. But what I think I'm understanding is that doing what you suggested will populate a great big list of skills to remove, for every single actor that can possibly learn a skill, even if they don't know that skill, am I right?

Like for example, let's say I have four party members, Luca, Kristin, Genos and Rena, and only Luca and Genos can learn the spell Fire.

If I use the Fire Book item on Luca, she will learn Fire, as specified in the item's effects. And, as you suggest, we also make this item add a hidden item that will be used to remove this Fire spell later on. Right? And in order to make it possible to remove this spell from any given actor, it will add hidden items applicable to every valid party member for that purpose... right? So even though we only use the Fire Book on Luca, it gives us the hidden items applicable to removing Fire from Luca *and* Genos. We would *have* to do that, right? Since there's only one Fire Book item, not one unique to each actor, but rather a singular Fire Book that teaches Fire to any applicable actor.... right?

Then... later on, we decide to remove Fire from Luca. So I speak to an NPC that brings up the Select Item menu... but because we have the hidden items applicable to both Luca and Genos, from using the Fire Book... then the menu will read "Fire - Remove from Luca" AND "Fire - Remove from Genos", even though Genos *doesn't know Fire*... right? Isn't that how this would work? So... that would be weird, right? For the player to be prompted to remove a skill from a character that doesn't know the skill.

And as for the number of skills and actors, I know that's not a lot, BUT... well, I just did the calculation, and among all of the party members (including the 8th one that gets her own unique spells), there are 256 possible skills to be learned. So I would have to set up hidden items for every single one of those potential skill deletions. Which... isn't as much as I initially thought it would be, but it's still kind of a lot.

But I think the bigger problem... is that if you've managed to have at least one instance of each skill across all of your party members... then when you try and access the deletion menu, you'll just end up with a massive select item list of 256 entries, many of which aren't even applicable to what your party has actually learned. To the player, that would most likely be a huge eyesore, and probably make them feel irritated that they have to go through this humongous list of skill deletion prompts, many of which don't even work because most of the actors don't know most of the skills.

I mean... unless I'm misunderstanding how this all works... But from what I'm understanding, it just seems like it would irritate players to have to delete their skills in this manner...

As for the console thing...

1658939689845.png


Whenever I try and teach a skill via an item while that plugin is active, it just plays a buzzer and gives one of those Skills length errors in the console.

In my opinion, that's small potatoes. Not to say that you won't get someone to create a plugin for you to make things easier, but if spreading out only sixty skills among seven actors sounds like a lot of work, you've got a long road ahead of you, buddy.

Well like I said above, its not so much the amount of work, but how irritating it would be for the player to have to go through such a massive (largely ineffective) list when they want to delete a skill.
If I use the Fire Book item on Luca, she will learn Fire, as specified in the item's effects. And, as you suggest, we also make this item add a hidden item that will be used to remove this Fire spell later on. Right?
Right.
And in order to make it possible to remove this spell from any given actor, it will add hidden items applicable to every valid party member for that purpose... right?
Wrong.
So even though we only use the Fire Book on Luca, it gives us the hidden items applicable to removing Fire from Luca *and* Genos. We would *have* to do that, right? Since there's only one Fire Book item, not one unique to each actor, but rather a singular Fire Book that teaches Fire to any applicable actor.... right?
This is not what I described in my last two posts.

You would say in the book's common event, "We're targeting the actor Luca, so we're going to give the party the Hidden Item 'Fire - Luca'." There's no reason you would also give 'Fire - Kristin' or 'Fire - Genos'...that would, in fact, defeat the entire purpose.

So, yes, the way you describe the system would be useless and annoying to the player...that's just quite different from how I described the system to you 🤣

Whenever I try and teach a skill via an item while that plugin is active, it just plays a buzzer and gives one of those Skills length errors in the console.
Huh. Okay, those numbers are what we'd expect to see. There must be something wrong with my code, but I don't know what. Let's try moving it into the older format that is what's originally in the function.

Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

return this.item().effects.some(function(effect) {
        return effect.code==Game_Action.EFFECT_LEARN_SKILL ? target.skills().length>=16 : this.testItemEffect(target, effect);
    }, this);
};
Right.

Wrong.

This is not what I described in my last two posts.

You would say in the book's common event, "We're targeting the actor Luca, so we're going to give the party the Hidden Item 'Fire - Luca'." There's no reason you would also give 'Fire - Kristin' or 'Fire - Genos'...that would, in fact, defeat the entire purpose.

So, yes, the way you describe the system would be useless and annoying to the player...that's just quite different from how I described the system to you 🤣


Huh. Okay, those numbers are what we'd expect to see. There must be something wrong with my code, but I don't know what. Let's try moving it into the older format that is what's originally in the function.

Code:
Game_Action.prototype.hasItemAnyValidEffects = function(target) {
if ($dataItems[this.item().id].meta.notClass && $dataItems[this.item().id].meta.notClass.includes(target.currentClass().id.toString()))
    return false;

return this.item().effects.some(function(effect) {
        return effect.code==Game_Action.EFFECT_LEARN_SKILL ? target.skills().length>=16 : this.testItemEffect(target, effect);
    }, this);
};
See? I told you I was confused! lol

So... hmm... Would it still come up as one big menu with skills from every actor, or could you bring up a menu exclusively of the skills on one actor? Like to make a choice of who is in your party and only display the hidden item selection box for the character you chose?

And so, since I didn't understand it correctly... what would one of these items/events look like? What do I need to put in the item's Effects box to do it the right way?

Tried the new code, but it doesn't work - just giving an error buzzer when I try and use the skill book on a character, regardless of how many skills they have. Also, the console doesn't seem to display any errors this time.
Okay. Last try, then I give up. Reset that code back to what I gave you last thread, where it worked fine and checked for the notetag.

Add this snippet (it can go in the same .js file as the other one):
Code:
Game_Action.prototype.testItemEffect = function(target, effect) {
    switch (effect.code) {
        case Game_Action.EFFECT_RECOVER_HP:
            return (
                target.hp < target.mhp || effect.value1 < 0 || effect.value2 < 0
            );
        case Game_Action.EFFECT_RECOVER_MP:
            return (
                target.mp < target.mmp || effect.value1 < 0 || effect.value2 < 0
            );
        case Game_Action.EFFECT_ADD_STATE:
            return !target.isStateAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_STATE:
            return target.isStateAffected(effect.dataId);
        case Game_Action.EFFECT_ADD_BUFF:
            return !target.isMaxBuffAffected(effect.dataId);
        case Game_Action.EFFECT_ADD_DEBUFF:
            return !target.isMaxDebuffAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_BUFF:
            return target.isBuffAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_DEBUFF:
            return target.isDebuffAffected(effect.dataId);
        case Game_Action.EFFECT_LEARN_SKILL:
            return target.isActor() && !target.isLearnedSkill(effect.dataId) && target.skills().length<16;
        default:
            return true;
    }
};
Okay. Last try, then I give up. Reset that code back to what I gave you last thread, where it worked fine and checked for the notetag.

Add this snippet (it can go in the same .js file as the other one):
Code:
Game_Action.prototype.testItemEffect = function(target, effect) {
    switch (effect.code) {
        case Game_Action.EFFECT_RECOVER_HP:
            return (
                target.hp < target.mhp || effect.value1 < 0 || effect.value2 < 0
            );
        case Game_Action.EFFECT_RECOVER_MP:
            return (
                target.mp < target.mmp || effect.value1 < 0 || effect.value2 < 0
            );
        case Game_Action.EFFECT_ADD_STATE:
            return !target.isStateAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_STATE:
            return target.isStateAffected(effect.dataId);
        case Game_Action.EFFECT_ADD_BUFF:
            return !target.isMaxBuffAffected(effect.dataId);
        case Game_Action.EFFECT_ADD_DEBUFF:
            return !target.isMaxDebuffAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_BUFF:
            return target.isBuffAffected(effect.dataId);
        case Game_Action.EFFECT_REMOVE_DEBUFF:
            return target.isDebuffAffected(effect.dataId);
        case Game_Action.EFFECT_LEARN_SKILL:
            return target.isActor() && !target.isLearnedSkill(effect.dataId) && target.skills().length<16;
        default:
            return true;
    }
};

IT WORKS!!!!

Okay but um... I think this may have been my fault. Do recall that you are dealing with an idiot (me)...

...Was I supposed to be appending these lines of code to the existing plugin the entire time? Cause uhh... I was removing the old plugin and just using the new one each time...

But uh... either way... it works!

Mind if I ask WHY it works? What was changed to make it work? Unless it was just me being stupid this whole time lol.

Well, now at least I can limit characters to 16 skills! Now I just need an easy way to forget them lol
I was removing the old plugin and just using the new one each time...
That's what I told you to do.
Mind if I ask WHY it works?
I have no clue 😛

It's the exact same code, for some reason it doesn't work correctly in the in-line function so I took it into the other one (which, technically, is slightly better coding practice anyway).

Glad it works.
That's what I told you to do.

I have no clue 😛

It's the exact same code, for some reason it doesn't work correctly in the in-line function so I took it into the other one (which, technically, is slightly better coding practice anyway).

Glad it works.
Oh, phew! At least I'm not an idiot (this time) lol!

Thanks again! 😀

Original thread: https://forums.rpgmakerweb.com/threads/learned-skills-limit-and-forget-skills-option.149078/