I want to make a skill that's only usable when a variable is above or below a certain value. How do i do this? My game involves a special battle mechanic. The game seems to only let you set required weapons and not variable conditions. Also, i would like to have certain event pages in the troop activates when variables reaches a certain number. If there isn't an option to do this, is there a plugin that let me do so?
making skills usable only when a variable is fulfilled
RPG Maker MZ SupportYou'd use Visustella Skills and States Core, the JS Skill Enable notetag.
Code:
<JS Skill Enable>
enabled=$gameVariables.value(X)>Y;
</JS Skill Enable>
The above means the skill is only enabled if variable ID X is greater than the number you replace Y with.
This is a little trickier, because troop conditions are coded into the editor and plugins can't change the editor, only the game.
There is a plugin that lets you code your own conditions with event commands, though, so you can check that out:
Custom Page Conditions - Eventing your own page conditions
Having trouble with event conditions? Are the default conditions not enough? If you look at the page conditions, you get - up to two switches - a variable (and must be greater or equal to a certain value) - a self switch - an item (in the party's inventory) - an actor (currently in the party)...
forums.rpgmakerweb.com
For the first part. Skill Conditions. I can point you to the rmmz_objects.js which is where you'll find the .meetsSkillCondition function. This is where it performs checks for skill cost, possible Sealed Effects and other requirements.
So you can add on requirements here.
In the skill database you can add meta data to individual skills like,
<requirement: 5>
So the line you want to add to the function might be something like
Which is evaluating 2 things at once.
First, if the skill has requirement data at all - otherwise return true
Second, if that data matches whatever variable - true or false.
But as I'm typing this, I realize it would probably be better to use
writing the condition statement in meta data like this, since you might have different skills dependent on different variables.
<requirement: $gameVariables.value(1) >= 5 >
Either way should work.
[img]https://i.imgur.com/qYGmdvi.png[/img]
So you can add on requirements here.
In the skill database you can add meta data to individual skills like,
<requirement: 5>
So the line you want to add to the function might be something like
skill.meta.requirement ? Number(skill.meta.requirement) <= $gameVariables.value(1) : trueWhich is evaluating 2 things at once.
First, if the skill has requirement data at all - otherwise return true
Second, if that data matches whatever variable - true or false.
But as I'm typing this, I realize it would probably be better to use
skill.meta.requirement ? eval(skill.meta.requirement) : truewriting the condition statement in meta data like this, since you might have different skills dependent on different variables.
<requirement: $gameVariables.value(1) >= 5 >
Either way should work.
[img]https://i.imgur.com/qYGmdvi.png[/img]
Original thread: https://forums.rpgmakerweb.com/threads/making-skills-usable-only-when-a-variable-is-fulfilled.147764/