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

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
It's to handle the case where you don't have anything selected in the skill list window, in which case its index will be -1.

listWindow.index() !== -1 ? listWindow.index() : 0

is basically saying

"if the list window's index is not -1, return the index, otherwise return 0".

It just means that when you don't have a skill selected the code will return whatever the skill in the first slot of the window is, but because the help window doesn't really do anything until a skill is selected it shouldn't make a difference.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
It's to handle the case where you don't have anything selected in the skill list window, in which case its index will be -1.

listWindow.index() !== -1 ? listWindow.index() : 0

is basically saying

"if the list window's index is not -1, return the index, otherwise return 0".

It just means that when you don't have a skill selected the code will return whatever the skill in the first slot of the window is, but because the help window doesn't really do anything until a skill is selected it shouldn't make a difference.
I see.

Alright, so I was feeling like it will work. But I noticed that I do have to set the variable every time I am on a new screen. A bit unfortunate but trying to implement it into the script where I set the variable at the beginning of each screen. However it seems that it returns the value 483, but checking the variable value returns a list
1596463925984.png

I was thinking if I can have a parallel common event always running, even when viewing menus that keeps doing the below code every frame.
Code:
var listWindow = SceneManager._scene instanceof Scene_Skill ? SceneManager._scene._itemWindow : SceneManager._scene._skillWindow;
$dataSkills[listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id].id
Since common events don't run whilst in the menus, is there some way I can make a proper background process?
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Well where are you actually setting the descriptions?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Is there a plugin that converts those to text?

Ah, Message Core with EvalText I think you said. Can you paste your full description for me and I'll debug it?
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Is there a plugin that converts those to text?

Ah, Message Core with EvalText I think you said. Can you paste your full description for me and I'll debug it?
Yanfly's plugin seems problematic in that it doesn't work with all javascript so I am suing WAY_EvalText. Only issue with WAY is that you can't make any function using {} as it ends the code reading. That's why I use "question ? stuff : stuff" instead of if statement.

I can post it, but it's not really done yet and I am still working on the structure of the description. It also does work with the exception that I have to type in each skill ID by hand for each separate skill. And considering there will be at least 100 different if-statements for each of the about 200-300 skills it will take a very long time, and if I have to change anything in the text I have to do it all again...
Edit: I guess I don't have to change every ID by hand, can just use find and replace but still a very demanding and consuming process.

What I see as the optimal solution would be that the if statement always checks for the currently viewed skill and that the description itself is grabbed from ONE variable that stores the entire description. With the possibility to to have to code in lines instead of a single line that it is now due to the description boxes' restriction of two lines.

But perhaps, if you are up for it, I could screen share over discord and then also go over in more detail what I am trying to truly accomplish so there aren't misunderstandings. Especially from my side as I'll have a hard time explaining certain elements as I don't always know what I am asking and that I don't understand all of the code you provide.

Also, is there no way to store the listWindow.id as a plain numerical value? Perhaps even in $gameVariables?
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Is there a plugin that converts those to text?

Ah, Message Core with EvalText I think you said. Can you paste your full description for me and I'll debug it?
So I realized something.
The var listWindow that I asked for before to just get the Id, I see that I used the wrong one and that you already showed how to get only the integer.

