Hello, my name is Maizarkos. I am wondering if it is possible to create a skill which damage depends on how many other skills are learned. I plan to make an ability called "All-In-One" which takes the damage values of other abilities (and possibly their effects such as paralysis from Thunder) and combines them into one powerful move.
RPG Maker MV - Skill that becomes stronger based on how many other skills a character learns.
RPG Maker MV SupportHi @Maizarkos - I've moved your thread to the MV support section, since you accidentally posted in RPG Creator (which is a totally different engine).
There is no easy way for RPG Maker to "know" which other skills the character has learned. If you control the learning of skills rather than have it automatically learned by levels, what you might be able to get away with is to having the skill's "power" added to a Variable when that skill is learned. And then, in the All in One skill's formula, you can access the Variable's current value with v[n] where n is the variable index (e.g. v[18] to check Variable #18).
If you simply want to know how many skills the character currently knows, there may be an easier way (that can also work with automatic skill-learning-by-levels). I'm not sure what the syntax is to check the size of the character's Known Skills array, but that's what you'd be looking to include in your skill formula. Maybe someone can answer here. If you don't get an answer within several days, feel free to ask with a post on the Damage Formula Help thread, or on the Learning JavaScript board.
There is no easy way for RPG Maker to "know" which other skills the character has learned. If you control the learning of skills rather than have it automatically learned by levels, what you might be able to get away with is to having the skill's "power" added to a Variable when that skill is learned. And then, in the All in One skill's formula, you can access the Variable's current value with v[n] where n is the variable index (e.g. v[18] to check Variable #18).
If you simply want to know how many skills the character currently knows, there may be an easier way (that can also work with automatic skill-learning-by-levels). I'm not sure what the syntax is to check the size of the character's Known Skills array, but that's what you'd be looking to include in your skill formula. Maybe someone can answer here. If you don't get an answer within several days, feel free to ask with a post on the Damage Formula Help thread, or on the Learning JavaScript board.
Try this (not tested, could work or explode horribly) in the all-in-one skill's damage formula box:
Code:
a.skills().reduce((acc, cur) => acc + (cur.damage.type === 1 ? (+eval(cur.damage.formula) || 0) : 0), 0)
Note that it:
- Doesn't take multiple hits/uses into account, so extra hits via action sequences or repeat/x random enemies options only count the first hit
- Doesn't take elements into account. Element is based on whatever you set up the all-in-one skill to use.
- Only counts "HP damage" skills. Didn't bother setting it up for hp drain skills
- Doesn't count additional effects, like states, debuffs, note tags, random action sequence effects, etc.
- May have slight lag if the user has a lot of skills because eval sucks, but its what we have to work with so oh well.
Code:
a.skills().length
I have entered the code into the damage formula for the All-In-One's skill box, along with having it set to HP damage. When trying it in battle, however it seems to freeze the game. I know I am missing something, which most likely involves the end zeros. I tested by changing the "?" into the number of skills which my character has (16). This caused it to not freeze, but still does no damage after placing each skill on them, even when changing it to the length. Playing with the other numbers doesn't seem to have any effect as well. If possible, could you give me an example of what the complete code should look like when taking into account of the "16" (for example) skills. I am still working on this as I am somewhat new and I am doing my best to learn as much as I possibly can with this.
Thank you for helping me.
Oh god, I'm such a moron. No, the ? should stay as it is, but the freeze is being caused by a recursive loop where the all-in-one skill is calling its own damage formula over and over and over to infinity. My bad. Try this version instead:
This version tells it to skip itself to avoid the infinite recursion, and should be copy/pasted exactly as it appears above.
Edit: Just tested it out this time and it appears to work.
Code:
a.skills().reduce((acc, cur) => acc + ((cur.damage.type === 1 && cur.id !== this.item().id) ? (+eval(cur.damage.formula) || 0) : 0), 0)
This version tells it to skip itself to avoid the infinite recursion, and should be copy/pasted exactly as it appears above.
Edit: Just tested it out this time and it appears to work.
Thank you very much! I tested the new code and it seems to work perfectly. It's attack power increases each time a skill is learned, just as planned. Once again, thanks for the help!
Original thread: https://forums.rpgmakerweb.com/threads/rpg-maker-mv-skill-that-becomes-stronger-based-on-how-many-other-skills-a-character-learns.125236/