Shield Dust does not block self-boosting secondaries

Refactor TrySecondaryHit to become ModifySecondaries instead to allow for
proper behavior.
This commit is contained in:
Kevin Lau 2015-08-30 19:54:31 -07:00
parent 449f0aaa16
commit 79732b414e
3 changed files with 10 additions and 7 deletions

View File

@ -2323,11 +2323,11 @@ Battle = (function () {
ModifyAtk: 1, ModifyDef: 1, ModifySpA: 1, ModifySpD: 1, ModifySpe: 1,
ModifyBoost: 1,
ModifyDamage: 1,
ModifySecondaries: 1,
ModifyWeight: 1,
TryHit: 1,
TryHitSide: 1,
TryMove: 1,
TrySecondaryHit: 1,
Hit: 1,
Boost: 1,
DragOut: 1

View File

@ -2350,9 +2350,11 @@ exports.BattleAbilities = {
},
"shielddust": {
shortDesc: "This Pokemon is not affected by the secondary effect of another Pokemon's attack.",
onTrySecondaryHit: function () {
onModifySecondaries: function (secondaries) {
this.debug('Shield Dust prevent secondary');
return null;
return secondaries.filter(function (effect) {
return !!effect.self;
});
},
id: "shielddust",
name: "Shield Dust",

View File

@ -551,12 +551,13 @@ exports.BattleScripts = {
this.moveHit(pokemon, pokemon, move, moveData.self, isSecondary, true);
}
}
if (moveData.secondaries && this.runEvent('TrySecondaryHit', target, pokemon, moveData)) {
if (moveData.secondaries) {
var secondaryRoll;
for (var i = 0; i < moveData.secondaries.length; i++) {
var secondaries = this.runEvent('ModifySecondaries', target, pokemon, moveData, moveData.secondaries.slice());
for (var i = 0; i < secondaries.length; i++) {
secondaryRoll = this.random(100);
if (typeof moveData.secondaries[i].chance === 'undefined' || secondaryRoll < moveData.secondaries[i].chance) {
this.moveHit(target, pokemon, move, moveData.secondaries[i], true, isSelf);
if (typeof secondaries[i].chance === 'undefined' || secondaryRoll < secondaries[i].chance) {
this.moveHit(target, pokemon, move, secondaries[i], true, isSelf);
}
}
}