JavaScript questions that don't deserve their own thread

Flame_Effigy

Villager
Member
Joined
Dec 21, 2020
Messages
15
Reaction score
5
First Language
English
Primarily Uses
RMMV
In Yanfly's "Enemy Levels" video (linked here) they use a skill they called "Study" which reveals all of the enemy stats as well as their weaknesses, resistances, immunities, etc.

I have been scouring their YouTube and website, but cannot find information on how they implemented the "Study" skill in MV. (I did find one for VX Ace, but presumably that doesn't transfer.)

Is someone able to link me to a resource explaining how that is done?

Here you go
 

Mushi

Villager
Member
Joined
Jul 13, 2021
Messages
22
Reaction score
106
First Language
English
Primarily Uses
RMMZ
Hii I'm sorry if this is a bad question but what's the difference between javascript classes and doing function.prototype stuff like rpg maker does it? I'm making a program (to help me make something in rpg maker, but it's not a plugin) and I'm starting to have a very long script with a bunch of those and I'm having an existential crisis thinking I should use classes and different script files. >_<
 

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,235
Reaction score
1,917
First Language
English
Primarily Uses
RMMZ
Hii I'm sorry if this is a bad question but what's the difference between javascript classes and doing function.prototype stuff like rpg maker does it? I'm making a program (to help me make something in rpg maker, but it's not a plugin) and I'm starting to have a very long script with a bunch of those and I'm having an existential crisis thinking I should use classes and different script files. >_<
The short answer is that RPG Maker's core scripts also use classes--they're just created using an older syntax. You're free to use the newer syntax if you want, but I personally prefer to try to keep my coding style consistent with that of the existing code that I'm extending/editing.
 

Mushi

Villager
Member
Joined
Jul 13, 2021
Messages
22
Reaction score
106
First Language
English
Primarily Uses
RMMZ
I see okay if there's no difference I will keep doing what I'm doing, thank youu!!
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
Is there a way to create a global variable whose name is based on an actor ID?

I'm using Yanfly's Buffs and States core. I want to create a global variable that is equal to an actor's Attack when a state is applied.

i.e.
<Custom Apply Effect>
var statAtk = a.atk
</Custom Apply Effect>

However, the issue is that in this form I believe that if you apply the state to another actor then 'statAtk' will be overwritten with the new target actor's Attack stat. So what I want is some way to have the statAtk variable created uniquely based on the targeted actor, but I don't know the syntax of how to do that in Javascript.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,643
Reaction score
11,146
First Language
English
Primarily Uses
RMMV
Is there a way to create a global variable whose name is based on an actor ID?

However, the issue is that in this form I believe that if you apply the state to another actor then 'statAtk' will be overwritten with the new target actor's Attack stat. So what I want is some way to have the statAtk variable created uniquely based on the targeted actor
I'm confused about what you're trying to achieve. Where do you use this variable? How is it referenced?

If you actually want a global variable, you should use a global variable:
Code:
$gameVariables.setValue(X, a.atk);
replacing X with the variable's ID, and then you can reference it anyplace else.

But you completely lost me when you talked about a different actor not overwriting it. You could simply use conditionals to see if the variable already has a stored value and only save a value if it's already 0.

Or maybe you don't actually want a global variable, you want something on the actor to reference again?

Please explain the entire situation in greater detail and you'll be able to get a better answer.
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
I'm confused about what you're trying to achieve. Where do you use this variable? How is it referenced?

If you actually want a global variable, you should use a global variable:
Code:
$gameVariables.setValue(X, a.atk);
replacing X with the variable's ID, and then you can reference it anyplace else.

But you completely lost me when you talked about a different actor not overwriting it. You could simply use conditionals to see if the variable already has a stored value and only save a value if it's already 0.

Or maybe you don't actually want a global variable, you want something on the actor to reference again?

Please explain the entire situation in greater detail and you'll be able to get a better answer.
Basically I want a state that buffs an ally's stat based on the Magic Attack of the Actor that applied the state. In my game all stats are between 1 and 100.

So I want to adjust stats in the state with, for example:

Code:
a.atk = a.atk * (1 + origin.mat/100)

