KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
So with Yanfly's skill learn system you can make it cost Job Points to learn skills. You can set the Job Point amount to learn a skill as 100jp, or 200jp etc. However, I'd like to make it so that it will cost different amounts based on how many skills you've unlocked, that way they are all available from the beginning. So for example there are 10 skills to learn, they would all cost X jp. Once you've unlocked one, there would be 9 unlockable and they'd all cost X jp, etc. This way the player can choose which skills they think are more important, and not have to pick the cheapest ones first. Would anyone know how I could do this?

Here is a link to the plugin:

Thanks for your help ^ ^
 

Beckx

Villager
Member
Joined
Mar 29, 2021
Messages
28
Reaction score
246
First Language
german
Primarily Uses
RMMV
Okay, so i can't give you a full solution as i haven't used it, but i think i can still help you out:
At the bottom of the page (in the JS part) are two things you'd need:

Code:
<Learn Cost Eval>
   code
   code
  </Learn Cost Eval>
  For those who know JavaScript, you can have custom actions be performed
  after learning the skill through the learn skill menu.
and

Code:
<Custom Learn JP Cost>
   cost = user.level * 100;
  </Custom Learn JP Cost>
  The 'cost' variable is the value that will be returned as a result of this
  Lunatic Mode notetag. The value returned here from this code will be added
  on top of the <Learn Cost: x JP> value.

(the cost here would need to be changed to something different later)

Sooo, there are different ways to do this, but i think easiest would be to count the number of learned skills inside a global variable and use that variable (instead of the user.level in the example above)
maybe you have that number already stored somewhere, too :D
(I'm not quite sure, where exactly those note tags need to be placed as i don't know the plugin, but this should come inside)


Code:
<Learn Cost Eval>
    var newCount = $gameVariables.getValue(id) + 1; //change id to the corresponding variable id
   $gameVariables.setValue(id, newCount)
</Learn Cost Eval>
And
Code:
<Custom Learn JP Cost>
   cost = $gameVariables.getValue(id) * 100;
  </Custom Learn JP Cost>

If you start the variable from 0, and set the initial cost to 0, the cost should grow like this:
0 skills learnd: 0 cost for next skill to learn
1 skill learned: 100 cost for next skill
2 skills learned: 200 cost for next skill
... and so on

But this is all form reading the docs, i have no clue if this actually works, (though it should )
sorry :)
 
Last edited:

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
Okay, so i can't give you a full solution as i haven't used it, but i think i can still help you out:
At the bottom of the page (in the JS part) are two things you'd need:

Code:
<Learn Cost Eval>
   code
   code
  </Learn Cost Eval>
  For those who know JavaScript, you can have custom actions be performed
  after learning the skill through the learn skill menu.
and

Code:
<Custom Learn JP Cost>
   cost = user.level * 100;
  </Custom Learn JP Cost>
  The 'cost' variable is the value that will be returned as a result of this
  Lunatic Mode notetag. The value returned here from this code will be added
  on top of the <Learn Cost: x JP> value.

(the cost here would need to be changed to something different later)

Sooo, there are different ways to do this, but i think easiest would be to count the number of learned skills inside a global variable and use that variable (instead of the user.level in the example above)
maybe you have that number already stored somewhere, too :D
(I'm not quite sure, where exactly those note tags need to be placed as i don't know the plugin, but this should come inside)


Code:
<Learn Cost Eval>
    var newCount = $gameVarables.getValue(id) + 1; //change id to the corresponding variable id
   $gameVarables.setValue(id, newCount)
</Learn Cost Eval>
And
Code:
<Custom Learn JP Cost>
   cost = $gameVarables.getValue(id) * 100;
  </Custom Learn JP Cost>

If you start the variable from 0, and set the initial cost to 0, the cost should grow like this:
0 skills learnd: 0 cost for next skill to learn
1 skill learned: 100 cost for next skill
2 skills learned: 200 cost for next skill
... and so on

But this is all form reading the docs, i have no clue if this actually works, (though it should )
sorry :)
Thanks, I'll try to see if I can figure it out with this~
 

Beckx

