I have a character with a skill that applies a state that makes his evasion rate and counter rate go up to insane levels so that you get an effect similar to something like the boobytrap skill from the thief in Miitopia for example. But I don't know how to just remove the state after he evades. I tried using remove on damage but the state wouldn't persist past one turn like that.
How to remove a state after evading an attack?
RPG Maker MV SupportWithout coding, auto-removal timing is the only way I could think of. Since "Overriding States plugin" also need the battler to land a successful hit to override/remove that Evasion State.
Untested, but should do it. Take the following snippet and install as a plugin.
JavaScript:
(() => {
const id = 5; // your evasion state id
const evade = Game_Battler.prototype.performEvasion;
Game_Battler.prototype.performEvasion = function() {
evade.apply(this);
this.removeState(id);
}
})();
I don't know if this is incorrect but I understood the method of using this as switching out the id at the top and saving it as a JS but this doesn't seem to work. the state still persists after the battler evades and counters.
Try this. It may be more compatible:
JavaScript:
(() => {
const id = 5; // your evasion state id
const apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
apply.call(this, target);
const result = target.result();
if (result.evaded) target.removeState(id);
}
})();
Tried this, also tried it with removing the counter parameter, changing the state to remove by restriction, making the test enemy have enough attack to do damage. but the state still persists. You are showing it working so i'm just not sure if i'm maybe installing it wrong, or maybe applying it wrong. Dunno.
Did you actually activate the plugin? Are you using any other plugins?
The first thing I posted would have worked in a fresh project without plugins. The second should be more compatible.
The first thing I posted would have worked in a fresh project without plugins. The second should be more compatible.
It's enabled, i tried turning off all other plugins and testing it, it's still persisting.
I'll describe how I installed the plugin. I copy pasted
(() => {
const id = 5; // your evasion state id
const apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
apply.call(this, target);
const result = target.result();
if (result.evaded) target.removeState(id);
}
})();
into notepad++ and changed the 5 to a 17, which is my ID, gave the plugin a name, saved it under that name with the JS extension and put it into the games plugin folder and enabled it in the plugin menu. Is there anything wrong with how I did it?
I'll describe how I installed the plugin. I copy pasted
(() => {
const id = 5; // your evasion state id
const apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
apply.call(this, target);
const result = target.result();
if (result.evaded) target.removeState(id);
}
})();
into notepad++ and changed the 5 to a 17, which is my ID, gave the plugin a name, saved it under that name with the JS extension and put it into the games plugin folder and enabled it in the plugin menu. Is there anything wrong with how I did it?
Not sure. You could try updating the plugin to include a console.log method; see below. Press F8 while play testing. You should see the word 'test' in the console any time a battle action occurs. If not, the plugin is not active.
JavaScript:
(() => {
const id = 5; // your evasion state id
const apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
apply.call(this, target);
console.log('test');
const result = target.result();
if (result.evaded) target.removeState(id);
}
})();
Yep the plugins active. test appears in console for each action so it's running.
lol, this is interesting. I guess you could try this:
Hit F8 and see whether or not you get a 'true' when your actor evades an attack.
JavaScript:
(() => {
const id = 5; // your evasion state id
const apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
apply.call(this, target);
const result = target.result();
console.log(result.evaded);
if (result.evaded) target.removeState(id);
}
})();
Hit F8 and see whether or not you get a 'true' when your actor evades an attack.
I do get a false. Is it the way I have the state set up, like is this not compatible with the evasion rate parameter? Wait the counter parameter is an evasion parameter i just tried it without the evasion parameter and it still negates damage, I assumed you have to have both. And yes that is it just tried it with just the evasion parameter, do i just change the evaded in the script with countered?
Ah, this is what I get for parsing your OP quickly and not asking for a screenshot of your state’s effects.
Counter is coded differently and won’t register an evade (or a result on the target, as far as I know).
I think counter and evade are also mechanically redundant. Counter prevents an attack from connecting by default, so the evasion doesn’t occur.
What I have given you will work for a successful evade assuming there are no plugin compatibility problems.
Counter is coded differently and won’t register an evade (or a result on the target, as far as I know).
I think counter and evade are also mechanically redundant. Counter prevents an attack from connecting by default, so the evasion doesn’t occur.
What I have given you will work for a successful evade assuming there are no plugin compatibility problems.
Yeah sorry about that, I probably should've clarified about counter, but I just thought that counter was "take damage, do counter attack" so I thought you had to also had to jack up evasion, apparently not, and I assume that complicates things immensely.
The easy way to do this is to use Yanfly's Buffs & States Core.
In your state, put the notetag:
where X is the ID of the state.
That should cause the state to go away after one physical attack targets the actor.
In your state, put the notetag:
Code:
<Custom Deselect Effect>
if (this.isPhysical() && this.isDamage())
target.removeState(X);
</Custom Deselect Effect>
where X is the ID of the state.
That should cause the state to go away after one physical attack targets the actor.
Uh, nope. that didn't work either. The actor countering is part of the state so maybe that's overriding him getting targeted somehow?
You can't counter if you're not targeted by an attack. Please supply a screenshot of the state.
Did you install the plugin, save your project, start a new game to test the battle?
Did you install the plugin, save your project, start a new game to test the battle?
plugin's installed, project's been saved, not sure what you mean by new game but I playtest with skip title so that should start a new game every time. Just to make sure, we are talking about YEP_BuffsStatesCore right? I took an assume and thought maybe I needed the battle core plugin, but that didn't help.
I'm of the opinion that there's nothing "easy" about managing code through the editor in any capacity. But I guess that boils down to personal preference.
I admittedly glossed over the fact that OP was using a counter effect on their evasion state, or else I wouldn't have spent several posts trying to help troubleshoot an evasion check.
The below snippet works for me in a blank project (no plugins). Unfortunately, if it doesn't work with your plugin setup, I'm probably not willing to help further.
I admittedly glossed over the fact that OP was using a counter effect on their evasion state, or else I wouldn't have spent several posts trying to help troubleshoot an evasion check.
The below snippet works for me in a blank project (no plugins). Unfortunately, if it doesn't work with your plugin setup, I'm probably not willing to help further.
JavaScript:
(() => {
const id = 5; // your counter state id
const counter = BattleManager.invokeCounterAttack;
BattleManager.invokeCounterAttack = function(subject, target) {
counter.call(this, subject, target);
target.removeState(5);
this._logWindow.displayRemovedStates(target); // remove if not using battle log
}
})();
OMG TYSM THE PROBLEM HAS BEEN RESOLVED THIS WORKS! I am absolutely crediting you dude, thank you for putting up with my idiocy to get this working.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-remove-a-state-after-evading-an-attack.155126/