# Yanfly Skill Learn System: Gradual JP Cost Increase

#### Cuprite

##### Previously Golden Is there a way to make an actor's learnable skills cost more JP the more skills they learn?
I got the idea from Octopath Traveller and it's something I'm thinking about adding to my game, as it adds a bit of freedom to the game.
Is there a way to do this without editing the plugin itself?
EDIT: I may have an idea of what to do for this, but the solution I came up with doesn't actually seem to work.
It's in my next reply (No need to post it twice).

Last edited:

#### shockra

##### Bored Code Guy Watch this video and it should give an idea of how to accomplish this.

• Cuprite

#### Cuprite

##### Previously Golden So, I've looked into it and I think I've found a solution to this, though I'm not entirely sure.
Can anyone tell me if this code being in a skill's notebox would work?
<Learn Cost Eval>
if (\$gameVariables.value(4) = 50) { \$gameVariables.setValue(4, 100); } else { if (\$gameVariables.value(4) = 100) { \$gameVariables.setValue(4, 300); } else { if (\$gameVariables.value(4) = 300) { \$gameVariables.setValue(4, 600); } else { if (\$gameVariables.value(4) = 600) { \$gameVariables.setValue(4, 1200); } else { if (\$gameVariables.value(4) = 1200) { \$gameVariables.setValue(4, 2000); } else { } } } } }
</Learn Cost Eval>

<Custom Learn JP Cost>
cost = \$gameVariables.value(4)
</Custom Learn JP Cost>
Basically, I have it so if a certain variable (Each actor would have one) is at a certain number (50), it would increase it to a number equal to the next JP cost (100) and I set the cost to equal that variable, so it always updates the rest of the actors learnable skills.
At least, that's what I was going for.

#### shockra

##### Bored Code Guy If you're going to use variables for this, the current approach can be refined. I would try this:

<Learn Cost Eval>
if (\$gameVariables.value(4) = 50) {
\$gameVariables.setValue(4, 100);
} else if (\$gameVariables.value(4) = 100) {
\$gameVariables.setValue(4, 300);
} else if... {

}
</Learn Cost Eval>

<Custom Learn JP Cost>
cost = \$gameVariables.value(4);
</Custom Learn JP Cost>

Repeat the else if part in the Learn Cost Eval as needed. Then at the end, it's just the final bracket with no else.

• Cuprite

#### Cuprite

##### Previously Golden If you're going to use variables for this, the current approach can be refined. I would try this:

<Learn Cost Eval>
if (\$gameVariables.value(4) = 50) {
\$gameVariables.setValue(4, 100);
} else if (\$gameVariables.value(4) = 100) {
\$gameVariables.setValue(4, 300);
} else if... {

}
</Learn Cost Eval>

<Custom Learn JP Cost>
cost = \$gameVariables.value(4);
</Custom Learn JP Cost>

Repeat the else if part in the Learn Cost Eval as needed. Then at the end, it's just the final bracket with no else.
I tried this, but it ended up giving me this error (Also, for testing purposes, I used variable 10 instead of 4).
Also, here's how I wrote out the rest of the code.
One other thing, the costs start as 75 for some reason.

Last edited:

#### shockra

##### Bored Code Guy My mistake. Each equal sign should be this:

if (\$gameVariables.value(4) === 50)

If statements need 3 equal signs to make the check.

• Cuprite

#### Cuprite

##### Previously Golden My mistake. Each equal sign should be this:

if (\$gameVariables.value(4) === 50)

If statements need 3 equal signs to make the check.
It works perfectly now! Thanks, Shockra! Also, it was defaulting to 75 because I had the default JP set to 25.

Last edited:

#### chobokid

##### Veteran How would one code it so that skill learn costs doubled each time an actor learned a skill?

### Latest Profile Posts

I've started the first steps of the final few maps that I need to make for B:ms. I haven't been able to say that in a really, really long time. It'd probably be a good idea to blog about this or something.
Question for the Mods: What am I supposed to do when I can't make a synopsis 350 words long? (for project recruitment thread) @Shaz @mlogan
The game is meant to be more on the simple side in order to be achievable so I'm a bit stuck...