Creating a skill where an enemy attacks you when you hit his ally

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
71
Reaction score
8
First Language
English
Primarily Uses
RMMV
Hello! I've been working on creating this skill but I haven't been able to get it working properly. I'm hoping someone could help!

A brief explanation of the battle encounter: If you hit Enemy 2, Enemy 1 will immediately attack the actor who hit Enemy 2. This should happen every time you hit Enemy 2 until it dies.

Right now I'm using "force action" in the Troops menu to do this. I have the conditions set as "Enemy HP, Enemy 2, 99% or below" The subject of the forced action is Enemy 1 and the target is set as "Last Target" and the skill is set as the specific attack skill I made for Enemy 1 in the Skill section of the database.

I have the span set as "Battle" and it DOES work, but Enemy 1 is only hitting the actors that hit Enemy 2 once in the battle. If I change the span to "Turn" or "Moment" than Enemy 1 hits the actors over and over again and I don't want that either. Does anyone know the best way to pull this off? My first thought was to have multiple pages with different Enemy 2 HP percentages that get lower by 10% each time, but I'm not sure if that will work or be accurate?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
Are you saying you want the enemy to retaliate no matter what the actor did to its ally, or that there's just one specific skill that incurs the retaliation if used?
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
71
Reaction score
8
First Language
English
Primarily Uses
RMMV
Are you saying you want the enemy to retaliate no matter what the actor did to its ally, or that there's just one specific skill that incurs the retaliation if used?
The first one! No matter what an actor does to Enemy 2, Enemy 1 will retaliate ^_^
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,860
Reaction score
516
First Language
English
Primarily Uses
N/A
The first one! No matter what an actor does to Enemy 2, Enemy 1 will retaliate ^_^
Even if the actor heals enemy 2?

Edit: maybe it could be done with variables. Each turn, it puts enemy 2's HP into a variable. Then, after each action by the actors, it puts enemy 2's HP into a second variable. If the first variable is higher than the second variable, enemy 1 retaliates. Then, it sets the first variable to the second variable

Edit: The setting the HP into a variable each turn is so you can allow for enemy 1 healing enemy 2 and have the situation still work
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
(This requires Yanfly's Buffs & States Core and Autopassive States plugins)

Give enemy 2 a passive state with the following notetag:

Code:
<Custom Respond Effect>
$gameSwitches.setValue(1, true)
</Custom Respond Effect>
Where 1 is the ID of an available switch. Then create a battle event that's triggered by the same switch, which forces action for enemy 1 to attack last target and turns the switch off.
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
71
Reaction score
8
First Language
English
Primarily Uses
RMMV
Yeah I wouldn't want it to include heals. I also just realised I wouldn't want it to include DoTs like poison either. It'd be ideal for Enemy 1 to only react when it's a normal attack or an offensive skill. Hmm...

My apologies for being confusing and giving the opposite answer now! I didn't actually realise this myself until I properly considered it. But I super appreciate your answers! Both of these ideas could be great if I wanted it to include healing/DoTs/etc.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
The Custom Respond Effect will actually work for this. You'd just have to check whether the action item has a positive damage value and that it doesn't have any regeneration traits on it.
 

RoseRainblood

Veteran
Veteran
Joined
Nov 29, 2018
Messages
71
Reaction score
8
First Language
English
Primarily Uses
RMMV
The Custom Respond Effect will actually work for this. You'd just have to check whether the action item has a positive damage value and that it doesn't have any regeneration traits on it.
Oh, that's awesome then!

I've tried this and it seems to have done the trick:

Code:
<Custom Respond Effect>
if (value > 0) {
$gameSwitches.setValue(33, true)
}
</Custom Respond Effect>
For the regeneration skill side, I've put each of them as a state resist in the traits section. Is that what you mean or is it easier to use a line of code for that too?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
Oh, that's awesome then!

I've tried this and it seems to have done the trick:

Code:
<Custom Respond Effect>
if (value > 0) {
$gameSwitches.setValue(33, true)
}
</Custom Respond Effect>
For the regeneration skill side, I've put each of them as a state resist in the traits section. Is that what you mean or is it easier to use a line of code for that too?
You can check whether the skill adds a state that has a negative regen trait with this code:

Code:
$dataSkills[id of skill you're checking].effects.filter(effect => effect.code == Game_Action.EFFECT_ADD_STATE).map(effect => $dataStates[effect.dataId]).some(state => state.traits.some(trait => trait.code == 22 && trait.value < 0))
 

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

Latest Threads

Latest Profile Posts

Just a heads-up that Slip into Ruby and Jump into Javascript might be a bit slow for now while I'm on the team porting the YEP plugins to VisuStella's MZ suite.
So I managed to build a teleport skill. You can see the progression in the development topic
https://forums.rpgmakerweb.com/index.php?threads/in-dev-multi-hit-target-selection.125049/

Here's how it looks:


But the real question is, can I pull off FF8?

I love these little slime battlers. Really wish I could find more animated ones :'(
The curse of retail: you get ideas, you want to make something with those ideas, but because you're always at friggin' work you can't actually do anything with them.
Quexp wrote on lumimae's profile.
Welcome! :)

Forum statistics

Threads
100,630
Messages
977,962
Members
132,248
Latest member
Dealdeg
Top