Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Implement True Force Switch (Roar, Whirlwind, Circle Throw, Dragon Tail) #4881

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5979,7 +5979,21 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
return false;
}

if (switchOutTarget.hp > 0) {
if (switchOutTarget.hp && SwitchType.FORCE_SWITCH) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the this.switchType === is missing.

switchOutTarget.leaveField(this.switchType === SwitchType.FORCE_SWITCH);
const slotIndex = Utils.randIntRange(user.scene.currentBattle.getBattlerCount(), user.scene.getPlayerParty().length);
user.scene.unshiftPhase(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing code uses prependToPhase(..., MoveEndPhase) so I swapped the new code to use that as well.

new SwitchSummonPhase(
user.scene,
this.switchType,
switchOutTarget.getFieldIndex(),
slotIndex,
false,
true
)
);
}
if (switchOutTarget.hp > 0 && !SwitchType.FORCE_SWITCH) {
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
user.scene.prependToPhase(new SwitchPhase(user.scene, this.switchType, switchOutTarget.getFieldIndex(), true, true), MoveEndPhase);
return true;
Expand All @@ -5990,8 +6004,21 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
if (switchOutTarget.scene.getEnemyParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) {
return false;
}

if (switchOutTarget.hp > 0) {
if (switchOutTarget.hp && SwitchType.FORCE_SWITCH) {
switchOutTarget.leaveField(this.switchType === SwitchType.FORCE_SWITCH);
const slotIndex = Utils.randIntRange(user.scene.currentBattle.getBattlerCount(), user.scene.getEnemyParty().length);
user.scene.unshiftPhase(
new SwitchSummonPhase(
user.scene,
this.switchType,
switchOutTarget.getFieldIndex(),
slotIndex,
false,
false
)
);
}
if (switchOutTarget.hp > 0 && !SwitchType.FORCE_SWITCH) {
// for opponent switching out
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
user.scene.prependToPhase(new SwitchSummonPhase(user.scene, this.switchType, switchOutTarget.getFieldIndex(),
Expand Down Expand Up @@ -7777,11 +7804,10 @@ export function initMoves() {
.windMove(),
new AttackMove(Moves.WING_ATTACK, Type.FLYING, MoveCategory.PHYSICAL, 60, 100, 35, -1, 0, 1),
new StatusMove(Moves.WHIRLWIND, Type.NORMAL, -1, 20, -1, -6, 1)
.attr(ForceSwitchOutAttr)
.attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH)
.ignoresSubstitute()
.hidesTarget()
.windMove()
.partial(), // Should force random switches
.windMove(),
new ChargingAttackMove(Moves.FLY, Type.FLYING, MoveCategory.PHYSICAL, 90, 95, 15, -1, 0, 1)
.chargeText(i18next.t("moveTriggers:flewUpHigh", { pokemonName: "{USER}" }))
.chargeAttr(SemiInvulnerableAttr, BattlerTagType.FLYING)
Expand Down Expand Up @@ -7857,10 +7883,9 @@ export function initMoves() {
.soundBased()
.target(MoveTarget.ALL_NEAR_ENEMIES),
new StatusMove(Moves.ROAR, Type.NORMAL, -1, 20, -1, -6, 1)
.attr(ForceSwitchOutAttr)
.attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH)
.soundBased()
.hidesTarget()
.partial(), // Should force random switching
.hidesTarget(),
new StatusMove(Moves.SING, Type.NORMAL, 55, 15, -1, 0, 1)
.attr(StatusEffectAttr, StatusEffect.SLEEP)
.soundBased(),
Expand Down Expand Up @@ -9222,8 +9247,8 @@ export function initMoves() {
.attr(StatStageChangeAttr, [ Stat.ATK ], 1, true)
.attr(StatStageChangeAttr, [ Stat.SPD ], 2, true),
new AttackMove(Moves.CIRCLE_THROW, Type.FIGHTING, MoveCategory.PHYSICAL, 60, 90, 10, -1, -6, 5)
.attr(ForceSwitchOutAttr)
.partial(), // Should force random switches
.attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH)
.hidesTarget(),
new AttackMove(Moves.INCINERATE, Type.FIRE, MoveCategory.SPECIAL, 60, 100, 15, -1, 0, 5)
.target(MoveTarget.ALL_NEAR_ENEMIES)
.attr(RemoveHeldItemAttr, true),
Expand Down Expand Up @@ -9291,9 +9316,8 @@ export function initMoves() {
new AttackMove(Moves.FROST_BREATH, Type.ICE, MoveCategory.SPECIAL, 60, 90, 10, 100, 0, 5)
.attr(CritOnlyAttr),
new AttackMove(Moves.DRAGON_TAIL, Type.DRAGON, MoveCategory.PHYSICAL, 60, 90, 10, -1, -6, 5)
.attr(ForceSwitchOutAttr)
.hidesTarget()
.partial(), // Should force random switches
.attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH)
.hidesTarget(),
new SelfStatusMove(Moves.WORK_UP, Type.NORMAL, -1, 30, -1, 0, 5)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, true),
new AttackMove(Moves.ELECTROWEB, Type.ELECTRIC, MoveCategory.SPECIAL, 55, 95, 15, 100, 0, 5)
Expand Down
5 changes: 4 additions & 1 deletion src/enums/switch-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ export enum SwitchType {
/** Transfers stat stages and other effects from the returning Pokemon to the switched in Pokemon */
BATON_PASS,
/** Transfers the returning Pokemon's Substitute to the switched in Pokemon */
SHED_TAIL
SHED_TAIL,
/** Force switchout to a random party member */
FORCE_SWITCH

}
Loading