JavaScript questions that don't deserve their own thread

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,093
Reaction score
1,579
First Language
English
Primarily Uses
RMMZ
I would just give the armors a passive state.

You can make the state do what you asked by giving it:
Code:
<JS Post-Damage as User>
if (!target.isDead() && Math.random()<.5)
    target.addState(64);
</JS Post-Damage as User>
Unless I'm misunderstanding the help documentation, I think you can actually just put that note tag directly on the armor itself, without the need for a state.
 

SSAyato

Warper
Member
Joined
Feb 24, 2023
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
RMMV: Attempting to make a state deal a set amount damage to an enemy at the start of their turn, not using a negative hp regen trait... using Yanfly's Buffs&StatesCore


I've been teaching myself the javascript as I go but I cant seem to figure this one out. Any help appreciated
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
RMMV: Attempting to make a state deal a set amount damage to an enemy at the start of their turn, not using a negative hp regen trait... using Yanfly's Buffs&StatesCore
Welcome!

Looking at the plugin instructions, we can find:
"Turn Start: Whenever the battler's turn starts."

Then you might reference the pinned thread with MV script calls (or just Google "rpg maker mv script deal damage" or something like that). You end up with:
Code:
<Custom Turn Start Effect>
user.gainHp(-X);
</Custom Turn Start Effect>
where X is the amount of HP to lose.

If it doesn't display the damage on its own, you might need to add a line with user.startDamagePopup()
 

SSAyato

Warper
Member
Joined
Feb 24, 2023
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
Welcome!

Looking at the plugin instructions, we can find:
"Turn Start: Whenever the battler's turn starts."

Then you might reference the pinned thread with MV script calls (or just Google "rpg maker mv script deal damage" or something like that). You end up with:
Code:
<Custom Turn Start Effect>
user.gainHp(-X);
</Custom Turn Start Effect>
where X is the amount of HP to lose.

If it doesn't display the damage on its own, you might need to add a line with user.startDamagePopup()
Thank you so much!
 

Narch

Regular
Regular
Joined
Jan 13, 2017
Messages
88
Reaction score
11
First Language
French
Primarily Uses
Not sure if it's the right thread, but I was wondering how hard would it be to make it so the RMMZ software allows to drag and drop the Common Events in the Databse menu so you are able to reorganize them visually without changing their unique ID.

And the same with the Switch/Variables/all similar lists in the Database.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
Not sure if it's the right thread, but I was wondering how hard would it be to make it so the RMMZ software allows to drag and drop the Common Events in the Databse menu so you are able to reorganize them visually without changing their unique ID.

And the same with the Switch/Variables/all similar lists in the Database.
You can't modify the editor. Plugins can only affect gameplay.
 

Narch

Regular
Regular
Joined
Jan 13, 2017
Messages
88
Reaction score
11
First Language
French
Primarily Uses
You can't modify the editor. Plugins can only affect gameplay.
I mean, I was not speaking of plugins. But I realise now this whole section of forum is in Javascript/Plugin Support.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
I mean, I was not speaking of plugins. But I realise now this whole section of forum is in Javascript/Plugin Support.
Well, you posted in a specific thread entitled "JavaScript questions," and JavaScript is used in MV and MZ to write plugins. :wink:

But the first part of my initial response still applies - you can't modify the editor. All of the database tabs list in order of ID and that can't be changed.
 

Gargoyle77

Regular
Regular
Joined
Dec 4, 2017
Messages
131
Reaction score
21
First Language
English
Primarily Uses
RMMV
How can I make a state that removes a state category as soon as it is applied to the user of the state? I'm trying to make a state that removes all negative states as soon as one is applied, and for that I created a state that would serve as a dummy for all negative states, so I just need to check if that dummy state is about to affect the battler. Apart from that I know that you need to put something between this tags: <Custom React Effect></Custom React Effect>, but I don't know much apart from that. Can you please help me? Thanks a lot for reading!

This are the plugins I know I need to make this thing to work.

 

Narch

Regular
Regular
Joined
Jan 13, 2017
Messages
88
Reaction score
11
First Language
French
Primarily Uses
Well, you posted in a specific thread entitled "JavaScript questions," and JavaScript is used in MV and MZ to write plugins. :wink:

But the first part of my initial response still applies - you can't modify the editor. All of the database tabs list in order of ID and that can't be changed.
I think it's technically not impossible to modify the editor but it was not what I was thinking about. More about something that would interpret the database prior to its display and/or inject new data before it's displayed in the vanilla menu.

It's beyond my level of execution but I was seeking for possible ways of attaining it. Also JSON might be too different from Javascript to be talked on this section I would guess?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
4,259
Reaction score
5,152
First Language
EN, FR
Primarily Uses
RMMZ
I think it's technically not impossible to modify the editor but it was not what I was thinking about.
Feasible and allowed under the license is two different things. You can't modify the editor itself.

More about something that would interpret the database prior to its display and/or inject new data before it's displayed in the vanilla menu.
That is definitely possible. When the game is launched, all the database info gets transferred into global objects, so it would be possible to modify those.

Also JSON might be too different from Javascript to be talked on this section I would guess?
I don't see why it can't be discussed in here. Coding sections are mainly divided into everything coding related for RMMZ and RMMV (javascript) and the RMVXA, VX, and XP section (ruby/rgss). So anything coding relating to RMMZ and RMMV is fine.
 

gimmer_

Regular
Regular
Joined
Jan 13, 2021
Messages
83
Reaction score
58
First Language
English
Primarily Uses
RMMV
I think it's technically not impossible to modify the editor but it was not what I was thinking about. More about something that would interpret the database prior to its display and/or inject new data before it's displayed in the vanilla menu.

