JavaScript questions that don't deserve their own thread

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
23,603
Reaction score
13,402
First Language
English
Primarily Uses
RMMZ
I have finally got the "if critical hit, add state to target" right, but so far have not been able to do "add TP to user". Here is what I have atm

Code:
<JS Post-Damage>
 if(target.result().critical == true)
 {
    user.tp=+15;
 }
</JS Post-Damage>
Can anyone correct the user.tp=+15 bit for me?

Thank you
 

ScorchedGround

Blizzards most disappointed fan (They keep going)
Veteran
Joined
Apr 12, 2020
Messages
810
Reaction score
1,266
First Language
German
Primarily Uses
RMMV
@Kes

JavaScript:
<JS Post-Damage>
 if(target.result().critical == true)
 {
    user.gainTp(15);
 }
</JS Post-Damage>
 

Phoenixsylph

=w= just chillin
Veteran
Joined
Sep 25, 2017
Messages
67
Reaction score
51
First Language
English
Primarily Uses
RMMV
I'm trying to figure out where I can learn/figure out where in the js files I actually edit say the width height, x and y of an item scenes. I'm learning js script but have a long way to go.

But I still wanted to test in an extra file to see if I can fiddle with it. [RPG MAKER MZ]

It would be the scenes.js I figured, but I'm not seeing any numbers or anything that can be adjusted. Anywhere I can learn more about this? Or figure to start ((where)) I go to change the say, x and y location of a window, placement of text, for the item list/different sections of the item scene.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
I'm trying to figure out where I can learn/figure out where in the js files I actually edit say the width height, x and y of an item scenes. It would be the scenes.js I figured, but I'm not seeing any numbers or anything that can be adjusted.
This can be a little confusing. A scene is just a collection of windows. Those individual windows are defined in the rmmz_windows file.

So if you open up the _scenes file and look for, say, the Scene_Item section for the item screen. You'll see the second function is the create() method and it creates a help window, category window, item window, and actor window.

You can then scroll down to those methods to see exactly what kind of window each one is. For example, inside createCategoryWindow(), you'll see it's a new Window_ItemCategory. You can then open up your _windows file and search for that to find the specs and functionality for that portion of the item scene.

Back in the scene file, a few lines up, you see a shape (rect = rectangle) is determined by categoryWindowRect(), so you can look at the very next function down to see how the dimensions of that window rectangle are calculated.

There's a lot of intermeshing code in this stuff, so it's not the easiest to sort through and work with for someone who's just learning about JavaScript. It might be easier to save this customization for when your game and coding tutorials are farther along, or save up for a plugin that helps you customize it visually like in your other thread.
 

Phoenixsylph

=w= just chillin
Veteran
Joined
Sep 25, 2017
Messages
67
Reaction score
51
First Language
English
Primarily Uses
RMMV
This can be a little confusing. A scene is just a collection of windows. Those individual windows are defined in the rmmz_windows file.

So if you open up the _scenes file and look for, say, the Scene_Item section for the item screen. You'll see the second function is the create() method and it creates a help window, category window, item window, and actor window.

You can then scroll down to those methods to see exactly what kind of window each one is. For example, inside createCategoryWindow(), you'll see it's a new Window_ItemCategory. You can then open up your _windows file and search for that to find the specs and functionality for that portion of the item scene.

Back in the scene file, a few lines up, you see a shape (rect = rectangle) is determined by categoryWindowRect(), so you can look at the very next function down to see how the dimensions of that window rectangle are calculated.

There's a lot of intermeshing code in this stuff, so it's not the easiest to sort through and work with for someone who's just learning about JavaScript. It might be easier to save this customization for when your game and coding tutorials are farther along, or save up for a plugin that helps you customize it visually like in your other thread.
Hey this actually helps a lot, I'm going to learn some more before delving in, I really appreciate your advice too x) But this was a big help to know where to look as well!
 

dewm3734

Warper
Member
Joined
Aug 11, 2014
Messages
3
Reaction score
1
First Language
English
Primarily Uses
Hey guys, I'm looking for a bit of insight in MV. How exactly does the main menu scene pass the selected actor info over into other scenes? Like, if I choose Skill in the menu then choose the first actor, how does Scene Skill know to display info about that chosen actor?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
Welcome!

Hey guys, I'm looking for a bit of insight in MV. How exactly does the main menu scene pass the selected actor info over into other scenes?
Well, it doesn't really. It's done at the window level.

Like, if I choose Skill in the menu then choose the first actor, how does Scene Skill know to display info about that chosen actor?
Short answer: Window_MenuStatus.processOk() sets the window's internal actor variable when you select an actor from a list window.

For a longer answer, you can start at Scene_Menu and follow the code back and forth between that and the windows code file and work your way back through parent classes until you find the relevant code.

As I said in my reply to the poster immediately previous to you in this thread, scenes have a lot of interconnecting and kind of convoluted code you need to follow carefully if you're trying to find a specific thing.

Good luck with your project!
 

LookAtThisDude

Villager
Member
Joined
Oct 18, 2018
Messages
8
Reaction score
0
First Language
German
Primarily Uses
RMMZ
Hello Community!

im trying to make a skill that inflicts damage, but prevent the target from moving when loosing HP through it.
Normally, everytime a battler receives damage, its sprite will step back a little. Especially for a fire skill that encase/enfold the target, it feels weird that it somehow moves, dragging the animation aswell.

In 2021, somebody asked for a tiny code that prevents actors from moving FORWARD when in turn:

