JavaScript questions that don't deserve their own thread

Hi guys, I need a script snipet to multiply a variable by a number.

Say for example variable x 5.
var t1 =0
var t3 = t1*t1
or var t1 = t1*5
Hey Everybody,

Unfortunately my Java Script knowledge is very poor so I was hoping somebody could help me out.
I am trying to add another element to the function below, basically I would like it to check if Physical and Melee damage is dealt for the recoil
effect to appear but I don;t know how to edit the function.
Any help would be appreciated,

thank you.


<Custom React Effect>

// Check to see if any physical damage is dealt.

if (value > 0 && this.isPhysical()) {

// Sets the Recoil Rate to 10%.

var rate = 0.10;

// Determines the amount of recoil damage dealt.

var recoil = value * rate;

// Sets the DEF bonus rate to 15%.

var rate = 0.15;

// Determines the amount of bonus damage dealt.

var bonus = target.def * rate;

// Rounds up the bonus damage and recoil damage.

var dmg = Math.ceil(bonus + recoil);

// Makes the attacker lose damage equal to the dmg variable.

user.gainHp(-1 * dmg);

// Check to see if the attacker is dead.

if (user.isDead()) {

// If the attacker is dead, make it collapse.

user.performCollapse();

}

}

</Custom React Effect>
What you want to edit is this part, which is the condition:
if (value > 0 && this.isPhysical())
I'm not sure what you meant by Melee damage, but I guess it's the damage element? If so, just change it to this:
if (value > 0 && this.isPhysical() && this.item().damage.elementId === ELEMENTID) {
Change ELEMENTID to Element ID that you want, the ID start from -1 (which is Normal Attack).
What you want to edit is this part, which is the condition:

I'm not sure what you meant by Melee damage, but I guess it's the damage element? If so, just change it to this:

Change ELEMENTID to Element ID that you want, the ID start from -1 (which is Normal Attack).

Thank you!! I give it a try.
I have a question regarding Yanfly's row formation plugin. How do you restrict the number of playable characters per row? For instance I would like to restrict the number of characters to 4 per row.
Hey, I'm trying to make an attack that deals increased damage based on the number of turns that a certain state on the target has.
Using Yanfly's Buffs and States Core, btw.

<Custom Apply Effect>

if (target.isStateAffected(11)) {

var dmg = "target.getStateCounter(11)";

}

target.loseHp(dmg * (rest of attack formula goes here));

</Custom Apply Effect>

I tried using this, but it does nothing. I know nothing of Javascript so I can't figure this out on my own, can someone lend me a hand?

Edit: Note, I'm using this code on a second state that is applied with the attack.
"target.getStateCounter(11)"
Remove those double quotations marks. Anything that are between quotation marks will be treated as string.
Remove those double quotations marks. Anything that are between quotation marks will be treated as string.
I tried this, but the state still doesn't work as intented; I'm getting the same error on the console.
upload_2018-4-14_11-14-24.png
There is no loseHp function in the core script, try to change it to this:
Code:
target.gainHp(-dmg * 1000)
There is no loseHp function in the core script, try to change it to this:
Code:
target.gainHp(-dmg * 1000)
Well, that kinda works, the console doesn't give an error anymore, but now the attack does 0 damage. I don't suppose .gainHp can actually DEAL damage, can it?
Is there any other function I can use?
gainHp can be used to execute damage. I think it's because dmg is 0. You can check the dmg value by logging to the console by adding this to the Custom Apply Effect:
Code:
console.log(dmg);
gainHp can be used to execute damage. I think it's because dmg is 0. You can check the dmg value by logging to the console by adding this to the Custom Apply Effect:
Code:
console.log(dmg);
The console just shows this...
upload_2018-4-14_12-6-20.png
Wait, did you remove this part?
Code:
if (target.isStateAffected(11)) {
   var dmg = "target.getStateCounter(11)";
}
Wait, did you remove this part?
Code:
if (target.isStateAffected(11)) {
   var dmg = "target.getStateCounter(11)";
}
This is my full code:
Code:
<Custom Apply Effect>

console.log(dmg);

if (target.isStateAffected(11)) {

var dmg = target.getStateCounter(11);

}

target.gainHp(-dmg * 1000);

</Custom Apply Effect>

Edit: NEVERMIND! The issue wasn't on this code, but instead on the state that calculates this damage. It's fixed now, but thanks anyway!
How can I hide an option in the options menu on the title screen but have it show in-game? Using Yanfly’s Options Core.
@BloodletterQ delete it from rpg_windows from Window_Options.
Actually I was able to put the shutdown command in the options core, but it’s still there while accessing options from the title screen.
Ah, it's a concrete option! OK, in that case let's do a little magic trick. There's an important if.

if (SceneManager._stack[0] != Scene_Title) this.addCommand (that shutdown command, not sure how it's handled)

wherever this shutdown command is.
Modified it a bit by removing the "if" and parenthesis. Thanks!

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