JavaScript questions that don't deserve their own thread

Kaimi

Veteran
Veteran
Joined
Aug 18, 2012
Messages
78
Reaction score
82
First Language
Polish
Primarily Uses
RMMZ
In RMMZ I'm hoping to allow to counter both physical and magic attacks when the character is defending. The way I want it to work is that upon first hit that the affected unit receives (there are a lot of skills that hit multiple times) the defending unit will retaliate with the Counter skill (mainly to increase the counterer's TP but I do realize there are other methods). I have this put in the Defend state's Note are (I am using Visustella):
<JS Post-Damage as Target> if (this.isHpEffect()) { const skill = 5; const target = -2; user.forceAction(skill, target); } </JS Post-Damage as Target>
However it's not working as I hope as it causes the enemy that attacks defender to attack the defender continuously until they evade. Sadly my programming skills are very limited.
As far as I can tell user.forceAction(skill, target); should be altered to something else. Also, note that I do plan to add additional condition for activating the Counter skill, that is to be affected by a state (which AFAIK would be user.isStateAffected(stateID)).
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
I'm attempting to have a common event that will only remove states within a specific category...from the party.
Code:
$gameParty.members().forEach(actor => actor.removeStateCategoryAll("food"));
or whatever your category is called.

However it's not working as I hope as it causes the enemy that attacks defender to attack the defender continuously until they evade. Sadly my programming skills are very limited.
You appear to be reversing "user" and "target" inside of your notetag. You're using the damaged "As Target" notetag, but then you're telling the user to attack the target again, which will produce the loop you see.

If you swap that around and it still doesn't work the way you want, per the first post of this thread, plugin-specific questions should go elsewhere - you can make a post in Plugin Support, or Trihan has a thread dedicated to VisuStella notetags.
 

Siffers

Villager
Member
Joined
Nov 7, 2019
Messages
13
Reaction score
4
First Language
English
Primarily Uses
RMMV
Code:
$gameParty.members().forEach(actor => actor.removeStateCategoryAll("food"));
or whatever your category is called.
Thank you, I really appreciate all the help I've gotten here ♥
 

Kurot

Veteran
Veteran
Joined
Jun 5, 2016
Messages
31
Reaction score
14
First Language
Portuguese
Primarily Uses
RMMV
Hello everyone, I use RPG Maker MV and I would like some help if possible, so thanks in advance to anyone who can help.

First, I know almost nothing about javascript, so my question may seem silly or stupid.

I'm making an event so that when a character "X" is in the group, while he is walking he makes a certain sound, for example, one of my characters is of the "Treant" race, and while he walks he makes a branch noise.

Therefore, I check if the character "X" is in position 1, 2 or 3 of the group (my group has a maximum limit of 3 characters) and if he is in any of these positions, either as a leader or not, the solution I found was temporarily set the conditional branch with a script command: $gamePlayer.isMoving()

exemple.png

At first I got what I wanted, but I noticed that in reality this command is only for the group leader.

So if the character "X" is in the second or third position, when I put the leader to move in an event where the character "X" doesn't move (for example, with the plugin "SimpleFollowerControl", or in any other situation ), the branch noise keeps playing even though the character "X" is not walking.

Finally, my question is: Is there any script command where I can put a conditional branch so that the branch noise only occurs when the player ID "X" is moving, or something like that?

Obs.: I already use a plugin to make noise when walking through Regions ID, so what I'm trying to do is put movement noise depending on the characteristics of each character, and the plugins I checked do not offer this functionality.

So again, thanks in advance for any light on this matter.
 

Kurot

Veteran
Veteran
Joined
Jun 5, 2016
Messages
31
Reaction score
14
First Language
Portuguese
Primarily Uses
RMMV
Apparently I got what I wanted after researching some subjects here on the forum, in particular a post by Nolonar, regarding a member's question HERE.

For those wondering, the script command that worked was: $gamePlayer.followers().follower(0).isMoving()
$gamePlayer.followers().follower(1).isMoving()

However, despite working as intended, I still have some questions.

For example, by what Nolonar said in that post and "logic" (I think), if I have 3 characters, the command follower(0) would be for the leader, follower(1) for the second position, and follower(2) for the third position.

However, when calling the script command for the third position, the command with follower(2) does not work, having to also remain as follower(1) to work, as can be seen:


work.png

dontwork.png

So, my question is, why does the follower(2) command don't work for the third position of the character but the follower(1) command does? Wouldn't the follower (1) command be just for the second position in the group and the follower (0) for the leader?

If anyone can clarify these doubts I would be grateful.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
For example, by what Nolonar said in that post and "logic" (I think), if I have 3 characters, the command follower(0) would be for the leader, follower(1) for the second position, and follower(2) for the third position.
That's not quite right, because you're mixing some terms there. The leader is the first person who is actually being controlled by the player's input. That is, by definition, not a follower - the followers start behind them.

So in a typical 4-character party, you will have the leader then followers 0, 1, and 2.

