Skip to content

Restricted Sparring

psf edited this page Jan 5, 2024 · 7 revisions

WARNING: this branch isn't ready for public usage, use at your own risk. there are optimizations I want to make before I release.

Restricted Sparring Header

Introduction

Demo of Master Dojo and Restricted Sparring

This branch allows developers to add Restricted Sparring to their pokeemerald decompilation projects.

Restricted Sparring is a battle facility challenge introduced in The Isle of Armor that takes place in the Master Dojo's Battle Court. The goal is for challengers to win five consecutive battles using a team of three Pokémon of a common type.

This is not a 1:1 recreation of Restricted Sparring. The goal was able re-imagine Restricted Sparring as a Battle Facility in pokeemerald, adhering to the common conventions of pokeemerald while retaining the original spirit of the battle mode. The feature is set up in a way that the developer could replace the Battle Arena in the Battle Frontier with the Master Dojo.

Features

Monotype Check

Gif of the player attempting to enter Restricted Sparring without having a party that matches the selected type

The player's party is checked to see if it matches the selected type.

Type Records

Gif of player scrolling through list of types, showing the number of wins for each type

For each type and level mode, the game will remember the player's streak. Optionally, the game can remember what Pokémon were used by the player.

Limited Heals

Gif of player healing their Pokemon between battles

Over the course a challenge, players can only heal a limited number of times.

BP Calculation

Gif of the player getting BP after finishing a challenge

At the end of the challenge, players will receive Battle Points based on length of their streak.

Item / Sketch Restoration

Gif of Alakazam using Trick, losing its item, and then getting it back after the battle

After battle, items are restored, unless they are consumable items like Berries.

Max Difficulty

Gif of the player running into a legendary during their first fight in the facility

Restricted Sparring battles begin in the highest difficulty of Frontier Trainers, as opposed to building over the course of a streak.

Frontier Features

Record / Rest / Level

Gif of the player recording their last battle and then taking a rest

Features from pokeemerald's Battle Facilities return:

  • Record: Use the Battle Recorder to save the player's last battle.
  • Rest: Player can save and turn off the game in the middle of a challenge. Booting up the game returns to the challenge.
  • Level Mode:
    • Level 50: All opposing Pokémon are Level 50. The player can use Pokémon that are less than level 51.
    • Open Level: All opposing Pokémon match the level of the player's highest level Pokémon, but is no less than 60.

Symbols

Gif of the player getting the Gold Guts symbol

After winning 50% of the types in a Level Mode, the player recieves the Silver Guts Symbol. After winning 100% of the types in a Level mode, the player recieves the Gold Guts Symbol.

Optional

Maps / Scripts

Gif showing the maps for the BattleRoom and BattleLobby in Porymap

This branch comes with the scripts required for the entire facility to work. Optionally, the developer can pull the restricted_sparring_maps branch, which features the Lobby and Battle Room (copied from the Battle Arena). .pory files are also included for developers that utilize poryscript.

Record Used Mons

Screenshot showing the player with their cursor on the Normal type, and a window showing the Pokémon used to achieve the highest streak.

Developers can enable the ability to save the Pokémon used to set a type's streak, which will appear when the player is choosing a type.

Changes from Sword / Shield

Save Requirement

Players will need to save when starting a challenge. Resetting the game in the middle of a challenge will render a challenge invalid - the player will not recieve any rewards, and their streak will reset to zero.

Battle Points

Players will recieve Battle Points at the end of the challenge, not after every match.

Level Scaling

There is no level scaling for opposing Trainers.

Dynymax

Players cannot Dynamax.

Installation

These instructions assume that you can build pokeemerald, have a basic understanding of C, and are familiar with using the in-game scripting language. If you do not, please watch the tutorials series from Team Aqua's Hideout.

If you would like the version of this branch that comes with maps, replace restricted_sparring with restricted_sparring_maps in all following instructions.

git merge (recommended)

From the root directory of your project, run the following commands in your terminal program of choice:

git remote add psf-emerald https://github.com/PokemonSanFran/pokeemerald/ # This adds our team's `pokeemerald` branch as a remote repo.
git pull psf-emerald restricted_sparring # This pulls in the restricted_sparring feature branch

Manual merge

If your project is:

  • Too far behind pokeemerald
  • Using a different base (pokeemerald-expansion or pokefirered)
  • Some other reason that I can't think of

You can manually implement the features using the diff between this branch and vanilla pokeemerald as a guide. You will need to manually edit or create each of these files in your project to properly recreate the feature.

Warnings

Saveblock2 space

Restricted Sparring consumes 36 bytes of space in gSaveblock2, used for storing the number of wins for each types and each level mode.

If the developer enables RESTRICTED_SPARRING_MONS, Restricted Sparring consumes 684 bytes of space, storing the species and personality for the 3 Pokémon for each type and level mode. gSaveblock2 does not have 684 bytes of free space, so developers will need to free up more space before compiling.

Saving Space

A developer could save space by doing any of the following:

Remove Impact % Saved % Saved w/ RESTRICTED_SPARRING_MONS
Level Mode Players can only enter the facility with the mon level defined by the developer. 50 50
Personality Saved mons will only show a species but not the right form n/a 37
struct RestrictedSparringMon
{
    u16 species; // 2 bytes
    u32 personality; // 4 bytes
}__attribute__((packed));

struct RestrictedSparring
{
    struct RestrictedSparringMon sparringMon[FRONTIER_PARTY_SIZE]; // FRONTIER_PARTY_SIZE * 6 = 18 bytes, optional
    u8 winStreak; // 1 byte
}__attribute__((packed));

