If then else statements, where to get skill information? - SOLVED

Hello!

I have some questions regarding making the description of a skill in javascript with a whole lotta if, then, else statements.

First thing I am curious about is how I reference a certain setting of a skill?
Let's say I have a skill that deals fire damage, how do I get that information as a question?

if (SkillID[X] = ElementID[3]) {
Element = "Fire";
}
if (SkillID[X] = ElementID[4]) {
Element = "Ice";
}

How do I get the skill and the element of that skill?

This question extends into the further question of how to get the below information into the if-statement:
Skill ID
MP cost
TP cost
Damage formula
Damage type
Scope
Added state
Chance to apply state
Skill variance

I hope this is the correct forum for such a question.

Best regards,
Are you using plugins for this or are you asking for the default engine?
Are you using plugins for this or are you asking for the default engine?
At the moment I have Yanfly's message core with the evaltext to allow javascript within descriptions. I have yanfly skill core as well but I don't really use that to set elements and the other stuff I am currently looking for.

I found this https://kinoar.github.io/rmmv-doc-web/interfaces/rpg.skill.html and believe it might be close to what I need?
Can you tell me specifically what it is you're trying to do?
Can you tell me specifically what it is you're trying to do?
I want the description of a skill to change depending on the different settings of the skill.
Changing the skill element from fire to ice should also change the description to the corresponding element.

Part of the code I have for this generation in google sheets is as follows:
1596297486599.png

In turn this generates one of many possible descriptions:
1596297464294.png
Ah, I see what you mean.
1596297737993.png

1596297867161.png

The map will give you an array of arrays where each element has a first element of the state ID inflicted, and the second element the percentage chance of inflicting it.
Ah, I see what you mean.


The map will give you an array of arrays where each element has a first element of the state ID inflicted, and the second element the percentage chance of inflicting it.
I am starting to understand, not that advanced in the scripting department. However, using the above code for the damage formula just returns NaN if there is a damage formula, otherwise it just returns 0.
${Math.floor($dataSkills[1113].damage.formula*(1+$dataSkills[1113].damage.variance/100))}
the idea naturally being to include the damage with the positive damage variance. Any idea where I am going wrong?

I also don't understand where I can get the element of the skill(fire, ice, lightning, etc.)? Seeing that you are mentioning it in the previous message about the map but then reading it I understand it to be more of a state reference? Are elements just states?
1596298921423.png

1596298932227.png

I guess it returns the value just as a string that can not be included with a math function?
You'd need to use eval for that.
1596298956608.png
You'd need to use eval for that.View attachment 153663
Ah, perfect!
Thanks.

I have another question. Below just returns belowbelow.
1596299929644.png

1596299945687.png


Since it is returning the value 1 it should only write the first statement.
You need to use double or triple equals if you're doing comparison, a single equals is assignment.
You need to use double or triple equals if you're doing comparison, a single equals is assignment.
Could you write out an element type comparison?

Sorry if I am asking a whole lot of questions.
Do you mean something like this?
Code:
if ($dataSkills[97].damage.elementId === 2) 
   console.log("This skill's element is Fire!");
As I am writing I realize that it would be good if I can check if the skills' notetag contains the string "<instant>". Is there any way to do that?

Do you mean something like this?
Code:
if ($dataSkills[97].damage.elementId === 2)
   console.log("This skill's element is Fire!");
Yes, exactly what I wished for. Thanks a lot mate! 🙂
You can check a skill's note tag like so:

Code:
if ($dataSkills[123].meta.instant) doSomething();

However note that, unlike a lot of plugin developer note tags, any note tag accessed via meta is case sensitive. As in x.meta.instant and x.meta.Instant are two different properties entirely.
You can check a skill's note tag like so:

Code:
if ($dataSkills[123].meta.instant) doSomething();

However note that, unlike a lot of plugin developer note tags, any note tag accessed via meta is case sensitive. As in x.meta.instant and x.meta.Instant are two different properties entirely.
Thanks a lot!

Another question that arose as I want to put in as much work now as possible so I can be as lazy as possible later. Let's say I am currently looking at a skill, can I make it so the $dataSkills[x] references $dataSkills[this]? So that I can just copy paste one line into everything.

To simplify, can I reference the skill I am looking at? Similar to a in a.atk.
That's a bit trickier, but if you're using the formula box, this._item might work. Not tested though. Note that it will depend entirely on what object is calling the function. "_item" (the associated skill or item) in this case is a property of a Game_Action object.
That's a bit trickier, but if you're using the formula box, this._item might work. Not tested though. Note that it will depend entirely on what object is calling the function. "_item" (the associated skill or item) in this case is a property of a Game_Action object.
The javascript is within the description box of the skill. I will see in the morning how it looks and if it's possible 🙂
That's a bit trickier, but if you're using the formula box, this._item might work.
You can just write item in the damage formula box to refer to the active skill.

You'd need to use eval for that.View attachment 153663
I think at this point it might be easier to construct a Game_Action and call evalDamageFormula on it. That'll automatically get you a and b, and it'll also get item and v and anything else a plugin might add. Of course, this is assuming that you have all the pieces you need, which might not be the case when you're writing code in the description box...

The javascript is within the description box of the skill. I will see in the morning how it looks and if it's possible 🙂
So I'm afraid there's probably no way to actually use the same line for every skill using just evalText (unless Yanfly has some sort of special case for using it in an item description).

You can definitely write it in such a way to allow you to copy-paste and change just a single constant for each skill, though. If that's not good enough you'll probably need a plugin that somehow makes the information available in the help window.

Or actually, come to think of it, if "this" refers to the help window then there might actually be a way...
You can just write item in the damage formula box to refer to the active skill.
Okay that's cool, I learned a new thing today!
You can just write item in the damage formula box to refer to the active skill.


I think at this point it might be easier to construct a Game_Action and call evalDamageFormula on it. That'll automatically get you a and b, and it'll also get item and v and anything else a plugin might add. Of course, this is assuming that you have all the pieces you need, which might not be the case when you're writing code in the description box...

So I'm afraid there's probably no way to actually use the same line for every skill using just evalText (unless Yanfly has some sort of special case for using it in an item description).

You can definitely write it in such a way to allow you to copy-paste and change just a single constant for each skill, though. If that's not good enough you'll probably need a plugin that somehow makes the information available in the help window.

Or actually, come to think of it, if "this" refers to the help window then there might actually be a way...

I agree that for the thing itself creating a Game_Action is the way to go; I was just doing that in the console to show the functions/properties needed.

Original thread: https://forums.rpgmakerweb.com/threads/if-then-else-statements-where-to-get-skill-information-solved.124804/