JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 145 of 171 View original ↗
  1. caethyril said:
    No: an event and an interpreter are two different things.
    The intent is to use it in a normal script call, not in a move route.

    Sorry this bit has me confused… in the original example “this” works to reference the event. If I wanted to add an interpreter reference, this will only work if I refer to the current event with 0 like in your suggestions above?

    ATT_Turan said:
    Sorry, I don't see an example of how you're using it in your project, but no.
    So I was trying to convey that animateTwelve(this, 0, 12, 20) works. So “this” here is actually the interpreter, and not the event as I had assumed?
  2. werzaque said:
    in the original example “this” works to reference the event.
    Oh...I should've noticed that sooner. :kaoblush:
    werzaque said:
    So “this” here is actually the interpreter, and not the event as I had assumed?
    In that case target is already an interpreter reference. _eventId is an interpreter property that stores the ID of This Event, and that's what you're using to reference it.
  3. @werzaque It occurs to me that pretty much all of your "questions that don't deserve a thread" actually do :wink:

    werzaque said:
    Sorry this bit has me confused… in the original example “this” works to reference the event.
    Again, I don't see any example aside from the pure code of your function, but; again, if you're running it from a Script command, it doesn't.

    As your function is written as a free-standing function (not a member of any data type), this will refer to the global object (or be undefined, in strict mode).
    1715087551907.png
    1715087568645.png
    1715087602744.png


    If you are running it from a Script command and you pass in a this, it will be an interpreter.
    1715087633464.png
    1715087652264.png


    You may find this useful.
    W3Schools.com
  4. caethyril said:
    Yep, in that case target is already an interpreter reference. _eventId is an interpreter property that stores the ID of This Event, and that's what you're using to reference it.
    Wonderful! Thanks!
    ATT_Turan said:
    If you are running it from a Script command and you pass in a this, it will be an
    Pennies dropping!

    Phew… so grateful for your perseverance! Many many thanks.
  5. Hello again, long time no see.

    I was looking around but no luck.

    is there a dmg formula to cap the DOT that use % of max hp?

    something like: [Poison] deals 10% of max hp at the end of the round, up to 1000 HP



    Thanks for your time
  6. SnakeBD said:
    is there a dmg formula to cap the DOT that use % of max hp?
    something like: [Poison] deals 10% of max hp at the end of the round, up to 1000 HP
    This is most easily done with an existing plugin, using my Eval Tags or VisuStella's Skills and States Core to do the damage as a formula.

    You could also make a little plugin to universally modify all slip damage:
    Code:
    Game_Battler.prototype.maxSlipDamage = function() {
        return $dataSystem.optSlipDeath ? Math.min(1000, this.hp) : Math.min(1000, Math.max(this.hp - 1, 0));
    };
    but obviously that's less versatile.
  7. ATT_Turan said:
    This is most easily done with an existing plugin, using my Eval Tags or VisuStella's Skills and States Core to do the damage as a formula.

    You could also make a little plugin to universally modify all slip damage:
    Code:
    Game_Battler.prototype.maxSlipDamage = function() {
        return $dataSystem.optSlipDeath ? Math.min(1000, this.hp) : Math.min(1000, Math.max(this.hp - 1, 0));
    };
    but obviously that's less versatile.
    Manage to make it work with <Custom Regenerate Effect> using a negative value:
    Code:
    <Custom Regenerate Effect>
    var value = Math.floor(Math.min(user.mhp * 0.1 , 1000) * -1);
    user.gainHp(value);
    </Custom Regenerate Effect>

    thanks for the help
  8. Is there a code I could use to get the name of the currently equipped weapon and actor is using?

    I want to save that to a variable.
  9. you can use
    Code:
    $gameActors.actor(x).weapons()[0].name
    just replace the x with the actor's id
  10. Hello again, this time im looking for an specific JS command that gives the amount of healing the target recived.

    im trying to make state that reduce the healing recived by 50% and ill use the same negative Custom Regen to do it, but i canr find the js command to store that amount of healing into my variable X to do the formula

    Code:
    <Custom Regenerate Effect>
    var X = ?????;
    user.gainHp((X * 0.5) * -1);
    </Custom Regenerate Effect>


    Thanks for your time
  11. SnakeBD said:
    for an specific JS command that gives the amount of healing the target recived.
    SnakeBD said:
    im trying to make state that reduce the healing recived by 50%
    are these separate? is the state supposed to reduce healing by 50% and then heal the one who applied it for that amount? just reducing incoming heals can be done by using the REC trait, but it doesnt affect heals from notetags without making them factor REC, and i dont think REC impacts hp regen traits.

    If youre trying to reduce healing on one battler and heal another for the same amount, regenerate effects have no notion of incoming heals and cannot impact them. you use can a <Custom React Effect> (or the equivalent tag for what plugin youre using. your profile says mz but youve provided yanfly ones in the thread so far?) to reduce incoming healing by half and heal the origin for that amount, or edit the Game_Battler.gainHp function to reduce the value by half if its positive and the state is on the battler, and then call another one on the other battler for that same value.
  12. Robro33 said:
    are these separate? is the state supposed to reduce healing by 50% and then heal the one who applied it for that amount? just reducing incoming heals can be done by using the REC trait, but it doesnt affect heals from notetags without making them factor REC, and i dont think REC impacts hp regen traits.

    If youre trying to reduce healing on one battler and heal another for the same amount, regenerate effects have no notion of incoming heals and cannot impact them. you use can a <Custom React Effect> (or the equivalent tag for what plugin youre using. your profile says mz but youve provided yanfly ones in the thread so far?) to reduce incoming healing by half and heal the origin for that amount, or edit the Game_Battler.gainHp function to reduce the value by half if its positive and the state is on the battler, and then call another one on the other battler for that same value.
    yeah is the same thing and i think i found what i was looking for

    Code:
    target.result().hpDamage < 0

    and yes, regenerate effects didnt work :aswt:

    To be specific with this state = if the user of this state is been healed by 1000 HP, the user will only recover half of that (500 HP),
    so im not sure if Recovery Effect is what im looking for since that only affects the caster and not the target (i think thats how it works)


    ill try to do something using this as a base tomorrow
    Code:
    <Custom Respond Effect>
    if (target.result().hpDamage < 0) {
         // code to reduce [target.result().hpDamage]
    }
    </Custom Respond Effect>
  13. @SnakeBD If you double check the instructions for Yanfly's Buffs & States Core, it tells you that the Custom Respond Effect includes a value variable that represents the incoming damage/healing.
  14. Robro33 said:
    you can use
    Code:
    $gameActors.actor(x).weapons()[0].name
    just replace the x with the actor's id
    Thank you.

    I’m assuming this works with “a” or “user” when being used in combat
  15. it depends on how youre running it. if its from a skill's formula box or notetag then you can use those. if its from a troop event or a common event, you cant use them.
  16. Robro33 said:
    it depends on how youre running it. if its from a skill's formula box or notetag then you can use those. if its from a troop event or a common event, you cant use them.
    Just wanted to confirm, as I've ran into some instances where code didn't work like that in the past.
  17. This is for MZ. Would anyone know of a script call to force the Skill window in battle to refresh?

    I have a feature in my game where the player can toggle on a common event in battle using a key, which then swaps their skill set and enables a state. The effect works just fine, but if the player triggers the common event with the skill list open, it does not refresh to show their new skill set. Backing out of the skill window and going back in redraws it just fine though.
  18. try
    Code:
    SceneManager._scene._skillWindow.refresh()
  19. Works like a charm!

    I greatly appreciate the help
    Robro33 said:
    try
    Code:
    SceneManager._scene._skillWindow.refresh()
  20. [MZ] Base function handling actor's parmas update from equipment.

    Hello everyone.
    I'm writing a plugin and need to change the standard behaviour of when an item is equipped (in particular an armor).
    I didn't have much luck figuring out how to achieve this.
    My base idea is to find what function handles this aspect, overwrite it with just the addition of a check (prob something along the line item.isArmor() or item.etype == 2) in order to do my custom calculation of bonus given by the item.

    A more detail explanation of what I want to do
    I'm creating a plugin that overhaul the base system with a modded version (from my very own homebrew campaign) of the D&D 5e one.
    In this particular case, I'm working over AC (def) calculation based on the Actor dex modifier (base def) and the armor type (light/medium/heavy). Basically, in D&D based on the armor category you either add you modifier, add it up to 2 or not add it at all.
    I'd like to express this when the Actor equips a new armor. The idea is to reduce the bonus based on the armor type, something along the line of:

    JavaScript:
    param -= (this.def * (item.atype == 3)) // Remove all dex bonus if Heavy Armor
        - (Math.max(this.def-2, 0) * (item.atype == 2)); // If it's medium armor should add only 2 dex bonus

    (where this is supposedly the Game_Actor entity)

    Thanks in advance for any help.