any chance theres some similar piece that i can use to make enemies "motionless" while receiving damage from special skills?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
im trying to make a skill that inflicts damage, but prevent the target from moving when loosing HP through it.
As your question is not going to be solved by a single code statement, I suggest you post a plugin request thread. It's not a complicated change, but you'll need a little plugin to either eliminate the damage motion entirely, or look for a notetag on the attacking skill that says to not play it (I presume from your post that you want the second way, but make it very clear).

Also, are you posting in the right place for it? Your profile says you use VX Ace, but only MV and MZ use JavaScript and have plugins. Make sure you specify which RPG Maker you want the plugin for (and if it's VX Ace, that's not a plugin but a Ruby script).
 

LookAtThisDude

Villager
Member
Joined
Oct 18, 2018
Messages
8
Reaction score
0
First Language
German
Primarily Uses
RMMZ
As your question is not going to be solved by a single code statement, I suggest you post a plugin request thread. It's not a complicated change, but you'll need a little plugin to either eliminate the damage motion entirely, or look for a notetag on the attacking skill that says to not play it (I presume from your post that you want the second way, but make it very clear).

Also, are you posting in the right place for it? Your profile says you use VX Ace, but only MV and MZ use JavaScript and have plugins. Make sure you specify which RPG Maker you want the plugin for (and if it's VX Ace, that's not a plugin but a Ruby script).
Thanks for your answer!

Guess ill try it soon the way you proposed. Hopefully there is the possibility to toggle "backstep motions" depending on the used skill ID (basically the 2nd way, like you supposed).
Besides, just recognized my misleading profile and corrected it.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
So, I've been watching an (un)healthy amount of Critical Role streams, and my DM tendencies have resurfaced. I'm trying to mimic the "attribute drain" ability that Shadows have (making them extremely dangerous to low-level parties), this is the best I could come up with, a notetag to attach to a custom state (which I kind of like as an approach).

JavaScript:
<JS On Apply>
const drainAmount = Math.floor(Math.random() * 8) + 1;
user._drainedAttack = drainAmount;
user.addParam(2, -drainAmount);
if (user.atk <= 0) {
  user.die();
}
</JS On Apply>

<JS On Remove>
if (user._drainedAttack) {
  user.addParam(2, user._drainedAttack);
  user._drainedAttack = 0;
}
</JS On Remove>

Relies on VisuStella MZ - Skills and States Core plugin installed. What did I do wrong?

PS: on a different note, is 1-8 too generous, should it just be flat damage? should the state persist after battle or be removed?
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
I don't know, what's going wrong? You never say that you have a problem or what it is.
Well it doesn't seem to be working- mind you, I have little ways to check since I can't check status window while in-battle and I'm always worried that I write the syntax wrong, it's a steep learning curve.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
Well it doesn't seem to be working- mind you, I have little ways to check
The code looks fine, so it would be helpful if you were more specific about how you did troubleshooting.

There are absolutely ways to check. You can make the damage formula for your attack skill be a.atk with no variance and see what value it produces.

You can press F8 and confirm there are no errors in the Console tab.

The one thing that I can see that's incorrect is user.atk is always going to return a minimum of 1. If you want to see if the total of the user's atk is <= 0, you'll need to add the separate parts manually.

But it looks like the actual atk reduction should work fine.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
The one thing that I can see that's incorrect is user.atk is always going to return a minimum of 1. If you want to see if the total of the user's atk is <= 0, you'll need to add the separate parts manually.
oh whoops. Could this be why it doesn't seem any party member is dying?
 

Robro33

Weeb Cringe Incarnate
Veteran
Joined
Oct 15, 2022
Messages
62
Reaction score
29
First Language
English
Primarily Uses
RMMV
any chance theres some similar piece that i can use to make enemies "motionless" while receiving damage from special skills?
If you are using Yanfly's battle core you can make a state with the <Sprite Cannot Move> notetag inside it, then have your special attacks apply and remove that state before and after the damage to make it so that they dont flinch from them
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
If you are using Yanfly's battle core you can make a state with the <Sprite Cannot Move> notetag inside it, then have your special attacks apply and remove that state before and after the damage to make it so that they dont flinch from them
Good suggestion, but according to their profile next to the post, that user is using MZ and Yanfly plugins are for MV.

VisuStella does not appear to have a corresponding notetag for actors.
 

Dark_Ansem

Veteran
Veteran
Joined
Jun 16, 2020
Messages
547
Reaction score
135
First Language
English
Primarily Uses
RMMZ
But it looks like the actual atk reduction should work fine.
well, it's not happening apparently. I got the state to hang after battle but attack power isn't reduced, not even after battle after making the status change not expire. so, it means it is not applied I think?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,920
Reaction score
6,731
First Language
English
Primarily Uses
RMMV
well, it's not happening apparently. I got the state to hang after battle but attack power isn't reduced, not even after battle after making the status change not expire. so, it means it is not applied I think?
I looked at the VisuStella Skills and States instructions and your notetag is wrong. It's JS On Add State, not On Apply.
 

Latest Threads

Latest Posts

Latest Profile Posts

With this, I'm gonna have a good night sleep
Damn. We’ve gotten so close to 0 reports, 0 approvals a few times over the past couple weeks. Does it matter? No. Is it realistic. No? Do I rely on your reports and want everyone to keep posting. Yes. Do I 100% games? …sigh… Yes.

Ah yes, all three of my moods all at once.
Here's a tutorial I did on how I made my Leonardo A.I.-assisted artworks for my game's recent update. :rhappy:

Disclaimer: This is meant to be a band-aid solution for people like me who aren't good artists or don't have the financial means to hire an amazing artist. If you have the means, please buy commissions and support your fav artists.:yhappy:

Forum statistics

Threads
131,756
Messages
1,223,012
Members
173,518
Latest member
Tiagrun
Top