JavaScript questions that don't deserve their own thread

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,060
First Language
English
Primarily Uses
RMMV
Yup, the math looks good to me. But of course, you'll want to make sure to test it thoroughly by setting up a variety of actors & enemies and doing a lot of battle tests. This will also help you decide what amount "feels right" to reward the player for having good stats while still keeping it balanced.
 

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
Hi, I've been having trouble getting a certain spell effect to work. It's basically a fire spell that leaves a Burning state on the target, dealing damage over time. However, I'm trying to get the Burning state to increase the target's fire damage taken by 10% per number of turns left on the state. It's this last part of the effect I can't seem to get working...
<Custom Apply Effect>
user.elementRate(4) += .1 * user.stateTurns(121);
</Custom Apply Effect>

<DoT Formula: a.mat * (100 + b.level) / (100 + b.level + b.mdf)>
<DoT Element: 4>
The DoT portion of the state's effect can more or less be ignored, as I'm really just trying to figure out the stateTurns/elementRate part. I have tried both:
"user.elementRate(4) += .1 * user.stateTurns(121);" as well as
"target.elementRate(4) += .1 * target.stateTurns(121);"

Is my syntax incorrect? Perhaps I shouldn't be using <Custom Apply Effect>? (I have tried other notetags as well tho)
Btw, I am using Yanfly's BuffsStatesCore and ExtDot plugins.
 

Fornoreason1000

Black Sheep
Veteran
Joined
Mar 1, 2014
Messages
200
Reaction score
92
First Language
English
Primarily Uses
RMMV
@staf00

Sure is!
in JavaScript when you put ( ) in front of something you are calling a function, and that function has something called a return value.
functions are not like variables so you cannot use operators such as "+=" to any benefit. you can't modify a return value of a function like that.
also you need to put a '0' in front of any decimals things like '.1' do not work so well.

Code:
user.elementRate(4) += .1 * user.stateTurns(121);
target.elementRate(4) += .1 * target.stateTurns(121);
at best will be this

Code:
var elementRate = user.elementRate(4) + (0.1 * user.stateTurns(121))
you said 10% per turn? you could just stack states on top of each other in the background as a result have having the first one.
easier than all this stuff.
 

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
Thx, I'm gonna give that a try, but I think I'd still need some kind of function that adjusts elementRate...

The idea of making a stacking state in the background has crossed my mind, but I also need the stacks to adjust based on the number of turns left on the Burning state (121). Sometimes an attack will add/reset the turns left or remove/reduce it.

Edit: Does this look about right?
<Custom React Effect>
if (value > 0 && this.isHpEffect() && this.getItemElements().contains(4)) {
var elementRate = user.elementRate(4) + (0.1 * user.stateTurns(121));
value *= elementRate;
}
</Custom React Effect>
 
Last edited:

Fornoreason1000

Black Sheep
Veteran
Joined
Mar 1, 2014
Messages
200
Reaction score
92
First Language
English
Primarily Uses
RMMV
Thx, I'm gonna give that a try, but I think I'd still need some kind of function that adjusts elementRate...

The idea of making a stacking state in the background has crossed my mind, but I also need the stacks to adjust based on the number of turns left on the Burning state (121). Sometimes an attack will add/reset the turns left or remove/reduce it.

Edit: Does this look about right?
Fair enough, that makes sense.
your code has one problems on why it will not work.

the existent element rate is being squared e.g ( 64 x 64 = 4096 times normal damage!). Elemental damage calculation already happens behind the scenes. they use something similar to user.Elemental(4) and multiply it with value. then your negate will multiply it again with the resistant rate, this means the target will take much more damage than it should.
heres basically what happens.

Note: this is Pseudo Code, that means its not actual JS or source code, its there to show coding logic

Code:
value = eval(damageFormula)
//defense already taken into account
// 1200

value *= elelemtRate; //element rate is 3x damage
//3600

//10 turns left
var elementrate = 3 + (0.1 x turns)
// element rate is 4

value *= elementrate
// 4 x 3600!!
//total damage is 14400!!!
the actual damage should only be around 4800, since you only increased the fire damage by 100%, not 1200%!
if you want to add on to the existing rate, you need to turn it into a fraction and divide out the existing damage.

