JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 156 of 171 View original ↗
  1. TheNewSon said:
    Hey guys! I'd like to know if there is a way to force all enemies to attack an enemy inflicted with a certain state?

    This is how it would work: I use a skill that inflicts a certain state onto an enemy, then all enemies proceed to attack that enemy.
    This is really not a JavaScript question that doesn't deserve a thread.

    You would have to use plugins for this, it's not something you can do with a script call.
  2. TheNewSon said:
    I use a skill that inflicts a certain state onto an enemy, then all enemies proceed to attack that enemy.
    easiest ways i can think of right now is giving your enemies damaging skills with an ally scope and then:
    - use yanfly's ai plugin to make them attack that ally with it
    - or use the selection control plugin to force it to only target enemies with that state and give the skill a 9 rating in the enemies' action patterns
  3. I can't find a script call in the master list to get an array of all skills that a class can learn (as you would set in the engine database under the Class tab). Is this something that exists or not? I know I can pull it as JSON data easily enough but getting it as part of a common event would be quite helpful.

    The flip side to this is just making an array per class within my common event of all skill names, but that would be tedious and I'd rather make a modular solution if possible.
  4. fablegamer said:
    I can't find a script call in the master list to get an array of all skills that a class can learn
    It's $dataClasses[ID].learnings

    Each entry has a level, note, meta, and skillId property.
  5. ATT_Turan said:
    It's $dataClasses[ID].learnings

    Each entry has a level, note, meta, and skillId property.
    Worked great, and I found the section in the MZ script call list about it. Using MV here. Having another issue however, in that when players hit a level that doesn't learn a skill, it just spits out the name of the last skill (though the actor correctly does not learn any skill on these levels).


    var id = $dataClasses[subclass].learnings[level].skillId;
    var skill = $dataSkills[id].name;
    $gameActors.actor($gameVariables.value(58)).learnSkill(id);
    $gameVariables.setValue(64, skill);

    This is my current script. Variable 64 is simply the string I output in the level up message. Is there a way to detect when there's no skill or id to gather from a specific level? Is it just a null value? And would I just run the empty value through a conditional (something like if (id == null), if it does spit out a null on these off-levels) to determine if the level message needs to say "x learned!" or not?
  6. is your console not showing any errors?
    trying to access the learnings for a blank level does return undefined. i assume youre getting an error for trying to get the skillId for undefined, the rest of the code isnt running, and wherever else youre using variable 64 is just using the last value
  7. I'm trying to create an icon inside the Window_BattleStatus during combat using this code:
    JavaScript:
    SceneManager._scene._statusWindow.drawIcon(64,0,0);
    Is there a way to change the opacity of the icon created? I want to make it dim.
  8. Robro33 said:
    is your console not showing any errors?
    trying to access the learnings for a blank level does return undefined. i assume youre getting an error for trying to get the skillId for undefined, the rest of the code isnt running, and wherever else youre using variable 64 is just using the last value
    Solved, thank you!
  9. @Fionn23 - you can use the window's changePaintOpacity method, e.g.
    JavaScript:
    const w = SceneManager._scene._statusWindow;
    w.changePaintOpacity(false);  // set to "disabled" transparency
    w.drawIcon(64, 0, 0);
    w.changePaintOpacity(true);   // reset
    This should work in MV or MZ.
  10. caethyril said:
    @Fionn23 - you can use the window's changePaintOpacity method, e.g.
    JavaScript:
    const w = SceneManager._scene._statusWindow;
    w.changePaintOpacity(false);  // set to "disabled" transparency
    w.drawIcon(64, 0, 0);
    w.changePaintOpacity(true);   // reset
    This should work in MV or MZ.
    This works. Thanks for this!
  11. @ATT_Turan @Robro33 ok, so here's how I'm trying to do it:

    1) I use a skill that applies state #55 onto one enemy, marking it as the "target" (working!).

    2) Upon applying that state, state #116 is applied onto all the other enemies, marking them as the "attackers" (working!).

    3) Now all the "attackers" must attack the "target" during that turn (not working).

    This is the code that I'm using for state #116 (meant for the attackers):

    Code:
    <Custom Action Start Effect>
    var action = user.currentAction();
    var foes = $gameTroop.aliveMembers();
    for (var i = 0; i < foes.length; i++) {
      var foe = foes[i];
      if (foe.isStateAffected(55)) {
        action.setTarget(foe.index);
      }
    }
    </Custom Action Start Effect>

    What am I missing? :(
  12. Robro33 said:
    index()
    I fixed it and it still isn't working... although I always thought "()" could be omitted? :unsure:
  13. TheNewSon said:
    I fixed it and it still isn't working... although I always thought "()" could be omitted? :unsure:
    No. Something either is a function or it isn't. Variables/properties never have parentheses attached to them and functions/methods must. There's never a "could be omitted."

    I would suggest for the number of posts about this - and the fact it has to do with a specific plugin - it may deserve its own thread.
  14. TheNewSon said:
    I fixed it and it still isn't working... :unsure:
    i just tried it myself and it seems to work exactly as you wanted. the state below goes on all actors, state 55 is on the enemy, and whenever the actors go to make an attack, its to be be redirected into the enemy with state 55, right? are sure you gave state 55 to the enemy? saved the project?
    Code:
    <Custom Action Start Effect>
    var action = user.currentAction();
    var foes = $gameTroop.aliveMembers();
    for (var i = 0; i < foes.length; i++) {
      var foe = foes[i];
      if (foe.isStateAffected(stateId+1)) { //mind you, stateId+1 can just be the other state's id
        action.setTarget(foe.index());
      }
    }
    </Custom Action Start Effect>

    TheNewSon said:
    although I always thought "()" could be omitted?
    index is a function, and the () is to call the function. if you dont use it, instead of getting the index of the battler, you get the definition for the function. That will just be read as being "true" if it exists and within the context of this overall effect will lead to attacking the enemy with the index of 1 (true)
  15. I want to get an actor's base stats without changes from buffs, debuffs, traits, states, etc. Is this correct for the HP? Just want to make sure.
    JavaScript:
    $dataClasses[actorClassID].params[0][actorLevel];
    // 0 - MHP, 1 - MMP, 2 - ATK, 3 - DEF, 4- MATK, 5 - MDEF, 6 - AGI, 7 - LUCK
  16. thatll work, but
    Fionn23 said:
    buffs, debuffs, traits, states, etc.
    it also wont count gear and grow parameter effects if you wanted either of those
  17. 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!
  18. Robro33 said:
    thatll work, but

    it also wont count gear and grow parameter effects if you wanted either of those
    Yup, that's what I want. Thanks. But what is a grow parameter?
  19. SolonWise said:
    $gameParty.members(1).currentClass.Id
    the right idea, but a couple mistakes
    members() is a function that doesnt have parameters and gives you an array of members. then, the individual members have a currentClass() function, but its a function and needs the (), and the id for the class youd get from that is id, not Id

    $gameParty.members()[1].currentClass().id

    Fionn23 said:
    But what is a grow parameter?
    skills and items can be given effects to permanently increase a parameter by some amount. the editor calls the effect "grow"