JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 50 of 171 View original ↗
  1. Hi guys, I need a script snipet to multiply a variable by a number.

    Say for example variable x 5.
  2. var t1 =0
    var t3 = t1*t1
    or var t1 = t1*5
  3. 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>
  4. 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).
  5. DrDhoom said:
    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.
  6. 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.
  7. 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.
  8. BoelSanec said:
    "target.getStateCounter(11)"
    Remove those double quotations marks. Anything that are between quotation marks will be treated as string.
  9. DrDhoom said:
    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
  10. There is no loseHp function in the core script, try to change it to this:
    Code:
    target.gainHp(-dmg * 1000)
  11. DrDhoom said:
    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?
  12. 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);
  13. DrDhoom said:
    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
  14. Wait, did you remove this part?
    Code:
    if (target.isStateAffected(11)) {
       var dmg = "target.getStateCounter(11)";
    }
  15. DrDhoom said:
    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!
  16. 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.
  17. @BloodletterQ delete it from rpg_windows from Window_Options.
  18. 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.
  19. 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.
  20. Modified it a bit by removing the "if" and parenthesis. Thanks!