JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 147 of 171 View original ↗
  1. I'm trying to apply a negative state onto an enemy through a note tag code, but target.addState(4) isn't working...? By the way, I'm using Yanfly's Buffs & States Core plugin, and this is the code:

    <Custom Confirm Effect>
    target.addState(4);
    </Custom Confirm Effect>

    I'll be adding conditions to check whether the state should be applied or not, but for now I just want to understand why this isn't working. I added a line to recover the user's HP and it worked, so the notetag is okay, the problem is on addState(), I guess.
  2. @TheNewSon That's the correct syntax.

    The only reasons that wouldn't work are if the target has state resistance to state 4, or you have some other plugin that modifies how adding states works.

    Does your skill actually hit and have a damage formula? Custom Confirm doesn't run if there's no hit.
  3. @ATT_Turan I'm actually trying to apply "death" (state 1) but because it didn't work, I tried applying "poison" (state 4)... Thing is, I tried it with an enemy that was immune to poison, lol. Shameful...

    So I tried poisoning another enemy and this time it worked, but the death state doesn't work against any enemy when I try it through "addState", only through the default effect settings (for skills).

    I can just use "target.die()" which I guess works the same way, but I'm still confused as to why it can't be done through addState...?

    Anyway, thanks for helping me so often, I'm good now! :)
  4. TheNewSon said:
    the death state doesn't work against any enemy when I try it through "addState"
    I bet it does, it just doesn't do everything that dying does because you're taking a shortcut through the expected process.

    If you try to target it, the enemy should be gone from the list and it won't take turns - but its sprite is probably still there because you circumvented the collapse process.

    You can do that manually by adding target.performCollapse()
  5. @ATT_Turan thanks as always for your great explanation, man! :D

    Now I'm back with yet another question... I'm using this notetag code to decrease the target's magic defense by 50% but it's not working.

    Just like before, I added an HP regen line to make sure the code is getting read, and it is: I'm getting healed in the process, but the target's mdef is still the same. Here's how it should be:

    <Custom Confirm Effect>
    target.mdf = target.mdf / 2;
    </Custom Confirm Effect>
  6. TheNewSon said:
    Now I'm back with yet another question... I'm using this notetag code to decrease the target's magic defense by 50% but it's not working.
    of all the default stats, only hp, mp and tp can be modified that way.
    if that state is just supposed to reduce mdef by 50%, why not give the state a trait to do it?
  7. @Robro33 oh, so what's why it wasn't working... Thanks for telling me, I'll be coming up with another solution, like messing with the final damage/value. (By the way, I can't use traits because of several conditions attached to that state.)
  8. Is there a JavaScript snippet I could use to count the number of characters in the active party that have a certain class?

    For example, if two people in the battle party are warriors, it would return 2 into a variable or something.
  9. Lonewulf123 said:
    Is there a JavaScript snippet I could use to count the number of characters in the active party that have a certain class?
    Code:
    $gameParty.battleMembers().filter(member => member.currentClass().id == x).length
    replace the x with the id of the class
  10. Robro33 said:
    Code:
    $gameParty.battleMembers().filter(member => member.currentClass().id == x).length
    replace the x with the id of the class
    Thank you.
  11. Not sure if this is actually simple, I couldn't quite solve it with the script call directory -

    how would I check if actor X is affected with state Y? The standard event commands only let me ask for specific actors (e.g. without use of variables), and with dozens of recruitable actors, this is really not an option.
  12. @Anthony Xue How do you want to reference X? The "Actors and Enemies" section of the pinned script call list gives several options.

    You can do it by ID and simply insert the script call for a variable's value inside the parentheses to supply the ID.
    1718463261496.png

    The row beneath that lets you reference it by position in the party:
    1718463289181.png

    Without you saying what you're actually trying to do, it's hard to give any more specific advice.
  13. ATT_Turan said:
    @Anthony Xue How do you want to reference X? The "Actors and Enemies" section of the pinned script call list gives several options.

    You can do it by ID and simply insert the script call for a variable's value inside the parentheses to supply the ID.
    View attachment 308518

    The row beneath that lets you reference it by position in the party:
    View attachment 308519

    Without you saying what you're actually trying to do, it's hard to give any more specific advice.

    Alright, trying to be more specific:

    1. The game has a flexible party roster which may include up to six of about 40 recruitable Actors (basically recruiting board hirelings).
    2. Regularly, the player will have to select which of the Actors in the currently active party shall execute a certain action (e.g. pick a lock, disarm a trap, examine a statue).
    3. When the selected Actor is afflicted with certain states (e.g. dead, unconscious, petrified etc.), the game shall recognize that and respond with "[Actor] is currently unable to perform this action".
    The "select an Actor in the currently active party" part is not an issue, but the "check whether that Actor is afflicted with state a, b or c" is. The standard "Conditional Branch" only allows for checking specific states of specific Actors, which would obviously be somewhat cumbersome with dozens of possible Actors and multiple relevant states.

    Hope that makes it more clear, and thanks for reading.
  14. Anthony Xue said:
    The "select an Actor in the currently active party" part is not an issue, but the "check whether that Actor is afflicted with state a, b or c" is.
    If you're picking someone in the party, logically you'd use the second script call I showed you, referencing an actor by their index in the party.
  15. ATT_Turan said:
    If you're picking someone in the party, logically you'd use the second script call I showed you, referencing an actor by their index in the party.
    I agree. If this question were about picking someone in the party, I'd logically do that. It's not, though, it's about checking whether the picked character is afflicted by states a, b and/or c.

    All the script calls help page has to say on the topic is this:

    battler.states()
    // Get all states affecting the party leader: $gameParty.leader().states()


    ...which isn't exactly helpful. I assume I'm looking for an equivalent to hasSkill:

    // Is skill ID 42 in the party leader's skill list?
    $gameParty.leader().hasSkill(42)


    which would allow me to determine whether Actor X afflicted by state 1, 3, or 19, etc. I'm not sure such a thing exists, though.
  16. Anthony Xue said:
    I'm not sure such a thing exists, though.
    once you have your reference to the actor in question, its
    Code:
    battler.isStateAffected(y)
  17. Anthony Xue said:
    If this question were about picking someone in the party, I'd logically do that. It's not, though, it's about checking whether the picked character is afflicted by states a, b and/or c.
    Well. You had said:
    Anthony Xue said:
    Regularly, the player will have to select which of the Actors in the currently active party shall execute a certain action
    So, by your description, it is about looking at someone in the party. That's the part I thought you needed help with, because the second part is so straightforward.

    Anthony Xue said:
    I'm looking for an equivalent to hasSkill...which would allow me to determine whether Actor X afflicted by state 1, 3, or 19, etc. I'm not sure such a thing exists, though.
    I'm not trying to be mean, but I don't know how you didn't find this :stickytongue:

    When I Google "rpg maker mv script call has state" at least three threads with the function call pop up; additionally, it's still listed in the script call document, which you said you'd looked through. It's, like, the seventh instance down of the word "state":
    1718555436865.png

    I had no idea that was the part you were asking about. I thought you were lost at how to reference the correct actor.

    Good luck with your project!
  18. ATT_Turan said:
    Well. You had said:

    So, by your description, it is about looking at someone in the party. That's the part I thought you needed help with, because the second part is so straightforward.


    I'm not trying to be mean, but I don't know how you didn't find this :stickytongue:

    When I Google "rpg maker mv script call has state" at least three threads with the function call pop up; additionally, it's still listed in the script call document, which you said you'd looked through. It's, like, the seventh instance down of the word "state":
    View attachment 308594

    I had no idea that was the part you were asking about. I thought you were lost at how to reference the correct actor.

    Good luck with your project!

    No offense taken - I was not deliberately trying to be stupid, but I certainly could have been more clever :biggrin:

    I actually looked for "Has State", because I had assumed it would be dead simple, and for some reason this didn't yield a result for me. Never mind, Robro33 and you brought me on the right path - the function I was looking for is $gameActors.actor(x).isStateAffected(x).

    Thank you for your patience!
  19. How does RPG Maker MV / MZ treat the canvas when running the game in it's executable format? Does it convert everything to WebGL counterparts, or is it still technically a web page even when ran through the exe?

    The reason I ask is because I noticed some changes I make to canvas inside of Gamefont.css does not actually do anything when running the game in test play or in a live build. I know some font things won't reflect because it's technically being rendered as bitmap sprites instead of pure text. Idk, just a random thought I had lol if anyone can shed some light on this I'd really appreciate it!

    Thanks in advance.
  20. 171stStreetGames said:
    That's what I thought, too! I was so confused. Somehow the black background seems intentionally put there, but there doesn't seem to be anything making it so.
    So, it's been a while since I've visited this. I got a couple people to look at it, but I still haven't figured out how to fix the problem. Does anyone have any insight at all?