NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
Hello, I'm back with another javascipt problem haha. I almost had this one solved, but I seem to be having a bit of trouble...
Currently, I am using yanfly's buffs and states core (http://www.yanfly.moe/wiki/Buffs_&_States_Core_(YEP)) to create an item that, when used, counters the next physical attack you take. It doesn't wear off unless you are either hit by a physical attack once, or the battle ends.

The problem is: I can't get the custom action effects to remove the state after the user is hit.

This is the first code I tried:
Code:
<Custom Deselect Effect>
if (this.isPhysical()){
target.removeState(28);
}
</Custom Deselect Effect>
Using that one did not remove the state at all, even after changing "target" to "user" just incase that's why it was messing up. Unfortunately, that did not fix it.

Then, I tried this one:
Code:
<Custom Conclude Effect>
if (this.Physical() && target.result().isHit()) {
  user.removeState(14);
}
</Custom Conclude Effect>
This one almost worked, since enemies would hit the user, get countered, and the state would be removed. However, the user affected with the state attacking an enemy removed the state as well, and that's not what I want.

Can anyone help me out on this? I saw a similar thread before, but that user had a similar problem as me where the state wasn't being removed. I've also tried disabling all other plugins incase it was a compatibility issue, but that didn't fix the problem either...
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
881
Reaction score
573
First Language
English
Primarily Uses
RMMV
The Custom Conclude Effect is going to trigger when the user does an attack- the reason it works defensively is because the user's counterattack triggers the removal condition.

For debugging purposes, I'd suggest putting the following tags in the counter state that's on the player:
Code:
<Custom Initiate Effect>
console.log("Initiate Effect runs");
</Custom Initiate Effect>

<Custom Select Effect>
console.log("Select Effect runs");
</Custom Select Effect>

<Custom Deselect Effect>
console.log("Deselect Effect runs");
</Custom Deselect Effect>

<Custom Conclude Effect>
console.log("Conclude Effect runs");
</Custom Conclude Effect>
Then, open up the debug console with F8, and see what happens when you test your counter state.
I would expect to see the following:
Select Effect runs
Deselect Effect runs
Initiate Effect runs
Conclude Effect runs

If you see a different output when your character is attacked and then counters, then you can investigate from there.
 

NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
The Custom Conclude Effect is going to trigger when the user does an attack- the reason it works defensively is because the user's counterattack triggers the removal condition.

For debugging purposes, I'd suggest putting the following tags in the counter state that's on the player:
Code:
<Custom Initiate Effect>
console.log("Initiate Effect runs");
</Custom Initiate Effect>

<Custom Select Effect>
console.log("Select Effect runs");
</Custom Select Effect>

<Custom Deselect Effect>
console.log("Deselect Effect runs");
</Custom Deselect Effect>

<Custom Conclude Effect>
console.log("Conclude Effect runs");
</Custom Conclude Effect>
Then, open up the debug console with F8, and see what happens when you test your counter state.
I would expect to see the following:


If you see a different output when your character is attacked and then counters, then you can investigate from there.

Yeah, but not only does the user's counterattack trigger the removal condition, but so does them initiating a physical attack normally. I know the very complicated way to fix this would be through giving every single physical attack a condition that removes that state, but honestly I feel like there's a better way to do it.

I tried testing with the console logs, and when the character is attacked, it only shows "initiate effect runs" and "conclude effect runs". When I selected an ally to use the actual item that gives the counterattack state, it showed "Deselect effect runs"

EDIT: Is there possibly a way to just force a counter attack from the custom initiate effect rather than the state parameters, so when the enemy initializes the attack, the user with the state just counters and then the state is removed?
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
881
Reaction score
573
First Language
English
Primarily Uses
RMMV
@NikkiKaji One more thing to try- if you remove the actual counterattack effect from the state, do you get Select and Deselect to show up?
 

NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
@NikkiKaji One more thing to try- if you remove the actual counterattack effect from the state, do you get Select and Deselect to show up?
When I use the item on myself, Deselect Effect runs, followed by conclude effect. When the enemy attacks, select effect runs, followed by deselect effect. That’s after I removed the counter effect.
 

Doktor_Q

I'm not a real doktor, but I am a real Q
Veteran
Joined
Aug 1, 2016
Messages
881
Reaction score
573
First Language
English
Primarily Uses
RMMV
So, from that we can determine that with the default counterattack system, countering an attack will skip the select and deselect phases entirely, which seems like a pretty major roadblock for this.

Have you considered using Yanfly's Counter Control? It might improve compatibility, or at least let you try to manage the state's removal via a specific counterattack skill.
 

NikkiKaji

Veteran
Veteran
Joined
Jun 30, 2016
Messages
30
Reaction score
6
First Language
English
Primarily Uses
So, from that we can determine that with the default counterattack system, countering an attack will skip the select and deselect phases entirely, which seems like a pretty major roadblock for this.

Have you considered using Yanfly's Counter Control? It might improve compatibility, or at least let you try to manage the state's removal via a specific counterattack skill.

Ive never tried using counter control before. Do you have any idea how it could be done for a consumable item to give the counter ability?
 

Latest Threads

Latest Profile Posts

I'm so annoyed with myself...I can't get this code to work so it looks like I'm going the plugin route for a problem I should be able to do myself :kaolivid:Great. Now I get to murder save file compatibility. Again.
Can't believe my code from four years ago is still working! Did some expansions, and...
1635194553179.png
In related news, I may have an update for my old Extra status window plugin ready. That is, once I manage to sit down and update the documentation... and the demo project... :kaoswt:
How does one pronounce Godot? I've heard it pronounced a couple of different ways, and I genuinely don't know the proper way.
March 2020 ...
1635188823939.jpeg
... vs October 2021
You look like you had a rough day...Here, have a Baby Panda!

Forum statistics

Threads
116,077
Messages
1,095,556
Members
151,446
Latest member
armanirmr
Top