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

[Move] Fully implement Freeze Dry #4840

Merged
merged 18 commits into from
Nov 13, 2024

Conversation

geeilhan
Copy link
Contributor

@geeilhan geeilhan commented Nov 10, 2024

What are the changes the user will see?

Freeze-Dry now does the correct amount of damage.

Why am I making these changes?

While I was working on the Bug Fix of Freeze-Dry interacting with a soaked wonder guard target I noticed that "Freeze-Dry" was not fully implemented and its interaction with "Electrify" as well as "Normalize" was faulty.
(#3503)

What are the changes from a developer perspective?

If the Player Pkm gets hit by Electrify before its attack the type of Freeze-Dry changes to electric. As a result the damage multiplier should change according to the Wiki.
If the move is of type electric it naturally has a super effectiveness against water/flying type pokemon (e.g.Gyarados). After already having a 4x multiplier against Gyarados the WaterSuperEffectTypeMultiplierAttr was forcefully applied even though the multiplier was correct which resulted in a 16x damage multiplier at the end of the calculation.
A similar thing happened with Freeze-Dry under the effect of Normalize.

I have changed WaterSuperEffectTypeMultiplierAttr so it considers if Normalize is in effect or if the move has been affected by Electrify.

Screenshots/Videos

Note: If you look at the right hand side of the recording you can see the mulitplier value through console.log

Before Changes Electrify + Freeze Dry (Multiplier should be 4x but is 16x after calculation)
Electrify.Before.Fix.mp4
Before Changes Normalize + Freeze Dry (Multiplier should be 2x but is 4x)
Normalize.Before.Fix.mp4
After Changes Electrify + Freeze Dry
Electrify.After.Fix.mp4
After Changes Normalize + Freeze Dry
Normalize.After.Fix.mp4

How to test the changes?

I used this to test Normalize:

const overrides = {
  MOVESET_OVERRIDE: [ Moves.FREEZE_DRY, Moves.ELECTRIFY, Moves.SEED_BOMB, Moves.SOAK ],
  ABILITY_OVERRIDE: Abilities.NORMALIZE,
  OPP_MOVESET_OVERRIDE: Moves.SPLASH ,
  OPP_SPECIES_OVERRIDE: Species.GYARADOS,
  OPP_ABILITY_OVERRIDE: Abilities.BALL_FETCH,
  OPP_LEVEL_OVERRIDE: 10,
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;

as well as this for Electriy:

const overrides = {
  MOVESET_OVERRIDE: [ Moves.FREEZE_DRY, Moves.ELECTRIFY, Moves.SEED_BOMB, Moves.SOAK ],
  OPP_MOVESET_OVERRIDE: Moves.ELECTRIFY ,
  OPP_SPECIES_OVERRIDE: Species.GYARADOS,
  OPP_ABILITY_OVERRIDE: Abilities.BALL_FETCH,
  OPP_LEVEL_OVERRIDE: 10,
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;

Also some automated tests have been added to src/test/moves/freeze_dry.test.ts in order to test 0.25x dmg multiplier as well as 4x dmg

Checklist

  • I'm using beta as my base branch
  • There is no overlap with another PR?
  • The PR is self-contained and cannot be split into smaller PRs?
  • Have I provided a clear explanation of the changes?
  • Have I considered writing automated tests for the issue?
  • If I have text, did I make it translatable and add a key in the English locale file(s)?
  • Have I tested the changes (manually)?
    • Are all unit tests still passing? (npm run test)
  • Are the changes visual?
    • Have I provided screenshots/videos of the changes?

src/data/move.ts Outdated Show resolved Hide resolved
src/test/moves/freeze_dry.test.ts Show resolved Hide resolved
src/data/move.ts Show resolved Hide resolved
@Tempo-anon Tempo-anon added Move Affects a move P2 Bug Minor. Non crashing Incorrect move/ability/interaction labels Nov 10, 2024
src/data/move.ts Show resolved Hide resolved
src/data/move.ts Outdated Show resolved Hide resolved
src/test/moves/freeze_dry.test.ts Show resolved Hide resolved
Copy link
Collaborator

@innerthunder innerthunder left a comment

Choose a reason for hiding this comment

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

I feel like there's a cleaner way to do this. The Normalize and Electrify interactions kind of suggest that Freeze Dry directly sets the type multiplier to 2 against the Water type (while the normal type matchup still applies for the target's other types). The way it behaves in inverse battles seems to suggest the same.

I'm not totally sure if this is actually the case and, if so, how well the attribute's parent class supports this, but I'd rather avoid the individual ability checks if possible.

@geeilhan
Copy link
Contributor Author

geeilhan commented Nov 11, 2024

I feel like there's a cleaner way to do this. The Normalize and Electrify interactions kind of suggest that Freeze Dry directly sets the type multiplier to 2 against the Water type (while the normal type matchup still applies for the target's other types). The way it behaves in inverse battles seems to suggest the same.

I'm not totally sure if this is actually the case and, if so, how well the attribute's parent class supports this, but I'd rather avoid the individual ability checks if possible.

All other classes that have VariableMoveTypeMultiplierAttr as a parent also force values like this. This seems to be a characteristic of this class. Either way it looks like l can't go around checking the conditions like this.
Moving this check somewhere else would make VariableMoveTypeMultiplierAttr children classes obsolete. (They would only serve as flags with no own functionality)

Example:

pokerogue/src/data/move.ts

Lines 4972 to 4978 in e5e3926

export class FlyingTypeMultiplierAttr extends VariableMoveTypeMultiplierAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
multiplier.value *= target.getAttackTypeEffectiveness(Type.FLYING, user);
return true;
}
}

pokerogue/src/data/move.ts

Lines 4952 to 4970 in e5e3926

export class IceNoEffectTypeAttr extends VariableMoveTypeMultiplierAttr {
/**
* Checks to see if the Target is Ice-Type or not. If so, the move will have no effect.
* @param user n/a
* @param target The {@linkcode Pokemon} targeted by the move
* @param move n/a
* @param args `[0]` a {@linkcode Utils.NumberHolder | NumberHolder} containing a type effectiveness multiplier
* @returns `true` if this Ice-type immunity applies; `false` otherwise
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const multiplier = args[0] as Utils.NumberHolder;
if (target.isOfType(Type.ICE)) {
multiplier.value = 0;
return true;
}
return false;
}
}

Edit: I agree that this looks not so clean so I reinformed myself on how Freeze-Drys calculates its damage multiplier and rewrote apply() so it looks more general now.

src/data/move.ts Outdated Show resolved Hide resolved
src/data/move.ts Outdated Show resolved Hide resolved
src/data/move.ts Outdated Show resolved Hide resolved
@innerthunder innerthunder changed the title Fully implement Freeze-dry [Move] Fully implement Freeze Dry Nov 12, 2024
src/data/move.ts Outdated Show resolved Hide resolved
src/test/moves/freeze_dry.test.ts Show resolved Hide resolved
@Tempo-anon Tempo-anon merged commit 0c521bb into pagefaultgames:beta Nov 13, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Move Affects a move P2 Bug Minor. Non crashing Incorrect move/ability/interaction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants