JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 146 of 171 View original ↗
  1. Lonfo said:
    My base idea is to find what function handles this aspect
    Game_BattlerBase.param is what handles stat calc overall.
    Game_Actor.paramPlus is what handles stats from gear and stat grow effects.
    Game_Actor.paramBase is what handles the base stats (raw stats from class)

    even though it looks like a regular property that holds a number, when you call a battler's param directly (mhp, def, etc), its actually calls their param() function and it calculates what the param should be right then and there based on paramBase and ParamPlus. because param() uses paramPlus() in its own calculation, you shouldnt reference param() within paramPlus() directly.

    you can edit paramPlus so that if the paramId is 3, look at if the current equipment is an armor, and if so add a bonus based on its atypeId.
    - if its heavy, just use the armor's def
    - if its medium, add in Math.min(Math.floor((this.paramBase(3)-10/)2), 2)
    - if its light, add in Math.floor((this.paramBase(3)-10/)2)

    Edit: I suppose you would also want to also make paramPlus no longer factor in this._paramPlus and move that into paramBase so that parameter grow effects count in dex bonuses
  2. Robro33 said:
    Game_BattlerBase.param is what handles stat calc overall.
    Game_Actor.paramPlus is what handles stats from gear and stat grow effects.
    Game_Actor.paramBase is what handles the base stats (raw stats from class)

    even though it looks like a regular property that holds a number, when you call a battler's param directly (mhp, def, etc), its actually calls their param() function and it calculates what the param should be right then and there based on paramBase and ParamPlus. because param() uses paramPlus() in its own calculation, you shouldnt reference param() within paramPlus() directly.

    you can edit paramPlus so that if the paramId is 3, look at if the current equipment is an armor, and if so add a bonus based on its atypeId.
    - if its heavy, just use the armor's def
    - if its medium, add in Math.min(Math.floor((this.paramBase(3)-10/)2), 2)
    - if its light, add in Math.floor((this.paramBase(3)-10/)2)

    Edit: I suppose you would also want to also make paramPlus no longer factor in this._paramPlus and move that into paramBase so that parameter grow effects count in dex bonuses
    Thanks for the answers.
    As soon as I have some free time I'll look into it
  3. Hey everyone!

    What's the correct way to leave the game back to the title screen?

    At the moment I'm using SceneManager.goto(Scene_Title) and it works, but for some reason the title BGM does not play at all, and sometimes some of the current map sounds (like BGS etc) still play in the title screen.

    Thanks for reading c:
  4. @raffle You might want to start a support thread, including what plugins you're using. That command is what the default engine uses when you go into the menu and quit back to the title - so it ought to work.
  5. VisuStella BattleCore Help

    I'm using VisuStella's fix on RMMZ's TPB (Wait) combat system and I'm having an issue where my actors are not moving in order on how fast their AGI is. From my tests, if actors are within 4 AGI of another actor, turn order will be decided on which actor appears first in the party order. So in some instances, an actor with 100 AGI will get their first turn before an actor with 103 AGI. I'm assuming the issue lies in Mechanics Settings/JS: Calculate, but I could be completely wrong.
    JavaScript:
    // Declare Constants
    const agi = this.subject().agi;
    
    // Create Speed
    let speed = agi;
    if (this.allowRandomSpeed()) {
        speed += Math.randomInt(Math.floor(5 + agi / 4));
    }
    if (this.item()) {
        speed += this.item().speed;
    }
    if (this.isAttack()) {
        speed += this.subject().attackSpeed();
    }
    
    // Return Speed
    return speed;
  6. @Tennshii Per the first post in this thread, questions about plugins should get their own thread in Plugin Support.

    Have you disabled whatever parameter will make the this.allowRandomSpeed() true?
  7. ATT_Turan said:
    @Tennshii Per the first post in this thread, questions about plugins should get their own thread in Plugin Support.

    Have you disabled whatever parameter will make the this.allowRandomSpeed() true?
    Ok I'll make a thread for this.
    Code:
    this.allowRandomSpeed()
    is also disabled by default. I can try to remove it since it's disabled anyways, but I'm worried that I'll break something if I do.

    Disabled Option
    1717086893466.png
  8. @Tennshii Well, I dunno what else to say - that's the only line in the code you posted which would change the end value.

    There's nothing in there which references formation order, so if the randomSpeed is returning negative, the return value will be the battler's agi plus the speed of the skill.

    Anything outside of that would be how the rest of the plugin's code handles that value, which we can't see.
  9. Guys, is there a list where I can check javascript code for stuff like enabling the Escape command, checking if an actor used Guard, checking if an actor inflicted magic damage etc.?

    By the way, I'm mostly interested in code that can be used during battle, like user.gainHP(), target.isDead() etc.
  10. TheNewSon said:
    enabling the Escape command
    the flag for that is BattleManager._canEscape

    TheNewSon said:
    checking if an actor used Guard, checking if an actor inflicted magic damage etc.?
    the important detail here is *when*. cant really tell you how to go about that without knowing when youre checking this. You dont have a listed engine, but between yanfly's buffs & states for MV and Turans Eval Tags for MZ you can set up states to do things when those criteria are met at different timings
  11. @TheNewSon Erm...the code? :stickytongue:

    A lot of that isn't in the script call list, as far as I know. You could also go through
    if that's easier for you to read than the code. You could also choose an individual item and Google it and usually find a thread where it's been already asked.

    Your profile doesn't say which engine you're using, and neither does your post, so that Web site doesn't detail the differences between MV and MZ.

    TheNewSon said:
    enabling the Escape command
    Code:
    BattleManager._canEscape = true
    or false

    TheNewSon said:
    checking if an actor used Guard
    "used" at what past point? You can see whether an actor is currently guarding for their turn with
    Code:
    your reference for the actor.isGuard()

    TheNewSon said:
    checking if an actor inflicted magic damage
    Again, at what point? During a skill's resolution, that Game_Action object will have an isMagical() method.
  12. @Robro33 @ATT_Turan thanks for the quick answer! And sorry, I forgot to say I'm using MV.

    EDIT: I created this post since my doubts have become more complex.
  13. @TheNewSon This thread is really designed for simple questions about JavaScript syntax or finding the right function, etc.

    For specific questions that interact with plugins - especially 5 questions - you really should make your own thread.
  14. Is there a way to go through the events on another map than the one the player is currently on?

    I am trying to apply this script to another map, e.g. go through every event on that map and if it has the notetag <enemy> set its self switch A to false.

    $gameMap.events().forEach(event => {if (event.event().meta.enemy && !event._erased){
    $gameSelfSwitches.setValue([$gameMap._mapId,event._eventId,'A'], false);
    }});
  15. AquaEcho said:
    Is there a way to go through the events on another map than the one the player is currently on?

    I am trying to apply this script to another map, e.g. go through every event on that map and if it has the notetag <enemy> set its self switch A to false.

    $gameMap.events().forEach(event => {if (event.event().meta.enemy && !event._erased){
    $gameSelfSwitches.setValue([$gameMap._mapId,event._eventId,'A'], false);
    }});
    Not easily, since other maps are not loaded, and so you can't directly access the information about their events.

    You'd probably need to load the JSON files for those maps yourself and look through those.
    Check out DataManager.loadMapData to see how the engine does it - you'd need to do something similar, just without using it to overwrite the currently loaded map.
  16. Just thinking out loud but... isn't it easier to have this be processed through an autorun event upon entering the target map?
    AquaEcho said:
    Is there a way to go through the events on another map than the one the player is currently on?
    I saw a Japanese blogger with the same issue a while ago, but can’t seem to find it. The conclusion (IIRC) was that it’s possible to load the map into another variable and reference the data there. Don’t recall him concluding the blog post with an “I did it!”, though… Will post it when I find it.
  17. werzaque said:
    isn't it easier to have this be processed through an autorun event upon entering the target map?
    Yes, but I'm trying to think of the best way to do this: When a day passes/the player sleeps, respawn the enemies on every map (or toggle their self switch A, which controls dead/alive states)
  18. You could put them in an array after they are defeated to be respawned and then during the sleep event or time system slice them out using a modified version of Trihan's tutorial for Respawn resource nodes

    I use it to respawn fish in my game.
  19. werzaque said:
    Don’t recall him concluding the blog post with an “I did it!”, though…
    There have been threads here where code was produced to load a second map's data. I don't recall the purpose, which would make searching difficult.

    AquaEcho said:
    Yes, but I'm trying to think of the best way to do this
    I think werzaque's suggestion is the best way to do this. When whatever happens that indicates a day has passed, set a switch/increment a variable that indicates the last date you were places, whatever. When you go to a map, if that switch is on, respawn enemies. Should be a few lines of an Autorun event, copy and paste.

    You could also do something like Slaughty suggests, but I'm not sure that level of complexity is merited.
  20. Has anyone else run into a problem where yanfly itemcore lags menus and item pickups when item stacks exceed ~999? I don’t understand why this matters, it’s just a variable with a high number. And this particular item is a consumable with zero function, so it’s not like there’s a ton of data in its notes or anything.

    I’m hoping there’s a clean fix for this, although I have some workarounds (that depend on my game design, not universal).