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
    Okay nevermind I'm being a huge noob with this. Realized the reason the state was staying the same is because I had the state setting set to something else which was preventing the state to end. Thank you Shockra and Naveed for your help. And sorry for my noobish designing haha I never would have noticed that I had inputing a single line of code wrong. I do however have one last quick question. I'm trying to have all basic attacks cause a state to occur but if skills are used that state won't be added. Haha any idea how I would do that? I swear it's my last question for this thread.
     
    #21
  2. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    Why not just give an add state effect in the attack skill?
     
    #22
  3. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Well I'm trying to make an enemy who is weak against standard attacks and I wanted to do that by having standard attacks afflict the enemy with a state. I don't want all my attacks to have the state because I don't want all my standard attacks afflicting that state. I want it to be a weakness to that specific enemy. Yeah I'm using the RowsFormation Plugin so attacking with regular attacks won't be easy in case it doesn't make sense as to why I would ask this. Hope that made sense.
     
    #23
  4. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    So if I understand correctly, you want basic attacks to inflict a state on that specific enemy only?
     
    #24
  5. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Yes that's correct. Sorry for the late reply Naveed. You keep finding a way to sum up my request in a simple sentence. XD
     
    #25
  6. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    Give that enemy a passive state. Then, on the passive state, use this code:

    <Custom Respond Effect>
    if (this.isAttack()) target.addState(stateId);
    </Custom Respond Effect>
     
    #26
    RPG Samurai likes this.
  7. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Okay I'm on it! Testing it right now.
     
    #27
  8. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    And just like that it worked... I tried doing it myself and couldn't get it to work. Tried repurposing your previous line of code you gave me but to no avail. The funny thing is your line doesn't look that much different from mine. But you did use a different execution for it so I guess I'm just blind lol. Thanks for taking the time to help me once again. Appreciate the help and it's pretty late on my end too. +1 Like of course.
     
    #28
  9. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    You can post your line here. I'll look at it and see what went wrong.
     
    #29
  10. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Oh sorry I didn't realized you had responded. Here was my incorrect code I tried to use.
    <Custom Establish Effect>

    if (this.isAttack()) {

    target.addState(71);

    }

    </Custom Establish Effect>
    I tried repurposing your original code you gave me before. I thought it might work because if the attack connects it would add the state. But I think I don't have a clear enough understanding as to what's going on with the Establish effects in the BuffStatesCore Plugin. I am curious why it didn't work however.
     
    #30
  11. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    You used <Custom Establish Effect>, so the code will run when the enemy attacks, not when it is attacked. To make the code run when the enemy is attacked, you have to use <Custom React Effect> or <Custom Respond Effect>. You should read through the help file of Yanfly's buffs and states core to understand which notetag you should use when. It has a clear explanation of when each code is run.
     
    #31
  12. RPG Samurai

    RPG Samurai Veteran Veteran

    Messages:
    31
    Likes Received:
    1
    First Language:
    English
    Okay that makes sense. Why didn't you have to use the "{" or "}" symbols in your coded version? You wrote the whole thing on a single line. Does that make any difference?
     
    #32
  13. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    It's sort of like a shorthand in coding. If there is only one line after the condition, you don't need curly brackets. So

    Code:
    if (this.isAttack()) target.addState(stateId);
    And

    Code:
    if (this.isAttack()) {
    target.addState(stateId);
    } 
    Are both the same thing and are both correct.

    However, if there is more than one line after the condition, curly brackets are mandatory:

    Code:
    Correct Code:
    
    if (this.isAttack()) {
    target.addState(stateId1);
    target.addState(stateId2);
    }
    
    
    Wrong Code:
    
    if (this.isAttack()) target.addState(stateId1); target.addState(stateId2);
     
    #33
    waynee95 likes this.

Share This Page