Villager
Member
Joined
Mar 29, 2021
Messages
28
Reaction score
246
First Language
german
Primarily Uses
RMMV
hey, so you know, i just edited my post because i found a typo in the code part... :D
(there was the "i" missing in "variables")
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,858
Reaction score
970
First Language
English
Primarily Uses
RMMV
I'll just put forth an alternate suggestion to the use of a global variable. To my reasoning, the only case that would be desirable is if one party member learning a skill affects everyone's skill cost. Or, I suppose, if you only have one character in the game.

It's possible that's what the OP would like, but we have no details on the game.

My presumption based on the original post would be that each party member can decide individually which order to learn the skills in; in which case it's better and easier to skip the variable, the skill cost, and just calculate the custom learn cost based on how many skills the actor has learned.

So that would be:
Code:
<Custom Learn JP Cost>
cost=(user.skills().length*100)+100;
</Custom Learn JP Cost>
That would make the skills cost 100 plus 100 per skill they know. Modify the formula however you like.
 
Last edited:

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
So this code seems perfect for adding up the skills to increase, the problem being that after learning each skill it needs to go to a specific number not just add to it. The reasoning being for this, say that a level 5 mob gives 10 jp, and the ability costs 100 to learn, then it only takes 10 mobs to learn. But then to get the next one it would only take 100, etc, so you would get them very fast by just grinding low level mobs. The more likely situation would be more along the lines of first skill is 100, 2nd skill is 400, 3rd skill is 1200, 4th skill is 2000 etc. The specific numbers would have to be determined through play testing so that the balance of the game is preserved and the player will waste time grinding low level mobs instead of progressing. Having them be specific rather than just a additive/multiplicative value is what I'd need here.

If I can't figure that out (since I really don't know much about programming. I get most of the logic, but the syntax and things befuddle me because I haven't really spent time learning it, so mainly program through common events etc) I'll just go the ol' tried and true method of making a lengthy event where you have to talk to an npc to learn them lol.

To do that I guess I'd make a variable skillLearnedVariable = 0
if skillLearnedVariable == 0 then jp value cost = 100
set skillLearnedVariable = 1

else if

if skillLearnedVariable == 1 then jp value cost = 400
set skillLearnedVariable = 2

and just continue that for the number of skills able to be learned

I'm pretty sure this is how I'd do it? But I don't know where to put that stuff or the right syntax. I'd just make a npc you talk to that has branches that read the variables and then returns a value of "you can't do that" if you don't have enough job points etc. I should probably just learn to code, but so much of my time is taken up by making maps, art, dialogue, battles, and everything else
I'll just put forth an alternate suggestion to the use of a global variable. To my reasoning, the only case that would be desirable is if one party member learning a skill affects everyone's skill cost. Or, I suppose, if you only have one character in the game.

It's possible that's what the OP would like, but we have no details on the game.

My presumption based on the original post would be that each party member can decide individually which order to learn the skills in; in which case it's better and easier to skip the variable, the skill cost, and just calculate the custom learn cost based on how many skills the actor has learned.

So that would be:
Code:
<Custom Learn JP Cost>
cost=(user.skills().length*100)+100;
</Custom Learn JP Cost>
That would make the skills cost 100 plus 100 per skill they know. Modify the formula however you like.
 

Beckx

Villager
Member
Joined
Mar 29, 2021
Messages
28
Reaction score
246
First Language
german
Primarily Uses
RMMV
oh yeah, i feel you, I'm lucky enough that i at least knew programming and JS before I started with my game, but i'm creating all the assets myself too and it is sooo time consuming.
But i think the way you're doing it right now is a great way to learn, too. Not everything is syntax, understanding what influences what is the important part, and of course asking questions when you don't understand something.

So, i have another idea for your skill points which wouldn't need so much branching with a NPC.
There's this thing called "arrays" and they will help us out :)
As i understand it, you want to have a fixed amount for each skills, so we create another global variable, that won't ever get changed and just stores those values in an array. So in script it could be something like this:

Code:
let pointArray = [0, 100, 500, 700]
$gameVariables.setValue(pointsArrayID, pointArray)


You should also be able to set this variable via event editor, i think it should be like this:
Bildschirmfoto von 2021-07-28 09-33-10.png