So I do believe that it should be doable with some tweaking, trying to work on it now. But seems that the hardest part is to properly update the variable when changing skill to view.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
That should be taken care of by the fact that when you change skill, the list window index changes too.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
That should be taken care of by the fact that when you change skill, the list window index changes too.
Unfortunately it does not. I believe I'll have to keep just copy pasting from my google sheet for the time being.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
525
Reaction score
230
First Language
English
Primarily Uses
RMMV
What I see as the optimal solution would be that the if statement always checks for the currently viewed skill and that the description itself is grabbed from ONE variable that stores the entire description. With the possibility to to have to code in lines instead of a single line that it is now due to the description boxes' restriction of two lines.
I definitely think that your goal is a very poor fit for EvalText (though I would never recommend EvalText for anything, but it's especially bad for this). I think it would be better to simply clear the description box entirely and have a plugin construct your desired description instead of reading from the description box.

This isn't a complete solution, but it might make a good starting point:

JavaScript:
Window_Help.prototype.setItem = function(item) {
    var template = "This does %1-%2 %3 damage";
    var user = ???; // Not sure how to get the user...
    var action = new Game_Action(user);
    action.setItem(item);
    var damage_avg = action.evalDamageFormula();
    var damage_min = damage_avg * item.damage.variance;
    var damage_max = damage_avg * (1 + item.damage.variance);
    var element = $dataSystem.elements[item.damage.element);
    this.setText(template.format(damage_min, damage_max, element));
};
You would use it by saving it in a file, giving it a name that ends with .js (be sure to save as All Files *.*), dropping it into your plugins folder, and enabling it in the plugins manager.

That's a very simple example that shows the damage range and element for skills that deal damage. A complete example would of course be much more complex, as there are tons of conditions to check.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
I definitely think that your goal is a very poor fit for EvalText (though I would never recommend EvalText for anything, but it's especially bad for this). I think it would be better to simply clear the description box entirely and have a plugin construct your desired description instead of reading from the description box.

This isn't a complete solution, but it might make a good starting point:

JavaScript:
Window_Help.prototype.setItem = function(item) {
    var template = "This does %1-%2 %3 damage";
    var user = ???; // Not sure how to get the user...
    var action = new Game_Action(user);
    action.setItem(item);
    var damage_avg = action.evalDamageFormula();
    var damage_min = damage_avg * item.damage.variance;
    var damage_max = damage_avg * (1 + item.damage.variance);
    var element = $dataSystem.elements[item.damage.element);
    this.setText(template.format(damage_min, damage_max, element));
};
You would use it by saving it in a file, giving it a name that ends with .js (be sure to save as All Files *.*), dropping it into your plugins folder, and enabling it in the plugins manager.

That's a very simple example that shows the damage range and element for skills that deal damage. A complete example would of course be much more complex, as there are tons of conditions to check.
Perhaps you are right, but as it stands, I am not advanced enough to comprehend how to make a plugin.

1.
But I know this following question might belong in plugin requests, but since this thread is open and on topic I am curious about how hard it would be to make a plugin like YEP_MessageMacros but with the possibility to just copy all of the lines below and add them into a list and then in the skill description you'd only have to write say "\sk[x] and it would do exactly what \m[x] does where it can read the evalText and such? "So why not just use YEP_MessageMacros?". Simple, you can't copy 300 lines of google sheet and paste it into a list where each line correlates to all values for x in \sk[x].

So, is this something that would take a lot of time or would it be doable?

2.
As I am writing I am thinking that perhaps I do not need a proper plugin for this.
Is there some way to just store below descriptions as variables with the names to the left and when referencing the variable it will do the calculations and such?
1596476855242.png
If this is possible I could technically paste it into a script similar to below. Seems there's a maximum amount of rows in the script command but feels like that can be corrected somehow.
1596477029058.png
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
525
Reaction score
230
First Language
English
Primarily Uses
RMMV
Regarding #2, I think the syntax you're looking for is:

JavaScript:
var sk12 = `This does ${Math.round(2.4 * a.mat)} - ...`
However, I'm not clear on how that would actually help you. (Also, it's localization-unfriendly, if you care about that. In other words, don't use that syntax if you have any plans to ever translate your game into another language.)

You were able to write all these formulas in Excel, right? So I think translating them into a plugin using my example as a base wouldn't be too much harder than it was to write them in Excel in the first place. Excel formulas are pure, so it shouldn't be too hard to write JavaScript that performs the exact same calculations. You would need to make a few substitutions, for example + instead of & and ** instead of ^, and any cell references would need to be translated to variables, but it should be doable. I would have even gotten a start on doing it for you, but you never posted the formulas in a readable format, so there was nothing I could do.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Regarding #2, I think the syntax you're looking for is:

JavaScript:
var sk12 = `This does ${Math.round(2.4 * a.mat)} - ...`
However, I'm not clear on how that would actually help you. (Also, it's localization-unfriendly, if you care about that. In other words, don't use that syntax if you have any plans to ever translate your game into another language.)

You were able to write all these formulas in Excel, right? So I think translating them into a plugin using my example as a base wouldn't be too much harder than it was to write them in Excel in the first place. Excel formulas are pure, so it shouldn't be too hard to write JavaScript that performs the exact same calculations. You would need to make a few substitutions, for example + instead of & and ** instead of ^, and any cell references would need to be translated to variables, but it should be doable. I would have even gotten a start on doing it for you, but you never posted the formulas in a readable format, so there was nothing I could do.
Yes, I don't know if you realize but you did respond to this in another thread to me. As you saw there I had realized the issue with the way I set the code and it now looks like this instead.
$gameVariables.setValue(437, "This will increase your magic defense by 45% for 3 turns.");

The reason I originally use var sk1013 was that I did not want to have a bunch of empty variables in the variable selector. However I decided to just write --- in each of the game variables so I know they are reserved so I don't accidentally try using them for something else you know :)

I can add that it works perfectly and I will now try the solution you provided in the other thread for setting the value directly into the actual macro plugin.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
Alright, so after somewhat of a long journey I think I've discovered the best way to do this. I'll keep doing it in the google sheets and I feel like I had a struck of genius, I understand that others may have thought of this but what I decided to do was to make a plugin function that essentially just changes it directly.

It started with me wanting to be able to change the MP cost of all skills similarly to how I want to change the descriptions of all skills. However I realized that I can probably just use the $dataSkills[x].mpCost = y to set the MP cost to whatever I feel like. Then this lead to me realizing that I can do the very same with the damage formula. At this point the light bulb came and I realized I can certainly do the very same by just doing the $dataSkills[x].descriptions = "X", and don't you know it worked perfectly.

So now I can actually generate every single skill without ever having to touch the skills section.
I actually just paste each column into the plugin, so all names will be set, then MP cost, then descriptions and then formula and so on.
1596540334393.png
So a short script list would look like this:
JavaScript:
$dataSkills[1113].name = "Fire Bolt";
$dataSkills[1114].name = "Fire Heal";
$gameVariables.setValue(432, "This does ${Math.round(2.4 * a.mat)} - ${Math.round(3.6 * a.mat)} fire damage and has a 20% chance to inflict burn that does ${Math.round(0.9 * a.mat)} fire damage per turn for 3 turns on the target.");
$gameVariables.setValue(433, "This does ${Math.round(2.4 * a.mat)} - ${Math.round(3.6 * a.mat)} healing magic to the target.");
$dataSkills[1113].mpCost = 15;
$dataSkills[1114].mpCost = 11;
$dataSkills[1113].damage.formula = "3 * a.matk";
$dataSkills[1114].damage.formula = "3 * a.matk";
$dataSkills[1113].iconIndex = 1113;
$dataSkills[1114].iconIndex = 1114
$dataSkills[1113].animationId = 513;
$dataSkills[1114].animationId = 514;
;
But essentially, this way I can set every skill in the game with a simple spreadsheet for easy balancing, I can change my variables however I like, then just paste the column into the function and voila! I have all my skills in the game!
 

Attachments

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
525
Reaction score
230
First Language
English
Primarily Uses
RMMV
At this point the light bulb came and I realized I can certainly do the very same by just doing the $dataSkills[x].descriptions = "X", and don't you know it worked perfectly.
I'm pretty sure I remembered suggesting exactly this at some point... maybe I just wasn't clear enough...

That said, I never would've suggested you take it to the extreme you're doing, though if it works for you, I guess I can't complain.
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
89
Reaction score
11
First Language
Swedish
Primarily Uses
N/A
I'm pretty sure I remembered suggesting exactly this at some point... maybe I just wasn't clear enough...

That said, I never would've suggested you take it to the extreme you're doing, though if it works for you, I guess I can't complain.
Can't find anything suggesting directly changing the description, perhaps I'm missing it. Perhaps it was to another thread not mine.
Unless you mean the below, which I guess does change the descriptions but not as straight forward, I don't know what a Game_Action is nor how to use it. The "user" situation is also something I am unsure of as you were as well. Perhaps it would work, but it is, and not afraid to admit it, too advanced for me at the moment. I also don't know if it is actually more effective than what I cam up with at the end. Especially since I actually already had the entire description system in place in google sheets.
JavaScript:
Window_Help.prototype.setItem = function(item) {
    var template = "This does %1-%2 %3 damage";
    var user = ???; // Not sure how to get the user...
    var action = new Game_Action(user);
    action.setItem(item);
    var damage_avg = action.evalDamageFormula();
    var damage_min = damage_avg * item.damage.variance;
    var damage_max = damage_avg * (1 + item.damage.variance);
    var element = $dataSystem.elements[item.damage.element);
    this.setText(template.format(damage_min, damage_max, element));
};
Well I can understand your opinion on it. But the biggest benefactor that I see is that it's all going to be consistent. As I don't have to write the skills descriptions by hand there won't be typos and accidents. Balance will be easy to control considering the overview I get of all the skills in a certain school. When making fire skills I see all the different fire skills available, when setting damage, adding states, effects, scope and similar it will automatically balance the mana costs ensuring that the cost for a skill will be relatively appropriate. A skill with more damage wont be as cost effective as a skill with lower damage but it will also deal more damage at once.

It makes it easier to balance the different skill schools against each other as well.

I can add that it's actually not that much work now, it took a long time to get here but now that I've sort of arrived the time of making a skill is reduced quite a lot. Making changes that affect all skills are now easier as well.

If I were to change how say the state burn works, I want the player to know how burn functions so it's in the description, but if I made a change to burn then I would have to make a change to every single description. What if I were to screw up and make a skill with a damage formula that say a.atk*3 but in the description it says a.atk*5 then the player would not understand why the attack never reaches apex damage.

So whilst I see how it may seem extreme I do indeed see the value in making this system and must disagree with the statement.



.... Now to make the same system for classes, states, actors and what have you o_O
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Part of me is really missin' the good 'ol days of RM '95... goodness just seems like such simpler times
Just got two Switch E-Shop 20$ gift cards... Is 3D All-Stars worth it? Or should I get something like Celeste? I'd love to know your opinion!
I’m looking at the MZ full body images and I think Priscilla is taller than Reid...
Ami
--- Music Selection ---

M.Archer: It's Music Station,You can Change the Music as you like.
F.Healer: i want to hear the Romantic Music.
M.Fighter: Then,i want the Hard-Rock one!
(the Troll Song has played)
M.Archer: Hey,i hear this Music.
F.Healer: It's popular from Internet Music,i wonder who change it?
Hero: I change it.
Entire Party: YOU????

Forum statistics

Threads
103,042
Messages
996,908
Members
134,516
Latest member
Pumpkinnubbin
Top