JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 119 of 171 View original ↗
  1. @Kes

    JavaScript:
    <JS Post-Damage>
     if(target.result().critical == true)
     {
        user.gainTp(15);
     }
    </JS Post-Damage>
  2. @ScorchedGround Thank you. That worked perfectly. Your help is much appreciated.
  3. 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.
  4. Phoenixsylph said:
    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.
  5. ATT_Turan said:
    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!
  6. 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?
  7. Welcome!

    dewm3734 said:
    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.

    dewm3734 said:
    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!
  8. 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:
    MZ - stop side-view battlers from moving forward during their command turn
    any chance theres some similar piece that i can use to make enemies "motionless" while receiving damage from special skills?
  9. LookAtThisDude said:
    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).
  10. ATT_Turan said:
    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.
  11. 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?
  12. Dark_Ansem said:
    What did I do wrong?
    I don't know, what's going wrong? You never say that you have a problem or what it is.
  13. ATT_Turan said:
    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.
  14. Dark_Ansem said:
    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.
  15. ATT_Turan said:
    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?
  16. LookAtThisDude said:
    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
  17. Robro33 said:
    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.
  18. ATT_Turan said:
    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?
  19. Dark_Ansem said:
    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.
  20. ATT_Turan said:
    I looked at the VisuStella Skills and States instructions and your notetag is wrong. It's JS On Add State, not On Apply.
    Thank you. and of course JS On Erase State is what should be in place of JS on remove?

    EDIT: after making this change, for some reason, it's the user of the skill that dies on the first use - progress, but I wonder what happened