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

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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,
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
Are you using plugins for this or are you asking for the default engine?
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
Can you tell me specifically what it is you're trying to do?
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
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.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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?
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
You'd need to use eval for that.1596298956608.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
You need to use double or triple equals if you're doing comparison, a single equals is assignment.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,302
Reaction score
1,180
First Language
English
Primarily Uses
RMMV
Do you mean something like this?
Code:
if ($dataSkills[97].damage.elementId === 2) 
   console.log("This skill's element is Fire!");
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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! :)
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,302
Reaction score
1,180
First Language
English
Primarily Uses
RMMV
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.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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.
 
Last edited:

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,302
Reaction score
1,180
First Language
English
Primarily Uses
RMMV
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.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
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 :)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
465
Reaction score
201
First Language
English
Primarily Uses
RMMV
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...
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Yaaay! My second public script is out and approved! A VX Ace Final Fantasy IX styled Throw Script!

I look forward to all the constructive feedback I get but most importantly I hope everyone who ends up using it enjoys!

Yaaaay! Making scripts is fun lol. :D
When you're lost out therrrrre and you're alllll alone, ahwahwah waitin, to carry you hooooommmme, uhhheverywhere you look! (someone hit me with those backing vocals)
X.X cant focus... too many thing want do... help!
Day 2 of teaching MV, student can move cat across the map.
Got inspired and started writing a simple tower defence battle system last night :o

Forum statistics

Threads
100,525
Messages
976,803
Members
132,080
Latest member
nwr
Top