Skip to content

Commit

Permalink
Fix multi-hit moves against Berserk/Emergency Exit/Wimp Out too
Browse files Browse the repository at this point in the history
  • Loading branch information
Marty-D committed Jun 27, 2019
1 parent 8fe6d89 commit 208c22a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions data/abilities.js
Expand Up @@ -302,10 +302,11 @@ let BattleAbilities = {
desc: "When this Pokemon has more than 1/2 its maximum HP and takes damage from an attack bringing it to 1/2 or less of its maximum HP, its Special Attack is raised by 1 stage. This effect applies after all hits from a multi-hit move; Sheer Force prevents it from activating if the move has a secondary effect.",
shortDesc: "This Pokemon's Sp. Atk is raised by 1 when it reaches 1/2 or less of its max HP.",
onAfterMoveSecondary(target, source, move) {
if (!source || source === target || !target.hp) return;
if (!source || source === target || !target.hp || !move.totalDamage) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.damage > target.maxhp / 2) {
const damage = move.multihit ? move.totalDamage : lastAttackedBy.damage;
if (target.hp <= target.maxhp / 2 && target.hp + damage > target.maxhp / 2) {
this.boost({spa: 1});
}
},
Expand Down Expand Up @@ -853,10 +854,11 @@ let BattleAbilities = {
desc: "When this Pokemon has more than 1/2 its maximum HP and takes damage bringing it to 1/2 or less of its maximum HP, it immediately switches out to a chosen ally. This effect applies after all hits from a multi-hit move; Sheer Force prevents it from activating if the move has a secondary effect. This effect applies to both direct and indirect damage, except Curse and Substitute on use, Belly Drum, Pain Split, and confusion damage.",
shortDesc: "This Pokemon switches out when it reaches 1/2 or less of its maximum HP.",
onAfterMoveSecondary(target, source, move) {
if (!source || source === target || !target.hp) return;
if (!source || source === target || !target.hp || !move.totalDamage) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.damage > target.maxhp / 2) {
const damage = move.multihit ? move.totalDamage : lastAttackedBy.damage;
if (target.hp <= target.maxhp / 2 && target.hp + damage > target.maxhp / 2) {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
target.switchFlag = true;
source.switchFlag = false;
Expand Down Expand Up @@ -4016,10 +4018,11 @@ let BattleAbilities = {
desc: "When this Pokemon has more than 1/2 its maximum HP and takes damage bringing it to 1/2 or less of its maximum HP, it immediately switches out to a chosen ally. This effect applies after all hits from a multi-hit move; Sheer Force prevents it from activating if the move has a secondary effect. This effect applies to both direct and indirect damage, except Curse and Substitute on use, Belly Drum, Pain Split, and confusion damage.",
shortDesc: "This Pokemon switches out when it reaches 1/2 or less of its maximum HP.",
onAfterMoveSecondary(target, source, move) {
if (!source || source === target || !target.hp) return;
if (!source || source === target || !target.hp || !move.totalDamage) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.damage > target.maxhp / 2) {
const damage = move.multihit ? move.totalDamage : lastAttackedBy.damage;
if (target.hp <= target.maxhp / 2 && target.hp + damage > target.maxhp / 2) {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
target.switchFlag = true;
source.switchFlag = false;
Expand Down

0 comments on commit 208c22a

Please sign in to comment.