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,379
Reaction score
1,558
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,864
Reaction score
518
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,379
Reaction score
1,558
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,379
Reaction score
1,558
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,379
Reaction score
1,558
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

I'm sure this question's been asked before, but I can't find an answer: is there any way to run the Steam version of RPGMaker *without* being logged into Steam? It's a frustrating extra step sometimes.
Been seeing bright flashes in the sky for a while, and thought it was my eyes playing tricks on me. Nope! Lightning. Now it's raining heavily. Seeing lightning, but not hearing thunder, is weird.
Small Update for myself:
>Two Dungeon maps are done, Dungeon 3 is in progress. Dungeon 4 needs work.
>4 characters set up out of a possible 6 but those come later.
>Hub area needs work.
>Game completion..., 20-25% maybe?
Does anyone else find writing dialogue hard?
You guys want more tutorials? Well not only are we doing new video tutorials with Driftwood, we've also brought in two contributing authors for the blog to get a new tutorial every week! First one here from @Avery
https://blog.rpgmakerweb.com/tutorials/tutorial-mapping-interior/

Next week we'll get something from @hiddenone

Forum statistics

Threads
100,712
Messages
978,633
Members
132,325
Latest member
ighjku
Top