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,231
Reaction score
4,360
First Language
English
Primarily Uses
RMMV

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
30,260
Reaction score
7,138
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,222
Reaction score
1,128
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
30,260
Reaction score
7,138
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,222
Reaction score
1,128
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 Posts

Latest Profile Posts

Newest RPG Maker drops: hey fellas, get on the MZ train to somewhere

Me: Building my VX Ace lego tower, blissfully unaware of time moving forward
When you are trying to make progress in your game. But something is stopping your motivation. Like come on mind! Let me do what I want! :<
Tfw everyone is trying their hardest to brainstorm about unique ideas and game mechanics, here I am just going: "How am I gonna event conversations with busts" everyday. :kaoswt2:
Comedy is third person, tragedy is first person.
Man. A historic 130 year old church nearby had all of its windows broken out with bricks last night. Such a shame, it wasn't generic stained glass patterns either but had beautifully crafted murals depicting various parts of the gospels.

Forum statistics

Threads
99,320
Messages
964,136
Members
130,928
Latest member
LadyElselin
Top