Best way to implement "Rogue Legacy" stat upgrades?

Hey guys, I was curious what the best way would be to implement "Rogue Legacy" stat upgrades and leveling into RPG Maker...that is, characters don't actually "level up" traditionally, but you just purchase upgrades to their HP, ATK, DEF, etc.


To clarify (if you haven't played Rogue Legacy):


-Upgrades increase stats (such as HP +10%, ATK +2)


-They would be global and affect all characters


-They would need to persist through GAME OVER...meaning when your party is eliminated, the upgrades stay and reapply themselves to a new party


My initial thought was to use some kind of variable/switch for each upgrade, and have them somehow not reset after game over. Then in the notes box for the actors, have a script that adds the stats to the base actors each time they are recreated...


Is this possible using Yanfly's Class Base Parameters and if so, how would I set it up and notate it?


I know y'all have been on the forums for a while and much better with MV than I am, so maybe there's an easy way to do this that I am overlooking?


ZGW3o.jpg
You can easly do it with Yanfly's Class Base Parameters. Just read the description part of the plugin, everything is well explain in it.


But a game over is different than a reset of all variables. The inital game over in RPG maker forces you to load a save (so some variables can be lost). Make your own game over common event, and when the player die, call this event (you will maybe need a plugin for this, I don't know).
You can easly do it with Yanfly's Class Base Parameters. Just read the description part of the plugin, everything is well explain in it.



Thank you InBlast! So, what would you suggest as to HOW to set this up? If I set a variable [ID:0001, for argument's sake] for HP Upgrades and increase it by one each time it is upgraded, how would I call that in the note? (sorry, I'm completely noob at JS)  😛


For example, to increase the base (40 + rand(1,20)) by 10% each upgrade:


<Custom Class Parameters>


maxhp = ((40 + rand(1,20)) * (1 + ($gameVariables.value(1) / 10))


</Custom Class Parameters>


Would this work?
Yes it should work, but I don't know about the rand(1,20). Whant do you want to do with this ?
Yes it should work, but I don't know about your rand(1,20) command. What do you want this to do ?



Oops...yeah it should be:


<Custom Class Parameters>


maxhp = ((40 + Math.randomInt(20)) * (1 + ($gameVariables.value(1) / 10))


</Custom Class Parameters>
From what I know (I'm not a pro in JS^^), if you want a random value, you have to make Math.random() (this function generate a number between 0 and 0.999999... and you have to multiply it by the number you want at max.)


I would do something like this : 


maxhp = ((40 + Math.ceil(Math.random()*20)) * (1 + ($gameVariables.value(1) / 10))


Edit : I don't know how a generating random number will affect this. I mean, I don't know if the maxHP is recalculated during the game, and not only when you start the game.
Edit : I don't know how a generating random number will affect this. I mean, I don't know if the maxHP is recalculated during the game, and not only when you start the game.



I think I got this working!


And to answer your question, it appears that it sets it at the beginning. I created an event to change the variable, and the HP stays the same. HOWEVER, if the character level changes, it re-creates the MaxHP (random number and all). There must be something in the base code that recreates the parameters on level up. So theoretically I should be able to "recreate" all of the actors on "GAME OVER", correct? 😉
I don't know. You can't create actors when playing, they must be in the database. Maybe if you add one level and substract one level, the stats are recalculated. I don't know. 


To recreate the actor, I think the easiest is to call some scripts functions to redefine the stats. I cannot make the tests actually, but it should be something like this : 


$gameActors.actor(ID).mhp =  ((40 + Math.ceil(Math.random()*20)) * (1 + ($gameVariables.value(1) / 10))


But I really don't know if this will work. Maybe someone better than me in playing with the code can help you better.
I don't actually need to create new actors...I'll have one in the database for each class. It won't matter that they get overwritten on a "NEW GAME".


My work-around for now will be increasing the level by one...the character level is directly determined by the amount of upgrades purchased (just like Rogue Legacy) so if you have three upgrades purchased, your character level is now 4, so I think this will work. I'll eventually have to have somebody who is better at scripting come in and clean it up a bit. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/best-way-to-implement-rogue-legacy-stat-upgrades.69634/