Yanfly Stat Upgrades with Increasing Cost (use Gold instead of JP)

Hey everyone, I feel like there is a simple solution to this, but I am spinning my wheels a LOT on this...
 


I'm using Yanfly's Skill Learn System to set up a shop where the player purchases upgrades to their stats. I have everything working great, except that I need the cost of the upgrades to increase each time that the player buys it (i.e. the first time, it is 100G, then 200G, then 300G, etc). I already have a variable set up that determines how many times the upgrade is purchased...Yanfly even has a Tips & Tricks video to explain how to do this...however only with JP and not Gold.


Basically, the note <Learn Cost: x Gold> is used to set the gold cost on the skill, but I cannot just put "<Learn Cost: $gameVariables.value(1) Gold>"...this causes it to use the Default Gold Cost parameter since it doesn't recognize the variable. Similarly, if I put $gameVariables.value(1) into the Default Gold Cost parameter field in the plugin manager, and I get a weird result where "NAN" shows up.


I even tried opening up the Yanfly script and just hard-coding the value but I keep getting TypeErrors and whatnot...


Thoughts?


BONUS: Is there a better (more succinct) way to code this:

Spoiler
Code:
<Learn Cost Eval>
user.forgetSkill(80);
$gameVariables.setValue(1,$gameVariables.value(1)+1);
$gameActors.actor(1).refresh();
$gameActors.actor(2).refresh();
$gameActors.actor(3).refresh();
$gameActors.actor(4).refresh();
$gameActors.actor(5).refresh();
$gameActors.actor(6).refresh();
$gameActors.actor(7).refresh();
$gameActors.actor(8).refresh();
$gameActors.actor(9).refresh();
$gameActors.actor(10).refresh();
$gameActors.actor(11).refresh();
$gameActors.actor(12).refresh();
$gameActors.actor(1).recoverAll();
$gameActors.actor(2).recoverAll();
$gameActors.actor(3).recoverAll();
$gameActors.actor(4).recoverAll();
$gameActors.actor(5).recoverAll();
$gameActors.actor(6).recoverAll();
$gameActors.actor(7).recoverAll();
$gameActors.actor(8).recoverAll();
$gameActors.actor(9).recoverAll();
$gameActors.actor(10).recoverAll();
$gameActors.actor(11).recoverAll();
$gameActors.actor(12).recoverAll();
</Learn Cost Eval>
This is the one yanfly just created, right? Did you check inside the plug-in settings whether or not there was a gold thingy and that it wasn't set to false?


EDIT: Went and looked at the copy paste code.

Spoiler
<Learn Cost Eval> // Set the param ID of the stat you wish to adjust. var id = 0; // Increase the parameter by this amount. user._paramPlus[id] += 200; // Adjust the number of times upgraded by 1. user._upgradeParam[id] += 1; // Make the user forget the skill. user.forgetSkill(skill.id); // Refresh the user. user.refresh(); </Learn Cost Eval> <Custom Learn JP Cost> // Set the param ID of the stat you wish to adjust. var id = 0; // Default the user's upgrade parameter times to empty. user._upgradeParam = user._upgradeParam || []; user._upgradeParam[id] = user._upgradeParam[id] || 0; // Adjust the cost of cost = user._upgradeParam[id] * 200; </Custom Learn JP Cost> <Custom Cost Display> \}Passive\{ </Custom Cost Display> <Hide in Battle>



Wouldn't it just become

Spoiler
<Learn Cost Eval> // Set the param ID of the stat you wish to adjust. var id = 0; // Increase the parameter by this amount. user._paramPlus[id] += 200; // Adjust the number of times upgraded by 1. user._upgradeParam[id] += 1; // Make the user forget the skill. user.forgetSkill(skill.id); // Refresh the user. user.refresh(); </Learn Cost Eval> <Custom Learn Gold Cost> // Set the param ID of the stat you wish to adjust. var id = 0; // Default the user's upgrade parameter times to empty. user._upgradeParam = user._upgradeParam || []; user._upgradeParam[id] = user._upgradeParam[id] || 0; // Adjust the cost of cost = user._upgradeParam[id] * 200; </Custom Learn Gold Cost> <Custom Cost Display> \}Passive\{ </Custom Cost Display> <Hide in Battle>
This is the one yanfly just created, right? Did you check inside the plug-in settings whether or not there was a gold thingy and that it wasn't set to false?



I did check, and you basically have only the one value to set the "Default Gold Cost" which I can't seem to involve the variable into (see below).


In the Increasing Costs video, Yanfly has a tag for <Custom Learn JP Cost> and does exactly what I want, but using JP. Since my game is using gold only, I can't figure out how to edit this.


Untitled-2.png
I don't think skills have self-upgrade the way the stats do. If anything, just create a new version of the skill they can upgrade after getting the old version. 


My example would be how I have Fire, which costs 350 JP and 200 Gold, then when you get that you can buy flame for 700 JP and 800 Gold. Would you know how to do that? 
The tag <Custom Learn Gold Cost> isn't recognized like <Custom Learn JP Cost> is...I think because Yanfly made that specifically to pair with another script  :|


I do know how to do that, I was just hoping to avoid that only because there will be dozens of upgrade levels for the stats, so it would likely take up a TON of the database 😉


As of now, I'm going to poke into the main script and see if I can add the <Custom Learn Gold Cost> tag...
If it's just straight up stat upgrading, I would just make it cost an outlandish amount of gold and have it not do upgrading costs. Cause eventually the upgrade isn't worth the cost.
Hello i'm also looking for a solution, i also wish use "gold" (which is actually a kind of xp for my game) to upgrade stat.


Jp plugin allow to choose between JP cost Or (and?) Gold.


For upgrating basic stats i wish only gold.


Me too i tried to replace "Gold" instead "JP" in formula... and yeah..that's not working, like if there's not formula at all...


If someone could help us we will appreciate a lot!


I will keep looking maybe there's similar subject, pretty sure many people asked "gold" cost instead JP for their game!


If i found anything working i come back here or i message you!


Anyway, all help are welcome!
*Bumping the thing*


Hello every one!


Too many challenge for that one? ^^


*winks*
*Bumping the thing*


Hello every one!


Too many challenge for that one? ^^


*winks*



I haven't poked back into the code yet, but I'm really bad with javascript and I have trouble modifying Yanfly's scripts for some reason...any good scripters have ideas? 🙂
user.forgetSkill(80);
$gameVariables.setValue(1,$gameVariables.value(1)+1);
for (var a = 1; act < 13; act++) {
$gameActors.actor(a).refresh();
$gameActors.actor(a).recoverAll();
}


I didn't see if anyone else wrote this answer, but assuming the eval can perform basic looping, this should do the trick.


Note: this is hard coded to do exactly as you described, and if you added more actors or whatever, this would not consider that (ie: a 14th and 15th actor later added would be ignored).
user.forgetSkill(80);
$gameVariables.setValue(1,$gameVariables.value(1)+1);
for (var a = 1; act < 13; act++) {
$gameActors.actor(a).refresh();
$gameActors.actor(a).recoverAll();
}


I didn't see if anyone else wrote this answer, but assuming the eval can perform basic looping, this should do the trick.


Note: this is hard coded to do exactly as you described, and if you added more actors or whatever, this would not consider that (ie: a 14th and 15th actor later added would be ignored).



Works like a charm! Thank you for the BONUS answer!


Still no luck on the increasing gold cost? I'll shoot a message to Yanfly directly to see if I can get an answer. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-stat-upgrades-with-increasing-cost-use-gold-instead-of-jp.69671/