sidenote: JS is sometimes wonky with types, so it could be that you'd need to put the numbers as strings (with "" around)


So NOW, with the other global variable that keeps count of amount of the learned skills you could try:

Code:
<Custom Learn JP Cost>
   cost = $gameVariables.getValue(pointArrayID)[$gameVariables.getValue(countID)]; //change the IDs to your corresponding variable IDs
</Custom Learn JP Cost>

it probably would help to read up a little bit about arrays if you don't know them already, but here's basically what it does:

you can select the values inside an array with following syntax, eg:
pointArray[0] would return 0 or pointArray[1] returns 100, pointArray[2] 500 and so on-> arrays start counting at 0!
 

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
oh yeah, i feel you, I'm lucky enough that i at least knew programming and JS before I started with my game, but i'm creating all the assets myself too and it is sooo time consuming.
But i think the way you're doing it right now is a great way to learn, too. Not everything is syntax, understanding what influences what is the important part, and of course asking questions when you don't understand something.

So, i have another idea for your skill points which wouldn't need so much branching with a NPC.
There's this thing called "arrays" and they will help us out :)
As i understand it, you want to have a fixed amount for each skills, so we create another global variable, that won't ever get changed and just stores those values in an array. So in script it could be something like this:

Code:
let pointArray = [0, 100, 500, 700]
$gameVariables.setValue(pointsArrayID, pointArray)


You should also be able to set this variable via event editor, i think it should be like this:
View attachment 197101

sidenote: JS is sometimes wonky with types, so it could be that you'd need to put the numbers as strings (with "" around)


So NOW, with the other global variable that keeps count of amount of the learned skills you could try:

Code:
<Custom Learn JP Cost>
   cost = $gameVariables.getValue(pointArrayID)[$gameVariables.getValue(countID)]; //change the IDs to your corresponding variable IDs
</Custom Learn JP Cost>

it probably would help to read up a little bit about arrays if you don't know them already, but here's basically what it does:

you can select the values inside an array with following syntax, eg:
pointArray[0] would return 0 or pointArray[1] returns 100, pointArray[2] 500 and so on-> arrays start counting at 0!
Omg okay so arrays can clean up so much code that's awesome! Ahhh programming is so interesting to me but seems so daunting. Now with this I just need to actually set the original value in the array. So I guess you'd just do that with custom code in a common event when the game starts?

Then I'd have to figure out how to actually set the value of the variable to the next number in the array after the player chooses a skill. I just don't know where to put in that code. Like would it go into the plugin somewhere or, idk lol
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,858
Reaction score
970
First Language
English
Primarily Uses
RMMV
Omg okay so arrays can clean up so much code that's awesome! Ahhh programming is so interesting to me but seems so daunting. Now with this I just need to actually set the original value in the array. So I guess you'd just do that with custom code in a common event when the game starts?
Yes, unless you simply keep it contained within your skills.
Then I'd have to figure out how to actually set the value of the variable to the next number in the array after the player chooses a skill. I just don't know where to put in that code. Like would it go into the plugin somewhere or, idk lol
Beckx showed you how to do that in her first post to you.

You still haven't told us whether this cost is supposed to be global or individual, because it greatly affects our suggestions to you. Beckx has been giving you code that will only work well if you're using a single character, whereas I was going off the presumption that you have a party of characters, each with their own costs. If you don't know any code, and you're asking people to do it for you, you need to give us all necessary information.
 

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
Yes, unless you simply keep it contained within your skills.

Beckx showed you how to do that in her first post to you.

You still haven't told us whether this cost is supposed to be global or individual, because it greatly affects our suggestions to you. Beckx has been giving you code that will only work well if you're using a single character, whereas I was going off the presumption that you have a party of characters, each with their own costs. If you don't know any code, and you're asking people to do it for you, you need to give us all necessary information.
Ah okay sorry. Yes it would be individual to each of the 4 party members. The values would be the same, but each would be needed to be tracked individually.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,858
Reaction score
970
First Language
English
Primarily Uses
RMMV
Ah okay sorry. Yes it would be individual to each of the 4 party members. The values would be the same, but each would be needed to be tracked individually.
Then all you need is this in each of your skills:
Code:
<Custom Learn JP Cost>
var pointArray = [100, 350, 900, 1325];
cost=pointArray[user.skills().length];
</Custom Learn JP Cost>

