Making a Magic spell book only work on those with Magic skill.

I know this has been mentioned before, but the scripts that were mentioned don't seem to work. I want to be able to teach my characters to use a Magic spell through a book. But only those who can use the Magic or those who don't already have the spell can learn it.
Does anyone have the updated script on how to do this with a common event?

P.s. If I just do learn skill through an item, it will teach it to anyone, even if they cant use magic. Thus wasting the item.
Hold on, I'll look at conditional branches in events and see if I can come up with something

Edit: ok i think i thought of something. The item adds a state then calls a common event; some characters are immune to the state.
It then goes through conditional branches checking each member of the party. If they have the state, it adds the skill, removes the state and does nothing. If no one has the state, it says "This person can't use this item." and nothing else happens
1•Go in Common Event

2•Pick a blank common event

3•Do a conditional branch

4•Go to actor section.

5•Chose which character you want to give the skill.

6•Click else.

7•Put the skill you want to add to your specific character.

8•Put in Else "This party member cannot learn this skill."

9•Put the common event in the effects of the item.

10• Choose if the item is consumable or not.
1•Go in Common Event

2•Pick a blank common event

3•Do a conditional branch

4•Go to actor section.

5•Chose which character you want to give the skill.

6•Click else.

7•Put the skill you want to add to your specific character.

8•Put in Else "This party member cannot learn this skill."

9•Put the common event in the effects of the item.

10• Choose if the item is consumable or not.
But how will the game know which character the item was used on? You need to add a marker state for that. They want the option for multiple people using it, but your solution doesn't include that
But how will the game know which character the item was used on? You need to add a marker state for that. They want the option for multiple people using it, but your solution doesn't include that

Sorry, here is a optional upgrade.

•Do first a choices option.

•Put all the characters ID codes or the names.

•Do conditional branch to all characters.

•Or simply give the skill to which character you want without making it complicated.
Sorry, here is a optional upgrade.

•Do first a choices option.

•Put all the characters ID codes or the names.

•Do conditional branch to all characters.

•Or simply give the skill to which character you want without making it complicated.
Doing a choice ironically complicates things. what if a certain character isn't in the party when they use it? they'll have to do branch after branch of conditions.

But having the item add a state, and some characters being immune to the sate and having the event go over each character and check if they have the state adding it that way (while removing the state) is a much simpler way to handle it then choices

Edit: the state would of course have to be removed afterwards
Doing a choice ironically complicates things. what if a certain character isn't in the party when they use it? they'll have to do branch after branch of conditions.

But having the item add a state, and some characters being immune to the sate and having the event go over each character and check if they have the state adding it that way (while removing the state) is a much simpler way to handle it then choices


... I like complicated stuff

•Add a variable that is added to your main event then..

Like, if your main character is starting and do magic.

Variable: Magic Party member= 1

Then you are two magic users.

Variable: Magic Party Members = 2

• Book demands in a conditional branch variable to reach 2
Or else.

You cannot.

• Then give the spell to to character of your choice.
The other thing that complicates this is I give the main character a choice of weather they are a fighting class or magic class. So I can't target the main character as someone who can use the spell unless they have the ability to use magic. I need something that targets characters who have that particular skill set, and not by name, if possible.
The other thing that complicates this is I give the main character a choice of weather they are a fighting class or magic class. So I can't target the main character as someone who can use the spell unless they have the ability to use magic. I need something that targets characters who have that particular skill set, and not by name, if possible.
with what i suggested. You can add a state that makes the charecter immune to the marker state in the choice if they dont choose magic

and by making some charectrs immune to the marker state and putting a message that says "this cant be used on that charecter", it does target the subset. Though ill try to think of a system thats not by name
Hold on, I'll look at conditional branches in events and see if I can come up with something

Edit: ok i think i thought of something. The item adds a state then calls a common event; some characters are immune to the state.
It then goes through conditional branches checking each member of the party. If they have the state, it adds the skill, removes the state and does nothing. If no one has the state, it says "This person can't use this item." and nothing else happens
OK this worked for me, mostly. It did only allow those with magic to learn the skill. Yay, got that. But after that it still says, "Player can't use magic" weather it works or not. Because it's in another character's Else: section that wasn't chosen. I've added a screenshot of my process if it helps.
Do this process in the common event

Item setup - item # 17 - change the price and stuff how you like and the variables you want to use
1648038981403.png


CE setup - id.data_id == 1 - special, 2 - magic, ...
1648038579077.png


And here it is for checking if you have the skill - checks for skill 26 (heal)
Ruby:
act = $game_actors[$game_variables[2]].class
act.features.each do |id|
if id.code == 41
if id.data_id == 2
$game_switches[1] = true
char = $game_actors[$game_variables[2]].skills
char.each do |sk|
if sk.id == 26
$game_switches[1] = false
end
end
end
end
end

equals
1648038129699.png
1648038709338.png
Do this process in the common event

Item setup - item # 17 - change the price and stuff how you like and the variables you want to use
View attachment 220763

CE setup - id.data_id == 1 - special, 2 - magic, ...
View attachment 220761

And here it is for checking if you have the skill - checks for skill 26 (heal)
Ruby:
act = $game_actors[$game_variables[2]].class
act.features.each do |id|
if id.code == 41
if id.data_id == 2
$game_switches[1] = true
char = $game_actors[$game_variables[2]].skills
char.each do |sk|
if sk.id == 26
$game_switches[1] = false
end
end
end
end
end

equals
View attachment 220754View attachment 220762
I tried this but kept getting this error.
what do you have for the damage formula? and did you copy the code I gave exactly?
I think you used a : in the formula and not a ;
what do you have for the damage formula? and did you copy the code I gave exactly?
I think you used a : in the formula and not a ;
Ok I figured out what I did wrong. I'm still a bit of noob when it comes to the coding. I typed in Script: at the start of the script. hehe. But yes, It worked. Thank you all very much.

Original thread: https://forums.rpgmakerweb.com/threads/making-a-magic-spell-book-only-work-on-those-with-magic-skill.145999/