If you only have 3 characters total, you only have 2 followers. You'd get the front character, the leader, with $gameParty.leader(), then you can use the code you got above for followers 0 and 1.

That's why you're getting an error when trying to look at follower 2 (and why the other conditionals could glitch, depending on your party formation).
 

Kurot

Veteran
Veteran
Joined
Jun 5, 2016
Messages
31
Reaction score
14
First Language
Portuguese
Primarily Uses
RMMV
Thank you very much for the feedback ATT_Turan, I already changed the command as per your explanation, everything is working perfectly now.
 

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
129
Reaction score
21
First Language
English
Primarily Uses
RMMV
Can you make this state's notetag to check for the actor's position in the party and also if a switch is on? Thanks a lot.

<Custom Passive Condition>
if ($gameParty.members()[0] === user) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
Can you make this state's notetag to check for the actor's position in the party
What do you mean here? It's already looking to see if the user is member 0 (the party leader). What do you want it to do differently?

and also if a switch is on?
To ask two things in a conditional, you use boolean AND: &&
And from the script call list, the function to check a switch is $gameSwitches.value(X)

So your notetag would be:
Code:
<Custom Passive Condition>
condition = $gameParty.members()[0]==user && $gameSwitches.value(X);
</Custom Passive Condition>
where X is the ID of the switch (no leading zeros).
 

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
129
Reaction score
21
First Language
English
Primarily Uses
RMMV
What do you mean here? It's already looking to see if the user is member 0 (the party leader). What do you want it to do differently?


To ask two things in a conditional, you use boolean AND: &&
And from the script call list, the function to check a switch is $gameSwitches.value(X)

So your notetag would be:
Code:
<Custom Passive Condition>
condition = $gameParty.members()[0]==user && $gameSwitches.value(X);
</Custom Passive Condition>
where X is the ID of the switch (no leading zeros).
Thanks a lot for the answer! Unfortunately, it seems that the conditions in Yanfly's Auto Passive States no longer work with switches. I tried your way (with and without the party members condition) and with the notetag the plugin itself provides (<Passive Condition: Switch x ON>), but nothing. The state is not in the party members as if the conditions are not met (and they are). I don't see what I'm doing wrong, that's why I think that maybe the plugin doesn't work that way anymore.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
I tried your way (with and without the party members condition) and with the notetag the plugin itself provides (<Passive Condition: Switch x ON>), but nothing.
There's a bug in the plugin where the Passive Condition: Switch notetag doesn't work correctly. If you click into my thread in my signature, I provide a fix.

However, what I just typed above with the Custom Passive Condition should work. So if that's also not working, you need to make sure your conditions in your game actually are what you think they are.

If you need more help getting it to work, you should make a new thread in Plugin Support. Make sure to provide screenshots of your setup.
 

Konan

Villager
Member
Joined
Oct 17, 2015
Messages
8
Reaction score
1
First Language
German
Primarily Uses
RMMZ
Hi,
i try Statpolygon to add on Visustella Statusmenu.
It´s working but i missed the Text "atk", def" etc.

Code:
//Polygon
sx = quarterWidth;
sy = rect.y + lineHeight * 5;
this.drawItemDarkRect(sx, sy, quarterWidth, lineHeight * 9);
this.contents.SPolyDrawStatPolygon(this._actor);
this.drawText(TextManager.param(stats));

when i try this.drawText(TextManager.param(stats)); it´s have an error:
ReferenceError
stats is not defined

what it´s my mistake o_O?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
i try Statpolygon to add on Visustella Statusmenu.
Per the first post in this thread, it's not for support with specific plugins. Those questions should go in that plugin's thread or you make a new thread in Plugin Support.

However, I'll give you one thing that I see off the top of my head: the Stat Polygon is for RPG Maker MV, and VisuStella and your profile indicate you're using MZ. You should not presume that an MV plugin will be compatible with MZ.

when i try this.drawText(TextManager.param(stats)); it´s have an error:
ReferenceError
stats is not defined

what it´s my mistake o_O?
Exactly what it said, that there's no variable called "stats". When you post your question again, include the entire function you're trying to make.
 

Konan

Villager
Member
Joined
Oct 17, 2015
Messages
8
Reaction score
1
First Language
German
Primarily Uses
RMMZ
I´m sorry.
I have found a another way, but thanks :)
 

AquaEcho

Script Kitty
Veteran
Joined
Sep 20, 2021
Messages
572
Reaction score
264
First Language
English
Primarily Uses
RMMV
Is there a script/plugin that will have an event follow the exact path the player took?
1. While the player is moving, an array logs the player's position every few frames and holds the past 10 or so positions.
2. Check if the following event is currently at the player's position, and if not move towards the nearest position the player was at. Then move to the next direction/position on the array.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,875
Reaction score
6,677
First Language
English
Primarily Uses
RMMV
Is there a script/plugin that will have an event follow the exact path the player took?
Yanfly's Move Route plugin has a Move To Coordinates command, along with Move Toward Location and Move Toward Player.

You can do what you're asking with that.
 

TheAM-Dol

