pokerogue icon indicating copy to clipboard operation
pokerogue copied to clipboard

[Move] Implement Substitute

Open innerthunder opened this issue 8 months ago • 6 comments

What are the changes?

This will implement the move Substitute

Why am I doing these changes?

Substitute is (N)

What did change?

Current Changes:

  • data/battler-tags: Added new SubstituteTag which represents the Substitute Doll effect and stores the doll's HP. This tag uses the new type SUBSTITUTE and several lapse types (including a new HIT lapse type) to trigger messages and animations.
  • data/move:
    • Added a new attribute AddSubstituteAttr for Substitute's effect.
    • Added a function that checks if a move can hit targets behind Substitutes as well as a new move flag that enables certain moves to bypass Substitute.
    • Added a new attribute RemoveAllSubstitutesAttr to Tidy Up that removes all Substitutes from the field.
  • field/pokemon:
    • Pokemon.apply() is updated so that if the Pokemon has a SubstituteTag:
      • Attack moves (unless unaffected) have their damage redirected to the SubstituteTag, removing the tag if it brings the tag's HP to 0 (or less)
      • Status moves (unless unaffected or self-targeting) will fail.
    • Added methods to manage the Pokemon's sprite and Substitute sprite (if it exists)
  • pokemon-anim-phase and enums/pokemon-anim-type: Implemented new animations for Substitute, including on-add, pre- and post-move, and on-remove animations.
  • phases: Various changes to help manage the sprite of a Pokemon's Substitute when the Pokemon switches, faints, or uses Baton Pass.
  • test/battlerTags/substitute.test: New unit test suite to test the functionality of SubstituteTag.
  • test/moves/substitute.test: New integration test suite to test the effects of Substitute in battle.
  • test/moves/tidy_up.test: Updated "clears substitutes" test to use Substitute's new implementation

Animations

With Substitute comes a new suite of in-battle animations (and a new phase to implement them)! The videos below show all of the new animations surrounding the Substitute doll in action during a double battle.

Videos

Adding Substitutes:

https://github.com/user-attachments/assets/7394e1ad-e066-4a79-a215-00c04f30ec9d

When a Pokemon uses Substitute, a new sprite is generated (with its reference attached to the respective SubstituteTag), and the Pokemon is moved "out of focus," becoming semi-transparent.

Switching Pokemon with Substitutes:

https://github.com/user-attachments/assets/edd2be80-a024-44f4-8538-bd96a7c2c2d5

  • When a Pokemon with an active Substitute switches normally, the Substitute's sprite despawns (after a short animation) before the switched-in Pokemon is summoned.
  • When a Pokemon with an active Substitute uses Baton Pass, the Substitute's sprite remains on the field and becomes visible after the move resolves.

Hitting and Removing Substitutes:

https://github.com/user-attachments/assets/884f6d08-0172-4815-9ac8-c9fb520546be

  • When a Pokemon with a Substitute uses a move, it moves into focus, uses the move, then moves back out of focus.
  • When a Pokemon's Substitute takes more than its remaining HP in damage, a fading animation despawns the Substitute's sprite and brings the Pokemon back "into focus."

KOing Pokemon with Substitutes:

https://github.com/user-attachments/assets/602954cd-b456-43c0-8594-dd3fb51ea2af

When a Pokemon faints while it has a Substitute active, the Substitute's sprite is also removed from the field.

Loading in Pokemon with Substitutes:

https://github.com/user-attachments/assets/2ab94298-7ac5-47c8-86d5-180899268e3c

When the player loads into a wave where a Pokemon started with a Substitute, the on-add animation is replayed to regenerate the Substitute sprite.

How to test the changes?

npm run test substitute npm run test tidy_up (see the "clears substitutes" test)

Checklist

  • [x] There is no overlap with another PR?
  • [x] The PR is self-contained and cannot be split into smaller PRs?
  • [x] Have I provided a clear explanation of the changes?
  • [x] Have I tested the changes (manually)?
    • [x] Are all unit tests still passing? (npm run test)
  • [x] Are the changes visual?
    • [x] Have I provided screenshots/videos of the changes?

innerthunder avatar Jun 24 '24 07:06 innerthunder