Properly fix Emergency Exit and related effects

This commit is contained in:
Marty-D 2016-12-15 09:57:06 -05:00
parent 8213dd3974
commit e1c43d4bb4
2 changed files with 4 additions and 10 deletions

View File

@ -848,18 +848,10 @@ exports.BattleAbilities = {
if (!source || source === target || !target.hp || !move.totalDamage) return;
if (target.hp <= target.maxhp / 2 && target.hp + move.totalDamage > target.maxhp / 2) {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
target.addVolatile('emergencyexit');
}
},
effect: {
onUpdatePriority: -10,
onUpdate: function (target) {
target.removeVolatile('emergencyexit');
if (target.hp > target.maxhp / 2) return;
target.switchFlag = true;
this.effectData.source.switchFlag = false;
source.switchFlag = false;
this.add('-activate', target, 'ability: Emergency Exit');
},
}
},
id: "emergencyexit",
name: "Emergency Exit",

View File

@ -460,6 +460,8 @@ exports.BattleScripts = {
if (!damage && damage !== 0) return damage;
this.eachEvent('Update');
if (target && !move.negateSecondary && !(pokemon.hasAbility('sheerforce') && pokemon.volatiles['sheerforce'])) {
this.singleEvent('AfterMoveSecondary', move, null, target, pokemon, move);
this.runEvent('AfterMoveSecondary', target, pokemon, move);