mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-31 05:07:11 +00:00
Attempt fixing some issues with move effects
This commit is contained in:
parent
68282d28da
commit
3afd43375a
@ -1324,23 +1324,26 @@ class MoveEffectPhase extends PokemonPhase {
|
|||||||
|
|
||||||
const hitResult = !isProtected ? target.apply(user, this.move) : HitResult.NO_EFFECT;
|
const hitResult = !isProtected ? target.apply(user, this.move) : HitResult.NO_EFFECT;
|
||||||
|
|
||||||
if (hitResult !== HitResult.NO_EFFECT && hitResult !== HitResult.FAIL) {
|
if (hitResult !== HitResult.FAIL) {
|
||||||
const chargeEffect = !!this.move.getMove().getAttrs(ChargeAttr).find(ca => (ca as ChargeAttr).chargeEffect);
|
const chargeEffect = !!this.move.getMove().getAttrs(ChargeAttr).find(ca => (ca as ChargeAttr).chargeEffect);
|
||||||
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
||||||
if (!chargeEffect)
|
if (!chargeEffect)
|
||||||
applyMoveAttrs(MoveEffectAttr, user, target, this.move.getMove());
|
applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && (attr as MoveEffectAttr).selfTarget, user, target, this.move.getMove());
|
||||||
if (hitResult < HitResult.NO_EFFECT) {
|
if (hitResult !== HitResult.NO_EFFECT) {
|
||||||
const flinched = new Utils.BooleanHolder(false);
|
applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveEffectAttr && !(attr as MoveEffectAttr).selfTarget, user, target, this.move.getMove());
|
||||||
user.scene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched);
|
if (hitResult < HitResult.NO_EFFECT) {
|
||||||
if (flinched.value)
|
const flinched = new Utils.BooleanHolder(false);
|
||||||
target.addTag(BattlerTagType.FLINCHED, undefined, this.move.moveId, user.id);
|
user.scene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched);
|
||||||
}
|
if (flinched.value)
|
||||||
if (!isProtected && !chargeEffect) {
|
target.addTag(BattlerTagType.FLINCHED, undefined, this.move.moveId, user.id);
|
||||||
applyFilteredMoveAttrs((attr: MoveAttr) => attr instanceof MoveHitEffectAttr && (!!target.hp || (attr as MoveHitEffectAttr).selfTarget), user, target, this.move.getMove());
|
}
|
||||||
if (!target.isFainted())
|
if (!isProtected && !chargeEffect) {
|
||||||
applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, hitResult);
|
applyMoveAttrs(MoveHitEffectAttr, user, target, this.move.getMove());
|
||||||
if (this.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT))
|
if (!target.isFainted())
|
||||||
this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target.getFieldIndex());
|
applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, hitResult);
|
||||||
|
if (this.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT))
|
||||||
|
this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target.getFieldIndex());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1773,7 +1776,7 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
else if (nonFaintedPartyMemberCount >= this.scene.currentBattle.getBattlerCount())
|
else if (nonFaintedPartyMemberCount >= this.scene.currentBattle.getBattlerCount())
|
||||||
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, true, false));
|
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, true, false));
|
||||||
else if (nonFaintedPartyMemberCount === 1 && this.scene.currentBattle.double)
|
else if (nonFaintedPartyMemberCount === 1 && this.scene.currentBattle.double)
|
||||||
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, false));
|
this.scene.unshiftPhase(new ToggleDoublePositionPhase(this.scene, true));
|
||||||
} else
|
} else
|
||||||
this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex));
|
this.scene.unshiftPhase(new VictoryPhase(this.scene, this.battlerIndex));
|
||||||
|
|
||||||
|
@ -849,6 +849,15 @@ export class MoveHitEffectAttr extends MoveAttr {
|
|||||||
|
|
||||||
this.selfTarget = !!selfTarget;
|
this.selfTarget = !!selfTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
|
||||||
|
return !!(this.selfTarget ? user.hp : target.hp)
|
||||||
|
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) || move.hasFlag(MoveFlags.IGNORE_PROTECT));
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
|
||||||
|
return this.canApply(user, target, move, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HighCritAttr extends MoveAttr {
|
export class HighCritAttr extends MoveAttr {
|
||||||
@ -1333,7 +1342,7 @@ export class SolarBeamChargeAttr extends ChargeAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StatChangeAttr extends MoveEffectAttr {
|
export class StatChangeAttr extends MoveHitEffectAttr {
|
||||||
public stats: BattleStat[];
|
public stats: BattleStat[];
|
||||||
public levels: integer;
|
public levels: integer;
|
||||||
|
|
||||||
@ -1651,7 +1660,7 @@ export class DisableMoveAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FrenzyAttr extends MoveEffectAttr {
|
export class FrenzyAttr extends MoveHitEffectAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user