Need Help With A State and Related Skills

Discussion in 'RPG Maker MV' started by Gray96, Aug 5, 2018.

  1. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Hey everyone, I've got a few questions about how to make a passive state and some skills work. First off, I should say that I'm using various Yanfly plugins including Buffs and States Core and Auto Passive States. What I'm going for is a character (an electric-oriented tanking character, if you're curious) that functions off of a "Static" mechanic. "Static" is a passive state that I want to do the following things:

    1. Gain a stack when the user deals damage.
    2. Gain a stack when the user receives damage.
    3. Give +1 magic attack per stack

    The state is currently set up as follows:
    upload_2018-8-4_21-29-38.png

    The <Custom Establish Effect> part seems to be working. During testing, whenever the character successfully deals damage, the state counter for this state goes up by 1, as intended.

    ...But I think I may be misunderstanding the <Custom Respond Effect> notetag, given that it is not functioning as I thought it would. Based on Yanfly's description of the notetag in his help file, I thought that a Custom Respond Effect would activate whenever the actor with the state was targeted and took damage. I originally didn't have the "if (result.isHit() && this.isDamage()) {" in the notebox, but I added it to see if that might fix it. It did not, unfortunately.

    The third effect I wanted this state to have was to give +1 magic attack per stack of static as a way to reward the player for getting higher and higher stacks. I'm not sure what notetags to use at all for this part...

    Beyond the state itself, I also wanted to have 2 skills that utilize Static stacks as a resource.

    Skill #1: Energy Conversion - I intend for this skill to consume all stacks of Static and heal the user for a portion of their magic attack times the number of stacks consumed (something like (0.25 * a.mat) * StaticStacks). Hopefully this formula at least gives the general idea of what I'm going for.

    Skill #2: Static Discharge - This skill is supposed to consume all stacks of Static and deal damage to all enemies based on the number of stacks consumed. The formula would probably be similar to the one for Energy Conversion, but would do AOE damage rather than self healing. The problem with this skill is that, after it deals damage, it will surely add a stack of Static back onto the counter due to the Custom Establish Effect in the passive state's notebox. I feel that this wouldn't make sense, given that the skill is thematically supposed to release all of the built up Static at once. So in addition to making the damage formula work right for this skill, I also need help bypassing the passive state for this one...

    Outside of what I've already attempted in the image above, I'm still pretty new to Yanfly's notetags, so help with any or all components of this post would be immensely appreciated. Thanks in advance!
     
    #1
  2. JGreene

    JGreene Dogs? They're all puppers Veteran

    Messages:
    359
    Likes Received:
    272
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't know what plugin this is from, but you didn't close out the custom respond effect function with }

    And it might need a semicolon after that, too. Try both ways and see if it works
     
    #2
    Gray96 likes this.
  3. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    394
    Likes Received:
    166
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    The first issue I noticed is that when doing a Respond effect, the target is the character with the state, not the user. That part should be:

    <Custom Respond Effect>
    if (this.isHpEffect() && value > 0) {
    target.addStateCounter(stateId, 1);
    }
    </Custom Respond Effect>

    This may require Skill Core to work correctly. As for increasing magic attack, that might not be possible. What is possible is using the counter to increase the power of magical attacks, like this:

    <Custom Confirm Effect>
    if (this.isMagical() && this.isHpEffect() && user.getStateCounter(stateId) > 0) {
    var stacks = user.getStateCounter(stateId);
    var ratio = 1 + stacks * 0.10;
    value = Math.floor(value * ratio);
    }
    </Custom Confirm Effect>

    That code will increase the power of magical attacks based on the current amount of stacks.

    Side Note: I would clamp the counters after each add to ensure that the user doesn't gain too many stacks and make the effect broken. Just add the following after each addCounter code to accomplish this:

    user.clampStateCounter(stateId, 0, 10);

    Make certain that in the Respond effect, it affects the target, NOT the user.

    That's enough info dumping for now. Start with that, then once we know that works, we'll get more into the rest of it.
     
    #3
    Gray96 likes this.
  4. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks for everything so far! All of these recommendations are working perfectly, and I was actually considering clamping the stacks as you suggested but didn't want to overload the original post too much haha. With the current setup, a stack is gained when the user deals damage and whenever they receive damage, and their magical attacks grow incrementally more powerful with each stack. The clamps are working too, as both triggers for stack increases do not put the counter over 10. So far so good! Would it be too much of a bother to get advice on the skills as well?
     
    #4
  5. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    394
    Likes Received:
    166
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    I just realized something with the Establish code that may need fixed. As it sits, the establish effect will trigger with non-damage skills as well. This should fix it:

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    user.addStateCounter(stateId, 1);
    }
    </Custom Establish Effect>

    For the first skill, if you don't already have them, you'll need the Skill Core and Damage Core plugins. These notetags should all go in the skill:

    <Custom Requirement>
    value = user.isStateAffected(StaticStateID) && user.getStateCounter(StaticStateID) > 0;
    </Custom Requirement>

    This is mainly to ensure that the user has the state with counters. Replace StaticStateID with the ID of the state; stateId won't automatically get the ID because we're not in the state code here.

    <Damage Formula>
    var stacks = user.getStateCounter(StaticStateID);
    value = a.mat * 2 * stacks;
    </Damage Formula>

    This part is the formula for the recovery. Make certain the skill is set to HP Recover.

    <After Eval>
    user.setStateCounter(StaticStateID, 0);
    </After Eval>

    This set the stacks to 0 after the skill is finished.

    As for the second skill, the Custom Requirement and Damage Formula are basically the same, as is the After Eval. But to ensure that you don't add stacks with this skill, we need to tweak the state itself. Change the Establish effect in the Static state to this:

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    if (!this.isSkill()) {
    user.addStateCounter(stateId, 1);
    } else {
    if (!this.item().itemId() = SkillID) user.addStateCounter(stateId, 1);
    }
    </Custom Establish Effect>

    Replace SkillID with the ID of the Discharge skill. This should prevent the Discharge skill from triggering the state.
     
    #5
    Gray96 likes this.
  6. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Cool, so parts of this are working, and parts are not. With everything set up as it is now, the counter no longer goes up when the user deals damage. Additionally, there is a problem when dealing damage in the discharge skill (the healing one is working fine!). The damage is scaling correctly with stacks of Static, but because it is an aoe skill, what happens is that one enemy will take the full damage and then the <After Eval> code kicks in before the other enemies get damaged (at least, this is my best guess at what is happening). This causes the stacks to reset to 0 after only one of the enemies has been damaged, making the other enemies take 0 damage.

    For troubleshooting purposes, here's the current code for the Static state (State 131):

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    if (!this.isSkill()) {
    user.addStateCounter(stateId, 1);
    } else {
    if (!this.item().itemId() = 352) user.addStateCounter(stateId, 1);
    }
    user.clampStateCounter(stateId, 0, 10);
    </Custom Establish Effect>

    <Custom Respond Effect>
    if (this.isHpEffect() && value > 0) {
    target.addStateCounter(stateId, 1);
    }
    target.clampStateCounter(stateId, 0, 10);
    </Custom Respond Effect>

    <Custom Confirm Effect>
    if (this.isMagical() && this.isHpEffect() && user.getStateCounter(stateId) > 0) {
    var stacks = user.getStateCounter(stateId);
    var ratio = 1 + stacks * 0.10;
    value = Math.floor(value * ratio);
    }
    </Custom Confirm Effect>




    And here's the current code for the damaging skill (Skill 352):

    <Custom Requirement>
    value = user.isStateAffected(131) && user.getStateCounter(131) > 0;
    </Custom Requirement>

    <Damage Formula>
    var stacks = user.getStateCounter(131);
    value = a.mat * 2 * stacks;
    </Damage Formula>

    <After Eval>
    user.setStateCounter(131, 0);
    </After Eval>

    EDIT: Just a random thought, but do you think the issue with the <After Eval> portion could be fixed somehow using an action sequence? Also, I do have Damage Core and Skill Core installed as well so should be good to go on plugins.
     
    Last edited: Aug 5, 2018
    #6
  7. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    394
    Likes Received:
    166
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    OK...in the Establish effect, I left the } off the end by mistake. It should be:

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    if (!this.isSkill()) {
    user.addStateCounter(stateId, 1);
    } else {
    if (!this.item().itemId() = 352) user.addStateCounter(stateId, 1);
    }
    user.clampStateCounter(stateId, 0, 10);
    }
    </Custom Establish Effect>

    The other problem may be trickier since it's an attack that hits everything and triggers the After Eval for each target. Maybe a better solution is to remove the After Eval and try a Custom Execution in the skill instead. Maybe this will work:

    <Custom Execution>
    user._staticCharges = user.getStateCounter(131);
    user.setStateCounter(131, 0);
    </Custom Execution>

    <Damage Formula>
    if (user._staticCharges) {
    var stacks = user._staticCharges;
    value = a.mat * 2 * stacks;
    } else {
    value = 0;
    }
    </Damage Formula>

    Then, in the state:

    <Custom Action End Effect>
    if (user._staticCharges) {
    user._staticCharges = undefined;
    }
    </Custom Action End Effect>

    It's a bit of a workaround, but I think it will work.
     
    #7
    Gray96 likes this.
  8. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Progress has been made once again! Both the damaging skill and healing skill are now working as intended, and the scaling appears to be working properly. However, the actor is still not gaining stacks when they deal damage with their other skills and basic attack, so there still seems to be an issue with the Establish effect. Here's the current one after updating it. It should be exactly the same as the new version in your last post.

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    if (!this.isSkill()) {
    user.addStateCounter(stateId, 1);
    } else {
    if (!this.item().itemId() = 352) user.addStateCounter(stateId, 1);
    }
    user.clampStateCounter(stateId, 0, 10);
    }
    </Custom Establish Effect>

    Are we perhaps missing something like an &&?

    In any case, thanks again for all your help so far! It's been extremely appreciated :) The best I can do to return the favor for now is like all your replies, ha.
     
    #8
  9. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    394
    Likes Received:
    166
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    OK, I think I set up the = wrong now. In conditionals, there should be 3 equals. So it should be:

    <Custom Establish Effect>
    if (this.isHpEffect() && value > 0) {
    if (!this.isSkill()) {
    user.addStateCounter(stateId, 1);
    } else {
    if (!this.item().itemId() === 352) user.addStateCounter(stateId, 1);
    }
    user.clampStateCounter(stateId, 0, 10);
    }
    </Custom Establish Effect>
     
    #9
    Gray96 likes this.
  10. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    Still having issues, but as a test I tried removing the ! in the "if (!this.isSkill()) {" part, because if I'm not mistaken that basically reads as "if this is NOT a skill", right? Removing that successfully allowed for damaging skills and basic attacks to raise the stacks (so the thing with the === was definitely part of the problem), but the issue of the aoe skill itself adding stacks came back.

    Perhaps we could dissect the current code part by part?

    If I'm reading it right, the skill basically reads:

    <After the damage and hit/evasion phase>
    If this deals damage and the damage value is great than zero, and if this is NOT a skill, add 1 to the state counter of this state;

    else (otherwise)

    If this item's ID is not 352 (if the skill dealing damage is not skill 352) add 1 to the state counter of this state;

    Clamp the range of values for the state counter from 0 - 10;

    </end>

    So from the logic I'm thinking its because the first part checks for the damage to be from a source that is not a skill and therefore always goes to the else branch?

    EDIT: Still testing stuff, I tried changing the code to this to see what would happen (still didn't work but might be something to go off of a bit?)

    <Custom Establish Effect>
    if (this.isSkill() && this.isHpEffect() && value > 0 && !this.item().itemId() === 352) user.addStateCounter(stateId, 1);
    {
    user.clampStateCounter(stateId, 0, 10);
    }
    </Custom Establish Effect>

    So I tried removing the else branch entirely and having the Establish effect check for if its a skill that deals damage > 0 and that it is not ID 352.
     
    Last edited: Aug 6, 2018
    #10
  11. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    394
    Likes Received:
    166
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    I was working under the assumption that we needed a way to check if the damage was from an item instead of a skill. I tried a few tweaks, but now I'm assuming that you want it to only work with skills, which makes it a little simpler. Maybe like this:

    <Custom Establish Effect>
    if (this.isSkill() && this.isHpEffect() && value > 0 && this.item().id !== 352) user.addStateCounter(stateId, 1);
    user.clampStateCounter(stateId, 0, 10);
    </Custom Establish Effect>

    The conditional with the equal sign may not have been right with the ! where it was, so I moved it to the equal sign.
     
    #11
    Gray96 likes this.
  12. Gray96

    Gray96 Veteran Veteran

    Messages:
    33
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    RMMV
    This seems to do the trick! Many many thanks for your help these past couple of days. I feel like I've learned a fair bit about some of Yanfly's notetags to boot :)
     
    #12

Share This Page