Ok!
So I give you some hints, but as I said, I'm not used to the battle codes. And I did not test it.
But I believe that your case is a simple case of setting a variable for control the counter-attack limit. Or with numbers or with a boolean(true/false). To allow or not the player or enemies be able to perform the counter.
And for reducing the damage, it will also a matter of math, like take the total calculation of the damage and reduce it by the amount you want.
The thing is where you can do this.
So based on the core files, you have these 3 functions on game object:
I believe Game_Battler will work for both players and enemies.
So you can try to add an if condition here to check the counter times. Maybe you have to set a flag variable to allow counter and disallow it. Or, as you said, apply a state.
Also, you can reduce the attack in the peformAttack, maybe?
Spoiler: game objects
JavaScript:
Game_Battler.prototype.performCounter = function() {
SoundManager.playEvasion();
};
Game_Actor.prototype.performCounter = function() {
Game_Battler.prototype.performCounter.call(this);
this.performAttack();
};
Game_Actor.prototype.performAttack = function() {
var weapons = this.weapons();
var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
var attackMotion = $dataSystem.attackMotions[wtypeId];
if (attackMotion) {
if (attackMotion.type === 0) {
this.requestMotion('thrust');
} else if (attackMotion.type === 1) {
this.requestMotion('swing');
} else if (attackMotion.type === 2) {
this.requestMotion('missile');
}
this.startWeaponAnimation(attackMotion.weaponImageId);
}
};
But you also have these ones on managers:
Maybe in "process turn" you can made the checks and apply the behaviours you want for the "counter attack limit"?
Spoiler: Managers
JavaScript:
BattleManager.updateTurn = function() {
$gameParty.requestMotionRefresh();
if (!this._subject) {
this._subject = this.getNextSubject();
}
if (this._subject) {
this.processTurn();
} else {
this.endTurn();
}
};
BattleManager.processTurn = function() {
var subject = this._subject;
var action = subject.currentAction();
if (action) {
action.prepare();
if (action.isValid()) {
this.startAction();
}
subject.removeCurrentAction();
} else {
subject.onAllActionsEnd();
this.refreshStatus();
this._logWindow.displayAutoAffectedStatus(subject);
this._logWindow.displayCurrentState(subject);
this._logWindow.displayRegeneration(subject);
this._subject = this.getNextSubject();
}
};
BattleManager.endTurn = function() {
this._phase = 'turnEnd';
this._preemptive = false;
this._surprise = false;
this.allBattleMembers().forEach(function(battler) {
battler.onTurnEnd();
this.refreshStatus();
this._logWindow.displayAutoAffectedStatus(battler);
this._logWindow.displayRegeneration(battler);
}, this);
if (this.isForcedTurn()) {
this._turnForced = false;
}
};