class specific item

Hey guys. Can anyone help me with making an item? i want to make it so you can buy a magic scroll and learn the spell, but only if your class can use that spell. I've got the item made and people can learn the skill, but how do i make it class specific? is there a way to do that using the mv stuff provided?

I've moved this thread to RPG Maker MV. Thank you.

have the item trigger a common event, and then in the common event check who used the item. if the actor is allowed to learn then learn and remove scroll - if not then show text "you don't understand this".

For identifying which actor used the item, add an invisible target state as another effect. then in the common event check every actor if they have that state - that way you also have the structure to decide if the actor should learn or not
Here's a copypasteable way to do this using a bit of javascript that will enable the same common event to be usable for every item that is meant to teach characters something:
  1. Create a common event and paste the script below into an event's conditional branch script box.
  2. Have an item (single target, not full party) call this common event. Make sure this item is nonconsumable (we'll consume it in the common event only if it successfully teaches something to someone). Set the ID of the skill to be taught in the item's note tag as follows: <Skill: 12345>, with 12345 being whatever the skill's ID is. The note tag is case sensitive, so make sure it's "Skill" and not "skill" or "SKILL" etc.
  3. Set actors to be able to learn a given skill by having it in their normal level-up skill list. If you don't want them to learn it normally, just set it to something absurdly high (past whatever level cap you might have, if you can do that. Can you? I didn't test that...)
  4. The big long mess posted below will return true if it teaches the actor the skill, false if they already know it or it isn't in their class's available skill list.
Code:
(function(x){ return !($gameParty.targetActor().currentClass().learnings.reduce((arr, obj) => arr.concat(obj.skillId), []).contains(x) && !$gameParty.targetActor().hasSkill(x) ? $gameParty.targetActor().learnSkill(x) : true); })(+$gameParty.lastItem().meta.Skill || 0)

Common event should be something like this:

06tCjiD.png


Note that you can set the veriable to be whichever one you want, like 10 or 200 or something in case you're already using 1. Just make sure to reflect it it in the text displays, too (the \V[1] part).

Good luck and let me know if it doesn't work.

PS: I know everyone says "find out which actor was targeted in common events using a hidden state and conditional branches," but you can more easily get the target actor with $gameParty.targetActor(). Hence why there's no hidden states required in this solution.
PS: I know everyone says "find out which actor was targeted in common events using a hidden state and conditional branches," but you can more easily get the target actor with $gameParty.targetActor(). Hence why there's no hidden states required in this solution.
yes and no - your method has one disadvantage that the hidden state method does not have.

your method works on the map, but not in battle. because in a battle the common events are executed at the end of the turn, after several actions have been used - and that means that the party target had been re-used an unknown number of times before your check is run, meaning it can point to the wrong actor at the end of a battleturn.

In this case it's unlikely that the OP uses the item in battle, but there have been other cases where that is a common option. That is why I prefer the non-scripted method with the hidden states.
yes and no - your method has one disadvantage that the hidden state method does not have.

your method works on the map, but not in battle. because in a battle the common events are executed at the end of the turn, after several actions have been used - and that means that the party target had been re-used an unknown number of times before your check is run, meaning it can point to the wrong actor at the end of a battleturn.

In this case it's unlikely that the OP uses the item in battle, but there have been other cases where that is a common option. That is why I prefer the non-scripted method with the hidden states.
Yeah, that's true. I figured the OP was going to make something like that a field-only item.

Original thread: https://forums.rpgmakerweb.com/threads/class-specific-item.122487/