making skills usable only when a variable is fulfilled

keqi

Villager
Member
Joined
Jan 29, 2022
Messages
13
Reaction score
13
First Language
Chinese
Primarily Uses
RMMZ
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?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,500
Reaction score
2,857
First Language
English
Primarily Uses
RMMV
I want to make a skill that's only usable when a variable is above or below a certain value.
You'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.
Also, i would like to have certain event pages in the troop activates when variables reaches a certain number.
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:
 

coyotecraft

Mythographer
Veteran
Joined
Mar 13, 2012
Messages
300
Reaction score
172
First Language
English
Primarily Uses
N/A
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
skill.meta.requirement ? Number(skill.meta.requirement) <= $gameVariables.value(1) : true
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
skill.meta.requirement ? eval(skill.meta.requirement) : true
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.
qYGmdvi.png
 

Latest Threads

Latest Profile Posts

Took some trial and error, but I managed to create "visuals" for underground dig path regions.
Couldn't sleep at all so I started working on the topmost deck. I've had to make several deviations from the Imperator/Berengaria's deck-plans to accommodate MV's movement, but 100% accuracy was never my intention.
Still no name for the poor ship...:kaodes:
Screenshot-2022-06-25-053308.png
ScreenShot_6_24_2022_9_20_7.png
Here's Mike when you get a preemptive strike in battle. There's another one for when an enemy sneaks up on you too.
Suddenly, games mean nothing. The money spent was worth it to bring souls towards the light of life. May God bless my path forever. I pray that all are shaken for truth and poured out flat on the table of true understanding, knowledge, and wisdom. Bless you.

Forum statistics

Threads
123,024
Messages
1,153,494
Members
161,369
Latest member
jaycen
Top