Creating a Counterattack Item

NikkiKaji

Villager
Member
Joined
Jun 30, 2016
Messages
26
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
662
Reaction score
386
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

Villager
Member
Joined
Jun 30, 2016
Messages
26
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
662
Reaction score
386
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

Villager
Member
Joined
Jun 30, 2016
Messages
26
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
662
Reaction score
386
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

Villager
Member
Joined
Jun 30, 2016
Messages
26
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?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

As for the Coronavirus? Well: "People that spend their life avoiding death are already dead (they're also rich, and I like to spend my life with their money.)"
- R. Sanchez, "Edge of Tomorty: Rick, Die, Repeat"
making pierogi and corrupting my game files wbu
Trying to regain my will to work on maps T_T
I miss working in rpgmaker but I can only do one thing at a time. Maybe after drawing lessons I can come back.
Ever have a day like... you play minesweeper and your very first click is always a mine?

Forum statistics

Threads
94,340
Messages
920,075
Members
124,100
Latest member
Vulgourso
Top