JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 151 of 171 View original ↗
  1. firestalker said:
    So, is there a way to NOT have the damage popup whenever there's a zero balance? Not a block, miss, or evade... but a hit that does zero damage. Is there a way to make that not pop up?
    ah. thats what was missing. I had installed LGP_BetterDamagePopup somewhat recently and noticed at some point that all 0 damage popups stopped. Instead of being sensible and assuming it was that, i chose to gaslight myself into thinking that they probably never showed before up and a yanfly plugin did it :guffaw:

    firestalker said:
    I'm sorry.... "Prototype"?
    save it as a js file and use it as a plugin, but make the changes they suggest to the
    Code:
    } else if (result.hpAffected) {
    line
  2. zfgzd.png

    Anyone know what this thing is called? Like in the scripts. I want to find a way to make it stop flashing/blinking/flickering but im running out of words to search for xD
  3. Willibab said:
    Anyone know what this thing is called?
    The English word for a UI element that highlights what you're selecting is the cursor.

    If you don't want it to fade in and out, you can paste the below into a text editor, save as a *.js file, and include as a plugin:
    Code:
    Window.prototype._makeCursorAlpha = function() {return this.contentsOpacity/255;};
  4. ATT_Turan said:
    The English word for a UI element that highlights what you're selecting is the cursor.

    Wow, im glad im not the type to become embarrassed now :p Guess i've been using a custom cursor for so long that the default one doesnt feel like one xD

    ATT_Turan said:
    If you don't want it to fade in and out, you can paste the below into a text editor, save as a *.js file, and include as a plugin:
    Code:
    Window.prototype._makeCursorAlpha = function() {return this.contentsOpacity/255;};

    Tnx!
  5. Could I get a script to check if an actor is affected with a state with a certain notetag, e.g. <aura>?
  6. @AquaEcho - if actor is a Game_Actor reference, then you could try:
    JavaScript:
    actor.states().some(state => "aura" in state.meta)
    If you're starting with an actor ID, you can use $gameActors.actor(id) instead, e.g.
    JavaScript:
    $gameActors.actor(1).some(state => "aura" in state.meta)
  7. caethyril said:
    @AquaEcho - if actor is a Game_Actor reference, then you could try:
    JavaScript:
    actor.states().some(state => "aura" in state.meta)
    If you're starting with an actor ID, you can use $gameActors.actor(id) instead, e.g.
    JavaScript:
    $gameActors.actor(1).some(state => "aura" in state.meta)
    Thank you, it works. Follow up: How do I get the state ID of the first result?
  8. AquaEcho said:
    How do I get the state ID of the first result?
    I think you could use this in Control Variables -> Script:
    JavaScript:
    var id = 0; for (var state of actor.states()) if (state.meta.aura) { id = state.id; break; }; id
    (As before, replace actor if necessary.)
  9. Hi. I have a little old enemy with a skill where they block the damage taken by the next attack (this skill applies a state to the enemy that makes them very tanky, pretty much). I would like to store this damage value into a variable, so I can use this value in the damage formula for this little enemy's second skill.

    Any tips on how to implement this?
  10. if you have yanfly's buffs and states, you can try putting
    Code:
    <custom react effect>
    if (this.isDamage() && value > 0)
      $gameVariables.setValue(x, $gameVariables.value(x) + value);
    </custom react effect>
    in the state's notebox. just replace the "x"s for some variable ID and refer to it in that skill's damage formula
  11. EDIT: sorry for the poor wording, edited and hope it’s clear now…

    I need a fresh set of eyes here. I want a parallel event to trigger when neither the player nor its followers are at its location. I can't get it to work so am trying to output it to the console to see what is going on and... the parameters seem right, yet the check fails…

    JavaScript:
    (!$gamePlayer.x == $gameMap.event(this._eventId).x) &&
    (!$gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));
    
    console.log("Player X: " + $gamePlayer.x + ", Event X: " + $gameMap.event(this._eventId).x + ", Player away: " + (!$gamePlayer.x == $gameMap.event(this._eventId).x) + ", Followers away: " + (!$gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x)));

    I move the player away and the output says: Player X: 47, Event X: 39, Player away: false, Followers away: true
    So nothing happens when the Player x and Event x do seem to be different... any idea?
  12. @werzaque OMG dude, really? Code tags, line breaks, something!

    You have some random placements of the NOT operator which is not doing what you are probably trying to do.

    !$gamePlayer.x is true if the x is a zero (or undefined) value. When you say
    Code:
    (!$gamePlayer.x == $gameMap.event(this._eventId).x)
    you're comparing a boolean result (the NOT operator will produce true or false) to a numeric value (the value of the event's x coordinate).

    I'm not sure what you're actually going for...are you trying to check
    Code:
    $gamePlayer.x != $gameMap.event(this._eventId).x
    ?
  13. EDIT: managed to get it to work, see below in green.

    Sorry for the block of code... so I tried your suggestion and now have:

    JavaScript:
    ($gamePlayer.x != $gameMap.event(this._eventId).x) &&
    !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));
    
    console.log(
    "Player X: " + $gamePlayer.x +
    ", Event X: " + $gameMap.event(this._eventId).x +
    ", Player away: " + ($gamePlayer.x != $gameMap.event(this._eventId).x) +
    ", Followers away: " + !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x))
    );

    Moving away from the event the console says:
    Player X: 45, Event X: 39, Player away: true, Followers away: true
    Yet still nothing happens...

    For context (please ignore the second IF, in the process of isolating the problem):

    1725757290485.png

    EDIT: I got it to work by reversing the order of the main code and the console.log part, i.e.:

    JavaScript:
    console.log(
    "Player X: " + $gamePlayer.x +
    ", Event X: " + $gameMap.event(this._eventId).x +
    ", Player away: " + ($gamePlayer.x != $gameMap.event(this._eventId).x) +
    ", Followers away: " + !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x))
    );
    
    ($gamePlayer.x != $gameMap.event(this._eventId).x) &&
    !($gamePlayer.followers().data().some((follower) => follower.x == $gameMap.event(this._eventId).x));

    So apparently only the last line of code is regarded for the script in the IF command. Which kind of makes sense now that I think about it...
  14. Robro33 said:
    if you have yanfly's buffs and states, you can try putting
    Code:
    <custom react effect>
    if (this.isDamage() && value > 0)
      $gameVariables.setValue(x, $gameVariables.value(x) + value);
    </custom react effect>
    in the state's notebox. just replace the "x"s for some variable ID and refer to it in that skill's damage formula
    Wonderful. Thank you so much!


    ---


    I have an unrelated question, and I know I should not double post, so here it is: Is there a way to use an enemy's TP value as a check when using Yanfly's Battle AI Core? The plugin documentation does not mention TP [edit: More precisely, it allows targeting based on TP values, but that is not what I am looking for], so I would assume not, but maybe there is a way? For example, say I have a skill that can only be used if the enemy has over 50 TP, and more than 1 MP. Checking the MP value is simple enough:

    JavaScript:
    <AI Priority>
    
    User MP param >= 1: SKILL 67
    
    </AI Priority>

    But this does not work, sadly:

    JavaScript:
    <AI Priority>
    
    User MP param >= 1 +++ User TP param >= 50: SKILL 67
    
    </AI Priority>
    Any tips would be appreciated! Edit: I suppose I could try storing the enemy's TP value into a variable, and using that as a check instead. But, it feels like over-engineering, and it gets complicated if I have more than one enemy, in a battle, at a time.
  15. DrBuni said:
    : Is there a way to use an enemy's TP value as a check when using Yanfly's Battle AI Core
    you could use
    Code:
    Eval user.tp > 50
    as one of your ai priority conditions for the skill.

    DrBuni said:
    But, it feels like over-engineering, and it gets complicated if I have more than one enemy, in a battle, at a time.
    if you want to talk about overengineered solutions, skill requirements are considered when the ai is selecting a skill. so if you had a duplicate version of the skill with a tp requirement of 50, it would have to be respected. its more work than using the eval, but its an idea that may be a useful idea for you later
  16. Robro33 said:
    you could use
    Code:
    Eval user.tp > 50
    as one of your ai priority conditions for the skill.


    if you want to talk about overengineered solutions, skill requirements are considered when the ai is selecting a skill. so if you had a duplicate version of the skill with a tp requirement of 50, it would have to be respected. its more work than using the eval, but its an idea that may be a useful idea for you later
    Thank you again!

    I have a question related to my first problem above (the one regarding the variable). I have been unable to store the damage value in the variable, in spite of implementing your suggestion. Here is what I have done so far.

    I gave the variable an initial value (of zero--and I tried giving it an absurd value of 50, for testing purposes, and the enemy could one shot the player character just fine, as opposed to dealing zero damage).

    I added your suggest code to the 'counter' STATE notebox (I think I may have misunderstood the instructions, and this is where the error is at):

    JavaScript:
    <custom react effect>
    if (this.isDamage() && value > 0)
      $gameVariables.setValue(501, $gameVariables.value(501) + value);
    </custom react effect>

    And, I tried this very basically formula (for the secondary skill) to see if it works at all: v[501]. Yup, just variable value as the damage value. However, if I add the variable value to my usual formula, it does not work at all. My usual formula is: (a.atk + skill_damage) - b.def) + 1. In this case, it would be ((a.atk + v[501]) - b.def) + 1. Still, the main problem is I failed to store the damage value in the variable.
  17. DrBuni said:
    Still, the main problem is I failed to store the damage value in the variable.
    an easy way to see if the state is working without opening up the console is to set a troop event to use show text to display the variable at the end of every turn. it should only increase on turns where the enemy is hit while the state is active

    DrBuni said:
    v[501]
    a thing to note is that if you use the variable that way, it needs to have its value set somewhere first. if not, v[501] will be undefined and would cause the entire formula as you have it to not result in any damage being dealt. if damage was dealt to the enemy while the state is active, then it should be fine, otherwise it wouldnt do anything no matter what the a.atk and b.def are
  18. Robro33 said:
    an easy way to see if the state is working without opening up the console is to set a troop event to use show text to display the variable at the end of every turn. it should only increase on turns where the enemy is hit while the state is active


    a thing to note is that if you use the variable that way, it needs to have its value set somewhere first. if not, v[501] will be undefined and would cause the entire formula as you have it to not result in any damage being dealt. if damage was dealt to the enemy while the state is active, then it should be fine, otherwise it wouldnt do anything no matter what the a.atk and b.def are
    I actually did that. I have a message that shows the value of the variable, at the end of every turn, and it always says 0. As for your second suggestion, I did that as well. I set the variable to 0, before the battle processing event is run.

    So, I am assuming I did not mess up the code I shared above?

    image hosted at ImgBB image hosted at ImgBB
  19. DrBuni said:
    So, I am assuming I did not mess up the code I shared above?
    nope. what you have should work just fine. theres no mistakes there or anything.

    just as a sanity check, yanfly's buffs and states plugin is installed, youve saved your project after setting the notetag, and youve made a new save file for the playtest while trying this out instead of loading one?
  20. Robro33 said:
    nope. what you have should work just fine. theres no mistakes there or anything.

    just as a sanity check, yanfly's buffs and states plugin is installed, youve saved your project after setting the notetag, and youve made a new save file for the playtest while trying this out instead of loading one?
    Yep! I always playtest from a fresh, brand new save file. Honestly, I am at loss. I can only imagine some plugin is interfering somehow.

    Here is a little recording I just made. In turn zero, the enemy uses the skill that applies the 'counter' STATE (the one with the code). You can see the STATE is applied because of the pink icon in the STATE icon column, to the left of the enemy. Then, the actor attacks, and deals 8 damage. If my understanding is correct, the STATE should store the 8 as the value of variable 501, right? But, in the next turn, the enemy uses its attack (the formula for the enemy attack is v[501]), and it does no damage. Then, the message shows the value of the variable, which is still 0.

    [embedded media]