struct RestrictedSparring restrictedSparring[NUMBER_OF_MON_TYPES][FRONTIER_LVL_MODE_COUNT]; // NUMBER_OF_MON_TYPES * FRONTIER_LVL_MODE_COUNT * 19 = 684 bytes

Usage

Script Dependency

If you pulled the restricted_sparring branch, this feature will not work out of the box.

  • data/scripts/restricted_sparring.inc has all of the scripts for Restricted Sparring to work, but all of the calls to map specific scripts have been commented out. You will need to manually re-enable them.
  • data/maps/MasterDojo_Lobby/scripts.inc has the mapscripts that are required to go in the entrance or lobby of your intended Battle Facility.
    • To start a Restricted Sparring challenge, run the script RestrictedSparring_Entrance_EventScript_AskEnterChallenge.
    • To check the Restricted Sparring records, run the script RestrictedSparring_Entrance_EventScript_ShowResults.
    • To read the Restricted Sparring rules, run the script RestrictedSparring_EventScript_RulesBoard.
  • data/maps/MasterDojo_BattleRoom/scripts.inc has the mapscripts that are required to go in the arena of Battle Room of your intended Battle Facility.

All aforementioned directories contain .pory files are also included for developers that utilize poryscript.

Lobby Pre Challenge

Monotype Check

To start a challenge, the player talks to the attendant (RestrictedSparring_Entrance_EventScript_AskEnterChallenge) , chooses a level mode, and a type. If Sparring_CheckIfPartyMonMatchesType does not detect that player has three Pokémon that matches the chosen type and level, the challenge registration is refused.

Type Records

In the type menu, when the player's cursor is selecting a type that the player has previous won for the selected Level Mode, the longest streak for that type is shown by FillRestrictedSparringWinWindow. When enabled in include/config.h, when the cursor is hovering over a type that the player has won, the Pokémon used are displayed by FillRestrictedSparringTypeMons.

Battle Room

Max Difficulty

GetRandomScaledFrontierTrainerId looks at the number of consectutive challenges the player has won in that Battle Facility, and sets table that Pokémon are pulled from based on the progress - the greater the number, the more powerful the Pokémon are, up to 7. Sparring_SetChallengeNumToMax bypasses this, always skipping to the hardest possible difficulty, mimicking the difficulty of the battles from Sword and Shield.

Developers can disable this by either removing the line where Sparring_SetChallengeNumToMax is called, or having that function always return challegeNum, and battles will resume the same difficulty curve found in pokeemerald.

Limited Heals

Over the course of a challenge, players can only heal their Pokémon SPARRING_MAX_NUM_RESTORE number of times. This is set to 2 by default, but can be changed by the developer.

Type Win / Max Streak

When the player achieves SPARRING_MIN_STREAK, they are registered as having a win for that type and Level Mode. Players can keep going until they win SPARRING_MAX_STREAK times in a row, which will automatically end the battle. By default, these are 5, and 255 respectively, but can be changed by the developer.

SPARRING_MAX_STREAK

Increasing this value past 255 requires the developer to also change the winStreak on the SaveBlock, or record will overflow to 0 after win 255.

Disable Stop

Developers can comment out RestrictedSparring_BattleCourt_EventScript_StopChallenge from being called, which will allow players to continue the challenge until they retire or lose a battle. Battles over SPARRING_MAX_STREAK will not be counted towards a streak or rewards.

Item / Sketch Restoration

After every battle, RestoreNonConsumableHeldItems will restore the player's Pokémon's held item, unless the item belongs in POCKET_BERRIES. At the end of the challenge, all items are restored. To allow berries to be restored, develoeprs can disable the check for IsItemConsumable, or always return FALSE.

After every battle, if Sketch was used, ResetSketchedMoves will revert the new move to Sketch and retore its PP. Disabling this will allow Sketch to retain the sketched move until the player ends the challenge and returns to the Lobby.

Lobby Post Challenge

Battle Points

CalculateBattlePoints works as follows:

For every battle that the player wins, they recieve SPARRING_BP_BASE points. For every battle won that is a multiple of SPARRING_BP_BONUS_MATCH, the player will instead recieve SPARRING_BP_STREAK_BONUS. If the player achieves a streak of SPARRING_BP_BONUS_MATCH for that type and Level Mode for the first time, the player additionally recieves SPARRING_BP_TYPE_WIN_BONUS.

Default values are as follows, but can be changed by the developer.

Name Value
SPARRING_BP_BASE 3
SPARRING_BP_BONUS_MATCH SPARRING_MIN_STREAK (5)
SPARRING_BP_STREAK_BONUS 20
SPARRING_BP_TYPE_WIN_BONUS 30

Known Issues

Screenshot showing the player with their cursor on the Normal type, and a window showing the Pokémon used to achieve the highest streak.

There are not enough unused palettes in the overworld to support three unique mon icons. Using a dynamic overworld palette management system will resolve this issue.

Support

Frequently Asked Questions (FAQ)

n/a

Other Questions

If you have read all of the documentation here and still have questions, please ask a good question in the pokeemerald channel of the pret Discord server. You can tag pkmnsnfrn and we will try to help if we can.

Donations

If you got some use out of this feature, please consider donating. We are currently not taking any donations, so please donate to some of our favorite charities.

Contributors

  • Tested the feature from a player perspective

CHANGELOG

All changes to this project will be documented in this section. The format is based on Keep a Changelog, and this project tries to adhere to Semantic Versioning.

Unreleased

n/a

[1.0.1] - XXXX-XX-XX

Fixed