JavaScript questions that don't deserve their own thread

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.
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.
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
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.
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.
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?
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
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.
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!
@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.
@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!
@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? 🙁
foe.index
index()
I fixed it and it still isn't working... although I always thought "()" could be omitted? 🤔
I fixed it and it still isn't working... although I always thought "()" could be omitted? 🤔
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.
I fixed it and it still isn't working... 🤔
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>

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)
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
thatll work, but
buffs, debuffs, traits, states, etc.
it also wont count gear and grow parameter effects if you wanted either of those
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!
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?

Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/