class specific item

jrockwv

Veteran
Veteran
Joined
Jan 30, 2013
Messages
67
Reaction score
0
First Language
english
Primarily Uses
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?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,685
First Language
English
Primarily Uses
RMMZ

I've moved this thread to RPG Maker MV. Please be sure to post your threads in the correct forum next time. Thank you.

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,531
Reaction score
1,424
First Language
English
Primarily Uses
RMMV
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:



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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
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.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,531
Reaction score
1,424
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,048
Messages
1,018,545
Members
137,834
Latest member
EverNoir
Top