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.
Yanfly Battle Java Assistance
Javascript/Plugin SupportWhy not just give an add state effect in the attack skill?
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.
So if I understand correctly, you want basic attacks to inflict a state on that specific enemy only?
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
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>
<Custom Respond Effect>
if (this.isAttack()) target.addState(stateId);
</Custom Respond Effect>
Okay I'm on it! Testing it right now.
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.
You can post your line here. I'll look at it and see what went wrong.
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.
<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.
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.
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?
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
And
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:
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);
Original thread: https://forums.rpgmakerweb.com/threads/yanfly-battle-java-assistance.80286/