Hello RPG Maker friends! ^_^ - so I was wondering if it was possible to create a state where when an enemy strikes you, there's a chance to inflict a state upon them in retaliation. I'm using Yanfly's Buffs & States Core, and that allows a lot of freedom, like for states that reflect a certain percentage of damage back at the attacker. But I haven't seen anything about something that gives a state, or random states in return. Is it possible?
State Help: Chance To Inflict Confusion When Struck?
RPG Maker MV SupportYou'll have to use the lunatic mode. I've done this before in my old project. I'm not sure if this script still works though since it came from an old version of Yanfly Buffs & States Core, but give it a try. Oh, you also need Yanfly Skill Core I think.
Let's call the state that has a chance to inflict another state upon retaliation be State A
Let's call the state inflicted upon retaliation be State B
Assume:
If you want State B to be inflicted on the enemy even when the attack misses, you can probably use "<Pre-Damage Eval>" instead.
In English, the code is basically:
if target to be attacked has State A, and if the attacker has State B already, then attacker gains further 3 turns in State B. Else, attacker gains State B which lasts 3 turns.
Let's call the state that has a chance to inflict another state upon retaliation be State A
Let's call the state inflicted upon retaliation be State B
Assume:
- State A is numbered 15 in the list
- State B is numbered 20 in the list
- State B lasts for 3 turns upon infliction
- If the striking enemy has State B already, then a further 3 turns will be added to its State B when striking opponent with State A
Code:
<Post-Damage Eval>
if (target.isStateAffected(15)) {
if (user.isStateAffected(20)) {
user._stateTurns[20] += 3 ;
} else {
user.addState(20) ;
user.setStateTurns[20 , 3];
}
}
</Post-Damage Eval>
If you want State B to be inflicted on the enemy even when the attack misses, you can probably use "<Pre-Damage Eval>" instead.
In English, the code is basically:
if target to be attacked has State A, and if the attacker has State B already, then attacker gains further 3 turns in State B. Else, attacker gains State B which lasts 3 turns.
This is very simple. For example, i have a state A which has a small chance (25%) to add Confusion state ( B ) to anyone who strikes my character. Let's create state A using Yanfly's Buffs & States Core:
State A note tag:
- For physical attacks only:
- For magical attacks only:
- For Certain Hit attacks only:
- For both physical and magical attacks:
- Or for every kind of attacks:
State A note tag:
- For physical attacks only:
Code:
<Custom React Effect>
//Set the condition for state B to be inflicted. It must be physical hit which affects defender's HP, and damage must be more than 0. Chance to inflict is 25% (0.25)
if (this.isPhysical() && this.isHpEffect() && value > 0 && Math.random() < 0.25){
//Add state B to the attacker
user.addState(B);}
</Custom React Effect>
- For magical attacks only:
Code:
<Custom React Effect>
//Set the condition for state B to be inflicted. It must be magical hit which affects defender's HP, and damage must be more than 0. Chance to inflict is 25% (0.25)
if (this.isMagical() && this.isHpEffect() && value > 0 && Math.random() < 0.25){
//Add state B to the attacker
user.addState(B);}
</Custom React Effect>
- For Certain Hit attacks only:
Code:
<Custom React Effect>
//Set the condition for state B to be inflicted. It must be certain hit which affects defender's HP, and damage must be more than 0. Chance to inflict is 25% (0.25)
if (this.isCertainHit() && this.isHpEffect() && value > 0 && Math.random() < 0.25){
//Add state B to the attacker
user.addState(B);}
</Custom React Effect>
- For both physical and magical attacks:
Code:
<Custom React Effect>
//Set the condition for state B to be inflicted. It must be physical or magical hit which affects defender's HP, and damage must be more than 0. Chance to inflict is 25% (0.25)
if (!this.isCertainHit() && this.isHpEffect() && value > 0 && Math.random() < 0.25){
//Add state B to the attacker
user.addState(B);}
</Custom React Effect>
- Or for every kind of attacks:
Code:
<Custom React Effect>
//Set the condition for state B to be inflicted. Should be any kind of damage which affects defender's HP, and damage must be more than 0. Chance to inflict is 25% (0.25)
if (this.isHpEffect() && value > 0 && Math.random() < 0.25){
//Add state B to the attacker
user.addState(B);}
</Custom React Effect>
Original thread: https://forums.rpgmakerweb.com/threads/state-help-chance-to-inflict-confusion-when-struck.91956/