JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 159 of 171 View original ↗
  1. SolonWise said:
    Then, ChatGPT gave me this:
    To be blunt with you, you're pretty unlikely to get people giving you a lot of help after this - it is very well known at this point that AI generators such as ChatGPT make up answers, and both their math and code tends to be nonsense.

    I'm not sure why anyone would think at this point it's a good idea to ask an AI technical questions instead of a human who has actual education.

    There are multiple errors in that formula, and many of the people who are actually knowledgeable about code on this forum are tired of people asking for help fixing AI garbage.

    If you spent a few moments doing a Google or other Internet search instead of asking a bot, you'd find the MV/MZ Script Call pinned thread, which has the script calls for setting parameters; as well as this thread which has very thorough information on how to format damage formulae.

    Damage Formulas 101
    Also, this should not go into a damage formula because the code will be executed when the enemies are considering their attacks, which means your actors will be reduced several times a turn. You should be using a plugin that executes code during actions, such as Yanfly's Skill Core.
  2. @ramza

    Hello, thanks for your reply. I didn't know it was better not to use scripts in the damage formula. I'll try to use the <after damage eval> to try to solve my problem. I'm reading a lot of topics about it to try to understand how to use this eval thing, and I'll do some tests.

    @ATT_Turan

    Hey, sorry about that. I know perfectly well that a trained human is much more capable of understanding my question and knows RPG Maker much better than an AI, but I don't like bothering people with my questions, so I thought maybe an AI could help with a damage formula. I don't know much about programming, but in the last few weeks I've managed to solve a lot of problems in my project just by searching the forum, but sometimes I have no choice. And yes, I checked the MV/MZ Script Call pinned thread and the damage 101 thread as well before asking, but I couldn't solve my problem.

    I'll try using Visustella Skill Core or maybe its Eval Tags 1.8. Thanks for your answer.
  3. Yea, the damage formula is only meant for calculating a value. By default actors with the Autobattle flag will evaluate a formula to see which one is best, but a plugin could easily extend that to affect enemy AI.

    From the "Actor/Enemy Params" section of the first/main sheet of the MV/MZ Script Call List:

    scl.png
    (By default the core scripts recalculate params when needed, including relevant traits.)
  4. I am trying to get the position of the current event and check its region ID, however the position portion doesn't work:
    Code:
    $gameMessage.add("RegionID: " + $gameMap.regionId(this.x, this.y));
    $gameMessage.add("X: " + this.x + ", Y: " + this.y);

    Any ideas why is that happening?
    sorry if the question is too simple I am completely new to RPG maker MV.
  5. HaiderBassim04 said:
    I am trying to get the position of the current event and check its region ID, however the position portion doesn't work:
    In the context of event commands, this is a Game_Interpreter.

    To access properties or methods of the event, you need to do
    Code:
    $gameMap.event(this.eventId())
  6. Or simply this.character(0).

    However, note that you don't need script calls to get or show the map coordinates or region ID:
    • Control Variables -> Game Data -> Character -> This Event -> Map X/Y
    • Get Location Info -> Region ID -> Designation with variables: (Map X/Y).
    • Show Text: the \v[x] text code gets replaced by the current value of variable ID x.
    So the event might look like this:

    ◆Control Variables:#0006 Target X = Map X of This Event ◆Control Variables:#0007 Target Y = Map Y of This Event ◆Get Location Info:Target ID, Region ID, ({Target X},{Target Y}) ◆Text:None, None, Window, Bottom : :X = \v[6], Y = \v[7], Region ID = \v[8]
    (If you only need the region ID, MZ's Get Location Info command offers "Designation by a character".)
  7. caethyril said:
    this.character(0)
    That's exactly what I wanted.

    I took the script approach so that I don't have to create a new variable for each new clone of that object and having to modify it myself. A script would just work locally.

    Thanks a lot
  8. SolonWise said:
    Hello. I don't think my question deserves a new thread, so I'm asking here. I hope it is the right place.

    I'm looking for help with something that is very difficult for me, but I think it could be easy, even silly, for someone who understands scripting. Basically, all I need is a script call line that checks what the current class of the second current party member is. I think it would be ideal for the class Id to be stored in a given variable.

    I need this because I'm creating a custom class change screen using events and images, and I would like to display the image of the current class in the menu, but since there are 16 different classes and almost 50 playable actors, I simply can't tell which character was selected to enter this custom class change screen. And even if I knew that, I would still need to know what the current class of the selected actor is to display the correct image.

    I've tried things like:
    $gameParty.members(1).currentClass.Id
    $gameParty.members(1).currentClass().name
    $gameParty.members(1).isClass($dataClasses[1])

    Nothing seems to work. I've discovered that there are actually two possible solutions to my problem: I can set the current class ID of the selected actor to a variable, then all I have to do after that is create a conditional branch asking if the value of the variable is equal to 1, or 2, or 3, until I finally know which class is the correct one. Or I can use the conditional branching to ask if the second member of my party is currently "using" class ID X.

    I'm hoping someone can help with this, as I've spent the last two days trying to figure it out with no luck.

    Edit: Oh, I forgot to tell that I'm using RPG Maker MZ!
    I'm not sure I understand all of your request, but if you want to store the classes of your group members in a game variable, you can use this script:

    Code:
    $gameVariables.setValue(X , $gameParty.members()[Y]._classId)

    Replace X by the number of the game variable you want to use
    Replace Y by the number of party member. (the first party member = 0)


    EDIT uh I don't know why the next 3 pages of the thread didn't appear on my computer, so you already had your answer :D )
  9. HaiderBassim04 said:
    That's exactly what I wanted.

    I took the script approach so that I don't have to create a new variable for each new clone of that object and having to modify it myself. A script would just work locally.

    Thanks a lot
    Going the script route, you can use string literals to save yourself from having to do another .add() function to create a new line (you could use \n too) and you can reference the region with the regionId() function for characters):
    JavaScript:
    const c = this.character(0);
    $gameMessage.add(`Region ID: ${c.regionId()}
    X: ${c.x}, Y: ${c.y}`);
  10. What function will let me modify the skill name shown in battle when an actor uses a skill? The string with an icon on the center top of the screen during combat.
  11. SolemnGravity said:
    What function will let me modify the skill name shown in battle when an actor uses a skill? The string with an icon on the center top of the screen during combat.
    Check your plugins - MZ does not show anything like that.

    The only thing displayed when an actor uses a skill is the Message defined in the skill's database entry.
  12. ATT_Turan said:
    Check your plugins - MZ does not show anything like that.

    The only thing displayed when an actor uses a skill is the Message defined in the skill's database entry.
    Didn't even realize that wasn't in the default engine.
  13. SolemnGravity said:
    Didn't even realize that wasn't in the default engine.
    One of the Moghunter plugins does that.

    Edit: MOG_ActionName
  14. o/

    So using SRD HUDmaker and would like to know the code for when it's a specific actors turn to put into the condition.
  15. Hello... I need help at reworking my character: Erica who specialized at dealing indirect damage. So she has a skill that put this state to all of her enemies. Rpg maker MZ

    Code:
    <JS On Add State>
    
      target._scorchMarkDamage = 0;
    
      this.setStateDisplay(163, target._scorchMarkDamage);
    
    </JS On Add State>
    
    
    
    <JS On Erase State>
    
      $gameTemp.requestAnimation([target], 146);
    
      const damage = Math.round(target._scorchMarkDamage / 100 * origin.mat - (target.mdf * target._scorchMarkDamage / 400));
    
      target.gainHp(-damage);
    
      delete target._scorchMarkDamage;
    
      target.startDamagePopup();
    
      if (target.hp <= 0) {
    
        target.addState(1); // Add KO state (state ID 1)
    
        target.performCollapse(); // Trigger collapse animation
    
        if (target.isEnemy()) {
    
          BattleManager.checkBattleEnd(); // Check for battle end if an enemy is KO'd
    
        }
    
      }
    
      target.clearResult();
    
    </JS On Erase State>
    
    
    
    <Help Description>
    
    This unit will take indirect fire element magic damage based
    
    on Erica's x% MAT, bypassing Barrier
    
    </Help Description>

    There are problem that this state will make the target state explode when the target already KO'ed and it plays the animation. So I feel like it's better to make this state do AoE damage when expiring.

    1. How to make the state deals AoE damage when the state expiring?
    2. At the help description, how to change x into target._scorchMarkDamage?
  16. @RicardoxRyu When you post code, you need to use the CODE tags (the </> on the edit bar). That preserves indentations and brackets.

    This really belongs in a thread in plugin support, as you're dealing with plugins that add notetags and your second question requires another plugin.

    You also need to actually tell us (and provide links) to what plugins the notetags are coming from.
  17. Hello, so I've been trying to make a load game system where it will load your progress upon opening the game, but the player starts at the title.
    For context, the game doesn't allow the player to save (it's done by completing a level, and I put a saving command so the player doesn't have to worry about saving)
    The thing is, the title and the save point are at different maps, and as far as I know, RPG Maker loads the game and will teleport the player to the map where they last saved (which is the savepoint map)
    I want them to return to the title, and after checking the MZ/MV Script Call list, this is what I did

    JavaScript:
    DataManager.loadGame(1)
      .then(() => {
        SceneManager._scene.fadeOutAll();
        $gameTemp.reserveCommonEvent(102);
        $gamePlayer.reserveTransfer(44, 0, 0, 0, 0)
        if ($gameSystem.versionId() !== $dataSystem.versionId) {
          const p = $gamePlayer;
          p.reserveTransfer(44, 0, 0, 0, 0);
        }
        SceneManager.goto(Scene_Map);
        $gameSystem.onAfterLoad();
      }).catch(() => {
        SoundManager.playBuzzer();
      }).finally(() => {
        SceneManager._scene.fadeOutAll();
        $gameTemp.reserveCommonEvent(102);
        $gamePlayer.reserveTransfer(44, 0, 0, 0, 0)
      });

    [44 is the Title Map ID, the common event is to erase pictures only (since there are pictures in the savepoint map)]

    At first it does work, I get teleported to the main menu--but it still teleports me back to the savepoint map and it results in something like this:



    I'd like that brief period of being teleported to the savepoint gone, I tried using fadeout command (event command, not script call) before the loading script call but it doesn't work. How do I fix it?
  18. gtoff said:
    Hello, so I've been trying to make a load game system where it will load your progress upon opening the game, but the player starts at the title.
    Can you explain more what the point of this is? Part of loading the game in RPG Maker is loading the map and location where the player was, but you say you don't want that - so what's the point? What do you need some other data for?

    If you want to have something like dynamic elements on the title screen that change based on what the player has done in the game, you might want to look at existing plugins for New Game+ or meta controls to have switches and variables you can access outside of saves.

    (you should also be able to use my Loading Map plugin and have the map it redirects to be your title map)