It's beyond my level of execution but I was seeking for possible ways of attaining it. Also JSON might be too different from Javascript to be talked on this section I would guess?

Your best bet would probably to build a tool that parses all the game files, and lets you dragon and drop the order of various things, and then detects (upon hitting save) all the users of all the old variables / switches / common events and updates them everywhere.

It wouldn't be a trivial tool to build though.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
How can I make a state that removes a state category as soon as it is applied to the user of the state? I'm trying to make a state that removes all negative states as soon as one is applied, and for that I created a state that would serve as a dummy for all negative states, so I just need to check if that dummy state is about to affect the battler.
This seems like a roundabout way to do it. Is there some reason you can't just give the skill that would apply this dummy state the notetag from the plugin you linked to: <Remove State Category: x> ?
 

Gargoyle77

Regular
Regular
Joined
Dec 4, 2017
Messages
131
Reaction score
21
First Language
English
Primarily Uses
RMMV
This seems like a roundabout way to do it. Is there some reason you can't just give the skill that would apply this dummy state the notetag from the plugin you linked to: <Remove State Category: x> ?
Sorry if I didn't explain myself properly. What I want is a state that'd serve as a shield that will block and remove the next negative state that targets the user. In my project, the state doesn't need to remove negative states already affecting the user because the state won't be applied if the user already has negative states (I already know how to do this last part, I just wanted to give more context).
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
Sorry if I didn't explain myself properly. What I want is a state that'd serve as a shield that will block and remove the next negative state that targets the user.
Okay - the trick here is that you're looping around the standard process for this in RPG Maker (give your state the State Resist trait for all states you want to block). You can do it this way, but you'd be allowing the negative state to apply then removing it immediately after, so it won't stop any, say, Custom Apply Effects that negative state might have.

The other problem is the timing - Custom Respond happens before the incoming attack applies effects, e.g. states.

So I'd suggest you add a State Resist for each state in your category, then give it:
Code:
<Custom Deselect Effect>
if (this.item().effects.some(effect => effect.code==EFFECT_ADD_STATE && $dataStates[effect.dataId].category.contains("debuff")));
    target.removeState(X);
</Custom Deselect Effect>
where "debuff" is the name of the state category you're blocking and X is the ID of your protective state.

That should cause it to resist applying the state and then be removed. If that doesn't work, you should post your own thread in plugin support.
 

Narch

Regular
Regular
Joined
Jan 13, 2017
Messages
88
Reaction score
11
First Language
French
Primarily Uses
I have :
gameVariables.value(1)
gameVariables.value(2)
gameVariables.value(3)

I want to use a conditional branch to check if 1 = 1 + (2 x 3)

What should I put in the event command?
 

AquaEcho

Script Kitty
Regular
Joined
Sep 20, 2021
Messages
1,703
Reaction score
1,169
First Language
English
Primarily Uses
RMMV
I have :
gameVariables.value(1)
gameVariables.value(2)
gameVariables.value(3)

I want to use a conditional branch to check if 1 = 1 + (2 x 3)

What should I put in the event command?
I assume you mean the variables 1, 2 and 3 and not the integers.
Script : $gameVariables.value(1) = $gameVariables.value(1) + $gameVariables.value(2) * $gameVariables.value(3)
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,158
Reaction score
9,109
First Language
English
Primarily Uses
RMMV
I have :
gameVariables.value(1)
gameVariables.value(2)
gameVariables.value(3)
That's not correct syntax - you need to prepend $ to the beginning of $gameVariables.

I want to use a conditional branch to check if 1 = 1 + (2 x 3)

What should I put in the event command?
Code:
!$gameVariables.value(2) || !$gameVariables.value(3)

The only that mathematical equation can happen is if variable 2 or 3 is 0.

Script : $gameVariables.value(1) = $gameVariables.value(1) + $gameVariables.value(2) * $gameVariables.value(3)
That's not quite right - one = is to assign a value. Narch asked how to check if it is equal to that. So you'd use == (and also the whole thing can be shortened, as above :wink:)

Also, you can't assign using the value() method like that, you would have to use setValue().
 

AquaEcho

Script Kitty
Regular
Joined
Sep 20, 2021
Messages
1,703
Reaction score
1,169
First Language
English
Primarily Uses
RMMV
That's not quite right - one = is to assign a value. Narch asked how to check if it is equal to that. So you'd use == (and also the whole thing can be shortened, as above :wink:)
Yeah, I just noticed that after I posted it. I didn't proofread.
 

alltheyuriz

The one the only Cat Dad
Regular
Joined
Sep 18, 2020
Messages
920
Reaction score
617
First Language
English
Primarily Uses
RMMZ
I'm trying to edit a window from a plugin (Terms of service says i can) so I was wondering what line i'm looking for to change the font of the plugin window. Is there a certain line im looking for or is it different with each plugin
 

Latest Threads

Latest Profile Posts

Woke up in the middle of the night with some game mechanic ideas. Unfortunately, they're for a new game, not the one I'm currently working on. Must... not... get... distracted!
I'm wondering about making a new pack of monsters or just divide them and add to my current packs. I'll end up having like 10+ packs If I just have 27 per pack xD
cesariohelp wrote on Ms Littlefish's profile.
Hi ! I see that you're a mod, right ? Can I ask you a question here ? If not, where ? So sorry
I just whipped up the blueprints for the final level in my game. (I say final, when really there is a final boss stage after this, but it's only like two maps long)
The good thing about making a scarecrow is, I can just use a T-pose on it and call it an animation. :kaojoy:
SA145K_idle.gif

Wait... it is starting to move on its own?:kaoswt2:

Forum statistics

Threads
134,936
Messages
1,252,020
Members
177,777
Latest member
bobg
Top