Yanfly Battle Java Assistance

Discussion in 'Javascript/Plugin Support' started by RPG Samurai, Jun 24, 2017.

  1. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Hello. I managed to recieve some great help the last time I posted a problem so I'm going to try here again. I'm using Yanfly's Battle Plugins and had a question regarding the <Post-Damage Eval> function. I'm trying to create a skill where if you hit an enemy's elemental weakness (Defined by if an enemy has less than 100% resistance to an element) with a skill; It will then add a state to the foe using the post damage eval code. Problem is I don't exactly know how or even if that is possible to write the code to do that. For example if I have a fire spell. I cast it on a rat; the rat is weak to it, deals normal additional damage and also inflicts burn state. That's what I'm trying to do in a nutshell. Hope that makes sense.
     
    #1
  2. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    Try something like this in the skill notetag:

    <Post-Damage Eval>
    if (target.elementRate(fireID) > 1) {
    target.addState(stateID);
    }
    </Post-Damage Eval>

    Keep in mind that element rates in the RPG Maker code uses 1 as no weakness or resistance to an element. So 0.5 would be resistance, while 1.5 would be a weakness.
     
    #2
  3. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Thanks for the help but that line of code crashed my game for some reason...
     
    #3
  4. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    Did it give an error? Maybe I should have clarified before, but FireID should be replaced by the ID number of the fire element, and StateID should be replaced by the ID number of the state applied.

    If that didn't help, what kind of error did you get exactly?
     
    #4
  5. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Yeah I figured out that Fire ID and State ID meant the ID's for both. I did that. My error was "Syntax Error: Unexpected Token {". I don't get what's happening when that happens. I can only the assume the code either conflicted with a plugin or something else maybe.
     
    #5
  6. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    Usually, that means there's a typo somewhere in the code. What exactly does your notetag say right now? Ideally, copy and paste the whole notetag.
     
    #6
  7. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    <Post-Damage Eval>

    if (target.elementRate(5) > 1) {

    target.addState(8);

    }

    </Post-Damage Eval>
     
    #7
  8. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Okay I just tested it without the code and I think it might be a coding error on my end. I can't figure out from where though.
     
    #8
  9. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    Maybe your plugins need to be rearranged. Can you show an image of your plugin list?
     
    #9
  10. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Screenshot (43).png Screenshot (43).png
     

    Attached Files:

    #10
  11. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
  12. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Sorry about the amount of pictures but it was the only way to fit them all on here.
     
    #12
  13. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    Some of the plugins are out of order, and that may be causing issues. Some of the problems include:

    Base Parameter Control needed to make Class Base Parameters work correctly, should go directly above
    Battle Status Window out of place, should be between Battle Select Cursor and Buffs & States Core
    Event Encounter Aid out of place, should be near the bottom with utility plugins
    Item Plugins should be this order: Item Core, Item Disassemble, Item Categories, Item Picture Images, Item Requirements, rest as is

    I'm guessing a few more plugins are below what is shown, so make sure the rest are in the right order. Yanfly's plugin page should show the correct order.
     
    #13
  14. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Okay. Well rearanged a few of them. This project is pretty old and as a result some of the plugins got shuffled about. Made the changes and am going to try again.
     
    #14
  15. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Well I tried again and got the same error. Maybe I should post all the code I'm using for the skill to clarify a few things.
    <Cooldown: 2>

    <Cooldown Steps: 10>

    <Row Only: 4>

    <Cast Animation: 0>



    <Select Conditions>

    Row 1 Only

    </Select Conditions>



    <target action>

    motion swing: user

    animation 122: user, mirror

    wait: 20

    motion spell: user

    wait for animation

    action animation

    wait: 60

    action effect

    wait for animation

    <\target action>



    <Post-Damage Eval>

    if (target.elementRate(5) > 1) {

    target.addState(8);

    }

    </Post-Damage Eval>



    <Custom Requirement>

    if (user.isStateAffected(45)) {

    value = true;

    } else {

    value = false;

    }

    </Custom Requirement>
     
    #15
  16. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    You closed the target action sequence using <\target action> whereas is should be </target action>. Maybe that's the problem in the code. Make the change and try again.
     
    #16
  17. AdamSakuru

    AdamSakuru [Null_Value] Veteran

    Messages:
    314
    Likes Received:
    168
    First Language:
    English
    Primarily Uses:
    N/A
    On topic question, is this how you would get it to add the state if a random number check passes? (so it checks for both that and the weakness)

    // Set the bonus success rate.
    var bonusStateRate = 0.50;

    // Make a random number check to see if bonus passes...
    if (Math.random() < bonusStateRate) {
    // If Number passes and the enemy is weak to the element, give the state
    if (target.elementRate(fireID) > 1) {
    target.addState(stateID); }
    }
     
    #17
  18. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    @AdamSakuru yes that's how you would do it.

    You could shorten the code for convenience if you wanted to, although its not necessary.

    Code:
    var bonusStateRate = 0.50;
    
    if (Math.random() < bonusStateRate && target.elementRate(fireID) > 1) target.addState(stateID);
     
    #18
  19. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Oh my gosh thank you Naveed. Haha I just checked and I think that solved my issue.
     
    #19
  20. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Well now I have a new problem though. The burn state that got added doesn't go down in turns for some reason... Is there a way to make it function as though a normal state was afflicted. What's happening is that the state that was added via the code won't go away after the usual amount of turns happens. I don't understand why.
     
    #20

Share This Page