Skip to content

Commit

Permalink
Fix Berserk/Emergency Exit/Wimp Out damage detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Marty-D committed Jun 27, 2019
1 parent 1df2fc5 commit 605ce56
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions data/abilities.js
Expand Up @@ -302,8 +302,10 @@ 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 || !move.totalDamage) return;
if (target.hp <= target.maxhp / 2 && target.hp + move.totalDamage > target.maxhp / 2) {
if (!source || source === target || !target.hp) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.damage > target.maxhp / 2) {
this.boost({spa: 1});
}
},
Expand Down Expand Up @@ -851,8 +853,10 @@ 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 || !move.totalDamage) return;
if (target.hp <= target.maxhp / 2 && target.hp + move.totalDamage > target.maxhp / 2) {
if (!source || source === target || !target.hp) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.damage > target.maxhp / 2) {
if (!this.canSwitch(target.side) || target.forceSwitchFlag || target.switchFlag) return;
target.switchFlag = true;
source.switchFlag = false;
Expand Down Expand Up @@ -4012,8 +4016,10 @@ 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 || !move.totalDamage) return;
if (target.hp <= target.maxhp / 2 && target.hp + move.totalDamage > target.maxhp / 2) {
if (!source || source === target || !target.hp) return;
const lastAttackedBy = target.getLastAttackedBy();
if (!lastAttackedBy) return;
if (target.hp <= target.maxhp / 2 && target.hp + lastAttackedBy.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 605ce56

Please sign in to comment.