It seems that doing that on its own permanently changes the stat. So I want to save the target Actor's original stat in a global variable that can then be referenced when the state is removed to reset the stat.

Something like:

Code:
<Custom Apply Effect>
var statAtk = a.atk

a.atk = a.atk * (1 + origin.mat/100)
</Custom Apply Effect>

<Custom Remove Effect>
a.atk = statAtk
</Custom Remove Effect>

But if I want to be able to apply this state to multiple actors at the same time I think I need to be able to save each actor's original stat in a unique variable to reference in the remove effect part.
 

eomereolsson

Regular
Regular
Joined
Sep 29, 2021
Messages
582
Reaction score
508
First Language
German
Primarily Uses
RMMV
You can just add a new property onto an existing object just like that.
JavaScript:
<Custom Apply Effect>
a._originalAtkValue = a.atk;

a.atk = a.atk * (1 + origin.mat/100);
</Custom Apply Effect>

<Custom Remove Effect>
a.atk = a._originalAtkValue;
</Custom Remove Effect>
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,643
Reaction score
11,146
First Language
English
Primarily Uses
RMMV
Basically I want a state that buffs an ally's stat based on the Magic Attack of the Actor that applied the state. In my game all stats are between 1 and 100.

So I want to adjust stats in the state with, for example:

Code:
a.atk = a.atk * (1 + origin.mat/100)
I would suggest that instead of this entire method, you do it more of the "right" way.

You should not be directly changing parameters to temporary other values. Instead, use a plugin that allows you to set a statis modifier, such as Quasi Params Plus.
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
I would suggest that instead of this entire method, you do it more of the "right" way.

You should not be directly changing parameters to temporary other values. Instead, use a plugin that allows you to set a statis modifier, such as Quasi Params Plus.
Thank you, that plugin is wonderful.

Out of curiosity, is my initial method considered "wrong" just cause of the potential for really problematic bugs?
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
I would suggest that instead of this entire method, you do it more of the "right" way.

You should not be directly changing parameters to temporary other values. Instead, use a plugin that allows you to set a statis modifier, such as Quasi Params Plus.
So unfortunately it seems that Qparams doesn't recognize the origin.X, which is not surprising. The work around I've thought of is saving the state applier's MAT as a variable (v[]) through a common event when they apply a state. However, I have two Actors right now which are both going to be using the same skill to apply the states. Would I have to create two identical skills/states for each Actor so that I wouldn't have them overwriting eachothers' v[] if they both are applying states?

Or am I missing an easier/more elegant solution?

Edit/Update:

So messing around with whether Yanfly's and Quasi's plugins can work together and I got this to seemingly do what I want:


Code:
<Custom Apply Effect>
a.modATK = origin.mat
</Custom Apply Effect>

<params>
ATK: a.modATK
</params>

I haven't actually put in the actual formulas, but that's just arithmetic which I know will work. However,
I am curious if this would be considered still a "wrong" way to do it or not?
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,643
Reaction score
11,146
First Language
English
Primarily Uses
RMMV
Code:
<Custom Apply Effect>
a.modATK = origin.mat
</Custom Apply Effect>

<params>
ATK: a.modATK
</params>

I haven't actually put in the actual formulas, but that's just arithmetic which I know will work. However,
I am curious if this would be considered still a "wrong" way to do it or not?
Not at all.

The whole idea is that RPG Maker uses its parameter system for a reason - your actual parameters on an actor are derived from their class and current level. That's it. Everything else (equipment, buffs, states, etc.) goes into several arrays of modifiers that add onto the base parameter.

The engine doesn't want to touch the base parameters except when the character levels up, changes class, etc. So any time you directly modify those values instead, you run the risk of messing with the character (and with your prior method you were actually overwriting all of that, so if the modifiers changed they while under the state, they wouldn't be reflected). This way works with the parameter modifiers as intended.
 
Last edited:

Super015

Regular
Regular
Joined
May 12, 2013
Messages
88
Reaction score
14
First Language
Italian
Primarily Uses
RMMV
Hi, my project's aspect ratio is 16:9.
In the main menu ther's too much space for the status of the actors, so I was wondering if it was possible to divide the actors into 2 columns.
In the first column there are the 4 main actors, while in the second all the others (in my project there are more than 10 actors), so in the second column they are in a different size so that they all fit!
I know that my request is difficult, I would be happy even if only having 2 columns of 4 actors each. :kaopride:
 

Super015

Regular
Regular
Joined
May 12, 2013
Messages
88
Reaction score
14
First Language
Italian
Primarily Uses
RMMV
Sorry, I move my request to a new thread.
 

Terrannus

Warper
Member
Joined
Sep 30, 2022
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
Heyo, does anyone know if it's possible to change the bitmap on a Game_Picture without referencing a new file? I'm editing some bitmaps on the fly and would like to be able to draw/move an image based on that new bitmap.

I've been able to add the bitmap to a Sprite_Picture but Sprite_Picture.picture is null and I don't know how to fill it with something that uses the same bitmap.

Many thanks!
 

Kes

Regular
Regular
Joined
Aug 3, 2012
Messages
23,887
Reaction score
13,896
First Language
English
Primarily Uses
RMMZ
I need to be able to transfer the player exactly where they were. I have set these switches:
1664821245303.png

On the transfer back, the map, x and y are all accurate. However the direction is not, as the sprite invariably faces right. The script call I am using is this:
Code:
$gamePlayer.setDirection($gameVariables.value(13))

Is my code incorrect?
Thank you.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,643
Reaction score
11,146
First Language
English
Primarily Uses
RMMV
Heyo, does anyone know if it's possible to change the bitmap on a Game_Picture without referencing a new file? I'm editing some bitmaps on the fly and would like to be able to draw/move an image based on that new bitmap.

I've been able to add the bitmap to a Sprite_Picture but Sprite_Picture.picture is null and I don't know how to fill it with something that uses the same bitmap.
I don't really understand your description of what you're trying to do. Are you trying to edit images within RPG Maker?

If you're saying you've edited the image while the game is open and you want to refresh that...I'm not super knowledgeable about how the caching system works, but you could try changing the bitmap using the same filename to reload it. But I suspect there are better ways to go about whatever it is (like using a screenshot for the game as a lower layer in your image editor).

Is my code incorrect?
No. But you might look at whether something else is temporarily fixing the player's direction, how the actual transfer command you're using works...for me, instead of splitting it into multiple commands, I'd just use the script call for transfer and plug in the stored direction there.
 

Kes

Regular
Regular
Joined
Aug 3, 2012
Messages
23,887
Reaction score
13,896
First Language
English
Primarily Uses
RMMZ
@ATT_Turan I think I'm already doing what you suggest. Here is the transfer command, nothing exotic there as far as I can see which would mess it up.

1664862795057.png
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,643
Reaction score
11,146
First Language
English
Primarily Uses
RMMV
I think I'm already doing what you suggest.
My suggestion was to use the script call, you're using the event command.

When you pull up that event command, you'll notice there's a setting for what to do with the player's facing direction. My thinking is that having an event command that transfers with some reference to direction and then having the setDirection function call immediately after might be conflicting in some timing.

Try replacing both lines with:
$gamePlayer.reserveTransfer($gameVariables.value(7), $gameVariables.value(5), $gameVariables.value(6), $gameVariables.value(13));

See if that makes any difference. If not, do some error-checking on the value stored in variable 13, make sure it's not being overwritten someplace.
 

Latest Threads

Latest Posts

Latest Profile Posts

I decided that for the video game i will work next year i will use characters from my TCG as main characters for the RPGMAKER game, so expand the universe, that will be a cool :CoOoOL: Here some of my characters :

Ah also yes I'm accepting commission in case tat you ask for haha.
Some people shouldn't be parents. Someone put their toddler in the hallway of the apartment building I live in at 11 p.m.... and let her wander. The heck is wrong with people?!
Twitch! Strean is currently live with some more gamedev! Feel free to drop by~
If you need some maps done, but don't like mapping or just want to focus on other areas of your gamedev, my workshop is alway open! Hit me up!
Someone leaked the GTA VI trailer, so Rockstar just put it out today. Let the hype period truly begin!!!

Forum statistics

Threads
136,755
Messages
1,269,591
Members
180,504
Latest member
Zginc
Top