Randomly Generated User Name
Veteran
Joined
Feb 26, 2022
Messages
643
Reaction score
981
First Language
English
Primarily Uses
RMMV
How would I modify this script:
Code:
var m = $gameMap.mapId();
for (var s = 1; s < $dataMap.events.length; s++){
$gameSelfSwitches.setValue([m, s, 'A'], false);
$gameSelfSwitches.setValue([m, s, 'B'], false);
$gameSelfSwitches.setValue([m, s, 'C'], false);
$gameSelfSwitches.setValue([m, s, 'D'], false);}

So that it only affects a specific range of event ID's instead of all events on the map?
(in my case, events 30 - 58)
 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
195
Reaction score
160
First Language
English
Primarily Uses
RMMZ
How would I modify this script:
Code:
var m = $gameMap.mapId();
for (var s = 1; s < $dataMap.events.length; s++){
$gameSelfSwitches.setValue([m, s, 'A'], false);
$gameSelfSwitches.setValue([m, s, 'B'], false);
$gameSelfSwitches.setValue([m, s, 'C'], false);
$gameSelfSwitches.setValue([m, s, 'D'], false);}

So that it only affects a specific range of event ID's instead of all events on the map?
(in my case, events 30 - 58)
You need to add an IF statement to check against those event IDs.


JavaScript:
var m = $gameMap.mapId();
for (var s = 1; s < $dataMap.events.length; s++) {
if ($dataMap.events[s].id >= 30 && $dataMap.events[s].id <= 58)
    {do this;}
}

Also, since S is going to be the same as what the ID is, you don't even need to compare IDs, this will also work:
JavaScript:
var m = $gameMap.mapId();
for (var s = 1; s < $dataMap.events.length; s++) {
if (s >= 30 && s <= 58)
    {do this;}
}

It's just (in my opinion) better to check against the actual eventId since it'll lead to less errors, and if one appears down the line you'll know why. Also, if you do compare against eventId, when you come back to look at this script later you'll know exactly what it's doing, because $gameMap.events.id is much easier to understand than just 's'.
 
Last edited:

TheAM-Dol

Randomly Generated User Name
Veteran
Joined
Feb 26, 2022
Messages
643
Reaction score
981
First Language
English
Primarily Uses
RMMV
I'm getting a script call error with this implemented. I'm sort of script-dumb so I am not sure if I am just overlooking something obvious - for example, I adjusted the formatting so it's easier for me to read, maybe I caused a problem when I did this? Can I get a sanity check?
Code:
var m = $gameMap.mapId();
for (var s = 1; < $dataMap.events.length; s++)
{
 if (s >= 30 && s <= 58)
 {
 $gameSelfSwitches.setValue([m, s, 'A'], false);
 $gameSelfSwitches.setValue([m, s, 'B'], false);
 $gameSelfSwitches.setValue([m, s, 'C'], false);
 $gameSelfSwitches.setValue([m, s, 'D'], false);
 }
}

edit:
Screen shot
error.png
 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
195
Reaction score
160
First Language
English
Primarily Uses
RMMZ
I'm getting a script call error with this implemented. I'm sort of script-dumb so I am not sure if I am just overlooking something obvious - for example, I adjusted the formatting so it's easier for me to read, maybe I caused a problem when I did this? Can I get a sanity check?
Code:
var m = $gameMap.mapId();
for (var s = 1; < $dataMap.events.length; s++)
{
 if (s >= 30 && s <= 58)
 {
 $gameSelfSwitches.setValue([m, s, 'A'], false);
 $gameSelfSwitches.setValue([m, s, 'B'], false);
 $gameSelfSwitches.setValue([m, s, 'C'], false);
 $gameSelfSwitches.setValue([m, s, 'D'], false);
 }
}

edit:
Screen shot
View attachment 252918
Ahh that was caused because I forgot to put the 's' in the for(loop). I edited my original post.
 

Latest Threads

Latest Profile Posts

imgur sure is getting weird, one day I lose gradually all my images, the other I get them back randomly and then again they disappear again.
Despite OPT2 praise it still has some strange stories in it. Lady Mikka is trying to work herself to death because of guilt. Guilt over what? ¯\_(ツ)_/¯ So instead of finding a NPC to have a heart to heart with her they decide the cure is a new kimono. So when she drops dead she'll at least be well dressed. I haven't even got to the strange part yet.
Did so much work on the game today. I wish I could post it all in this status update but there is a character limit of course haha. I thought about making a topic for updates, though... maybe.
The most recent sign that I am old. I have done martial arts for over 4 decades. Never HAD to stretch out. Good, of course, but never required. Was doing some kicks in the kitchen because, why not, and I felt a pop in the back of my thigh. Now I am limping around. Gotta love getting old.
One of the biggest perks of being fluent in English is how many new and interesting recipes I am able to find and try out that I would have hardly come across if I just spoke my mothertounge :3

Forum statistics

Threads
131,683
Messages
1,222,229
Members
173,435
Latest member
TheAmplifier
Top