e.g
i want to add 100% fire damage to a existing 130% damage (that's 30% extra) for a total of 230% damage or 2.3x normal dmamage

damage = 100;
damage *= 1.3; //30% extra damage!
//damage is now 130
//we want to get it to 230
damage *= (100 + 130) / 130
//damage is now 230


Code:
if (value > 0 && this.isHpEffect() && this.getItemElements().contains(4)) {
var elementRate = (user.elementRate(4) + (0.1 * user.stateTurns(121)) / user.elementRate();
value *= elementRate;
}
 

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
Ahh, I hadn't considered that! Thank you for pointing that out. I incorporated your insights as well as changed the final value to a Math.round since I was getting decimal results lol. I also had to change "user." to "target." because the former was causing damage to always result as 0 and the enemy would turn invisible. o_O
<Custom React Effect>
if (value > 0 && this.isHpEffect() && this.getItemElements().contains(4)) {
var elementRate = (target.elementRate(4) + target.stateTurns(121) * 0.05) / target.elementRate(4);
value = Math.round(value * elementRate);
}
</Custom React Effect>
Upon testing, everything works as intended now!
(also lowered it to 5% per turn cuz fine tuning)
 

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
48
Reaction score
20
First Language
French
Primarily Uses
RMMV
Hey makers,

What script do I have to use to call a Scene_Status of specific actor with an event ?

I tried Scene_Push(Scene_Status) but it displayed the 1st actor of the party.

What suffix should I use ?
 

Fornoreason1000

Black Sheep
Veteran
Joined
Mar 1, 2014
Messages
200
Reaction score
92
First Language
English
Primarily Uses
RMMV
Hey makers,
What script do I have to use to call a Scene_Status of specific actor with an event ?
I tried Scene_Push(Scene_Status) but it displayed the 1st actor of the party.
What suffix should I use ?
i think you mean this for changing scenes
Code:
SceneManager.push(Scene_Status);
now to make it select an actor you need to set a property in $gameParty via this function
note that unlike most fucntions, this one takes an Game_Actor as a parameter instead of just an ID.

Code:
/**
* @method setMenuActor
* @param {Game_Actor} actor the actor being set
*/
Game_Party.prototype.setMenuActor = function(actor) {
    this._menuActorId = actor.actorId();
};
so your code will be something like this.
replace 10 with the actor ID you want.

Code:
$gameParty.setMenuActor($gameActors.actor(10));
SceneManager.push(Scene_Status)
 

Boonty

Veteran
Veteran
Joined
Oct 10, 2018
Messages
48
Reaction score
20
First Language
French
Primarily Uses
RMMV
@Fornoreason1000 Thanks for your quick and detailed answer. It worked perfectly !

I also saw that you can't display a status menu for a specific actor if he is not in the party with this method.
 

ryoma1492

Villager
Member
Joined
Nov 11, 2017
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hey "General RPG Maker MV Community" I'm new to posting problems, i got MV for Christmas, and am SO glad that the comunity isn't dead already

I have a question about setting in-game switches via plugin script

I have successfully created several variables that are accessible via Script-based Conditionals, but i want to make my plugin more user-firendly, and change a switch (which is a parameterized variable) instead.

I can't, however, get it off of the ground. I tried to use $gameSwitches.setValue(<switch number>, true); but it didn't work

Please Help!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
@ryoma1492 <switch number> is not how you format variables in javascript. A variable's name can only contain letters, numbers or underscore. Also, you need to define the variable before you can use it.
Code:
var switchID = 30;
$gameSwitches.setValue (switchID, true);
changes switch 30 to true
 

Dicleon

Villager
Member
Joined
Apr 3, 2016
Messages
6
Reaction score
0
First Language
French
Primarily Uses
Hello everyone, I'm in a bit of a pickle, In my project I have been using Yanfly Doodads (up to date) without issue until I made my custom iconset(huge) and it's overloading the plugin causing bugs.

The short version is that i would like to remove the option to use the iconset entirely so it's not loading 16k icons and bugging.

The bug itself : Sometime if I just placed a rock from the rock folder, I go back to the main list and then it say that the plugin can't load it, but the plugin is looking in the doodads folder itself or any folder I am at the moment and it won't find it here.

So if someone knows how to remove that option (iconset) or just not loading them that'be great! Thank you for reading.

Ps: I made sure the Iconset is the problem with a blank project, but it took me so many hour to do I don't want to pass on it...
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
Code:
ImageManager.loadDoodad = function(filename, hue, smooth) {
  return this.loadDoodadBitmap(Yanfly.Param.GFDFolder, filename, hue, smooth);
};
Code:
Window_GFD_List.prototype.makeCommandList = function() {
  this.addCommand('../Previous Folder', 'cancel', true);
  this.addFolderList();
  this.addFileList();
};
Code:
Window_GFD_List.prototype.drawItem = function(index) {
  var rect = this.itemRectForText(index);
  var align = this.itemTextAlign();
  var symbol = this.commandSymbol(index);
  var ext = this._list[index].ext;
  var icon = 0;
  var indent = false;
  var text = this.commandName(index);
  this.resetTextColor();
  this.changePaintOpacity(this.isCommandEnabled(index));
  switch (symbol) {
  case 'folder':
    icon = 164;
    break;
  case 'file':
    indent = true;
    this.drawDoodadImage(index, ext);
    text = text.replace(/\[(\d+)x(\d+)\]/g, '');
    break;
  }
  this.drawText(text, rect.x, rect.y, rect.width, align);
};
Code:
Window_GFD_Icons.prototype.makeCommandList = function() {
  var rows = Math.floor(bitmap.height / Window_Base._iconHeight);
  var length = rows * this.maxCols();
  for (var i = 0; i < length; ++i) {
    this.addCommand('', 'iconIndex', i > 0, i);
  }
};
Not sure if that fixes your problem, but I made a couple of changes to the code as above. I'd recommend you to reduce the iconset size though, I doubt you'll need 16k icons.
 

Dicleon

Villager
Member
Joined
Apr 3, 2016
Messages
6
Reaction score
0
First Language
French
Primarily Uses
Thanks, just what I needed, for the icons, sure I won't use all of them but having the option to have every pieces of equipment look different is really alluring to me! Thanks again!
 

Izimori Anahuyu

Villager
Member
Joined
Feb 3, 2013
Messages
24
Reaction score
2
First Language
Canadian
Primarily Uses
RMMV
My testers get this error…

Tester: "So I found out the NPC Dialogue crash occurs when the player is running, but only if they're running. Other than that, the game doesn't crash for the dialogue."

Any ideas how to fix this that doesn't involve disabling dashing?
Sorry if I posted this in the wrong thread.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
Apparently you have a bad plugin there.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,627
Reaction score
1,060
First Language
English
Primarily Uses
RMMV
@Izimori Anahuyu You should reproduce the error in a playtest and get a screenshot of the full error message from the console (press F8 during playtest to open it)

You probably want to create a new thread in Plugin support after you get the full error message.
 
Last edited:

Izimori Anahuyu

Villager
Member
Joined
Feb 3, 2013
Messages
24
Reaction score
2
First Language
Canadian
Primarily Uses
RMMV
@Izimori Anahuyu You should reproduce the error in a playtest and get a screenshot of the full error message from the console (press F8 during playtest to open it)

You probably want to create a new thread in Plugin support after you get the full error message.
Thar's the problem, it doesn't exist on my end. I can't reproduce the error.
 

Ronove

♫꒰・‿・๑꒱
Veteran
Joined
Mar 12, 2012
Messages
1,028
Reaction score
345
First Language
English
Primarily Uses
RMVXA
Hopefully easy question:
I was editing the item menu and while I sized everything how I wanted to be, one thing has been stubborn. The width of the item categories text. Even though I've made the window smaller, the item categories continue to act like they have more room than they have:As you can probably see, item is definitely supposed to be not there and centered over the line (thus making room for Key Item which should be centered on the space beside Item). I made it smaller with this:

Code:
        this._categoryWindow.y = 110;
        this._categoryWindow.x = 180;
        this._categoryWindow.width = 460;
But the text seems to have ignored it! Can someone just point me to what I should have used or what I should look for?

NVM Figured it out!
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 7)

Latest Threads

Latest Posts

Latest Profile Posts

Have you appreciated a Hedgehog today?

Storybook Hero demo has been well received so far. Yay! We are developing it steadily albeit slowly <_<. We will get there one day o_O.
TFW: You get a text from someone and a long conversation--but you have no idea who this person is and don't wanna be that guy that asks "Who is this by the way?" I have no clue who this person is... but they seem to know me quite well. :rswt
You know, after all these years of using RM I've never played To The Moon. With being busy with life and then after my mom died I was too emotionally fragile to play something that heavy. Has anyone played the Switch version? Is there any big differences between that and the RM version?
Today I finished my Lets Play. Gonna have the videos scheduled for daily uploads now. Woo I finished something ^^

Forum statistics

Threads
93,406
Messages
912,067
Members
122,914
Latest member
Arcannis
Top