Set the numbers inside of pointArray to be the progression of costs that you want. Make sure you have enough values for the number of skills you could learn.
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
946
Reaction score
412
First Language
english
Primarily Uses
RMMV
The more likely situation would be more along the lines of first skill is 100, 2nd skill is 400, 3rd skill is 1200, 4th skill is 2000 etc.
skills*rate*skills+minimum = cost
ie:
0 * 300 * 0 + 100 = 100
1 * 300 * 1 + 100 = 400
2 * 300 * 2 + 100 = 1300
3 = 2800
 

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
Then all you need is this in each of your skills:
Code:
<Custom Learn JP Cost>
var pointArray = [100, 350, 900, 1325];
cost=pointArray[user.skills().length];
</Custom Learn JP Cost>

Set the numbers inside of pointArray to be the progression of costs that you want. Make sure you have enough values for the number of skills you could learn.
This returns the JP cost of NaN ingame.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,858
Reaction score
970
First Language
English
Primarily Uses
RMMV
This returns the JP cost of NaN ingame.
I have no idea why any of that would not be considered a number, but you can force it to be:
Code:
cost=Number(pointarray[etc.]);

But you should probably post a screenshot of your notetag for good measure. Are you sure you specified enough numbers in the array? Arrays will return NaN if you try to index an element that doesn't exist.

skills*rate*skills+minimum = cost
ie:
0 * 300 * 0 + 100 = 100
1 * 300 * 1 + 100 = 400
2 * 300 * 2 + 100 = 1300
3 = 2800

You must've missed it, but about a line below the sentence you quoted, he specifically said he wanted to use specified values, not a multiplicative progression.
 
Last edited:

KawaiiKid

Veteran
Veteran
Joined
Oct 13, 2015
Messages
188
Reaction score
45
First Language
English
Primarily Uses
I have no idea why any of that would not be considered a number, but you can force it to be:
Code:
cost=Number(pointarray[etc.]);

But you should probably post a screenshot of your notetag for good measure. Are you sure you specified enough numbers in the array? Arrays will return NaN if you try to index an element that doesn't exist.



You must've missed it, but about a line below the sentence you quoted, he specifically said he wanted to use specified values, not a multiplicative progression.
So I figured it out. It takes into consideration what skills the class can learn in the engine itself NOT the ones dictated by notetags for the plugin itself. Therefore, when I added enough numbers to the array to account for all the spells that class can get in the engine (once again the tags for the plugin are irrelivent here) it works fine!

Thanks for the help!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,858
Reaction score
970
First Language
English
Primarily Uses
RMMV
It takes into consideration what skills the class can learn in the engine itself NOT the ones dictated by notetags for the plugin itself.
This doesn't make sense to me. There's nothing in the code I supplied you that references what skills a class can learn.

Do you mean that you have both skills that are automatically granted to you by class levels in addition to ones you learn with JP? In that case, yes, a skill is a skill is a skill, and looking at what the actor has in user.skills() has no way to differentiate. But if that were the case, you'd need to approach this differently, because you probably don't want leveling up and learning a skill to increase your JP costs.
it works fine!
I'm glad you came up with something that works for you.
 

Latest Threads

Latest Profile Posts

Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking. :)
Working on a characteeer! (Why is it so hard to color hair?) ;-;
Silly-Sketches.png
Just finished eventing a couple simple puzzles in RMMV, for my very first game "Sample Quest." Just messing around, throwing things together, and calling it a story XD On a non-RM note, got my hair cut today!
I feel the need to inform everyone on the forums NOT to go with Web Hosting Canada for your hosting needs. It is by far the worst customer service and just overall experience I have ever had with hosting and I am Canadian...
BCj
Got another eye surgery monday. Hope I'll recover quick and all's well. A bit tired of surgeries. On a happy note, working on the next chapter of Escalia so hope I can continue soon :)

Forum statistics

Threads
115,372
Messages
1,089,344
Members
150,065
Latest member
Ariel240gamer
Top