JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 84 of 171 View original ↗
  1. Would someone be able to help me create a script call that checks if an actor (ActorID equal to variable 20) has any of 5 different skills, and if they do, turn a switch on, and add 1 to a different variable for each of those 5 skills they have? (For example, if the actor has 3 of the skills being checked, then the variable gets +3 added to it, and the switch gets turned on)

    I found a seemingly similar bit of code from @ramza a few months back, that I believe can be adjusted to do what I'm hoping to accomplish:

    Code:
        var listofskills = [1,2,3,4,5,6,7,8,9]
        var knownskills = []
        for (var i = 0; i < listofskills.length; i++){
            if (user.isLearnedSkill(listofskills[i])) knownskills.push(true)
        }
        if (knownskills.length >= 5){
            value = true
        } else {
            value = false
        }
  2. Hi everybody. I'm trying to change the code of the Battle Status Window script so that the sprites are displayed over the window. It's an issue because I'm trying to replace the character's face with the animated sideview character, and the sprite is only visible through the window's transparency.

    Can somebody tell me what I need to move around?
  3. Working with Yanfly's Critical Control plugin: http://www.yanfly.moe/wiki/Critical_Control_(YEP)

    Having an issue where subtracting a percentage from Critical Multipliers just doesn't seem to work:
    1609084561926.png

    Switching the `-` to a `+` works perfectly, but I'm looking to lower critical hit damage when a certain state is applied. Anyone have any experience with this, or have a clue why subtracting wouldn't work?
  4. Use this instead no?

    <Critical Rate Formula>
    rate -= 0.15;
    </Critical Rate Formula>
  5. The <Critical Rate/Multiplier Formula> tags are for use in Skills/Items.

    I'm looking to make the change in a state. It works for addition, but not subtraction, and I'm unsure why.
  6. Bumping a question of mine from about a week ago:

    Vis_Mage said:
    Would someone be able to help me create a script call that checks if an actor (ActorID equal to variable 20) has any of 5 different skills, and if they do, turn a switch on, and add 1 to a different variable for each of those 5 skills they have? (For example, if the actor has 3 of the skills being checked, then the variable gets +3 added to it, and the switch gets turned on)

    I found a seemingly similar bit of code from @ramza a few months back, that I believe can be adjusted to do what I'm hoping to accomplish:

    Code:
        var listofskills = [1,2,3,4,5,6,7,8,9]
        var knownskills = []
        for (var i = 0; i < listofskills.length; i++){
            if (user.isLearnedSkill(listofskills[i])) knownskills.push(true)
        }
        if (knownskills.length >= 5){
            value = true
        } else {
            value = false
        }
  7. Hi everybody, this one should be less technical than usual.

    One of the enemies I've set up has an AI (from Battle AI Core) that includes a skill. That skill has a passive state that I don't want on enemies, so of course I'll use the following code in the state's notes so that enemies can't have it:
    JavaScript:
    <Custom Passive Condition>
    if(user.isActor()) {
      condition = true;
    } else {
      condition = false;
    }
    </Custom Passive Condition>
    But for some reason, this condition doesn't work.
    I tried putting just condition = false to see what's wrong, and the passive state still appears on everybody that knows the skill, as if the conditions for this specific state were entirely ignored.

    Can somebody help me with troubleshooting this?
  8. Simpler question this time, how would I divide a variable by 2 (using eval, since I'm using this in a notetag for Yanfly's Buff and State Core)?
  9. Vis_Mage said:
    Simpler question this time, how would I divide a variable by 2 (using eval, since I'm using this in a notetag for Yanfly's Buff and State Core)?
    I don't really know the answer. I never used eval().
    But perhaps the documentation might help you: eval() - JavaScript | MDN (mozilla.org)
  10. Hi there, sorry for interrupting, but i just resolve a problem and i wanted to share it with you guys maybe it will make you gain some time in the future :
    When you use the tcr parameter in order to upgrade or downgrade tp gain, the engine by default don't Math.round the final value. I was really surprised to learn that because in battle by default you juste have on screen some infinite number after decimal for tp.

    You just need to go in rpg_objects.js line 3196 and just add some Math.round

    Game_Battler.prototype.gainTp = function(value) {
    this._result.tpDamage = Math.round(-value * this.tcr);
    this.setTp(this.tp + Math.round(value * this.tcr));
    };
  11. Hi :( I installed Yanfly Core Engine and (underneath) Yanfly Core Message in the Plugins as described on the website. I have a new project and on the guide it says I can add \n<x> anywhere in the message window to get a namebox. I tried this by putting \n<James>, but all that happens is that the in-game dialogue displays <James>. I tried \n<2> instead and it also just gives me <2>. I have no other plugins and this is a fresh install on a PC I received last week. I have no other projects and am a bit confused why it is not working when everything was downloaded from Yanfly's site 30min ago. Thank you!

    I attached an example. When I run the game, it appears exactly like that. No namebox. I also tried putting the \n<James> at the beginning of the message and the result is the same.

    [EDIT] Regional Restrictions also is not working. I followed the guide for that as well. The three Yanfly plugins are in the right order and turned on in Plugins. I edited the Regional Restrictions so that events cannot past through Region 3, but they go through it anyway. I'm trying to contain my fish to the lake.
  12. Hello, I'm using all of yanfly's plugins on MV and I'm trying to make an item with a passive state that converts the current game party gold into defense, but only while equipped. The problem is that I don't think <Custom Apply Effect> works because it's passive rather than something cast on the target, and...

    <Custom Battle Effect>
    user.addDef($gameParty.gold());
    </Custom Battle Effect>

    <Custom Remove Effect>
    user.clearParamPlus()
    </Custom Remove Effect>

    Only updates every battle, and does not reflect the defense buff in the menu after gaining more gold. Is there any <Custom Effect> tag that fits the bill? I'd like to have the stats be reflected, and when the item is unequipped, have the bonuses disappear.
  13. MiddleMang said:
    Hello, I'm using all of yanfly's plugins on MV and I'm trying to make an item with a passive state that converts the current game party gold into defense, but only while equipped. The problem is that I don't think <Custom Apply Effect> works because it's passive rather than something cast on the target, and...

    <Custom Battle Effect>
    user.addDef($gameParty.gold());
    </Custom Battle Effect>

    <Custom Remove Effect>
    user.clearParamPlus()
    </Custom Remove Effect>

    Only updates every battle, and does not reflect the defense buff in the menu after gaining more gold. Is there any <Custom Effect> tag that fits the bill? I'd like to have the stats be reflected, and when the item is unequipped, have the bonuses disappear.
    Set the custom battle effect to change that state's counter to the amount of Gold the party has (user.setStateCounter(X, $gameParty.gold())).
    Then, use user.addDef(user.getStateCounter(X)) to add the Defense stat. Make sure the Defense cap (Base Parameter Control plugin settings) is high enough to not be hit.
    In all effects that happen at the end of battles (Victory, Defeat, Escape), use user.minusDef(user.getStateCounter(X)) to end the effect.

    Notes: might not work if that item can be removed from the wearer mid-battle. Won't adapt to gold gains in the middle of a battle. Won't appear in the menus, it would've worked very easily if we could use the <stat Plus: +x> tag.
  14. CHKNRAVE said:
    Set the custom battle effect to change that state's counter to the amount of Gold the party has (user.setStateCounter(X, $gameParty.gold())).
    Then, use user.addDef(user.getStateCounter(X)) to add the Defense stat. Make sure the Defense cap (Base Parameter Control plugin settings) is high enough to not be hit.
    In all effects that happen at the end of battles (Victory, Defeat, Escape), use user.minusDef(user.getStateCounter(X)) to end the effect.

    Notes: might not work if that item can be removed from the wearer mid-battle. Won't adapt to gold gains in the middle of a battle. Won't appear in the menus, it would've worked very easily if we could use the <stat Plus: +x> tag.
    Thanks a bunch, really appreciate it. Are you saying that the <stat Plus: +x> can work or it doesn't work with $gameParty.gold()?
  15. MiddleMang said:
    Thanks a bunch, really appreciate it. Are you saying that the <stat Plus: +x> can work or it doesn't work with $gameParty.gold()?
    You might as well try, but as far as I know it's a tag in which the x has to be a number and not a formula.
  16. Hey guys, I really need some advanced javascript advice. So I have a string "Gen0Ba3" and I need to check if "Ba3" is in it. Usually, I'd do "Gen0Ba3".match(/Ba3/) but the problem is that the number after "Ba" is random and after "Ba(number)" there may be random letters. For example, it may be "Gen0Ba31Dn" and "Gen0Ba31Dn".match(/Ba3/) would still match despite the fact the number is different. How can I make it so that it would only match "Ba" and the number as a whole?
  17. What's the script call to refresh all events on the map?
  18. Kyuukon said:
    What's the script call to refresh all events on the map?
    $gameMap.requestRefresh();
  19. Hello everyone!
    I'm trying to create a passive ability that if the actor and the enemy are of the same elemental type, the actor is given a buff of MAT and ATK.
    The main problem here is, how do you designate a specific type for the characters to create the passive skill formula?
    :LZSskeptic: