MV - Need help to set up some passive skills using notetags/javascript code

● ARCHIVED · READ-ONLY
Started by TheNewSon 7 posts View original ↗
  1. So, I'm creating passive skills using a couple of Yanfly's plugins: Buffs & States Core, and Auto Passive States. However, some of these skills require some additional javascript code to work, but since I'm not a coder myself, I'm having trouble finding some of these codes out there. These are the passive skills:

    1. Increases the user's chance of attacking a target more than once based on the user's AGI (only when using the default Attack command).
    2. Restores a bit of MP whenever the user use the Guard command (should happen once they enter the Guard stance).
    3. Restores a bit of HP whenever the user successfully inflicts magic damage (the amount restored should be based on the inflicted damage).
    4. Increases damage output based on the user's HP (higher HP = higher damage).
    5. Adds magic damage whenever the user attacks (only when using the default Attack command).

    By the way, I'm not the one designing these skills, so I can't change anything. If anyone could kindly help me, or at least point me the right direction, I'd be much obliged. :)
  2. TheNewSon said:
    Increases the user's chance of attacking a target more than once based on the user's AGI (only when using the default Attack command).
    You can't really do that using these plugins. You'd program the skill using Yanfly's Action Sequences and include an if command in there to see if a second attack should be done.

    TheNewSon said:
    Restores a bit of MP whenever the user use the Guard command (should happen once they enter the Guard stance).
    Code:
    <Custom Action End Effect>
    if (user.isGuard())
        user.gainMp(10);
    </Custom Action End Effect>

    TheNewSon said:
    Restores a bit of HP whenever the user successfully inflicts magic damage (the amount restored should be based on the inflicted damage).
    Code:
    <Custom Confirm Effect>
    if (this.isDamage() && this.isMagical())
        user.gainHp(Math.round(value / 10));
    </Custom Confirm Effect>

    TheNewSon said:
    Increases damage output based on the user's HP (higher HP = higher damage).
    Code:
    <Custom Confirm Effect>
    if (this.isDamage())
        value += Math.round(user.hp / 10);
    </Custom Confirm Effect>

    TheNewSon said:
    Adds magic damage whenever the user attacks (only when using the default Attack command).
    Depending on what other plugins you're using and what your settings are, this is meaningless or difficult to do.

    What does "magic damage" mean? Is magic an element, and you want the additional damage modified by the target's element rate? If you're using any element immunity or absorption plugins, that could be a lot of code to duplicate in the notetag.

    You didn't provide any actual numbers for any of your requests, so I stuck in random things. Hopefully you can identify where numbers and formulae are and adjust them to your liking.
  3. TheNewSon said:
    Increases the user's chance of attacking a target more than once based on the user's AGI (only when using the default Attack command).
    going to need a bit more explanation for this one. do you already have a plugin that lets you do that to some degree? you could write the whole thing as an action sequence, but i cant think of an easy way to have a state alone increase the hit count of a skill. it would be easier to make it a feature of the skill itself

    TheNewSon said:
    Restores a bit of MP whenever the user use the Guard command (should happen once they enter the Guard stance).
    id make more sense to me to have your guard skill give the user mp with yanfly's skill core on use if the user has the passive active on them than it is to have a state check the user's current action at the start of their action

    Code:
    <After Eval>
    if (user.isStateAffected(x)) //state id goes here
      user.gainMp(15);
    </After Eval>

    TheNewSon said:
    Restores a bit of HP whenever the user successfully inflicts magic damage (the amount restored should be based on the inflicted damage).
    Code:
    <custom confirm effect>
    if (this.isDamage() && this.isMagical())
      user.gainHp(Math.ceil(value/4));
    </custom confirm effect>
    id give this one low priority so that its effect is carried out later than others and the description remains accurate

    TheNewSon said:
    Increases damage output based on the user's HP (higher HP = higher damage).
    you'd use the user's hpRate() for that. it would look something like this
    Code:
    <Custom Confirm Effect>
    value = Math.ceil(value*(user.hpRate()+1))
    </Custom Confirm Effect>
    only you know how it should actually scale right now

    TheNewSon said:
    Adds magic damage whenever the user attacks (only when using the default Attack command).
    a skill is either physical, magical, or certain hit. damage isnt categorized like that. you could "fake" it by adding additional damage based on mat and mdf, but you wouldnt be adding "magic damage"

    Edit: mostly ninja'd
  4. @ATT_Turan @Robro33 guys, thank you so much for helping me out with this! Sorry for not providing exact values for the skills, I still don't have them, as the team member responsible for that part is still working on it. For now I'm just trying to find out the right codes for the skills.

    1. PENDING: The skill that increases the number of successive hits based on AGI should be a passive one, that's what's killing me, lol. And that's also why I'm using states for all these skills, but looks like I'm gonna need more plugins for this one (I have Yanfly's full pack, by the way).
    2. KINDA SOLVED: The skill that recovers MP when guarding worked nicely, but it isn't displaying any number. Is there a way to display the amount of MP recovered?
    3. SOLVED: The skill that recovers HP based on magic damage worked perfectly, it even showed the amount of HP recovered, unlike the previous one... Odd.
    4. SOLVED: The skill that increases damage based on HP also worked perfectly, thanks!
    5. PENDING: Now about the passive skill that adds magic damage when attacking, this is the logic behind it: it's for a Mage-type class with a high Magic Attack, but a low Attack (the usual stats for Mage-like classes); but this passive skill would allow the Mage to have some of his Magic Attack added to his Attack when using the Attack command. Now I see I gave a very poor explanation in the main post, sorry for that, haha.

    Thanks again for helping me out with this, guys! :cutesmile:
  5. TheNewSon said:
    PENDING: The skill that increases the number of successive hits based on AGI should be a passive one, that's what's killing me, lol. And that's also why I'm using states for all these skills, but looks like I'm gonna need more plugins for this one (I have Yanfly's full pack, by the way).
    as said before, it could be done through action sequences. youd make the skill do the normal thing by default, look for the passive, and then make it able to do an extra hit based on agi. theres a plugin floating around to add loops to action sequences. a quick search would bring it up. you could use it to handle multiple additional hits instead of handwriting each condition

    TheNewSon said:
    KINDA SOLVED: The skill that recovers MP when guarding worked nicely, but it isn't displaying any number. Is there a way to display the amount of MP recovered?
    whichever way you chose, add "user.startDamagePopup()" the line after the user.gainMp(). youll have to add an open brace at the end of the line with the "if" in it and a closing brace after the damage popup line now though.

    TheNewSon said:
    PENDING: Now about the passive skill that adds magic damage when attacking, this is the logic behind it: it's for a Mage-type class with a high Magic Attack, but a low Attack (the usual stats for Mage-like classes); but this passive skill would allow the Mage to have some of his Magic Attack added to his Attack when using the Attack command. Now I see I gave a very poor explanation in the main post, sorry for that, haha.
    that doesnt really have to be done through the passive itself is just for attack. you could do that with the damage formula with a ternary operation.
    Code:
    a.isStateAffected(passive's id) ? a.atk+a.mat/2-b.def : a.atk-b.def
    . check out this thread if you want more examples. it might reduce the need for more passives in the future
    Damage Formulas 101
    if it has to be done explicitly through the passive though...
    Code:
    <custom confirm effect>
    if (this.isAttack()) value +=user.mat/2;
    </custom confirm effect>

    keep in mind that if its a passive, itll add the damage ontop of whatever the formula calculated any time damage is dealt with no further consideration.
    if the skill did 0 damage because of stat difference, 0% physical damage rate, or 0% element rate, itll add that bonus damage and the skill will deal that damage at minimum.
    if you wanted the target's magic defence to factor into the bonus damage, youll have to write that in and make sure the damage cant become negative or else the damage becomes a heal.
    if you want magic damage rate to be factored in, youll have to write that in too.

    any consideration not written in is ignored, which is part of the reason why id suggest making it a part of the formula as it would handle most of those for you natively

    EDIT:
    TheNewSon said:
    SOLVED: The skill that recovers HP based on magic damage worked perfectly, it even showed the amount of HP recovered, unlike the previous one... Odd.
    theres only a few times in a turn that the engine looks at a battler to do a damage popup. which means theres timings and conditions that would make it so that a popup *isnt* generated when damage/healing is done. the default engine handles all of the ones you can possibly get through the default engine, but it becomes more relevant once you start doing damage outside of what the engine lets you with plugins
  6. @Robro33 thanks again, buddy! That page with damage formulas will be helping me a lot!

    1. POSTPONED: Right, I'll be taking a look at some of Yanfly's battle plugins next week.
    2. SOLVED: That code worked like a charm, thanks a lot!
    3. SOLVED.
    4. SOLVED.
    5. SOLVED: The solution you provided for the passive skill worked perfectly too; again, thanks a lot, buddy!

    Mods may close this thread. :)