Counterattack without canceling the enemy attack?

Does anyone know how to keep an enemy attack valid if it attacks an actor with counterattack?

I looked here:

BattleManager.invokeAction = function(subject, target) {    this._logWindow.push('pushBaseLine');    if (Math.random() < this._action.itemCnt(target)) {        this.invokeCounterAttack(subject, target);    } else if (Math.random() < this._action.itemMrf(target)) {        this.invokeMagicReflection(subject, target);    } else {        this.invokeNormalAction(subject, target);    }    subject.setLastTarget(target);    this._logWindow.push('popBaseLine');    this.refreshStatus();};But if I change it to this:

if (Math.random() < this._action.itemCnt(target)) { this.invokeNormalAction(subject, target); // add first attack instead of reflect this.invokeCounterAttack(subject, target);Then the damage popup won't play for the enemy's attack on the actor. Just the counterattack damage will play.

You can turn both lines around, and then only the damage popup for the counter attack will play.
I tried to write a plugin for this, but haven't managed to do it in a way that smoothly integrated with the default battle system.


Will try again when I understand more about how the default battle log works.
I tried to write a plugin for this, but haven't managed to do it in a way that smoothly integrated with the default battle system.

Will try again when I understand more about how the default battle log works.
I'm messing around but can't even get them both to show at the same time...which is weird...because it's possible to show the damage popups of multiple targets at the same time.

At least with Yanfly's battle engine.
Maybe this:

http://forums.rpgmakerweb.com/index.php?/topic/50418-improve-counter-attack-state-snippet/?
Unfortunately, that script also has one damage popup. Maybe worth posting there. 🙂 Thanks.
There was a snippet that fixed this in ACE, I'm sure if you coded something similar in MV it would work. Here's the snippet:

class Scene_Battle < Scene_Base alias bg_counterattackedit invoke_counter_attack def invoke_counter_attack(target, item) #Apply the damage first apply_item_effects(apply_substitute(target, item), item) #Exit if the target is killed before it can counterattack. return if target.hp <= 0 #Call aliased function bg_counterattackedit(target, item) endendI've been using it for over a year now in ACE and it shows both pop-ups with Yanfly's engine over there, so if a similar code doesn't do it in MV then its something unique in how pop-ups are done in the engine.
I'm messing around but can't even get them both to show at the same time...which is weird...because it's possible to show the damage popups of multiple targets at the same time.

At least with Yanfly's battle engine.
Yes.

The problem is the order that the requested actions are executed.

Action processing is broken down into a sequence of requested commands.

For example, normal attack looks like

1. Start Action2. Calculate damage/states/etc3. Display attack animation4. Wait...5. Show damage popup, hit/evade animations, etc.6. Wait...7. DoneOr something like that. I don't remember the exact sequence of processing.Now if you just throw in counterattack logic, what NEW stuff should be added into this mix?

Anyways I tried this again, and this is what I got. Not the same as what you're looking for (simultaneous hit) but it's an improvement.
There was a snippet that fixed this in ACE, I'm sure if you coded something similar in MV it would work. Here's the snippet:

class Scene_Battle < Scene_Base alias bg_counterattackedit invoke_counter_attack def invoke_counter_attack(target, item) #Apply the damage first apply_item_effects(apply_substitute(target, item), item) #Exit if the target is killed before it can counterattack. return if target.hp <= 0 #Call aliased function bg_counterattackedit(target, item) endendI've been using it for over a year now in ACE and it shows both pop-ups with Yanfly's engine over there, so if a similar code doesn't do it in MV then its something unique in how pop-ups are done in the engine.
Hmm, I wish I knew how to convert that.

Yes.

The problem is the order that the requested actions are executed.

Action processing is broken down into a sequence of requested commands.

For example, normal attack looks like

1. Start Action2. Calculate damage/states/etc3. Display attack animation4. Wait...5. Show damage popup, hit/evade animations, etc.6. Wait...7. DoneOr something like that. I don't remember the exact sequence of processing.Now if you just throw in counterattack logic, what NEW stuff should be added into this mix?

Anyways I tried this again, and this is what I got. Not the same as what you're looking for (simultaneous hit) but it's an improvement.
Ooooh, looks fine to me? Could you post the code? ^_^;
You can look at the code here


http://forums.rpgmakerweb.com/index.php?/topic/51946-counter-after-hit/
I tweaked the base code a bit so I would see the counter attack message/damage immediately after the attacker hit. No more of this evasion nonsense and then counter... if you are attacking and the enemy gets its chance to counter both damage popups happens. 😀

Link to a vid showing the effect (you can download it or just watch it there):

https://www.mediafire.com/?b9abo3m1axv8p6p

The counter attack will no occur if the enemy is dead or has a state that prevent actions from happening like Paralyze... anything labeled "Cannot Move" in the states restrictions.

One last thing, this is just an edit to Yanfly's Battle Engine Core, not a stand along plugin or anything... so it will only work if you're using Yanflys plugin. It would be simple to make for the default battle system as well though if needed.

The code change: 

BattleManager.invokeCounterAttack = function(subject, target) { var realTarget = this.applySubstitute(target); this._action.apply(realTarget); if (target.hp == 0) { // EDIT } // EDIT else { // EDIT var action = new Game_Action(target); this._logWindow.displayCounter(target); action.setAttack(); action.apply(subject); this._logWindow.displayActionResults(subject, subject); if (subject.isDead()) subject.performCollapse(); } // EDIT};If you do use this small snippet to fix the problem you will want to save it somewhere so you can re-paste it again after every update for Yanfly's Battle Core plugin.
Thanks so much, you two!!

This community has become amazing since RMMV's release. ^^

Original thread: https://forums.rpgmakerweb.com/threads/counterattack-without-canceling-the-enemy-attack.51920/