Lizardcats

Villager
Member
Joined
Nov 5, 2021
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Hello, I am trying to create a counter-attack state, but can't seem to get things working right.

I want the character to actually take the attack before counterattacking, instead of the default dodge in vanilla MZ. I'm using Visustella Plugins (specifically Auto Skill Triggers) to do this. First I create a state that gives the character the skill, so that when the are hit by a physical attack the character takes the hit then counterattacks. This works but with one problem, the attacker simply attacks a random target instead of enemy that attacked.
1638329428492.png

1638329297816.png

Is there any way to control the counterattack target, or do I have to approach this a different way?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,971
Reaction score
3,161
First Language
English
Primarily Uses
RMMV
Unless there are any settings in the plugin parameters, the Auto Skills plugin doesn't allow any kind of targeting with the notetags.

Yanfly wrote a Counter Control plugin for MV, but I don't see anything by VisuStella that reproduces it. Perhaps it works via FOSSIL?

The other approach I thought of was Yanfly's states plugin had lots of tags for code to be executed at different times of the battle turn (custom respond effects, etc.) but, again, I'm not seeing any equivalents in the VisuStella states plugin.
 

Lizardcats

Villager
Member
Joined
Nov 5, 2021
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Thanks for the reply.

Well that's a pain. Can I do anything with the Javascript notetags? I not exactly literate with Javascripting, but I can get my head around the simple stuff with a bit of trial and error.

Fossil seems like an interesting idea. I dabbled with MV and Yanfly back with my old computer, but that was long enough ago that I thought starting from scratch with MZ would be a better idea. Does anyone know if it clashes with the MZ Visustella plugins?

I did think about doing the counterattacks with common events, might have to give that a shot. If that doesn't work then I'll look into FOSSIL.
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
524
Reaction score
300
First Language
English
Primarily Uses
RMMZ
You wanted something like this?

StateActivation.png
Skill which adds state

CounterState.png
This state adds the skill Counter Attack

CounterSkill.png
Skill added by state, hidden in battle.
Auto Skill Trigger set.
Linked to Common Event: CounterAttack

There are a few ways to do this, here is one I think you can customise to your liking.

Setting variable from here will add 1, so to counter act this effect, Control Variable again, but subtract 1.

Code:
◆Control Variables:#0044 Counter Target = Last Enemy Index to Act
◆Control Variables:#0044 Counter Target -= 1
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Setup Action Set
:              :Display Action = true
:              :Immortal: On = true
:              :Battle Step = true
:              :Wait For Movement = true
:              :Cast Animation = true
:              :Wait For Animation = true
◆If:Counter Target = 0
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 0"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 0"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 0"]
  ◆
:End
◆If:Counter Target = 1
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 1"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 1"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 1"]
  ◆
:End
◆If:Counter Target = 2
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 2"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 2"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 2"]
  ◆
:End
◆If:Counter Target = 3
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 3"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 3"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 3"]
  ◆
:End
◆If:Counter Target = 4
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 4"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 4"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 4"]
  ◆
:End
◆If:Counter Target = 5
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 5"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 5"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 5"]
  ◆
:End
◆If:Counter Target = 6
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 6"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 6"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 6"]
  ◆
:End
◆If:Counter Target = 7
  ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
  :              :Targets (Moving) = ["user"]
  :              :Targets (Destination) = ["enemy index 7"]
  :              :Target Location = front base
  :              :Melee Distance = 24
  :              :Offset Adjustment = horz
  :              :Offset: X = 0
  :              :Offset: Y = 0
  :              :Duration = 12
  :              :Face Destination? = true
  :              :Movement Easing = Linear
  :              :Movement Motion = walk
  :              :Wait For Movement? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = attack
  :              :Show Weapon? = true
  ◆Wait:30 frames
  ◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Action Animation
  :              :Targets = ["enemy index 7"]
  :              :Mirror Animation = false
  :              :Wait For Animation? = true
  ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
  :              :Targets = ["enemy index 7"]
  ◆
:End
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Home Reset
:              :Targets = ["user"]
:              :Wait For Movement? = true
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Finish Action
:              :Immortal: Off = true
:              :Wait For New Line = true
:              :Wait For Effects = true
:              :Clear Battle Log = true
:              :Home Reset = true
:              :Wait For Movement = true
 
Last edited:

Lizardcats

Villager
Member
Joined
Nov 5, 2021
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Thanks, I'll see if that works.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,917
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Thank you.

 

Lizardcats

Villager
Member
Joined
Nov 5, 2021
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Thanks so much. Also, sorry for double-posting.

It works perfectly. I'll admit I had a bit of a mix up with the enemy index/ID in the plugin commands, and was left wondering why the countering character disappeared entirely and only countered certain enemies (whose shared an ID/Index number). But after fixing that, everything worked just fine.

I was also concerned that multiple actors having the skill at the same time would cause problems, as well as if party-wide attacks would cause problems either (and obviously both at once). But it works perfectly in all three situations.
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
524
Reaction score
300
First Language
English
Primarily Uses
RMMZ
Im glad you enjoy it :D
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
667
Reaction score
425
First Language
English
Primarily Uses
N/A
I hate to Necropost, but this thread can be really useful for others looking for this solution, so I wanted to offer a cleaner way of pulling this off.

In the counter attack skill, you can use the following code from VS Battle Core:
JavaScript:
<JS Targets>
// Clears all targets
targets = [];
// Get the index of the last enemy to attack
let eIndex = $gameTemp._lastActionData[3] - 1;
// Adds the enemy that acted last to the pool of available targets
targets.push($gameTroop.members()[eIndex])
</JS Targets>
What this does is override the original scope of the skill so that only the last enemy to attack is added as an available target. Now you can simply set your action sequence targets as "all targets", removing the need for conditional branches to check for every possible index.
 

Latest Threads

Latest Posts

Latest Profile Posts

Coin Locker title screen:
Still in progress...

Screenshot_134.png
the girls.png
So, these are all the girls of the party =3 (beside the protagonist if you play as a female.)
Now, I just have one more character sheet of the guys left and I'm done with their presentations =3
Can you recognize where this area is from? :kaocry:
Mq9QM3h.png
For those with up to 9 elements of magic; how do you structure your database. By element? Or by what is offensive vs supportive spells?
would anyone here be interested in rough concept art for the main protagonist of my game that might get changed later? :kaoswt2:

Forum statistics

Threads
124,442
Messages
1,163,679
Members
163,256
Latest member
onbetltd
Top