2018-08-15 15:49:50 +02:00
# include "global.h"
2018-08-25 19:59:47 +02:00
# include "battle_dome.h"
2018-08-15 15:49:50 +02:00
# include "battle.h"
2019-12-18 08:32:52 +01:00
# include "battle_main.h"
2018-08-15 15:49:50 +02:00
# include "battle_setup.h"
2018-08-25 18:46:15 +02:00
# include "battle_tower.h"
2018-10-30 22:17:03 +01:00
# include "frontier_util.h"
2018-08-15 23:04:46 +02:00
# include "battle_message.h"
2018-08-15 15:49:50 +02:00
# include "event_data.h"
# include "overworld.h"
# include "util.h"
2019-09-09 03:07:54 +02:00
# include "malloc.h"
2018-08-15 23:04:46 +02:00
# include "string_util.h"
# include "random.h"
2018-08-18 00:54:18 +02:00
# include "task.h"
# include "main.h"
# include "gpu_regs.h"
# include "text.h"
# include "bg.h"
# include "window.h"
2019-02-08 18:08:25 +01:00
# include "strings.h"
2018-08-18 00:54:18 +02:00
# include "palette.h"
# include "decompress.h"
2018-12-24 00:02:29 +01:00
# include "party_menu.h"
2018-08-18 00:54:18 +02:00
# include "menu.h"
2018-08-18 19:52:25 +02:00
# include "sound.h"
2018-08-18 00:54:18 +02:00
# include "pokemon_icon.h"
2019-04-04 23:53:06 +02:00
# include "data.h"
2018-08-19 17:13:05 +02:00
# include "international_string_util.h"
2018-08-19 01:06:10 +02:00
# include "trainer_pokemon_sprites.h"
2018-08-21 23:36:59 +02:00
# include "scanline_effect.h"
2020-08-13 23:42:12 +02:00
# include "script_pokemon_util.h"
2018-10-21 09:24:57 +02:00
# include "graphics.h"
2019-11-29 03:09:35 +01:00
# include "constants/battle_dome.h"
2019-11-21 03:46:29 +01:00
# include "constants/frontier_util.h"
2018-08-15 23:04:46 +02:00
# include "constants/moves.h"
# include "constants/trainers.h"
# include "constants/abilities.h"
2018-08-18 19:52:25 +02:00
# include "constants/songs.h"
2018-08-25 19:59:47 +02:00
# include "constants/battle_frontier.h"
2018-08-29 20:38:54 +02:00
# include "constants/rgb.h"
2018-08-18 19:52:25 +02:00
2020-01-05 16:50:32 +01:00
// Enough space to hold 2 match info cards worth of trainers and their parties
# define NUM_INFOCARD_SPRITES ((FRONTIER_PARTY_SIZE + 1) * 4)
# define NUM_INFOCARD_TRAINERS 2
// An 'Info Card' is a trainer or match information page that can be viewed on the Tourney Tree
struct TourneyTreeInfoCard
2018-08-18 00:54:18 +02:00
{
2020-09-02 15:49:04 +02:00
u8 spriteIds [ NUM_INFOCARD_SPRITES ] ;
2020-01-05 16:50:32 +01:00
u8 pos ;
u8 tournamentIds [ NUM_INFOCARD_TRAINERS ] ;
2018-08-18 00:54:18 +02:00
} ;
2020-01-05 16:50:32 +01:00
struct TourneyTreeLineSection
2018-08-25 19:59:47 +02:00
{
u8 x ;
u8 y ;
u16 src ;
} ;
2019-12-18 08:32:52 +01:00
# define DOME_TRAINERS gSaveBlock2Ptr->frontier.domeTrainers
# define DOME_MONS gSaveBlock2Ptr->frontier.domeMonIds
2020-01-05 16:50:32 +01:00
# define tState data[0]
// Task data for Task_ShowTourneyTree
# define tNotInteractive data[1]
# define tIsPrevTourneyTree data[4]
// Task data for Task_ShowTourneyInfoCard
# define tTournamentId data[1]
# define tMode data[2]
# define tPrevTaskId data[3]
2022-06-01 18:41:57 +02:00
# define EFFECTIVENESS_MODE_GOOD 0
# define EFFECTIVENESS_MODE_BAD 1
# define EFFECTIVENESS_MODE_AI_VS_AI 2
2022-05-21 21:21:50 +02:00
static u8 GetDomeTrainerMonIvs ( u16 ) ;
static void SwapDomeTrainers ( int , int , u16 * ) ;
static void CalcDomeMonStats ( u16 , int , int , u8 , u8 , int * ) ;
static void CreateDomeOpponentMons ( u16 ) ;
2022-06-01 18:41:57 +02:00
static int SelectOpponentMons_Good ( u16 , bool8 ) ;
static int SelectOpponentMons_Bad ( u16 , bool8 ) ;
2022-05-21 21:21:50 +02:00
static int GetTypeEffectivenessPoints ( int , int , int ) ;
static int SelectOpponentMonsFromParty ( int * , bool8 ) ;
static void Task_ShowTourneyInfoCard ( u8 ) ;
static void Task_HandleInfoCardInput ( u8 ) ;
static u8 Task_GetInfoCardInput ( u8 ) ;
2019-12-21 10:27:12 +01:00
static void SetFacilityTrainerAndMonPtrs ( void ) ;
2022-05-21 21:21:50 +02:00
static int TrainerIdToTournamentId ( u16 ) ;
2018-08-25 19:59:47 +02:00
static u16 TrainerIdOfPlayerOpponent ( void ) ;
2022-05-21 21:21:50 +02:00
static void Task_ShowTourneyTree ( u8 ) ;
static void Task_HandleStaticTourneyTreeInput ( u8 ) ;
2020-01-05 16:50:32 +01:00
static void CB2_TourneyTree ( void ) ;
static void VblankCb_TourneyInfoCard ( void ) ;
2022-05-21 21:21:50 +02:00
static void DisplayMatchInfoOnCard ( u8 , u8 ) ;
static void DisplayTrainerInfoOnCard ( u8 , u8 ) ;
2019-12-21 10:27:12 +01:00
static int BufferDomeWinString ( u8 , u8 * ) ;
2018-08-25 19:59:47 +02:00
static u8 GetDomeBrainTrainerPicId ( void ) ;
static u8 GetDomeBrainTrainerClass ( void ) ;
2022-05-21 21:21:50 +02:00
static void CopyDomeBrainTrainerName ( u8 * ) ;
static void CopyDomeTrainerName ( u8 * , u16 ) ;
2020-01-05 16:50:32 +01:00
static void HblankCb_TourneyTree ( void ) ;
static void VblankCb_TourneyTree ( void ) ;
2022-05-21 21:21:50 +02:00
static u8 UpdateTourneyTreeCursor ( u8 ) ;
static void DecideRoundWinners ( u8 ) ;
static u8 GetOpposingNPCTournamentIdByRound ( u8 , u8 ) ;
2020-01-05 16:50:32 +01:00
static void DrawTourneyAdvancementLine ( u8 , u8 ) ;
2022-05-21 21:21:50 +02:00
static void SpriteCb_HorizontalScrollArrow ( struct Sprite * ) ;
static void SpriteCb_VerticalScrollArrow ( struct Sprite * ) ;
2019-02-08 18:08:25 +01:00
static void InitDomeChallenge ( void ) ;
static void GetDomeData ( void ) ;
static void SetDomeData ( void ) ;
static void BufferDomeRoundText ( void ) ;
static void BufferDomeOpponentName ( void ) ;
static void InitDomeOpponentParty ( void ) ;
2018-08-26 15:51:14 +02:00
static void ShowDomeOpponentInfo ( void ) ;
2019-02-08 18:08:25 +01:00
static void ShowDomeTourneyTree ( void ) ;
2020-01-05 16:50:32 +01:00
static void ShowPreviousDomeTourneyTree ( void ) ;
2019-02-08 18:08:25 +01:00
static void SetDomeOpponentId ( void ) ;
static void SetDomeOpponentGraphicsId ( void ) ;
static void ShowNonInteractiveDomeTourneyTree ( void ) ;
static void ResolveDomeRoundWinners ( void ) ;
2019-11-29 03:09:35 +01:00
static void SaveDomeChallenge ( void ) ;
static void IncrementDomeStreaks ( void ) ;
static void ResetSketchedMoves ( void ) ;
2019-02-08 18:08:25 +01:00
static void RestoreDomePlayerPartyHeldItems ( void ) ;
2019-12-18 08:32:52 +01:00
static void ReduceDomePlayerPartyToSelectedMons ( void ) ;
2019-02-08 18:08:25 +01:00
static void GetPlayerSeededBeforeOpponent ( void ) ;
static void BufferLastDomeWinnerName ( void ) ;
2019-12-18 08:32:52 +01:00
static void InitRandomTourneyTreeResults ( void ) ;
2018-08-26 15:51:14 +02:00
static void InitDomeTrainers ( void ) ;
2018-08-26 14:40:36 +02:00
2019-12-18 08:32:52 +01:00
EWRAM_DATA u32 gPlayerPartyLostHP = 0 ; // never read
static EWRAM_DATA u32 sPlayerPartyMaxHP = 0 ; // never read
2020-01-05 16:50:32 +01:00
static EWRAM_DATA struct TourneyTreeInfoCard * sInfoCard = { 0 } ;
2018-08-25 19:59:47 +02:00
static EWRAM_DATA u8 * sTilemapBuffer = NULL ;
2020-01-05 16:50:32 +01:00
// Each move has an array of points for different move characteristics which contribute to a tourney trainers listed battle style (see sBattleStyleThresholds)
// All move points are either 1 or 0, so theyre essentially flags saying whether or not the move has that characteristic
static const u8 sBattleStyleMovePoints [ MOVES_COUNT ] [ NUM_MOVE_POINT_TYPES ] =
2019-12-21 10:27:12 +01:00
{
[ MOVE_NONE ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_POUND ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_KARATE_CHOP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_DOUBLE_SLAP ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_COMET_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_MEGA_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_PAY_DAY ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FIRE_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_ICE_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_THUNDER_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SCRATCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2021-01-01 00:57:36 +01:00
[ MOVE_VISE_GRIP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_GUILLOTINE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_RAZOR_WIND ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SWORDS_DANCE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 } ,
[ MOVE_CUT ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_GUST ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_WING_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_WHIRLWIND ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FLY ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_BIND ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SLAM ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_VINE_WHIP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_STOMP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DOUBLE_KICK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_MEGA_KICK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_JUMP_KICK ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_ROLLING_KICK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SAND_ATTACK ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_HEADBUTT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_HORN_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FURY_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_HORN_DRILL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_TACKLE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_BODY_SLAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_WRAP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_TAKE_DOWN ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_THRASH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DOUBLE_EDGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TAIL_WHIP ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_POISON_STING ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_TWINEEDLE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_PIN_MISSILE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_LEER ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_BITE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_GROWL ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ROAR ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SING ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_SUPERSONIC ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_SONIC_BOOM ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_DISABLE ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_ACID ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_EMBER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FLAMETHROWER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_MIST ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_WATER_GUN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_HYDRO_PUMP ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SURF ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_ICE_BEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BLIZZARD ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_PSYBEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BUBBLE_BEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_AURORA_BEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_HYPER_BEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_PECK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_DRILL_PECK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SUBMISSION ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_LOW_KICK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_COUNTER ] = { [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_SEISMIC_TOSS ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_STRENGTH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ABSORB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_MEGA_DRAIN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_LEECH_SEED ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_GROWTH ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_RAZOR_LEAF ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SOLAR_BEAM ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_POISON_POWDER ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_STUN_SPORE ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_SLEEP_POWDER ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_PETAL_DANCE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_STRING_SHOT ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 } ,
[ MOVE_DRAGON_RAGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FIRE_SPIN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_THUNDER_SHOCK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_THUNDERBOLT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_THUNDER_WAVE ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_THUNDER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_ROCK_THROW ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_EARTHQUAKE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_FISSURE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LUCK ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_DIG ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TOXIC ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_CONFUSION ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_PSYCHIC ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_HYPNOSIS ] = { [ MOVE_POINTS_COMBO ] = 1 } ,
[ MOVE_MEDITATE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_AGILITY ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_QUICK_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_RAGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_TELEPORT ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_NIGHT_SHADE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_MIMIC ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SCREECH ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 } ,
[ MOVE_DOUBLE_TEAM ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_RECOVER ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_HARDEN ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_MINIMIZE ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_SMOKESCREEN ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CONFUSE_RAY ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_WITHDRAW ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_DEFENSE_CURL ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_BARRIER ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_LIGHT_SCREEN ] = { [ MOVE_POINTS_DEF ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_HAZE ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_REFLECT ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_FOCUS_ENERGY ] = { [ MOVE_POINTS_COMBO ] = 1 } ,
[ MOVE_BIDE ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_METRONOME ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_MIRROR_MOVE ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_SELF_DESTRUCT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_EGG_BOMB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_LICK ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SMOG ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SLUDGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BONE_CLUB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FIRE_BLAST ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_WATERFALL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CLAMP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SWIFT ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SKULL_BASH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_SPIKE_CANNON ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CONSTRICT ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_AMNESIA ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_KINESIS ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 } ,
[ MOVE_SOFT_BOILED ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2021-01-01 00:57:36 +01:00
[ MOVE_HIGH_JUMP_KICK ] = { [ MOVE_POINTS_DMG ] = 1 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_GLARE ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 } ,
[ MOVE_DREAM_EATER ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_POISON_GAS ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_BARRAGE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_LEECH_LIFE ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_LOVELY_KISS ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_SKY_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_TRANSFORM ] = { [ MOVE_POINTS_RARE ] = 1 } ,
[ MOVE_BUBBLE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DIZZY_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SPORE ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_FLASH ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_PSYWAVE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SPLASH ] = { [ MOVE_POINTS_RARE ] = 1 } ,
[ MOVE_ACID_ARMOR ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_CRABHAMMER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_EXPLOSION ] = { [ MOVE_POINTS_RISKY ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_FURY_SWIPES ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_BONEMERANG ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_REST ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 } ,
[ MOVE_ROCK_SLIDE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_HYPER_FANG ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SHARPEN ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_CONVERSION ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_TRI_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SUPER_FANG ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SLASH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SUBSTITUTE ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_STRUGGLE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } , // Odd that this is assigned qualities
[ MOVE_SKETCH ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_TRIPLE_KICK ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_THIEF ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SPIDER_WEB ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_MIND_READER ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_NIGHTMARE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FLAME_WHEEL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SNORE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_CURSE ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_FLAIL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CONVERSION_2 ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_AEROBLAST ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_COTTON_SPORE ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 } ,
[ MOVE_REVERSAL ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SPITE ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_RISKY ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_POWDER_SNOW ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_PROTECT ] = { [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 } ,
[ MOVE_MACH_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_SCARY_FACE ] = { 0 } ,
2021-01-01 00:57:36 +01:00
[ MOVE_FEINT_ATTACK ] = { [ MOVE_POINTS_DMG ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_SWEET_KISS ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_BELLY_DRUM ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_SLUDGE_BOMB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MUD_SLAP ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_OCTAZOOKA ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SPIKES ] = { [ MOVE_POINTS_COMBO ] = 1 } ,
[ MOVE_ZAP_CANNON ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_LUCK ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FORESIGHT ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_DESTINY_BOND ] = { [ MOVE_POINTS_RISKY ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_PERISH_SONG ] = { [ MOVE_POINTS_RISKY ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_ICY_WIND ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DETECT ] = { [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_BONE_RUSH ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_LOCK_ON ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_OUTRAGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_SANDSTORM ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_GIGA_DRAIN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_ENDURE ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_CHARM ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ROLLOUT ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_FALSE_SWIPE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SWAGGER ] = { [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MILK_DRINK ] = { [ MOVE_POINTS_HEAL ] = 1 } ,
[ MOVE_SPARK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FURY_CUTTER ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_STEEL_WING ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MEAN_LOOK ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_ATTRACT ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SLEEP_TALK ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_HEAL_BELL ] = { [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_RETURN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_PRESENT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_FRUSTRATION ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SAFEGUARD ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_PAIN_SPLIT ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SACRED_FIRE ] = { [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MAGNITUDE ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_DYNAMIC_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LUCK ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MEGAHORN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_DRAGON_BREATH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BATON_PASS ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_RARE ] = 1 } ,
[ MOVE_ENCORE ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_PURSUIT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_RAPID_SPIN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SWEET_SCENT ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_IRON_TAIL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_METAL_CLAW ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_VITAL_THROW ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_MORNING_SUN ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SYNTHESIS ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_MOONLIGHT ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_HIDDEN_POWER ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CROSS_CHOP ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_TWISTER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_RAIN_DANCE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SUNNY_DAY ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_CRUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MIRROR_COAT ] = { [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_PSYCH_UP ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_EXTREME_SPEED ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_ANCIENT_POWER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SHADOW_BALL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FUTURE_SIGHT ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_ROCK_SMASH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_WHIRLPOOL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BEAT_UP ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FAKE_OUT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_UPROAR ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_STOCKPILE ] = { [ MOVE_POINTS_COMBO ] = 1 } ,
[ MOVE_SPIT_UP ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_SWALLOW ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 } ,
[ MOVE_HEAT_WAVE ] = { [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_HAIL ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_TORMENT ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FLATTER ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_WILL_O_WISP ] = { [ MOVE_POINTS_STATUS ] = 1 } ,
[ MOVE_MEMENTO ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FACADE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FOCUS_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
2021-01-01 00:57:36 +01:00
[ MOVE_SMELLING_SALTS ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_FOLLOW_ME ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_NATURE_POWER ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_CHARGE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TAUNT ] = { [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_HELPING_HAND ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TRICK ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ROLE_PLAY ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_WISH ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ASSIST ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_INGRAIN ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_SUPERPOWER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_MAGIC_COAT ] = { [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_RECYCLE ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_REVENGE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_BRICK_BREAK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_YAWN ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_KNOCK_OFF ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_ENDEAVOR ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_ERUPTION ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SKILL_SWAP ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_IMPRISON ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_REFRESH ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_GRUDGE ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SNATCH ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LUCK ] = 1 } ,
[ MOVE_SECRET_POWER ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DIVE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ARM_THRUST ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CAMOUFLAGE ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TAIL_GLOW ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_LUSTER_PURGE ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MIST_BALL ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_FEATHER_DANCE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_TEETER_DANCE ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_BLAZE_KICK ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MUD_SPORT ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ICE_BALL ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_NEEDLE_ARM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SLACK_OFF ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_HYPER_VOICE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_POISON_FANG ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_CRUSH_CLAW ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BLAST_BURN ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_HYDRO_CANNON ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_METEOR_MASH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_ASTONISH ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_WEATHER_BALL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_AROMATHERAPY ] = { [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_FAKE_TEARS ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_AIR_CUTTER ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_OVERHEAT ] = { [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_ODOR_SLEUTH ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_ROCK_TOMB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SILVER_WIND ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_METAL_SOUND ] = { 0 } ,
[ MOVE_GRASS_WHISTLE ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_TICKLE ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_COSMIC_POWER ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_WATER_SPOUT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_SIGNAL_BEAM ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SHADOW_PUNCH ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_EXTRASENSORY ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SKY_UPPERCUT ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SAND_TOMB ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_SHEER_COLD ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LUCK ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_MUDDY_WATER ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_BULLET_SEED ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_AERIAL_ACE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_ICICLE_SPEAR ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_IRON_DEFENSE ] = { [ MOVE_POINTS_DEF ] = 1 } ,
[ MOVE_BLOCK ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
2019-12-21 10:27:12 +01:00
[ MOVE_HOWL ] = { 0 } ,
2020-01-05 16:50:32 +01:00
[ MOVE_DRAGON_CLAW ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_FRENZY_PLANT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_BULK_UP ] = { [ MOVE_POINTS_COMBO ] = 1 } ,
[ MOVE_BOUNCE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_MUD_SHOT ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_POISON_TAIL ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_COVET ] = { [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_VOLT_TACKLE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ MOVE_MAGICAL_LEAF ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_WATER_SPORT ] = { [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_CALM_MIND ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_LEAF_BLADE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 } ,
[ MOVE_DRAGON_DANCE ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 } ,
[ MOVE_ROCK_BLAST ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_SHOCK_WAVE ] = { [ MOVE_POINTS_DMG ] = 1 } ,
[ MOVE_WATER_PULSE ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_ACCURATE ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
[ MOVE_DOOM_DESIRE ] = { [ MOVE_POINTS_RARE ] = 1 , [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 } ,
[ MOVE_PSYCHO_BOOST ] = { [ MOVE_POINTS_DMG ] = 1 , [ MOVE_POINTS_POWERFUL ] = 1 , [ MOVE_POINTS_STRONG ] = 1 , [ MOVE_POINTS_LOW_PP ] = 1 , [ MOVE_POINTS_EFFECT ] = 1 } ,
2018-08-19 22:26:07 +02:00
} ;
2020-09-02 15:49:04 +02:00
// This array is searched in-order to determine what battle style a tourney trainer uses.
2020-01-05 16:50:32 +01:00
// If the sum of the points for the party's moves meets/exceeds all the point totals of an element, then they use that battle style
static const u8 sBattleStyleThresholds [ NUM_BATTLE_STYLES - 1 ] [ NUM_MOVE_POINT_TYPES ] =
{
[ DOME_BATTLE_STYLE_RISKY ] = { [ MOVE_POINTS_RISKY ] = 1 } ,
[ DOME_BATTLE_STYLE_STALL ] = { [ MOVE_POINTS_HEAL ] = 2 , [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_DEF ] = 2 } ,
[ DOME_BATTLE_STYLE_VARIED ] = { [ MOVE_POINTS_COMBO ] = 1 , [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_STATUS ] = 1 , [ MOVE_POINTS_DEF ] = 1 } ,
[ DOME_BATTLE_STYLE_COMBO_HIGH ] = { [ MOVE_POINTS_COMBO ] = 3 } ,
[ DOME_BATTLE_STYLE_RARE_MOVES ] = { [ MOVE_POINTS_RARE ] = 2 } ,
[ DOME_BATTLE_STYLE_RARE_MOVE ] = { [ MOVE_POINTS_RARE ] = 1 } ,
[ DOME_BATTLE_STYLE_HP ] = { [ MOVE_POINTS_HEAL ] = 3 } ,
[ DOME_BATTLE_STYLE_STORE_POWER ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_HEAL ] = 1 } ,
[ DOME_BATTLE_STYLE_ENFEEBLE_LOW ] = { [ MOVE_POINTS_STAT_LOWER ] = 1 , [ MOVE_POINTS_STATUS ] = 1 } ,
[ DOME_BATTLE_STYLE_LUCK ] = { [ MOVE_POINTS_LUCK ] = 2 } ,
[ DOME_BATTLE_STYLE_REGAL ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_DEF ] = 1 , [ MOVE_POINTS_POPULAR ] = 1 , [ MOVE_POINTS_STRONG ] = 1 } ,
[ DOME_BATTLE_STYLE_LOW_PP ] = { [ MOVE_POINTS_LOW_PP ] = 3 } ,
[ DOME_BATTLE_STYLE_STATUS_ATK ] = { [ MOVE_POINTS_STAT_RAISE ] = 1 , [ MOVE_POINTS_STATUS ] = 1 } ,
[ DOME_BATTLE_STYLE_ENDURE ] = { [ MOVE_POINTS_HEAL ] = 2 , [ MOVE_POINTS_DEF ] = 2 } ,
[ DOME_BATTLE_STYLE_STATUS ] = { [ MOVE_POINTS_STATUS ] = 2 } ,
[ DOME_BATTLE_STYLE_STRAIGHTFORWARD ] = { [ MOVE_POINTS_ACCURATE ] = 3 , [ MOVE_POINTS_STRONG ] = 3 } ,
[ DOME_BATTLE_STYLE_AGGRESSIVE ] = { [ MOVE_POINTS_STRONG ] = 4 } ,
[ DOME_BATTLE_STYLE_DEF ] = { [ MOVE_POINTS_DEF ] = 3 } ,
[ DOME_BATTLE_STYLE_ENFEEBLE_HIGH ] = { [ MOVE_POINTS_STAT_LOWER ] = 2 , [ MOVE_POINTS_STATUS ] = 2 } , // BUG: This battle style is unobtainable; DOME_BATTLE_STYLE_ENFEEBLE_LOW will always succeed before it
[ DOME_BATTLE_STYLE_POPULAR_POWER ] = { [ MOVE_POINTS_POWERFUL ] = 3 , [ MOVE_POINTS_POPULAR ] = 3 } ,
[ DOME_BATTLE_STYLE_COMBO_LOW ] = { [ MOVE_POINTS_COMBO ] = 2 } ,
[ DOME_BATTLE_STYLE_ACCURATE ] = { [ MOVE_POINTS_HEAL ] = 1 , [ MOVE_POINTS_ACCURATE ] = 3 } ,
[ DOME_BATTLE_STYLE_POWERFUL ] = { [ MOVE_POINTS_POWERFUL ] = 4 } ,
[ DOME_BATTLE_STYLE_ATK_OVER_DEF ] = { [ MOVE_POINTS_DMG ] = 7 } ,
[ DOME_BATTLE_STYLE_DEF_OVER_ATK ] = { [ MOVE_POINTS_DEF ] = 4 } , // BUG: This battle style is unobtainable; DOME_BATTLE_STYLE_DEF will always succeed before it
[ DOME_BATTLE_STYLE_POPULAR_STRONG ] = { [ MOVE_POINTS_POPULAR ] = 2 , [ MOVE_POINTS_STRONG ] = 4 } ,
[ DOME_BATTLE_STYLE_EFFECTS ] = { [ MOVE_POINTS_EFFECT ] = 4 } ,
2019-12-21 10:27:12 +01:00
[ DOME_BATTLE_STYLE_BALANCED ] = { 0 } , // If no other thresholds are met, this battle style is used
[ DOME_BATTLE_STYLE_UNUSED1 ] = { 0 } , // Here below is unreachable
[ DOME_BATTLE_STYLE_UNUSED2 ] = { 0 } ,
[ DOME_BATTLE_STYLE_UNUSED3 ] = { 0 } ,
//[DOME_BATTLE_STYLE_UNUSED4] = {0}, // Excluded here, presumably was meant to be a style just for Dome Ace Tucker
2018-08-26 14:40:36 +02:00
} ;
static const u8 sUnusedArray [ ] =
{
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
3 , 0 , 0 , 0 , 0 , 0 , 3 , 0 , 0 , 0 , 0 , 0 , 3 , 0 , 0 , 0 ,
0 , 0 , 3 , 0 , 0 , 0 , 0 , 0 , 3 , 2 , 0 , 0 , 0 , 0 , 0 , 2 ,
0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 ,
0 , 2 , 253 , 0 , 0 , 0 , 0 , 0 , 253 , 0 , 0 , 0 , 0 , 0 , 253 , 0 ,
0 , 0 , 0 , 0 , 253 , 0 , 0 , 0 , 0 , 0 , 253 , 254 , 0 , 0 , 0 , 0 ,
0 , 254 , 0 , 0 , 0 , 0 , 0 , 254 , 0 , 0 , 0 , 0 , 0 , 254 , 0 , 0 ,
0 , 0 , 0 , 254 , 0 , 0 , 0 , 0 , 0 ,
} ;
2020-01-05 16:50:32 +01:00
// 1st array is for cursor position (sprite id): cursor can be on a trainer info button, a match info button, or the exit/cancel button
// 2nd array is for round count. For some reason this array contains an inaccessible Round 5 which is identical to Round 4
// 3rd array is movement direction (see the MOVE_DIR_* constants in UpdateTourneyTreeCursor)
// The values are sprite IDs for the cursor position to move to, with 0xFF being an invalid move
static const u8 sTourneyTreeCursorMovementMap [ DOME_TOURNAMENT_TRAINERS_COUNT + DOME_TOURNAMENT_MATCHES_COUNT + 1 ] [ DOME_ROUNDS_COUNT + 1 ] [ 4 ] =
{
[ 0 ] = { { 7 , 1 , 8 , 16 } , { 7 , 1 , 8 , 16 } , { 7 , 1 , 8 , 16 } , { 7 , 1 , 8 , 16 } , { 7 , 1 , 8 , 16 } } ,
[ 1 ] = { { 0 , 2 , 9 , 16 } , { 0 , 2 , 9 , 16 } , { 0 , 2 , 9 , 16 } , { 0 , 2 , 9 , 16 } , { 0 , 2 , 9 , 16 } } ,
[ 2 ] = { { 1 , 3 , 10 , 17 } , { 1 , 3 , 10 , 17 } , { 1 , 3 , 10 , 17 } , { 1 , 3 , 10 , 17 } , { 1 , 3 , 10 , 17 } } ,
[ 3 ] = { { 2 , 4 , 11 , 17 } , { 2 , 4 , 11 , 17 } , { 2 , 4 , 11 , 17 } , { 2 , 4 , 11 , 17 } , { 2 , 4 , 11 , 17 } } ,
[ 4 ] = { { 3 , 5 , 12 , 18 } , { 3 , 5 , 12 , 18 } , { 3 , 5 , 12 , 18 } , { 3 , 5 , 12 , 18 } , { 3 , 5 , 12 , 18 } } ,
[ 5 ] = { { 4 , 6 , 13 , 18 } , { 4 , 6 , 13 , 18 } , { 4 , 6 , 13 , 18 } , { 4 , 6 , 13 , 18 } , { 4 , 6 , 13 , 18 } } ,
[ 6 ] = { { 5 , 7 , 14 , 19 } , { 5 , 7 , 14 , 19 } , { 5 , 7 , 14 , 19 } , { 5 , 7 , 14 , 19 } , { 5 , 7 , 14 , 19 } } ,
[ 7 ] = { { 6 , 0 , 15 , 19 } , { 6 , 0 , 15 , 19 } , { 6 , 0 , 15 , 19 } , { 6 , 0 , 15 , 19 } , { 6 , 0 , 15 , 19 } } ,
[ 8 ] = { { 31 , 9 , 20 , 31 } , { 31 , 9 , 20 , 31 } , { 31 , 9 , 20 , 31 } , { 31 , 9 , 20 , 31 } , { 31 , 9 , 20 , 31 } } ,
[ 9 ] = { { 8 , 10 , 20 , 1 } , { 8 , 10 , 20 , 1 } , { 8 , 10 , 20 , 1 } , { 8 , 10 , 20 , 1 } , { 8 , 10 , 20 , 1 } } ,
[ 10 ] = { { 9 , 11 , 21 , 2 } , { 9 , 11 , 21 , 2 } , { 9 , 11 , 21 , 2 } , { 9 , 11 , 21 , 2 } , { 9 , 11 , 21 , 2 } } ,
[ 11 ] = { { 10 , 12 , 21 , 3 } , { 10 , 12 , 21 , 3 } , { 10 , 12 , 21 , 3 } , { 10 , 12 , 21 , 3 } , { 10 , 12 , 21 , 3 } } ,
[ 12 ] = { { 11 , 13 , 22 , 4 } , { 11 , 13 , 22 , 4 } , { 11 , 13 , 22 , 4 } , { 11 , 13 , 22 , 4 } , { 11 , 13 , 22 , 4 } } ,
[ 13 ] = { { 12 , 14 , 22 , 5 } , { 12 , 14 , 22 , 5 } , { 12 , 14 , 22 , 5 } , { 12 , 14 , 22 , 5 } , { 12 , 14 , 22 , 5 } } ,
[ 14 ] = { { 13 , 15 , 23 , 6 } , { 13 , 15 , 23 , 6 } , { 13 , 15 , 23 , 6 } , { 13 , 15 , 23 , 6 } , { 13 , 15 , 23 , 6 } } ,
[ 15 ] = { { 14 , 31 , 23 , 7 } , { 14 , 31 , 23 , 7 } , { 14 , 31 , 23 , 7 } , { 14 , 31 , 23 , 7 } , { 14 , 31 , 23 , 7 } } ,
[ 16 ] = { { 19 , 17 , 0 , 20 } , { 19 , 17 , 0 , 24 } , { 19 , 17 , 0 , 24 } , { 19 , 17 , 0 , 24 } , { 19 , 17 , 0 , 24 } } ,
[ 17 ] = { { 16 , 18 , 2 , 21 } , { 16 , 18 , 2 , 24 } , { 16 , 18 , 2 , 24 } , { 16 , 18 , 2 , 24 } , { 16 , 18 , 2 , 24 } } ,
[ 18 ] = { { 17 , 19 , 4 , 22 } , { 17 , 19 , 4 , 25 } , { 17 , 19 , 4 , 25 } , { 17 , 19 , 4 , 25 } , { 17 , 19 , 4 , 25 } } ,
[ 19 ] = { { 18 , 16 , 6 , 23 } , { 18 , 16 , 6 , 25 } , { 18 , 16 , 6 , 25 } , { 18 , 16 , 6 , 25 } , { 18 , 16 , 6 , 25 } } ,
[ 20 ] = { { 23 , 21 , 16 , 8 } , { 23 , 21 , 26 , 8 } , { 23 , 21 , 26 , 8 } , { 23 , 21 , 26 , 8 } , { 23 , 21 , 26 , 8 } } ,
[ 21 ] = { { 20 , 22 , 17 , 10 } , { 20 , 22 , 26 , 10 } , { 20 , 22 , 26 , 10 } , { 20 , 22 , 26 , 10 } , { 20 , 22 , 26 , 10 } } ,
[ 22 ] = { { 21 , 23 , 18 , 12 } , { 21 , 23 , 27 , 12 } , { 21 , 23 , 27 , 12 } , { 21 , 23 , 27 , 12 } , { 21 , 23 , 27 , 12 } } ,
[ 23 ] = { { 22 , 20 , 19 , 14 } , { 22 , 20 , 27 , 14 } , { 22 , 20 , 27 , 14 } , { 22 , 20 , 27 , 14 } , { 22 , 20 , 27 , 14 } } ,
[ 24 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 25 , 25 , 16 , 26 } , { 25 , 25 , 16 , 28 } , { 25 , 25 , 16 , 28 } , { 25 , 25 , 16 , 28 } } ,
[ 25 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 24 , 24 , 18 , 27 } , { 24 , 24 , 18 , 28 } , { 24 , 24 , 18 , 28 } , { 24 , 24 , 18 , 28 } } ,
[ 26 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 27 , 27 , 24 , 20 } , { 27 , 27 , 29 , 20 } , { 27 , 27 , 29 , 20 } , { 27 , 27 , 29 , 20 } } ,
[ 27 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 26 , 26 , 25 , 22 } , { 26 , 26 , 29 , 22 } , { 26 , 26 , 29 , 22 } , { 26 , 26 , 29 , 22 } } ,
[ 28 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 24 , 29 } , { 0xFF , 0xFF , 24 , 30 } , { 0xFF , 0xFF , 24 , 30 } } ,
[ 29 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 28 , 26 } , { 0xFF , 0xFF , 30 , 26 } , { 0xFF , 0xFF , 30 , 26 } } ,
[ 30 ] = { { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 0xFF , 0xFF } , { 0xFF , 0xFF , 28 , 29 } , { 0xFF , 0xFF , 28 , 29 } } ,
[ 31 ] = { { 15 , 8 , 8 , 0 } , { 15 , 8 , 8 , 0 } , { 15 , 8 , 8 , 0 } , { 15 , 8 , 8 , 0 } , { 15 , 8 , 8 , 0 } } , // TOURNEY_TREE_CLOSE_BUTTON
2018-08-26 14:40:36 +02:00
} ;
2019-12-21 10:27:12 +01:00
static const struct BgTemplate sTourneyTreeBgTemplates [ 4 ] =
2018-08-26 14:40:36 +02:00
{
{
. bg = 0 ,
. charBaseIndex = 0 ,
. mapBaseIndex = 28 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 0 ,
. baseTile = 0
} ,
{
. bg = 1 ,
. charBaseIndex = 1 ,
. mapBaseIndex = 29 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 1 ,
. baseTile = 0
} ,
{
. bg = 2 ,
. charBaseIndex = 2 ,
. mapBaseIndex = 30 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 2 ,
. baseTile = 0
} ,
{
. bg = 3 ,
. charBaseIndex = 2 ,
. mapBaseIndex = 31 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 2 ,
. baseTile = 0
} ,
} ;
2020-01-05 16:50:32 +01:00
static const struct BgTemplate sInfoCardBgTemplates [ 4 ] =
2018-08-26 14:40:36 +02:00
{
{
. bg = 0 ,
. charBaseIndex = 0 ,
. mapBaseIndex = 20 ,
. screenSize = 3 ,
. paletteMode = 0 ,
. priority = 0 ,
. baseTile = 0
} ,
{
. bg = 1 ,
. charBaseIndex = 1 ,
. mapBaseIndex = 24 ,
. screenSize = 3 ,
. paletteMode = 0 ,
. priority = 0 ,
. baseTile = 0
} ,
{
. bg = 2 ,
. charBaseIndex = 2 ,
. mapBaseIndex = 28 ,
. screenSize = 3 ,
. paletteMode = 0 ,
. priority = 1 ,
. baseTile = 0
} ,
{
. bg = 3 ,
. charBaseIndex = 2 ,
. mapBaseIndex = 7 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 1 ,
. baseTile = 0
} ,
} ;
2019-12-21 10:27:12 +01:00
static const struct WindowTemplate sTourneyTreeWindowTemplates [ ] =
2018-08-26 14:40:36 +02:00
{
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 0 ,
. tilemapTop = 3 ,
. width = 8 ,
. height = 16 ,
. paletteNum = 15 ,
. baseBlock = 16 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 22 ,
. tilemapTop = 3 ,
. width = 8 ,
. height = 16 ,
. paletteNum = 15 ,
. baseBlock = 144 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 8 ,
. tilemapTop = 1 ,
. width = 14 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 272 ,
} ,
DUMMY_WIN_TEMPLATE ,
} ;
2020-01-05 16:50:32 +01:00
static const struct WindowTemplate sInfoCardWindowTemplates [ ] =
2018-08-26 14:40:36 +02:00
{
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 2 ,
. width = 26 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 1 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 16 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 53 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 19 ,
. tilemapTop = 7 ,
. width = 9 ,
. height = 3 ,
. paletteNum = 15 ,
. baseBlock = 69 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 16 ,
. tilemapTop = 10 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 96 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 12 ,
. width = 26 ,
. height = 7 ,
. paletteNum = 15 ,
. baseBlock = 112 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 5 ,
. tilemapTop = 2 ,
. width = 23 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 294 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 340 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 20 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 356 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 0 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 16 ,
. width = 26 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 372 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 2 ,
. width = 26 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 1 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 16 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 53 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 19 ,
. tilemapTop = 7 ,
. width = 9 ,
. height = 3 ,
. paletteNum = 15 ,
. baseBlock = 69 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 16 ,
. tilemapTop = 10 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 96 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 12 ,
. width = 26 ,
. height = 7 ,
. paletteNum = 15 ,
. baseBlock = 112 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 5 ,
. tilemapTop = 2 ,
. width = 23 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 294 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 340 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 20 ,
. tilemapTop = 5 ,
. width = 8 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 356 ,
} ,
{
2018-10-27 00:53:07 +02:00
. bg = 1 ,
2018-08-26 14:40:36 +02:00
. tilemapLeft = 2 ,
. tilemapTop = 16 ,
. width = 26 ,
. height = 2 ,
. paletteNum = 15 ,
. baseBlock = 372 ,
} ,
2020-12-13 05:28:01 +01:00
# ifdef UBFIX
DUMMY_WIN_TEMPLATE ,
# endif
2018-08-26 14:40:36 +02:00
} ;
2019-02-08 18:08:25 +01:00
static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams =
2018-08-26 14:40:36 +02:00
{
2021-11-10 23:01:21 +01:00
. dmaDest = & REG_BG3CNT ,
2019-02-08 18:08:25 +01:00
. dmaControl = SCANLINE_EFFECT_DMACNT_16BIT ,
2018-08-26 14:40:36 +02:00
. initState = 1 ,
} ;
2020-01-05 16:50:32 +01:00
static const struct CompressedSpriteSheet sTourneyTreeButtonsSpriteSheet [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
{ gDomeTourneyTreeButtons_Gfx , 0x0600 , 0x0000 } ,
2018-08-26 15:51:14 +02:00
{ } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// Unused
static const struct CompressedSpritePalette sTourneyTreeButtonsSpritePal [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
{ gDomeTourneyTreeButtons_Pal , 0x0000 } ,
2018-08-26 15:51:14 +02:00
{ } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct OamData sOamData_TourneyTreePokeball =
2018-08-26 14:40:36 +02:00
{
. y = 0 ,
2019-12-04 21:25:13 +01:00
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2018-08-26 14:40:36 +02:00
. mosaic = 0 ,
2019-12-04 21:25:13 +01:00
. bpp = ST_OAM_4BPP ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x16 ) ,
2018-08-26 14:40:36 +02:00
. x = 0 ,
. matrixNum = 0 ,
2019-03-11 08:12:15 +01:00
. size = SPRITE_SIZE ( 16 x16 ) ,
2018-08-26 14:40:36 +02:00
. tileNum = 0 ,
. priority = 0 ,
. paletteNum = 0 ,
. affineParam = 0 ,
} ;
2020-01-05 16:50:32 +01:00
// For Exit/Cancel buttons
static const struct OamData sOamData_TourneyTreeCloseButton =
2018-08-26 14:40:36 +02:00
{
. y = 0 ,
2019-12-04 21:25:13 +01:00
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2018-08-26 14:40:36 +02:00
. mosaic = 0 ,
2019-12-04 21:25:13 +01:00
. bpp = ST_OAM_4BPP ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x16 ) ,
2018-08-26 14:40:36 +02:00
. x = 0 ,
. matrixNum = 0 ,
2019-03-11 08:12:15 +01:00
. size = SPRITE_SIZE ( 32 x16 ) ,
2018-08-26 14:40:36 +02:00
. tileNum = 0 ,
. priority = 0 ,
. paletteNum = 1 ,
. affineParam = 0 ,
} ;
2020-01-05 16:50:32 +01:00
static const struct OamData sOamData_VerticalScrollArrow =
2018-08-26 14:40:36 +02:00
{
. y = 0 ,
2019-12-04 21:25:13 +01:00
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2018-08-26 14:40:36 +02:00
. mosaic = 0 ,
2019-12-04 21:25:13 +01:00
. bpp = ST_OAM_4BPP ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x8 ) ,
2018-08-26 14:40:36 +02:00
. x = 0 ,
. matrixNum = 0 ,
2019-03-11 08:12:15 +01:00
. size = SPRITE_SIZE ( 16 x8 ) ,
2018-08-26 14:40:36 +02:00
. tileNum = 0 ,
. priority = 0 ,
. paletteNum = 2 ,
. affineParam = 0 ,
} ;
2020-01-05 16:50:32 +01:00
static const struct OamData sOamData_HorizontalScrollArrow =
2018-08-26 14:40:36 +02:00
{
. y = 0 ,
2019-12-04 21:25:13 +01:00
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2018-08-26 14:40:36 +02:00
. mosaic = 0 ,
2019-12-04 21:25:13 +01:00
. bpp = ST_OAM_4BPP ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 8 x16 ) ,
2018-08-26 14:40:36 +02:00
. x = 0 ,
. matrixNum = 0 ,
2019-03-11 08:12:15 +01:00
. size = SPRITE_SIZE ( 8 x16 ) ,
2018-08-26 14:40:36 +02:00
. tileNum = 0 ,
. priority = 0 ,
. paletteNum = 2 ,
. affineParam = 0 ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreePokeballNormal [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 20 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreePokeballSelected [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 24 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd * const sSpriteAnimTable_TourneyTreePokeball [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
sSpriteAnim_TourneyTreePokeballNormal ,
sSpriteAnim_TourneyTreePokeballSelected ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// Sprite template for the pokeballs on the tourney tree that act as buttons to view a trainer/match info card
static const struct SpriteTemplate sTourneyTreePokeballSpriteTemplate =
2018-08-26 16:45:08 +02:00
{
. tileTag = 0x0000 ,
2021-09-14 19:14:14 +02:00
. paletteTag = TAG_NONE ,
2020-01-05 16:50:32 +01:00
. oam = & sOamData_TourneyTreePokeball ,
. anims = sSpriteAnimTable_TourneyTreePokeball ,
2018-08-26 16:45:08 +02:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-01-05 16:50:32 +01:00
. callback = SpriteCallbackDummy
2018-08-26 16:45:08 +02:00
} ;
2018-08-26 14:40:36 +02:00
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreeCancelButtonNormal [ ] =
2018-08-26 14:40:36 +02:00
{
2018-08-26 15:51:14 +02:00
ANIMCMD_FRAME ( 8 , 1 ) ,
2018-08-26 14:40:36 +02:00
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreeCancelButtonSelected [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 0 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd * const sSpriteAnimTable_TourneyTreeCancelButton [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
sSpriteAnim_TourneyTreeCancelButtonNormal ,
sSpriteAnim_TourneyTreeCancelButtonSelected ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct SpriteTemplate sCancelButtonSpriteTemplate =
2018-08-26 16:45:08 +02:00
{
. tileTag = 0x0000 ,
2021-09-14 19:14:14 +02:00
. paletteTag = TAG_NONE ,
2020-01-05 16:50:32 +01:00
. oam = & sOamData_TourneyTreeCloseButton ,
. anims = sSpriteAnimTable_TourneyTreeCancelButton ,
2018-08-26 16:45:08 +02:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2018-08-26 14:40:36 +02:00
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreeExitButtonNormal [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 40 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_TourneyTreeExitButtonSelected [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 32 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd * const sSpriteAnimTable_TourneyTreeExitButton [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
sSpriteAnim_TourneyTreeExitButtonNormal ,
sSpriteAnim_TourneyTreeExitButtonSelected ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct SpriteTemplate sExitButtonSpriteTemplate =
2018-08-26 16:45:08 +02:00
{
. tileTag = 0x0000 ,
2021-09-14 19:14:14 +02:00
. paletteTag = TAG_NONE ,
2020-01-05 16:50:32 +01:00
. oam = & sOamData_TourneyTreeCloseButton ,
. anims = sSpriteAnimTable_TourneyTreeExitButton ,
2018-08-26 16:45:08 +02:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2018-08-26 14:40:36 +02:00
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_UpArrow [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 18 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_DownArrow [ ] =
2018-08-26 14:40:36 +02:00
{
2019-06-26 14:13:38 +02:00
ANIMCMD_FRAME ( 18 , 1 , . vFlip = TRUE ) ,
2018-08-26 14:40:36 +02:00
ANIMCMD_END ,
} ;
2018-08-26 15:51:14 +02:00
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_LeftArrow [ ] =
2018-08-26 14:40:36 +02:00
{
2019-06-26 14:13:38 +02:00
ANIMCMD_FRAME ( 16 , 1 , . hFlip = TRUE ) ,
2018-08-26 14:40:36 +02:00
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd sSpriteAnim_RightArrow [ ] =
2018-08-26 14:40:36 +02:00
{
ANIMCMD_FRAME ( 16 , 1 ) ,
ANIMCMD_END ,
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd * const sSpriteAnimTable_VerticalScrollArrow [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
sSpriteAnim_UpArrow ,
sSpriteAnim_DownArrow ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const union AnimCmd * const sSpriteAnimTable_HorizontalScrollArrow [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
sSpriteAnim_LeftArrow ,
sSpriteAnim_RightArrow ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct SpriteTemplate sHorizontalScrollArrowSpriteTemplate =
2018-08-26 16:45:08 +02:00
{
. tileTag = 0x0000 ,
2021-09-14 19:14:14 +02:00
. paletteTag = TAG_NONE ,
2020-01-05 16:50:32 +01:00
. oam = & sOamData_HorizontalScrollArrow ,
. anims = sSpriteAnimTable_HorizontalScrollArrow ,
2018-08-26 16:45:08 +02:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-01-05 16:50:32 +01:00
. callback = SpriteCb_HorizontalScrollArrow
2018-08-26 16:45:08 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct SpriteTemplate sVerticalScrollArrowSpriteTemplate =
2018-08-26 16:45:08 +02:00
{
. tileTag = 0x0000 ,
2021-09-14 19:14:14 +02:00
. paletteTag = TAG_NONE ,
2020-01-05 16:50:32 +01:00
. oam = & sOamData_VerticalScrollArrow ,
. anims = sSpriteAnimTable_VerticalScrollArrow ,
2018-08-26 16:45:08 +02:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-01-05 16:50:32 +01:00
. callback = SpriteCb_VerticalScrollArrow
2018-08-26 16:45:08 +02:00
} ;
2018-08-26 14:40:36 +02:00
2019-12-21 10:27:12 +01:00
// Organized by seed starting position, i.e. seed 0 battles seed 8 first
2020-01-05 16:50:32 +01:00
static const u8 sTourneyTreeTrainerIds [ DOME_TOURNAMENT_TRAINERS_COUNT ] = { 0 , 8 , 12 , 4 , 7 , 15 , 11 , 3 , 2 , 10 , 14 , 6 , 5 , 13 , 9 , 1 } ;
2018-08-26 14:40:36 +02:00
2019-02-08 18:08:25 +01:00
static void ( * const sBattleDomeFunctions [ ] ) ( void ) =
2018-08-26 14:40:36 +02:00
{
2019-11-29 03:09:35 +01:00
[ BATTLE_DOME_FUNC_INIT ] = InitDomeChallenge ,
[ BATTLE_DOME_FUNC_GET_DATA ] = GetDomeData ,
[ BATTLE_DOME_FUNC_SET_DATA ] = SetDomeData ,
[ BATTLE_DOME_FUNC_GET_ROUND_TEXT ] = BufferDomeRoundText ,
[ BATTLE_DOME_FUNC_GET_OPPONENT_NAME ] = BufferDomeOpponentName ,
[ BATTLE_DOME_FUNC_INIT_OPPONENT_PARTY ] = InitDomeOpponentParty ,
[ BATTLE_DOME_FUNC_SHOW_OPPONENT_INFO ] = ShowDomeOpponentInfo ,
[ BATTLE_DOME_FUNC_SHOW_TOURNEY_TREE ] = ShowDomeTourneyTree ,
2020-01-05 16:50:32 +01:00
[ BATTLE_DOME_FUNC_SHOW_PREV_TOURNEY_TREE ] = ShowPreviousDomeTourneyTree ,
2019-11-29 03:09:35 +01:00
[ BATTLE_DOME_FUNC_SET_OPPONENT_ID ] = SetDomeOpponentId ,
[ BATTLE_DOME_FUNC_SET_OPPONENT_GFX ] = SetDomeOpponentGraphicsId ,
[ BATTLE_DOME_FUNC_SHOW_STATIC_TOURNEY_TREE ] = ShowNonInteractiveDomeTourneyTree ,
[ BATTLE_DOME_FUNC_RESOLVE_WINNERS ] = ResolveDomeRoundWinners ,
[ BATTLE_DOME_FUNC_SAVE ] = SaveDomeChallenge ,
[ BATTLE_DOME_FUNC_INCREMENT_STREAK ] = IncrementDomeStreaks ,
2019-12-21 10:27:12 +01:00
[ BATTLE_DOME_FUNC_SET_TRAINERS ] = SetFacilityTrainerAndMonPtrs ,
2019-11-29 03:09:35 +01:00
[ BATTLE_DOME_FUNC_RESET_SKETCH ] = ResetSketchedMoves ,
[ BATTLE_DOME_FUNC_RESTORE_HELD_ITEMS ] = RestoreDomePlayerPartyHeldItems ,
2019-12-18 08:32:52 +01:00
[ BATTLE_DOME_FUNC_REDUCE_PARTY ] = ReduceDomePlayerPartyToSelectedMons ,
2019-11-29 03:09:35 +01:00
[ BATTLE_DOME_FUNC_COMPARE_SEEDS ] = GetPlayerSeededBeforeOpponent ,
[ BATTLE_DOME_FUNC_GET_WINNER_NAME ] = BufferLastDomeWinnerName ,
2019-12-18 08:32:52 +01:00
[ BATTLE_DOME_FUNC_INIT_RESULTS_TREE ] = InitRandomTourneyTreeResults ,
2019-11-29 03:09:35 +01:00
[ BATTLE_DOME_FUNC_INIT_TRAINERS ] = InitDomeTrainers ,
2018-08-26 14:40:36 +02:00
} ;
2019-11-24 22:58:40 +01:00
static const u32 sWinStreakFlags [ ] [ 2 ] =
2018-08-26 14:40:36 +02:00
{
2019-11-24 22:58:40 +01:00
{ STREAK_DOME_SINGLES_50 , STREAK_DOME_SINGLES_OPEN } ,
{ STREAK_DOME_DOUBLES_50 , STREAK_DOME_DOUBLES_OPEN } ,
2018-08-26 14:40:36 +02:00
} ;
2019-11-24 22:58:40 +01:00
static const u32 sWinStreakMasks [ ] [ 2 ] =
2018-08-26 14:40:36 +02:00
{
2019-11-24 22:58:40 +01:00
{ ~ ( STREAK_DOME_SINGLES_50 ) , ~ ( STREAK_DOME_SINGLES_OPEN ) } ,
{ ~ ( STREAK_DOME_DOUBLES_50 ) , ~ ( STREAK_DOME_DOUBLES_OPEN ) } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// TODO: The below two arrays probably need better names. The one below for example is only true of sIdToOpponentId[i][0]
2018-08-26 21:41:47 +02:00
static const u8 sIdToOpponentId [ DOME_TOURNAMENT_TRAINERS_COUNT ] [ DOME_ROUNDS_COUNT ] =
{
2020-01-05 16:50:32 +01:00
[ 0 ] = { 8 , 0 , 4 , 8 } ,
[ 1 ] = { 9 , 12 , 8 , 0 } ,
[ 2 ] = { 10 , 8 , 12 , 0 } ,
[ 3 ] = { 11 , 4 , 0 , 8 } ,
[ 4 ] = { 12 , 0 , 4 , 8 } ,
[ 5 ] = { 13 , 12 , 8 , 0 } ,
[ 6 ] = { 14 , 8 , 12 , 0 } ,
[ 7 ] = { 15 , 4 , 0 , 8 } ,
[ 8 ] = { 0 , 0 , 4 , 8 } ,
[ 9 ] = { 1 , 12 , 8 , 0 } ,
[ 10 ] = { 2 , 8 , 12 , 0 } ,
[ 11 ] = { 3 , 4 , 0 , 8 } ,
[ 12 ] = { 4 , 0 , 4 , 8 } ,
[ 13 ] = { 5 , 12 , 8 , 0 } ,
[ 14 ] = { 6 , 8 , 12 , 0 } ,
[ 15 ] = { 7 , 4 , 0 , 8 } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// sTourneyTreeTrainerIds with every other pair swapped
static const u8 sTourneyTreeTrainerOpponentIds [ DOME_TOURNAMENT_TRAINERS_COUNT ] = { 0 , 8 , 4 , 12 , 7 , 15 , 3 , 11 , 2 , 10 , 6 , 14 , 5 , 13 , 1 , 9 } ;
// The match number - 1 that a given tournament trainer will participate in for a given round
static const u8 sIdToMatchNumber [ DOME_TOURNAMENT_TRAINERS_COUNT ] [ DOME_ROUNDS_COUNT ] =
{
{ 0 , 8 , 12 , 14 } ,
{ 0 , 8 , 12 , 14 } ,
{ 1 , 8 , 12 , 14 } ,
{ 1 , 8 , 12 , 14 } ,
{ 2 , 9 , 12 , 14 } ,
{ 2 , 9 , 12 , 14 } ,
{ 3 , 9 , 12 , 14 } ,
{ 3 , 9 , 12 , 14 } ,
{ 4 , 10 , 13 , 14 } ,
{ 4 , 10 , 13 , 14 } ,
{ 5 , 10 , 13 , 14 } ,
{ 5 , 10 , 13 , 14 } ,
{ 6 , 11 , 13 , 14 } ,
{ 6 , 11 , 13 , 14 } ,
{ 7 , 11 , 13 , 14 } ,
{ 7 , 11 , 13 , 14 } ,
2018-08-26 14:40:36 +02:00
} ;
2020-09-02 15:49:04 +02:00
static const u8 sLastMatchCardNum [ DOME_ROUNDS_COUNT ] =
2019-12-18 08:32:52 +01:00
{
2020-09-02 15:49:04 +02:00
[ DOME_ROUND1 ] = 23 ,
[ DOME_ROUND2 ] = 27 ,
[ DOME_SEMIFINAL ] = 29 ,
2019-12-18 08:32:52 +01:00
[ DOME_FINAL ] = 30
} ;
2018-08-26 14:40:36 +02:00
2021-11-01 23:06:15 +01:00
static const u8 sTrainerAndRoundToLastMatchCardNum [ DOME_TOURNAMENT_TRAINERS_COUNT / 2 ] [ DOME_ROUNDS_COUNT ] =
2018-08-26 14:40:36 +02:00
{
2019-12-21 10:27:12 +01:00
{ 16 , 24 , 28 , 30 } ,
{ 17 , 24 , 28 , 30 } ,
{ 18 , 25 , 28 , 30 } ,
{ 19 , 25 , 28 , 30 } ,
{ 20 , 26 , 29 , 30 } ,
{ 21 , 26 , 29 , 30 } ,
{ 22 , 27 , 29 , 30 } ,
{ 23 , 27 , 29 , 30 } ,
2018-08-26 14:40:36 +02:00
} ;
2021-11-01 23:06:15 +01:00
static const u8 sTournamentIdToPairedTrainerIds [ DOME_TOURNAMENT_TRAINERS_COUNT ] = { 0 , 15 , 8 , 7 , 3 , 12 , 11 , 4 , 1 , 14 , 9 , 6 , 2 , 13 , 10 , 5 } ;
2019-12-21 10:27:12 +01:00
2021-07-03 14:38:22 +02:00
// The first line of text on a trainers info card. It describes their potential to win, based on their seed in the tournament tree.
// Dome Ace Tucker has their own separate potential text.
2019-12-21 10:27:12 +01:00
static const u8 * const sBattleDomePotentialTexts [ DOME_TOURNAMENT_TRAINERS_COUNT + 1 ] =
{
BattleDome_Text_Potential1 , // Highest potential
BattleDome_Text_Potential2 ,
BattleDome_Text_Potential3 ,
BattleDome_Text_Potential4 ,
BattleDome_Text_Potential5 ,
BattleDome_Text_Potential6 ,
BattleDome_Text_Potential7 ,
BattleDome_Text_Potential8 ,
BattleDome_Text_Potential9 ,
BattleDome_Text_Potential10 ,
BattleDome_Text_Potential11 ,
BattleDome_Text_Potential12 ,
BattleDome_Text_Potential13 ,
BattleDome_Text_Potential14 ,
BattleDome_Text_Potential15 ,
BattleDome_Text_Potential16 , // Lowest potential
BattleDome_Text_PotentialDomeAceTucker ,
2018-08-26 14:40:36 +02:00
} ;
2021-07-03 14:38:22 +02:00
// The second line of text on a trainers info card. It gives information about their battle style (dependent on their party's moves).
2019-12-21 10:27:12 +01:00
static const u8 * const sBattleDomeOpponentStyleTexts [ NUM_BATTLE_STYLES ] =
{
[ DOME_BATTLE_STYLE_RISKY ] = BattleDome_Text_StyleRiskDisaster ,
[ DOME_BATTLE_STYLE_STALL ] = BattleDome_Text_StyleEndureLongBattles ,
[ DOME_BATTLE_STYLE_VARIED ] = BattleDome_Text_StyleVariesTactics ,
[ DOME_BATTLE_STYLE_COMBO_HIGH ] = BattleDome_Text_StyleToughWinningPattern ,
[ DOME_BATTLE_STYLE_RARE_MOVES ] = BattleDome_Text_StyleUsesVeryRareMove , // Seems like the text for these two was swapped
[ DOME_BATTLE_STYLE_RARE_MOVE ] = BattleDome_Text_StyleUsesStartlingMoves , //
[ DOME_BATTLE_STYLE_HP ] = BattleDome_Text_StyleConstantlyWatchesHP ,
[ DOME_BATTLE_STYLE_STORE_POWER ] = BattleDome_Text_StyleStoresAndLoosesPower ,
[ DOME_BATTLE_STYLE_ENFEEBLE_LOW ] = BattleDome_Text_StyleEnfeeblesFoes ,
[ DOME_BATTLE_STYLE_LUCK ] = BattleDome_Text_StylePrefersLuckTactics ,
2020-01-05 16:50:32 +01:00
[ DOME_BATTLE_STYLE_REGAL ] = BattleDome_Text_StyleRegalAtmosphere ,
2019-12-21 10:27:12 +01:00
[ DOME_BATTLE_STYLE_LOW_PP ] = BattleDome_Text_StylePowerfulLowPPMoves ,
[ DOME_BATTLE_STYLE_STATUS_ATK ] = BattleDome_Text_StyleEnfeebleThenAttack ,
[ DOME_BATTLE_STYLE_ENDURE ] = BattleDome_Text_StyleBattlesWhileEnduring ,
[ DOME_BATTLE_STYLE_STATUS ] = BattleDome_Text_StyleUpsetsFoesEmotionally ,
[ DOME_BATTLE_STYLE_STRAIGHTFORWARD ] = BattleDome_Text_StyleStrongAndStraightforward ,
[ DOME_BATTLE_STYLE_AGGRESSIVE ] = BattleDome_Text_StyleAggressivelyStrongMoves ,
[ DOME_BATTLE_STYLE_DEF ] = BattleDome_Text_StyleCleverlyDodgesAttacks ,
[ DOME_BATTLE_STYLE_ENFEEBLE_HIGH ] = BattleDome_Text_StyleUsesUpsettingMoves ,
[ DOME_BATTLE_STYLE_POPULAR_POWER ] = BattleDome_Text_StyleUsesPopularMoves ,
[ DOME_BATTLE_STYLE_COMBO_LOW ] = BattleDome_Text_StyleHasPowerfulComboMoves ,
[ DOME_BATTLE_STYLE_ACCURATE ] = BattleDome_Text_StyleUsesHighProbabilityMoves ,
[ DOME_BATTLE_STYLE_POWERFUL ] = BattleDome_Text_StyleAggressivelySpectacularMoves ,
[ DOME_BATTLE_STYLE_ATK_OVER_DEF ] = BattleDome_Text_StyleEmphasizesOffenseOverDefense ,
[ DOME_BATTLE_STYLE_DEF_OVER_ATK ] = BattleDome_Text_StyleEmphasizesDefenseOverOffense ,
[ DOME_BATTLE_STYLE_POPULAR_STRONG ] = BattleDome_Text_StyleAttacksQuicklyStrongMoves ,
[ DOME_BATTLE_STYLE_EFFECTS ] = BattleDome_Text_StyleUsesAddedEffectMoves ,
[ DOME_BATTLE_STYLE_BALANCED ] = BattleDome_Text_StyleUsesBalancedMixOfMoves ,
[ DOME_BATTLE_STYLE_UNUSED1 ] = BattleDome_Text_StyleSampleMessage1 ,
[ DOME_BATTLE_STYLE_UNUSED2 ] = BattleDome_Text_StyleSampleMessage2 ,
[ DOME_BATTLE_STYLE_UNUSED3 ] = BattleDome_Text_StyleSampleMessage3 ,
[ DOME_BATTLE_STYLE_UNUSED4 ] = BattleDome_Text_StyleSampleMessage4 ,
2018-08-26 14:40:36 +02:00
} ;
2021-07-03 14:38:22 +02:00
// The third line of text on a trainers info card. It that gives information about their party's stat spread (based on their Pokémon's effort values and Nature).
2019-02-08 18:08:25 +01:00
static const u8 * const sBattleDomeOpponentStatsTexts [ ] =
{
2020-01-05 16:50:32 +01:00
BattleDome_Text_EmphasizesHPAndAtk , // DOME_TEXT_TWO_GOOD_STATS and DOME_TEXT_HP start here
2019-12-21 10:27:12 +01:00
BattleDome_Text_EmphasizesHPAndDef ,
BattleDome_Text_EmphasizesHPAndSpeed ,
BattleDome_Text_EmphasizesHPAndSpAtk ,
BattleDome_Text_EmphasizesHPAndSpDef ,
2020-01-05 16:50:32 +01:00
BattleDome_Text_EmphasizesAtkAndDef , // DOME_TEXT_ATK starts here
BattleDome_Text_EmphasizesAtkAndSpeed ,
BattleDome_Text_EmphasizesAtkAndSpAtk ,
BattleDome_Text_EmphasizesAtkAndSpDef ,
BattleDome_Text_EmphasizesDefAndSpeed , // DOME_TEXT_DEF starts here
BattleDome_Text_EmphasizesDefAndSpAtk ,
BattleDome_Text_EmphasizesDefAndSpDef ,
BattleDome_Text_EmphasizesSpeedAndSpAtk , // DOME_TEXT_SPEED starts here
BattleDome_Text_EmphasizesSpeedAndSpDef ,
BattleDome_Text_EmphasizesSpAtkAndSpDef , // DOME_TEXT_SPATK starts here
BattleDome_Text_EmphasizesHP , // DOME_TEXT_ONE_GOOD_STAT starts here
BattleDome_Text_EmphasizesAtk ,
BattleDome_Text_EmphasizesDef ,
BattleDome_Text_EmphasizesSpeed ,
BattleDome_Text_EmphasizesSpAtk ,
BattleDome_Text_EmphasizesSpDef ,
BattleDome_Text_NeglectsHPAndAtk , // DOME_TEXT_TWO_BAD_STATS starts here
BattleDome_Text_NeglectsHPAndDef ,
BattleDome_Text_NeglectsHPAndSpeed ,
BattleDome_Text_NeglectsHPAndSpAtk ,
BattleDome_Text_NeglectsHPAndSpDef ,
BattleDome_Text_NeglectsAtkAndDef ,
BattleDome_Text_NeglectsAtkAndSpeed ,
BattleDome_Text_NeglectsAtkAndSpAtk ,
BattleDome_Text_NeglectsAtkAndSpDef ,
BattleDome_Text_NeglectsDefAndSpeed ,
BattleDome_Text_NeglectsDefAndSpAtk ,
BattleDome_Text_NeglectsDefAndSpDef ,
BattleDome_Text_NeglectsSpeedAndSpAtk ,
BattleDome_Text_NeglectsSpeedAndSpDef ,
BattleDome_Text_NeglectsSpAtkAndSpDef ,
BattleDome_Text_NeglectsHP , // DOME_TEXT_ONE_BAD_STAT starts here
BattleDome_Text_NeglectsAtk ,
BattleDome_Text_NeglectsDef ,
BattleDome_Text_NeglectsSpeed ,
BattleDome_Text_NeglectsSpAtk ,
BattleDome_Text_NeglectsSpDef ,
[ DOME_TEXT_WELL_BALANCED ] = BattleDome_Text_RaisesMonsWellBalanced ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const u8 sInfoTrainerMonX [ FRONTIER_PARTY_SIZE ] = { 104 , 136 , 104 } ;
static const u8 sInfoTrainerMonY [ FRONTIER_PARTY_SIZE ] = { 38 , 62 , 78 } ;
2019-12-18 08:32:52 +01:00
static const u8 sSpeciesNameTextYCoords [ ] = { 0 , 4 , 0 } ;
2018-08-26 14:40:36 +02:00
2020-01-05 16:50:32 +01:00
// Offsets within sBattleDomeOpponentStatsTexts for stat combinations
// SPDEF has no offset because by then all stat combinations have been reached, so it has no combination texts
2020-09-02 15:49:04 +02:00
static const u8 sStatTextOffsets [ NUM_STATS - 1 ] =
2020-01-05 16:50:32 +01:00
{
2020-09-02 15:49:04 +02:00
DOME_TEXT_HP ,
DOME_TEXT_ATK ,
DOME_TEXT_DEF ,
DOME_TEXT_SPEED ,
2020-01-05 16:50:32 +01:00
DOME_TEXT_SPATK
} ;
2018-08-26 14:40:36 +02:00
2019-12-21 10:27:12 +01:00
static const u8 * const sBattleDomeMatchNumberTexts [ DOME_TOURNAMENT_MATCHES_COUNT ] =
2019-02-08 18:08:25 +01:00
{
2020-01-05 16:50:32 +01:00
BattleDome_Text_Round1Match1 ,
BattleDome_Text_Round1Match2 ,
BattleDome_Text_Round1Match3 ,
BattleDome_Text_Round1Match4 ,
BattleDome_Text_Round1Match5 ,
BattleDome_Text_Round1Match6 ,
BattleDome_Text_Round1Match7 ,
BattleDome_Text_Round1Match8 ,
BattleDome_Text_Round2Match1 ,
BattleDome_Text_Round2Match2 ,
BattleDome_Text_Round2Match3 ,
BattleDome_Text_Round2Match4 ,
BattleDome_Text_SemifinalMatch1 ,
BattleDome_Text_SemifinalMatch2 ,
BattleDome_Text_FinalMatch ,
2018-08-26 14:40:36 +02:00
} ;
2019-02-08 18:08:25 +01:00
static const u8 * const sBattleDomeWinTexts [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
[ DOME_TEXT_NO_WINNER_YET ] = BattleDome_Text_LetTheBattleBegin ,
[ DOME_TEXT_WON_USING_MOVE ] = BattleDome_Text_TrainerWonUsingMove ,
[ DOME_TEXT_CHAMP_USING_MOVE ] = BattleDome_Text_TrainerBecameChamp ,
[ DOME_TEXT_WON_ON_FORFEIT ] = BattleDome_Text_TrainerWonByDefault ,
[ DOME_TEXT_CHAMP_ON_FORFEIT ] = BattleDome_Text_TrainerWonOutrightByDefault ,
[ DOME_TEXT_WON_NO_MOVES ] = BattleDome_Text_TrainerWonNoMoves ,
[ DOME_TEXT_CHAMP_NO_MOVES ] = BattleDome_Text_TrainerWonOutrightNoMoves ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const u8 sLeftTrainerMonX [ FRONTIER_PARTY_SIZE ] = { 96 , 96 , 96 } ;
static const u8 sLeftTrainerMonY [ FRONTIER_PARTY_SIZE ] = { 56 , 80 , 104 } ;
static const u8 sRightTrainerMonX [ FRONTIER_PARTY_SIZE ] = { 144 , 144 , 144 } ;
static const u8 sRightTrainerMonY [ FRONTIER_PARTY_SIZE ] = { 56 , 80 , 104 } ;
// Duplicate of sTourneyTreeTrainerIds
static const u8 sTourneyTreeTrainerIds2 [ DOME_TOURNAMENT_TRAINERS_COUNT ] = { 0 , 8 , 12 , 4 , 7 , 15 , 11 , 3 , 2 , 10 , 14 , 6 , 5 , 13 , 9 , 1 } ;
// The number of possible trainers that could be competing in a given match
# define NUM_POSSIBLE_MATCH_TRAINERS(round) (DOME_TOURNAMENT_TRAINERS_COUNT / (1 << (DOME_ROUNDS_COUNT - round - 1)))
// The range of tournament trainers to check as possible participants in a given match
// Given by the offset in sCompetitorRangeByMatch[][0], the number of trainers in sCompetitorRangeByMatch[][1], and the round
static const u8 sCompetitorRangeByMatch [ DOME_TOURNAMENT_MATCHES_COUNT ] [ 3 ] =
{
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 0 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 1 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 2 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 3 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 4 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 5 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 6 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) * 7 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND1 ) , DOME_ROUND1 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) * 0 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) , DOME_ROUND2 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) * 1 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) , DOME_ROUND2 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) * 2 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) , DOME_ROUND2 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) * 3 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_ROUND2 ) , DOME_ROUND2 } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_SEMIFINAL ) * 0 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_SEMIFINAL ) , DOME_SEMIFINAL } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_SEMIFINAL ) * 1 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_SEMIFINAL ) , DOME_SEMIFINAL } ,
{ NUM_POSSIBLE_MATCH_TRAINERS ( DOME_FINAL ) * 0 , NUM_POSSIBLE_MATCH_TRAINERS ( DOME_FINAL ) , DOME_FINAL } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// 1st value is the windowId (0 for left column, 1 for right column)
// 2nd value is the y coord
static const u8 sTrainerNamePositions [ DOME_TOURNAMENT_TRAINERS_COUNT ] [ 2 ] =
{
{ 0 , 0 } ,
{ 1 , 112 } ,
{ 1 , 0 } ,
{ 0 , 112 } ,
{ 0 , 48 } ,
{ 1 , 64 } ,
{ 1 , 48 } ,
{ 0 , 64 } ,
{ 0 , 16 } ,
{ 1 , 96 } ,
{ 1 , 16 } ,
{ 0 , 96 } ,
{ 0 , 32 } ,
{ 1 , 80 } ,
{ 1 , 32 } ,
{ 0 , 80 } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// Coords for the pokeballs on the tourney tree that act as buttons to view trainer/match info
static const u8 sTourneyTreePokeballCoords [ DOME_TOURNAMENT_TRAINERS_COUNT + DOME_TOURNAMENT_MATCHES_COUNT ] [ 2 ] =
{
{ 68 , 33 } , // Left side trainers
2020-09-02 15:49:04 +02:00
{ 68 , 49 } ,
2020-01-05 16:50:32 +01:00
{ 68 , 65 } ,
{ 68 , 81 } ,
{ 68 , 97 } ,
{ 68 , 113 } ,
{ 68 , 129 } ,
{ 68 , 145 } ,
{ 172 , 33 } , // Right side trainers
{ 172 , 49 } ,
{ 172 , 65 } ,
{ 172 , 81 } ,
{ 172 , 97 } ,
{ 172 , 113 } ,
{ 172 , 129 } ,
{ 172 , 145 } ,
{ 87 , 41 } , // Left side Round 1 matches
{ 87 , 73 } ,
{ 87 , 105 } ,
{ 87 , 137 } ,
{ 153 , 41 } , // Right side Round 1 matches
{ 153 , 73 } ,
{ 153 , 105 } ,
{ 153 , 137 } ,
{ 95 , 57 } , // Left side Round 2 matches
{ 95 , 121 } ,
{ 145 , 57 } , // Right side Round 2 matches
{ 145 , 121 } ,
{ 103 , 89 } , // Left side semifinal match
{ 137 , 89 } , // Right side semifinal match
{ 120 , 89 } , // Final match
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
// Each of these line sections define the position of the advancement line on the tourney tree for the victor of that round
// The trainers here are numbered by tourney ID (rank/seed) and ordered according to where they start on the tourney tree
# define LINESECTION_ROUND1_TRAINER1(lastSrc) \
{ . src = 0x6021 , . y = 0x04 , . x = 0x09 } , \
{ . src = 0x6023 , . y = 0x04 , . x = 0x0a } , \
{ . src = 0x6047 , . y = 0x05 , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x05 , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER9(lastSrc) \
{ . src = 0x6021 , . y = 0x06 , . x = 0x09 } , \
{ . src = 0x6021 , . y = 0x06 , . x = 0x0a } , \
{ . src = 0x6027 , . y = 0x05 , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x05 , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER13(lastSrc) \
{ . src = 0x6021 , . y = 0x08 , . x = 0x09 } , \
{ . src = 0x6023 , . y = 0x08 , . x = 0x0a } , \
{ . src = 0x6047 , . y = 0x09 , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x09 , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER5(lastSrc) \
{ . src = 0x6021 , . y = 0x0a , . x = 0x09 } , \
{ . src = 0x6021 , . y = 0x0a , . x = 0x0a } , \
{ . src = 0x6027 , . y = 0x09 , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x09 , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER8(lastSrc) \
{ . src = 0x6021 , . y = 0x0c , . x = 0x09 } , \
{ . src = 0x6023 , . y = 0x0c , . x = 0x0a } , \
{ . src = 0x6047 , . y = 0x0d , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x0d , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER16(lastSrc) \
{ . src = 0x6021 , . y = 0x0e , . x = 0x09 } , \
{ . src = 0x6021 , . y = 0x0e , . x = 0x0a } , \
{ . src = 0x6027 , . y = 0x0d , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x0d , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER12(lastSrc) \
{ . src = 0x6021 , . y = 0x10 , . x = 0x09 } , \
{ . src = 0x6023 , . y = 0x10 , . x = 0x0a } , \
{ . src = 0x6047 , . y = 0x11 , . x = 0x0a } , \
2020-09-02 15:49:04 +02:00
{ . src = lastSrc , . y = 0x11 , . x = 0x0b } ,
2020-01-05 16:50:32 +01:00
# define LINESECTION_ROUND1_TRAINER4(lastSrc) \
{ . src = 0x602b , . y = 0x12 , . x = 0x09 } , \
{ . src = 0x602b , . y = 0x12 , . x = 0x0a } , \
{ . src = 0x6027 , . y = 0x11 , . x = 0x0a } , \
{ . src = lastSrc , . y = 0x11 , . x = 0x0b } ,
# define LINESECTION_ROUND1_TRAINER3(lastSrc) \
{ . src = 0x6021 , . y = 0x04 , . x = 0x14 } , \
{ . src = 0x6025 , . y = 0x04 , . x = 0x13 } , \
{ . src = 0x6049 , . y = 0x05 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x05 , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER11(lastSrc) \
{ . src = 0x6021 , . y = 0x06 , . x = 0x14 } , \
{ . src = 0x6021 , . y = 0x06 , . x = 0x13 } , \
{ . src = 0x6029 , . y = 0x05 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x05 , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER15(lastSrc) \
{ . src = 0x6021 , . y = 0x08 , . x = 0x14 } , \
{ . src = 0x6025 , . y = 0x08 , . x = 0x13 } , \
{ . src = 0x6049 , . y = 0x09 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x09 , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER7(lastSrc) \
{ . src = 0x6021 , . y = 0x0a , . x = 0x14 } , \
{ . src = 0x6021 , . y = 0x0a , . x = 0x13 } , \
{ . src = 0x6029 , . y = 0x09 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x09 , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER6(lastSrc) \
{ . src = 0x6021 , . y = 0x0c , . x = 0x14 } , \
{ . src = 0x6025 , . y = 0x0c , . x = 0x13 } , \
{ . src = 0x6049 , . y = 0x0d , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x0d , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER14(lastSrc) \
{ . src = 0x6021 , . y = 0x0e , . x = 0x14 } , \
{ . src = 0x6021 , . y = 0x0e , . x = 0x13 } , \
{ . src = 0x6029 , . y = 0x0d , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x0d , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER10(lastSrc) \
{ . src = 0x6021 , . y = 0x10 , . x = 0x14 } , \
{ . src = 0x6025 , . y = 0x10 , . x = 0x13 } , \
{ . src = 0x6049 , . y = 0x11 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x11 , . x = 0x12 } ,
# define LINESECTION_ROUND1_TRAINER2(lastSrc) \
{ . src = 0x602b , . y = 0x12 , . x = 0x14 } , \
{ . src = 0x602b , . y = 0x12 , . x = 0x13 } , \
{ . src = 0x6029 , . y = 0x11 , . x = 0x13 } , \
{ . src = lastSrc , . y = 0x11 , . x = 0x12 } ,
# define LINESECTION_ROUND2_MATCH1(lastSrc) \
{ . src = 0x6027 , . y = 0x06 , . x = 0x0b } , \
{ . src = 0x6047 , . y = 0x07 , . x = 0x0b } , \
{ . src = lastSrc , . y = 0x07 , . x = 0x0c } ,
# define LINESECTION_ROUND2_MATCH2(lastSrc) \
{ . src = 0x6027 , . y = 0x08 , . x = 0x0b } , \
{ . src = 0x6027 , . y = 0x07 , . x = 0x0b } , \
{ . src = lastSrc , . y = 0x07 , . x = 0x0c } ,
# define LINESECTION_ROUND2_MATCH3(lastSrc) \
{ . src = 0x6027 , . y = 0x0e , . x = 0x0b } , \
{ . src = 0x6047 , . y = 0x0f , . x = 0x0b } , \
{ . src = lastSrc , . y = 0x0f , . x = 0x0c } ,
# define LINESECTION_ROUND2_MATCH4(lastSrc) \
{ . src = 0x6027 , . y = 0x10 , . x = 0x0b } , \
{ . src = 0x6027 , . y = 0x0f , . x = 0x0b } , \
{ . src = lastSrc , . y = 0x0f , . x = 0x0c } ,
# define LINESECTION_ROUND2_MATCH5(lastSrc) \
{ . src = 0x6029 , . y = 0x06 , . x = 0x12 } , \
{ . src = 0x6049 , . y = 0x07 , . x = 0x12 } , \
{ . src = lastSrc , . y = 0x07 , . x = 0x11 } ,
# define LINESECTION_ROUND2_MATCH6(lastSrc) \
{ . src = 0x6029 , . y = 0x08 , . x = 0x12 } , \
{ . src = 0x6029 , . y = 0x07 , . x = 0x12 } , \
{ . src = lastSrc , . y = 0x07 , . x = 0x11 } ,
# define LINESECTION_ROUND2_MATCH7(lastSrc) \
{ . src = 0x6029 , . y = 0x0e , . x = 0x12 } , \
{ . src = 0x6049 , . y = 0x0f , . x = 0x12 } , \
{ . src = lastSrc , . y = 0x0f , . x = 0x11 } ,
# define LINESECTION_ROUND2_MATCH8(lastSrc) \
{ . src = 0x6029 , . y = 0x10 , . x = 0x12 } , \
{ . src = 0x6029 , . y = 0x0f , . x = 0x12 } , \
{ . src = lastSrc , . y = 0x0f , . x = 0x11 } ,
# define LINESECTION_SEMIFINAL_TOP_LEFT \
{ . src = 0x6027 , . y = 0x08 , . x = 0x0c } , \
{ . src = 0x6027 , . y = 0x09 , . x = 0x0c } , \
{ . src = 0x6027 , . y = 0x0a , . x = 0x0c } , \
{ . src = 0x603b , . y = 0x0b , . x = 0x0c } ,
# define LINESECTION_SEMIFINAL_BOTTOM_LEFT \
{ . src = 0x6033 , . y = 0x0e , . x = 0x0c } , \
{ . src = 0x6032 , . y = 0x0d , . x = 0x0c } , \
{ . src = 0x6031 , . y = 0x0c , . x = 0x0c } , \
{ . src = 0x6030 , . y = 0x0b , . x = 0x0c } ,
# define LINESECTION_SEMIFINAL_TOP_RIGHT \
{ . src = 0x6029 , . y = 0x08 , . x = 0x11 } , \
{ . src = 0x6029 , . y = 0x09 , . x = 0x11 } , \
{ . src = 0x6029 , . y = 0x0a , . x = 0x11 } , \
{ . src = 0x603c , . y = 0x0b , . x = 0x11 } ,
# define LINESECTION_SEMIFINAL_BOTTOM_RIGHT \
{ . src = 0x6038 , . y = 0x0e , . x = 0x11 } , \
{ . src = 0x6037 , . y = 0x0d , . x = 0x11 } , \
{ . src = 0x6036 , . y = 0x0c , . x = 0x11 } , \
{ . src = 0x6035 , . y = 0x0b , . x = 0x11 } ,
# define LINESECTION_FINAL_LEFT \
{ . src = 0x602c , . y = 0x0b , . x = 0x0d } , \
{ . src = 0x602d , . y = 0x0b , . x = 0x0e } ,
# define LINESECTION_FINAL_RIGHT \
{ . src = 0x602f , . y = 0x0b , . x = 0x10 } , \
{ . src = 0x602e , . y = 0x0b , . x = 0x0f } ,
static const struct TourneyTreeLineSection sLineSectionTrainer1Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER1 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer1Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER1 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer1Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER1 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer1Final [ ] =
{
LINESECTION_ROUND1_TRAINER1 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer9Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER9 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer9Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER9 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer9Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER9 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer9Final [ ] =
{
LINESECTION_ROUND1_TRAINER9 ( 0x6023 )
LINESECTION_ROUND2_MATCH1 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer13Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER13 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer13Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER13 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer13Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER13 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer13Final [ ] =
{
LINESECTION_ROUND1_TRAINER13 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer5Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER5 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer5Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER5 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer5Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER5 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer5Final [ ] =
{
LINESECTION_ROUND1_TRAINER5 ( 0x6021 )
LINESECTION_ROUND2_MATCH2 ( 0x6023 )
LINESECTION_SEMIFINAL_TOP_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer8Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER8 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer8Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER8 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer8Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER8 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer8Final [ ] =
{
LINESECTION_ROUND1_TRAINER8 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer16Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER16 ( 0x6043 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer16Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER16 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer16Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER16 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer16Final [ ] =
{
LINESECTION_ROUND1_TRAINER16 ( 0x6023 )
LINESECTION_ROUND2_MATCH3 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer12Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER12 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer12Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER12 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer12Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER12 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer12Final [ ] =
{
LINESECTION_ROUND1_TRAINER12 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer4Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER4 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer4Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER4 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer4Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER4 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer4Final [ ] =
{
LINESECTION_ROUND1_TRAINER4 ( 0x6021 )
LINESECTION_ROUND2_MATCH4 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_LEFT
LINESECTION_FINAL_LEFT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer3Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER3 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer3Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER3 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer3Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER3 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer3Final [ ] =
{
LINESECTION_ROUND1_TRAINER3 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer11Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER11 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer11Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER11 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer11Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER11 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer11Final [ ] =
{
LINESECTION_ROUND1_TRAINER11 ( 0x6025 )
LINESECTION_ROUND2_MATCH5 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer15Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER15 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer15Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER15 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer15Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER15 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer15Final [ ] =
{
LINESECTION_ROUND1_TRAINER15 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer7Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER7 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer7Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER7 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer7Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER7 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer7Final [ ] =
{
LINESECTION_ROUND1_TRAINER7 ( 0x6021 )
LINESECTION_ROUND2_MATCH6 ( 0x6025 )
LINESECTION_SEMIFINAL_TOP_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer6Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER6 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer6Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER6 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer6Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER6 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer6Final [ ] =
{
LINESECTION_ROUND1_TRAINER6 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer14Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER14 ( 0x6045 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer14Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER14 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer14Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER14 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer14Final [ ] =
{
LINESECTION_ROUND1_TRAINER14 ( 0x6025 )
LINESECTION_ROUND2_MATCH7 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer10Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER10 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer10Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER10 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer10Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER10 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer10Final [ ] =
{
LINESECTION_ROUND1_TRAINER10 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer2Round1 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER2 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer2Round2 [ ] =
2018-08-26 14:40:36 +02:00
{
2020-01-05 16:50:32 +01:00
LINESECTION_ROUND1_TRAINER2 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer2Semifinal [ ] =
{
LINESECTION_ROUND1_TRAINER2 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection sLineSectionTrainer2Final [ ] =
{
LINESECTION_ROUND1_TRAINER2 ( 0x6021 )
LINESECTION_ROUND2_MATCH8 ( 0x6021 )
LINESECTION_SEMIFINAL_BOTTOM_RIGHT
LINESECTION_FINAL_RIGHT
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const struct TourneyTreeLineSection * const sTourneyTreeLineSections [ DOME_TOURNAMENT_TRAINERS_COUNT ] [ DOME_ROUNDS_COUNT ] =
{
{ sLineSectionTrainer1Round1 , sLineSectionTrainer1Round2 , sLineSectionTrainer1Semifinal , sLineSectionTrainer1Final } ,
{ sLineSectionTrainer2Round1 , sLineSectionTrainer2Round2 , sLineSectionTrainer2Semifinal , sLineSectionTrainer2Final } ,
{ sLineSectionTrainer3Round1 , sLineSectionTrainer3Round2 , sLineSectionTrainer3Semifinal , sLineSectionTrainer3Final } ,
{ sLineSectionTrainer4Round1 , sLineSectionTrainer4Round2 , sLineSectionTrainer4Semifinal , sLineSectionTrainer4Final } ,
{ sLineSectionTrainer5Round1 , sLineSectionTrainer5Round2 , sLineSectionTrainer5Semifinal , sLineSectionTrainer5Final } ,
{ sLineSectionTrainer6Round1 , sLineSectionTrainer6Round2 , sLineSectionTrainer6Semifinal , sLineSectionTrainer6Final } ,
{ sLineSectionTrainer7Round1 , sLineSectionTrainer7Round2 , sLineSectionTrainer7Semifinal , sLineSectionTrainer7Final } ,
{ sLineSectionTrainer8Round1 , sLineSectionTrainer8Round2 , sLineSectionTrainer8Semifinal , sLineSectionTrainer8Final } ,
{ sLineSectionTrainer9Round1 , sLineSectionTrainer9Round2 , sLineSectionTrainer9Semifinal , sLineSectionTrainer9Final } ,
{ sLineSectionTrainer10Round1 , sLineSectionTrainer10Round2 , sLineSectionTrainer10Semifinal , sLineSectionTrainer10Final } ,
{ sLineSectionTrainer11Round1 , sLineSectionTrainer11Round2 , sLineSectionTrainer11Semifinal , sLineSectionTrainer11Final } ,
{ sLineSectionTrainer12Round1 , sLineSectionTrainer12Round2 , sLineSectionTrainer12Semifinal , sLineSectionTrainer12Final } ,
{ sLineSectionTrainer13Round1 , sLineSectionTrainer13Round2 , sLineSectionTrainer13Semifinal , sLineSectionTrainer13Final } ,
{ sLineSectionTrainer14Round1 , sLineSectionTrainer14Round2 , sLineSectionTrainer14Semifinal , sLineSectionTrainer14Final } ,
{ sLineSectionTrainer15Round1 , sLineSectionTrainer15Round2 , sLineSectionTrainer15Semifinal , sLineSectionTrainer15Final } ,
{ sLineSectionTrainer16Round1 , sLineSectionTrainer16Round2 , sLineSectionTrainer16Semifinal , sLineSectionTrainer16Final } ,
2018-08-26 14:40:36 +02:00
} ;
2020-01-05 16:50:32 +01:00
static const u8 sTourneyTreeLineSectionArrayCounts [ DOME_TOURNAMENT_TRAINERS_COUNT ] [ DOME_ROUNDS_COUNT ] =
{
{ ARRAY_COUNT ( sLineSectionTrainer1Round1 ) , ARRAY_COUNT ( sLineSectionTrainer1Round2 ) , ARRAY_COUNT ( sLineSectionTrainer1Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer1Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer2Round1 ) , ARRAY_COUNT ( sLineSectionTrainer2Round2 ) , ARRAY_COUNT ( sLineSectionTrainer2Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer2Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer3Round1 ) , ARRAY_COUNT ( sLineSectionTrainer3Round2 ) , ARRAY_COUNT ( sLineSectionTrainer3Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer3Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer4Round1 ) , ARRAY_COUNT ( sLineSectionTrainer4Round2 ) , ARRAY_COUNT ( sLineSectionTrainer4Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer4Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer5Round1 ) , ARRAY_COUNT ( sLineSectionTrainer5Round2 ) , ARRAY_COUNT ( sLineSectionTrainer5Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer5Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer6Round1 ) , ARRAY_COUNT ( sLineSectionTrainer6Round2 ) , ARRAY_COUNT ( sLineSectionTrainer6Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer6Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer7Round1 ) , ARRAY_COUNT ( sLineSectionTrainer7Round2 ) , ARRAY_COUNT ( sLineSectionTrainer7Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer7Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer8Round1 ) , ARRAY_COUNT ( sLineSectionTrainer8Round2 ) , ARRAY_COUNT ( sLineSectionTrainer8Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer8Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer9Round1 ) , ARRAY_COUNT ( sLineSectionTrainer9Round2 ) , ARRAY_COUNT ( sLineSectionTrainer9Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer9Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer10Round1 ) , ARRAY_COUNT ( sLineSectionTrainer10Round2 ) , ARRAY_COUNT ( sLineSectionTrainer10Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer10Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer11Round1 ) , ARRAY_COUNT ( sLineSectionTrainer11Round2 ) , ARRAY_COUNT ( sLineSectionTrainer11Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer11Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer12Round1 ) , ARRAY_COUNT ( sLineSectionTrainer12Round2 ) , ARRAY_COUNT ( sLineSectionTrainer12Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer12Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer13Round1 ) , ARRAY_COUNT ( sLineSectionTrainer13Round2 ) , ARRAY_COUNT ( sLineSectionTrainer13Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer13Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer14Round1 ) , ARRAY_COUNT ( sLineSectionTrainer14Round2 ) , ARRAY_COUNT ( sLineSectionTrainer14Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer14Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer15Round1 ) , ARRAY_COUNT ( sLineSectionTrainer15Round2 ) , ARRAY_COUNT ( sLineSectionTrainer15Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer15Final ) } ,
{ ARRAY_COUNT ( sLineSectionTrainer16Round1 ) , ARRAY_COUNT ( sLineSectionTrainer16Round2 ) , ARRAY_COUNT ( sLineSectionTrainer16Semifinal ) , ARRAY_COUNT ( sLineSectionTrainer16Final ) } ,
2018-08-26 14:40:36 +02:00
} ;
2018-08-25 19:59:47 +02:00
void CallBattleDomeFunction ( void )
2018-08-15 15:49:50 +02:00
{
2019-02-08 18:08:25 +01:00
sBattleDomeFunctions [ gSpecialVar_0x8004 ] ( ) ;
2018-08-15 15:49:50 +02:00
}
2019-02-08 18:08:25 +01:00
static void InitDomeChallenge ( void )
2018-08-15 15:49:50 +02:00
{
2018-08-25 19:59:47 +02:00
u32 lvlMode = gSaveBlock2Ptr - > frontier . lvlMode ;
u32 battleMode = VarGet ( VAR_FRONTIER_BATTLE_MODE ) ;
2018-08-15 15:49:50 +02:00
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . challengeStatus = 0 ;
2018-10-21 00:06:42 +02:00
gSaveBlock2Ptr - > frontier . curChallengeBattleNum = 0 ;
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . challengePaused = FALSE ;
2019-12-14 09:58:20 +01:00
gSaveBlock2Ptr - > frontier . disableRecordBattle = FALSE ;
2019-11-24 22:58:40 +01:00
if ( ! ( gSaveBlock2Ptr - > frontier . winStreakActiveFlags & sWinStreakFlags [ battleMode ] [ lvlMode ] ) )
2018-10-27 17:39:05 +02:00
gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] = 0 ;
2018-08-15 15:49:50 +02:00
2021-11-15 18:04:54 +01:00
SetDynamicWarp ( 0 , gSaveBlock1Ptr - > location . mapGroup , gSaveBlock1Ptr - > location . mapNum , WARP_ID_NONE ) ;
2018-08-15 15:49:50 +02:00
gTrainerBattleOpponent_A = 0 ;
}
2019-02-08 18:08:25 +01:00
static void GetDomeData ( void )
2018-08-15 15:49:50 +02:00
{
2018-08-25 19:59:47 +02:00
u32 lvlMode = gSaveBlock2Ptr - > frontier . lvlMode ;
u32 battleMode = VarGet ( VAR_FRONTIER_BATTLE_MODE ) ;
2018-08-15 15:49:50 +02:00
switch ( gSpecialVar_0x8005 )
{
2019-11-29 04:46:39 +01:00
case DOME_DATA_WIN_STREAK :
2018-10-27 17:39:05 +02:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
break ;
2019-11-29 04:46:39 +01:00
case DOME_DATA_WIN_STREAK_ACTIVE :
2019-11-24 22:58:40 +01:00
gSpecialVar_Result = ( ( gSaveBlock2Ptr - > frontier . winStreakActiveFlags & sWinStreakFlags [ battleMode ] [ lvlMode ] ) ! = 0 ) ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_SINGLES_50 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedSingles50 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_SINGLES_OPEN :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedSinglesOpen ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_SINGLES_50 :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonSingles50 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_SINGLES_OPEN :
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonSinglesOpen ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_CHALLENGE :
2018-08-25 19:59:47 +02:00
if ( VarGet ( VAR_FRONTIER_BATTLE_MODE ) = = FRONTIER_MODE_DOUBLES )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedDoublesOpen ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedDoubles50 ;
2018-08-15 15:49:50 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedSinglesOpen ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeAttemptedSingles50 ;
2018-08-15 15:49:50 +02:00
}
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_CHALLENGE :
2018-08-25 19:59:47 +02:00
if ( VarGet ( VAR_FRONTIER_BATTLE_MODE ) = = FRONTIER_MODE_DOUBLES )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonDoublesOpen ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonDoubles50 ;
2018-08-15 15:49:50 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonSinglesOpen ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSpecialVar_Result = gSaveBlock2Ptr - > frontier . domeHasWonSingles50 ;
2018-08-15 15:49:50 +02:00
}
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_SELECTED_MONS :
2019-10-18 01:22:03 +02:00
ClearSelectedPartyOrder ( ) ;
2019-11-24 22:58:40 +01:00
gSelectedOrderFromParty [ 0 ] = gSaveBlock2Ptr - > frontier . selectedPartyMons [ 3 ] ;
gSelectedOrderFromParty [ 1 ] = gSaveBlock2Ptr - > frontier . selectedPartyMons [ 3 ] > > 8 ;
2018-08-15 15:49:50 +02:00
break ;
2020-01-05 16:50:32 +01:00
case DOME_DATA_PREV_TOURNEY_TYPE :
2019-12-18 08:32:52 +01:00
gSpecialVar_Result = ( gSaveBlock2Ptr - > frontier . domeLvlMode * 2 ) - 3 + gSaveBlock2Ptr - > frontier . domeBattleMode ;
2018-08-15 15:49:50 +02:00
break ;
}
}
2019-02-08 18:08:25 +01:00
static void SetDomeData ( void )
2018-08-15 15:49:50 +02:00
{
2018-08-25 19:59:47 +02:00
u32 lvlMode = gSaveBlock2Ptr - > frontier . lvlMode ;
u32 battleMode = VarGet ( VAR_FRONTIER_BATTLE_MODE ) ;
2018-08-15 15:49:50 +02:00
switch ( gSpecialVar_0x8005 )
{
2019-11-29 04:46:39 +01:00
case DOME_DATA_WIN_STREAK :
2018-10-27 17:39:05 +02:00
gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
2019-11-29 04:46:39 +01:00
case DOME_DATA_WIN_STREAK_ACTIVE :
2018-08-15 15:49:50 +02:00
if ( gSpecialVar_0x8006 )
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . winStreakActiveFlags | = sWinStreakFlags [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
else
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . winStreakActiveFlags & = sWinStreakMasks [ battleMode ] [ lvlMode ] ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_SINGLES_50 :
gSaveBlock2Ptr - > frontier . domeAttemptedSingles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_SINGLES_OPEN :
gSaveBlock2Ptr - > frontier . domeAttemptedSinglesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_SINGLES_50 :
gSaveBlock2Ptr - > frontier . domeHasWonSingles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_SINGLES_OPEN :
gSaveBlock2Ptr - > frontier . domeHasWonSinglesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_ATTEMPTED_CHALLENGE :
2018-08-25 19:59:47 +02:00
if ( VarGet ( VAR_FRONTIER_BATTLE_MODE ) = = FRONTIER_MODE_DOUBLES )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSaveBlock2Ptr - > frontier . domeAttemptedDoublesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . domeAttemptedDoubles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSaveBlock2Ptr - > frontier . domeAttemptedSinglesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . domeAttemptedSingles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
}
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_HAS_WON_CHALLENGE :
2018-08-25 19:59:47 +02:00
if ( VarGet ( VAR_FRONTIER_BATTLE_MODE ) = = FRONTIER_MODE_DOUBLES )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSaveBlock2Ptr - > frontier . domeHasWonDoublesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . domeHasWonDoubles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( lvlMode ! = FRONTIER_LVL_50 )
gSaveBlock2Ptr - > frontier . domeHasWonSinglesOpen = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
else
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . domeHasWonSingles50 = gSpecialVar_0x8006 ;
2018-08-15 15:49:50 +02:00
}
break ;
2019-12-18 08:32:52 +01:00
case DOME_DATA_SELECTED_MONS :
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . selectedPartyMons [ 3 ] = T1_READ_16 ( gSelectedOrderFromParty ) ;
2018-08-15 15:49:50 +02:00
break ;
}
}
2018-08-26 15:51:14 +02:00
static void InitDomeTrainers ( void )
2018-08-15 15:49:50 +02:00
{
2019-02-08 18:08:25 +01:00
int i , j , k ;
int monLevel ;
2019-11-29 03:09:35 +01:00
int species [ FRONTIER_PARTY_SIZE ] ;
2019-02-08 18:08:25 +01:00
int monTypesBits , monTypesCount ;
int trainerId ;
2020-01-05 16:50:32 +01:00
int monId ;
2019-12-21 10:27:12 +01:00
u16 * rankingScores ;
2019-02-08 18:08:25 +01:00
int * statValues ;
2018-08-18 18:23:40 +02:00
u8 ivs = 0 ;
species [ 0 ] = 0 ;
species [ 1 ] = 0 ;
species [ 2 ] = 0 ;
2019-12-21 10:27:12 +01:00
rankingScores = AllocZeroed ( sizeof ( u16 ) * DOME_TOURNAMENT_TRAINERS_COUNT ) ;
2019-12-18 08:32:52 +01:00
statValues = AllocZeroed ( sizeof ( int ) * NUM_STATS ) ;
2018-08-15 15:49:50 +02:00
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . domeLvlMode = gSaveBlock2Ptr - > frontier . lvlMode + 1 ;
gSaveBlock2Ptr - > frontier . domeBattleMode = VarGet ( VAR_FRONTIER_BATTLE_MODE ) + 1 ;
DOME_TRAINERS [ 0 ] . trainerId = TRAINER_PLAYER ;
DOME_TRAINERS [ 0 ] . isEliminated = FALSE ;
DOME_TRAINERS [ 0 ] . eliminatedAt = 0 ;
DOME_TRAINERS [ 0 ] . forfeited = FALSE ;
2018-08-15 15:49:50 +02:00
2019-12-21 10:27:12 +01:00
// Store the data used to display party information on the player's tourney page
2019-11-24 22:58:40 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
DOME_MONS [ 0 ] [ i ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . selectedPartyMons [ i ] - 1 ] , MON_DATA_SPECIES , NULL ) ;
2018-12-25 18:50:15 +01:00
for ( j = 0 ; j < MAX_MON_MOVES ; j + + )
2019-12-21 10:27:12 +01:00
gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . moves [ j ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . selectedPartyMons [ i ] - 1 ] , MON_DATA_MOVE1 + j , NULL ) ;
2019-11-24 22:58:40 +01:00
for ( j = 0 ; j < NUM_STATS ; j + + )
2019-12-21 10:27:12 +01:00
gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . evs [ j ] = GetMonData ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . selectedPartyMons [ i ] - 1 ] , MON_DATA_HP_EV + j , NULL ) ;
2018-08-15 15:49:50 +02:00
2019-12-21 10:27:12 +01:00
gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . nature = GetNature ( & gPlayerParty [ gSaveBlock2Ptr - > frontier . selectedPartyMons [ i ] - 1 ] ) ;
2018-08-15 15:49:50 +02:00
}
2019-12-21 10:27:12 +01:00
// Populate the tourney roster with random frontier trainers (dependent on streak)
2018-08-18 18:23:40 +02:00
for ( i = 1 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
2018-08-15 15:49:50 +02:00
{
2020-01-05 16:50:32 +01:00
// Choose trainer. First 5/16 trainers are easier than the rest
2018-08-18 18:23:40 +02:00
if ( i > 5 )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
do
2018-08-15 15:49:50 +02:00
{
2019-12-21 00:52:29 +01:00
trainerId = GetRandomScaledFrontierTrainerId ( GetCurrentFacilityWinStreak ( ) , 0 ) ;
2018-08-18 18:23:40 +02:00
for ( j = 1 ; j < i ; j + + )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ j ] . trainerId = = trainerId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( j ! = i ) ;
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ i ] . trainerId = trainerId ;
2018-08-15 15:49:50 +02:00
}
else
{
2018-08-18 18:23:40 +02:00
do
2018-08-15 15:49:50 +02:00
{
2019-12-21 00:52:29 +01:00
trainerId = GetRandomScaledFrontierTrainerId ( GetCurrentFacilityWinStreak ( ) + 1 , 0 ) ;
2018-08-18 18:23:40 +02:00
for ( j = 1 ; j < i ; j + + )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ j ] . trainerId = = trainerId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( j ! = i ) ;
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ i ] . trainerId = trainerId ;
2018-08-15 15:49:50 +02:00
}
2020-01-05 16:50:32 +01:00
// Choose party
2019-11-29 03:09:35 +01:00
for ( j = 0 ; j < FRONTIER_PARTY_SIZE ; j + + )
2018-08-15 15:49:50 +02:00
{
do
{
2020-01-05 16:50:32 +01:00
monId = GetRandomFrontierMonFromSet ( trainerId ) ;
2018-08-18 18:23:40 +02:00
for ( k = 0 ; k < j ; k + + )
2018-08-15 15:49:50 +02:00
{
2020-01-05 16:50:32 +01:00
// Make sure the mon is valid.
int alreadySelectedMonId = DOME_MONS [ i ] [ k ] ;
if ( alreadySelectedMonId = = monId
| | species [ 0 ] = = gFacilityTrainerMons [ monId ] . species
| | species [ 1 ] = = gFacilityTrainerMons [ monId ] . species
| | gFacilityTrainerMons [ alreadySelectedMonId ] . itemTableId = = gFacilityTrainerMons [ monId ] . itemTableId )
2018-08-15 15:49:50 +02:00
break ;
}
2018-08-18 18:23:40 +02:00
} while ( k ! = j ) ;
2018-08-15 15:49:50 +02:00
2020-01-05 16:50:32 +01:00
DOME_MONS [ i ] [ j ] = monId ;
species [ j ] = gFacilityTrainerMons [ monId ] . species ;
2018-08-15 15:49:50 +02:00
}
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ i ] . isEliminated = FALSE ;
DOME_TRAINERS [ i ] . eliminatedAt = 0 ;
DOME_TRAINERS [ i ] . forfeited = FALSE ;
2018-08-15 15:49:50 +02:00
}
2019-12-21 10:27:12 +01:00
// rankingScores is used to determine the seed (ranking) of the trainers
// rankingScores[0] is for the player, rankingScores[1-15] are for the opponent trainers
// Calculate player's ranking score
2018-08-18 18:23:40 +02:00
monTypesBits = 0 ;
2019-12-21 10:27:12 +01:00
rankingScores [ 0 ] = 0 ;
2019-11-24 22:58:40 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-15 15:49:50 +02:00
{
2019-12-21 10:27:12 +01:00
// trainerId var re-used here as index of selected mons
2019-11-24 22:58:40 +01:00
trainerId = gSaveBlock2Ptr - > frontier . selectedPartyMons [ i ] - 1 ;
2019-12-21 10:27:12 +01:00
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_ATK , NULL ) ;
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_DEF , NULL ) ;
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPATK , NULL ) ;
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPDEF , NULL ) ;
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPEED , NULL ) ;
rankingScores [ 0 ] + = GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_MAX_HP , NULL ) ;
2018-08-18 18:23:40 +02:00
monTypesBits | = gBitTable [ gBaseStats [ GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPECIES , NULL ) ] . type1 ] ;
monTypesBits | = gBitTable [ gBaseStats [ GetMonData ( & gPlayerParty [ trainerId ] , MON_DATA_SPECIES , NULL ) ] . type2 ] ;
2018-08-15 15:49:50 +02:00
}
2019-12-21 10:27:12 +01:00
// Count the number of types in the players party, to factor into the ranking
2018-08-18 18:23:40 +02:00
for ( monTypesCount = 0 , j = 0 ; j < 32 ; j + + )
2018-08-15 15:49:50 +02:00
{
if ( monTypesBits & 1 )
monTypesCount + + ;
monTypesBits > > = 1 ;
}
2018-10-24 23:14:45 +02:00
monLevel = SetFacilityPtrsGetLevel ( ) ;
2019-12-21 10:27:12 +01:00
rankingScores [ 0 ] + = ( monTypesCount * monLevel ) / 20 ;
2018-08-15 15:49:50 +02:00
2019-12-21 10:27:12 +01:00
// Calculate rankingScores for the opponent trainers
2018-08-18 18:23:40 +02:00
for ( i = 1 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
2018-08-15 15:49:50 +02:00
{
2018-08-18 18:23:40 +02:00
monTypesBits = 0 ;
2019-12-21 10:27:12 +01:00
rankingScores [ i ] = 0 ;
2019-12-18 08:32:52 +01:00
ivs = GetDomeTrainerMonIvs ( DOME_TRAINERS [ i ] . trainerId ) ;
2019-11-29 03:09:35 +01:00
for ( j = 0 ; j < FRONTIER_PARTY_SIZE ; j + + )
2018-08-15 15:49:50 +02:00
{
2019-12-18 08:32:52 +01:00
CalcDomeMonStats ( gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ,
2018-08-18 18:23:40 +02:00
monLevel , ivs ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . evSpread ,
gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . nature ,
2018-08-18 18:23:40 +02:00
statValues ) ;
2019-12-21 10:27:12 +01:00
rankingScores [ i ] + = statValues [ STAT_ATK ] ;
rankingScores [ i ] + = statValues [ STAT_DEF ] ;
rankingScores [ i ] + = statValues [ STAT_SPATK ] ;
rankingScores [ i ] + = statValues [ STAT_SPDEF ] ;
rankingScores [ i ] + = statValues [ STAT_SPEED ] ;
rankingScores [ i ] + = statValues [ STAT_HP ] ;
2019-12-18 08:32:52 +01:00
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ] . type1 ] ;
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ] . type2 ] ;
2018-08-18 18:23:40 +02:00
}
for ( monTypesCount = 0 , j = 0 ; j < 32 ; j + + )
{
if ( monTypesBits & 1 )
monTypesCount + + ;
monTypesBits > > = 1 ;
2018-08-15 15:49:50 +02:00
}
2019-12-21 10:27:12 +01:00
rankingScores [ i ] + = ( monTypesCount * monLevel ) / 20 ;
2018-08-15 15:49:50 +02:00
}
2020-09-02 15:49:04 +02:00
// Seed tourney trainers according to their ranking
2018-08-18 18:23:40 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1 ; i + + )
{
for ( j = i + 1 ; j < DOME_TOURNAMENT_TRAINERS_COUNT ; j + + )
{
2019-12-21 10:27:12 +01:00
if ( rankingScores [ i ] < rankingScores [ j ] )
2018-08-18 18:23:40 +02:00
{
2019-12-21 10:27:12 +01:00
SwapDomeTrainers ( i , j , rankingScores ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2019-12-21 10:27:12 +01:00
if ( rankingScores [ i ] = = rankingScores [ j ] )
2018-08-18 18:23:40 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ j ] . trainerId = = TRAINER_PLAYER )
2019-12-21 10:27:12 +01:00
SwapDomeTrainers ( i , j , rankingScores ) ;
2019-12-18 08:32:52 +01:00
else if ( DOME_TRAINERS [ i ] . trainerId > DOME_TRAINERS [ j ] . trainerId )
2019-12-21 10:27:12 +01:00
SwapDomeTrainers ( i , j , rankingScores ) ;
2018-08-18 18:23:40 +02:00
}
}
}
}
2019-12-21 10:27:12 +01:00
// Add Frontier Brain to the tourney if they should be fought at the end of it
2019-11-21 03:46:29 +01:00
if ( GetFrontierBrainStatus ( ) ! = FRONTIER_BRAIN_NOT_READY )
2018-08-18 18:23:40 +02:00
{
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = TRAINER_PLAYER )
2018-08-18 18:23:40 +02:00
break ;
}
2020-01-05 16:50:32 +01:00
if ( sTrainerNamePositions [ i ] [ 0 ] ! = 0 )
2018-08-18 18:23:40 +02:00
{
j = 0 ;
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ j ] . trainerId = TRAINER_FRONTIER_BRAIN ;
2018-08-18 18:23:40 +02:00
}
else
{
j = 1 ;
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ j ] . trainerId = TRAINER_FRONTIER_BRAIN ;
2018-08-18 18:23:40 +02:00
}
2019-11-29 03:09:35 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2019-12-18 08:32:52 +01:00
DOME_MONS [ j ] [ i ] = GetFrontierBrainMonSpecies ( i ) ;
2018-08-18 18:23:40 +02:00
}
2019-12-21 10:27:12 +01:00
Free ( rankingScores ) ;
2018-08-18 18:23:40 +02:00
Free ( statValues ) ;
2018-08-15 15:49:50 +02:00
}
# define CALC_STAT(base, statIndex) \
{ \
u8 baseStat = gBaseStats [ species ] . base ; \
stats [ statIndex ] = ( ( ( 2 * baseStat + ivs + evs [ statIndex ] / 4 ) * level ) / 100 ) + 5 ; \
stats [ statIndex ] = ( u8 ) ModifyStatByNature ( nature , stats [ statIndex ] , statIndex ) ; \
}
2019-02-08 18:08:25 +01:00
static void CalcDomeMonStats ( u16 species , int level , int ivs , u8 evBits , u8 nature , int * stats )
2018-08-15 15:49:50 +02:00
{
2019-02-08 18:08:25 +01:00
int i , count ;
2018-08-15 15:49:50 +02:00
u8 bits ;
u16 resultingEvs ;
2019-02-08 18:08:25 +01:00
int evs [ NUM_STATS ] ;
2018-08-15 15:49:50 +02:00
count = 0 , bits = evBits ;
2018-11-18 20:00:36 +01:00
for ( i = 0 ; i < NUM_STATS ; bits > > = 1 , i + + )
2018-08-15 15:49:50 +02:00
{
if ( bits & 1 )
count + + ;
}
2018-08-29 20:38:54 +02:00
resultingEvs = MAX_TOTAL_EVS / count ;
2018-11-18 20:00:36 +01:00
for ( i = 0 ; i < NUM_STATS ; bits < < = 1 , i + + )
2018-08-15 15:49:50 +02:00
{
evs [ i ] = 0 ;
if ( evBits & bits )
evs [ i ] = resultingEvs ;
}
if ( species = = SPECIES_SHEDINJA )
{
stats [ STAT_HP ] = 1 ;
}
else
{
2019-02-08 18:08:25 +01:00
int n = 2 * gBaseStats [ species ] . baseHP ;
2018-08-15 15:49:50 +02:00
stats [ STAT_HP ] = ( ( ( n + ivs + evs [ STAT_HP ] / 4 ) * level ) / 100 ) + level + 10 ;
}
CALC_STAT ( baseAttack , STAT_ATK ) ;
CALC_STAT ( baseDefense , STAT_DEF ) ;
CALC_STAT ( baseSpeed , STAT_SPEED ) ;
CALC_STAT ( baseSpAttack , STAT_SPATK ) ;
CALC_STAT ( baseSpDefense , STAT_SPDEF ) ;
}
2019-02-08 18:08:25 +01:00
static void SwapDomeTrainers ( int id1 , int id2 , u16 * statsArray )
2018-08-15 15:49:50 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-15 15:49:50 +02:00
u16 temp ;
2018-08-30 15:01:07 +02:00
SWAP ( statsArray [ id1 ] , statsArray [ id2 ] , temp ) ;
2019-12-18 08:32:52 +01:00
SWAP ( DOME_TRAINERS [ id1 ] . trainerId , DOME_TRAINERS [ id2 ] . trainerId , temp ) ;
2018-08-15 15:49:50 +02:00
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
SWAP ( DOME_MONS [ id1 ] [ i ] , DOME_MONS [ id2 ] [ i ] , temp ) ;
2018-08-15 15:49:50 +02:00
}
2018-08-15 23:04:46 +02:00
2019-02-08 18:08:25 +01:00
static void BufferDomeRoundText ( void )
2018-08-15 23:04:46 +02:00
{
2018-10-21 00:06:42 +02:00
StringCopy ( gStringVar1 , gRoundsStringTable [ gSaveBlock2Ptr - > frontier . curChallengeBattleNum ] ) ;
2018-08-15 23:04:46 +02:00
}
2019-02-08 18:08:25 +01:00
static void BufferDomeOpponentName ( void )
2018-08-15 23:04:46 +02:00
{
2018-10-21 00:06:42 +02:00
StringCopy ( gStringVar1 , gRoundsStringTable [ gSaveBlock2Ptr - > frontier . curChallengeBattleNum ] ) ;
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar2 , gTrainerBattleOpponent_A ) ;
2018-08-15 23:04:46 +02:00
}
2019-02-08 18:08:25 +01:00
static void InitDomeOpponentParty ( void )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
gPlayerPartyLostHP = 0 ;
sPlayerPartyMaxHP = GetMonData ( & gPlayerParty [ 0 ] , MON_DATA_MAX_HP , NULL ) ;
sPlayerPartyMaxHP + = GetMonData ( & gPlayerParty [ 1 ] , MON_DATA_MAX_HP , NULL ) ;
2018-08-15 23:04:46 +02:00
CalculatePlayerPartyCount ( ) ;
2019-02-08 18:08:25 +01:00
CreateDomeOpponentMons ( TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ) ;
2018-08-15 23:04:46 +02:00
}
2019-02-08 18:08:25 +01:00
static void CreateDomeOpponentMon ( u8 monPartyId , u16 tournamentTrainerId , u8 tournamentMonId , u32 otId )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2019-12-18 08:32:52 +01:00
u8 friendship = MAX_FRIENDSHIP ;
2020-12-13 05:28:01 +01:00
# ifdef BUGFIX
u8 fixedIv = GetDomeTrainerMonIvs ( DOME_TRAINERS [ tournamentTrainerId ] . trainerId ) ;
# else
u8 fixedIv = GetDomeTrainerMonIvs ( tournamentTrainerId ) ; // BUG: Using the wrong ID. As a result, all Pokemon have ivs of 3.
# endif
2018-10-24 23:14:45 +02:00
u8 level = SetFacilityPtrsGetLevel ( ) ;
2018-11-11 16:44:27 +01:00
CreateMonWithEVSpreadNatureOTID ( & gEnemyParty [ monPartyId ] ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . species ,
2018-08-15 23:04:46 +02:00
level ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . nature ,
2018-08-15 23:04:46 +02:00
fixedIv ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . evSpread , otId ) ;
2018-08-15 23:04:46 +02:00
2019-12-18 08:32:52 +01:00
friendship = MAX_FRIENDSHIP ;
2018-12-25 18:50:15 +01:00
for ( i = 0 ; i < MAX_MON_MOVES ; i + + )
2018-08-15 23:04:46 +02:00
{
SetMonMoveSlot ( & gEnemyParty [ monPartyId ] ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . moves [ i ] , i ) ;
if ( gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . moves [ i ] = = MOVE_FRUSTRATION )
friendship = 0 ;
2018-08-15 23:04:46 +02:00
}
2019-12-18 08:32:52 +01:00
SetMonData ( & gEnemyParty [ monPartyId ] , MON_DATA_FRIENDSHIP , & friendship ) ;
2018-08-15 23:04:46 +02:00
SetMonData ( & gEnemyParty [ monPartyId ] , MON_DATA_HELD_ITEM ,
2019-12-18 08:32:52 +01:00
& gBattleFrontierHeldItems [ gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ tournamentMonId ] ] . itemTableId ] ) ;
2018-08-15 23:04:46 +02:00
}
2019-02-08 18:08:25 +01:00
static void CreateDomeOpponentMons ( u16 tournamentTrainerId )
2018-08-15 23:04:46 +02:00
{
u8 monsCount = 0 ;
u32 otId = 0 ;
2019-12-18 08:32:52 +01:00
int i , selectedMonBits ;
2018-08-15 23:04:46 +02:00
ZeroEnemyPartyMons ( ) ;
2019-12-18 08:32:52 +01:00
selectedMonBits = GetDomeTrainerSelectedMons ( tournamentTrainerId ) ;
2018-08-15 23:04:46 +02:00
otId = Random32 ( ) ;
2019-12-18 08:32:52 +01:00
2018-08-15 23:04:46 +02:00
if ( Random ( ) % 10 > 5 )
{
2019-12-18 08:32:52 +01:00
// Create mon if it was selected, starting from front
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
if ( selectedMonBits & 1 )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
CreateDomeOpponentMon ( monsCount , tournamentTrainerId , i , otId ) ;
2018-08-15 23:04:46 +02:00
monsCount + + ;
}
2019-12-18 08:32:52 +01:00
selectedMonBits > > = 1 ;
2018-08-15 23:04:46 +02:00
}
}
else
{
2019-12-18 08:32:52 +01:00
// Create mon if it was selected, starting from back
for ( i = FRONTIER_PARTY_SIZE - 1 ; i > = 0 ; i - - )
2018-08-15 23:04:46 +02:00
{
2020-04-09 21:18:53 +02:00
if ( selectedMonBits & ( 1 < < ( FRONTIER_PARTY_SIZE - 1 ) ) )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
CreateDomeOpponentMon ( monsCount , tournamentTrainerId , i , otId ) ;
2018-08-15 23:04:46 +02:00
monsCount + + ;
}
2019-12-18 08:32:52 +01:00
selectedMonBits < < = 1 ;
2018-08-15 23:04:46 +02:00
}
}
}
2022-06-01 18:41:57 +02:00
// Returns a bitmask representing which 2 of the trainer's 3 pokemon to select.
// The choice is calculated solely depending on the type effectiveness of their
// movesets against the player's pokemon.
// There is a 50% chance of either a "good" or "bad" selection mode being used.
// In the good mode movesets are preferred which are more effective against the
// player, and in the bad mode the opposite is true. If all 3 pokemon tie, the
// other mode will be tried. If they tie again, the pokemon selection is random.
2019-12-18 08:32:52 +01:00
int GetDomeTrainerSelectedMons ( u16 tournamentTrainerId )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
int selectedMonBits ;
2018-08-15 23:04:46 +02:00
if ( Random ( ) & 1 )
{
2022-06-01 18:41:57 +02:00
selectedMonBits = SelectOpponentMons_Good ( tournamentTrainerId , FALSE ) ;
2019-12-18 08:32:52 +01:00
if ( selectedMonBits = = 0 )
2022-06-01 18:41:57 +02:00
selectedMonBits = SelectOpponentMons_Bad ( tournamentTrainerId , TRUE ) ;
2018-08-15 23:04:46 +02:00
}
else
{
2022-06-01 18:41:57 +02:00
selectedMonBits = SelectOpponentMons_Bad ( tournamentTrainerId , FALSE ) ;
2019-12-18 08:32:52 +01:00
if ( selectedMonBits = = 0 )
2022-06-01 18:41:57 +02:00
selectedMonBits = SelectOpponentMons_Good ( tournamentTrainerId , TRUE ) ;
2018-08-15 23:04:46 +02:00
}
2019-12-18 08:32:52 +01:00
return selectedMonBits ;
2018-08-15 23:04:46 +02:00
}
2022-06-01 18:41:57 +02:00
static int SelectOpponentMons_Good ( u16 tournamentTrainerId , bool8 allowRandom )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int i , moveId , playerMonId ;
2019-12-18 08:32:52 +01:00
int partyMovePoints [ FRONTIER_PARTY_SIZE ] ;
2018-08-15 23:04:46 +02:00
2019-11-29 03:09:35 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] = 0 ;
2018-12-25 18:50:15 +01:00
for ( moveId = 0 ; moveId < MAX_MON_MOVES ; moveId + + )
2018-08-15 23:04:46 +02:00
{
2019-11-29 03:09:35 +01:00
for ( playerMonId = 0 ; playerMonId < FRONTIER_PARTY_SIZE ; playerMonId + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentTrainerId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] + = GetTypeEffectivenessPoints ( GetFrontierBrainMonMove ( i , moveId ) ,
2022-06-01 18:41:57 +02:00
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , EFFECTIVENESS_MODE_GOOD ) ;
2018-08-15 23:04:46 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] + = GetTypeEffectivenessPoints ( gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ i ] ] . moves [ moveId ] ,
2022-06-01 18:41:57 +02:00
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , EFFECTIVENESS_MODE_GOOD ) ;
2018-08-15 23:04:46 +02:00
}
}
}
}
2019-12-18 08:32:52 +01:00
return SelectOpponentMonsFromParty ( partyMovePoints , allowRandom ) ;
2018-08-15 23:04:46 +02:00
}
2022-06-01 18:41:57 +02:00
// Identical to function above, but uses EFFECTIVENESS_MODE_BAD
static int SelectOpponentMons_Bad ( u16 tournamentTrainerId , bool8 allowRandom )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int i , moveId , playerMonId ;
2019-12-18 08:32:52 +01:00
int partyMovePoints [ FRONTIER_PARTY_SIZE ] ;
2018-08-15 23:04:46 +02:00
2019-11-29 03:09:35 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] = 0 ;
2018-12-25 18:50:15 +01:00
for ( moveId = 0 ; moveId < MAX_MON_MOVES ; moveId + + )
2018-08-15 23:04:46 +02:00
{
2019-11-29 03:09:35 +01:00
for ( playerMonId = 0 ; playerMonId < FRONTIER_PARTY_SIZE ; playerMonId + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentTrainerId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] + = GetTypeEffectivenessPoints ( GetFrontierBrainMonMove ( i , moveId ) ,
2022-06-01 18:41:57 +02:00
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , EFFECTIVENESS_MODE_BAD ) ;
2018-08-15 23:04:46 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
partyMovePoints [ i ] + = GetTypeEffectivenessPoints ( gFacilityTrainerMons [ DOME_MONS [ tournamentTrainerId ] [ i ] ] . moves [ moveId ] ,
2022-06-01 18:41:57 +02:00
GetMonData ( & gPlayerParty [ playerMonId ] , MON_DATA_SPECIES , NULL ) , EFFECTIVENESS_MODE_BAD ) ;
2018-08-15 23:04:46 +02:00
}
}
}
}
2019-12-18 08:32:52 +01:00
return SelectOpponentMonsFromParty ( partyMovePoints , allowRandom ) ;
2018-08-15 23:04:46 +02:00
}
2019-12-18 08:32:52 +01:00
static int SelectOpponentMonsFromParty ( int * partyMovePoints , bool8 allowRandom )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int i , j ;
2019-12-18 08:32:52 +01:00
int selectedMonBits = 0 ;
int partyPositions [ FRONTIER_PARTY_SIZE ] ;
2018-08-15 23:04:46 +02:00
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
partyPositions [ i ] = i ;
2018-08-15 23:04:46 +02:00
2019-12-18 08:32:52 +01:00
// All party mons have equal move score totals, choose randomly
2020-09-02 15:49:04 +02:00
if ( partyMovePoints [ 0 ] = = partyMovePoints [ 1 ]
2019-12-18 08:32:52 +01:00
& & partyMovePoints [ 0 ] = = partyMovePoints [ 2 ] )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
if ( allowRandom )
2018-08-15 23:04:46 +02:00
{
i = 0 ;
2019-12-18 08:32:52 +01:00
while ( i ! = DOME_BATTLE_PARTY_SIZE )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
u32 rand = Random ( ) & FRONTIER_PARTY_SIZE ;
if ( rand ! = FRONTIER_PARTY_SIZE & & ! ( selectedMonBits & gBitTable [ rand ] ) )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
selectedMonBits | = gBitTable [ rand ] ;
2018-08-15 23:04:46 +02:00
i + + ;
}
}
}
}
else
{
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < DOME_BATTLE_PARTY_SIZE ; i + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
for ( j = i + 1 ; j < FRONTIER_PARTY_SIZE ; j + + )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int temp ;
2018-08-15 23:04:46 +02:00
2019-12-18 08:32:52 +01:00
if ( partyMovePoints [ i ] < partyMovePoints [ j ] )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
SWAP ( partyMovePoints [ i ] , partyMovePoints [ j ] , temp )
SWAP ( partyPositions [ i ] , partyPositions [ j ] , temp )
2018-08-15 23:04:46 +02:00
}
2019-12-18 08:32:52 +01:00
if ( partyMovePoints [ i ] = = partyMovePoints [ j ] & & ( Random ( ) & 1 ) )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
SWAP ( partyMovePoints [ i ] , partyMovePoints [ j ] , temp )
SWAP ( partyPositions [ i ] , partyPositions [ j ] , temp )
2018-08-15 23:04:46 +02:00
}
}
}
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < DOME_BATTLE_PARTY_SIZE ; i + + )
2018-08-15 23:04:46 +02:00
{
2019-12-18 08:32:52 +01:00
selectedMonBits | = gBitTable [ partyPositions [ i ] ] ;
2018-08-15 23:04:46 +02:00
}
}
2019-12-18 08:32:52 +01:00
return selectedMonBits ;
2018-08-15 23:04:46 +02:00
}
2018-08-26 21:41:47 +02:00
# define TYPE_x0 0
# define TYPE_x0_25 5
# define TYPE_x0_50 10
# define TYPE_x1 20
# define TYPE_x2 40
# define TYPE_x4 80
2022-06-01 18:41:57 +02:00
static int GetTypeEffectivenessPoints ( int move , int targetSpecies , int mode )
2018-08-15 23:04:46 +02:00
{
2019-02-08 18:08:25 +01:00
int defType1 , defType2 , defAbility , moveType ;
int i = 0 ;
int typePower = TYPE_x1 ;
2018-08-15 23:04:46 +02:00
2022-07-11 16:18:13 +02:00
if ( move = = MOVE_NONE | | move = = MOVE_UNAVAILABLE | | gBattleMoves [ move ] . power = = 0 )
2018-08-15 23:04:46 +02:00
return 0 ;
2018-08-26 21:41:47 +02:00
defType1 = gBaseStats [ targetSpecies ] . type1 ;
defType2 = gBaseStats [ targetSpecies ] . type2 ;
2019-05-14 15:42:55 +02:00
defAbility = gBaseStats [ targetSpecies ] . abilities [ 0 ] ;
2018-08-15 23:04:46 +02:00
moveType = gBattleMoves [ move ] . type ;
2018-08-26 21:41:47 +02:00
if ( defAbility = = ABILITY_LEVITATE & & moveType = = TYPE_GROUND )
2018-08-15 23:04:46 +02:00
{
2022-06-01 18:41:57 +02:00
// They likely meant to return here, as 8 is the number of points normally used in this mode for moves with no effect.
// Because there's no return the value instead gets interpreted by the switch, and the number of points becomes 0.
if ( mode = = EFFECTIVENESS_MODE_BAD )
{
2018-08-15 23:04:46 +02:00
typePower = 8 ;
2022-06-01 18:41:57 +02:00
# ifdef BUGFIX
return ;
# endif
}
2018-08-15 23:04:46 +02:00
}
else
{
2019-01-05 16:00:57 +01:00
u32 typeEffectiveness1 = UQ_4_12_TO_INT ( GetTypeModifier ( moveType , defType1 ) * 2 ) * 5 ;
u32 typeEffectiveness2 = UQ_4_12_TO_INT ( GetTypeModifier ( moveType , defType2 ) * 2 ) * 5 ;
typePower = ( typeEffectiveness1 * typePower ) / 10 ;
if ( defType2 ! = defType1 )
typePower = ( typeEffectiveness2 * typePower ) / 10 ;
2022-07-15 18:58:46 +02:00
if ( defAbility = = ABILITY_WONDER_GUARD & & typeEffectiveness1 ! = TYPE_x1 & & typeEffectiveness2 ! = TYPE_x1 )
2019-01-05 16:00:57 +01:00
typePower = 0 ;
2018-08-15 23:04:46 +02:00
}
2022-06-01 18:41:57 +02:00
switch ( mode )
2018-08-15 23:04:46 +02:00
{
2022-06-01 18:41:57 +02:00
case EFFECTIVENESS_MODE_GOOD :
// Weights moves that more effective.
2018-08-15 23:04:46 +02:00
switch ( typePower )
{
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
case TYPE_x0 :
2022-06-01 18:41:57 +02:00
case TYPE_x0_25 :
case TYPE_x0_50 :
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
default :
2018-08-15 23:04:46 +02:00
typePower = 0 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x1 :
2018-08-15 23:04:46 +02:00
typePower = 2 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x2 :
2018-08-15 23:04:46 +02:00
typePower = 4 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x4 :
2018-08-15 23:04:46 +02:00
typePower = 8 ;
break ;
}
break ;
2022-06-01 18:41:57 +02:00
case EFFECTIVENESS_MODE_BAD :
// Weights moves that are less effective.
// Odd that there's no limit on this being used, even the Frontier Brain could end up using this.
2018-08-15 23:04:46 +02:00
switch ( typePower )
{
2022-06-01 18:41:57 +02:00
case TYPE_x0 :
typePower = 8 ;
2018-08-15 23:04:46 +02:00
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x0_25 :
2018-08-15 23:04:46 +02:00
typePower = 4 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x0_50 :
2018-08-15 23:04:46 +02:00
typePower = 2 ;
break ;
2022-06-01 18:41:57 +02:00
default :
case TYPE_x1 :
typePower = 0 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x2 :
2018-08-15 23:04:46 +02:00
typePower = - 2 ;
break ;
2019-12-18 08:32:52 +01:00
case TYPE_x4 :
2018-08-15 23:04:46 +02:00
typePower = - 4 ;
break ;
}
break ;
2022-06-01 18:41:57 +02:00
case EFFECTIVENESS_MODE_AI_VS_AI :
// Used as part of calculating the winner in a battle between two AIs.
// Weights moves that are more effective much more strongly in both directions.
2018-08-15 23:04:46 +02:00
switch ( typePower )
{
2018-08-26 21:41:47 +02:00
case TYPE_x0 :
2018-08-15 23:04:46 +02:00
typePower = - 16 ;
break ;
2018-08-26 21:41:47 +02:00
case TYPE_x0_25 :
2018-08-15 23:04:46 +02:00
typePower = - 8 ;
break ;
2020-09-02 20:14:29 +02:00
case TYPE_x0_50 :
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
default :
2018-08-15 23:04:46 +02:00
typePower = 0 ;
break ;
2018-08-26 21:41:47 +02:00
case TYPE_x1 :
2018-08-15 23:04:46 +02:00
typePower = 4 ;
break ;
2018-08-26 21:41:47 +02:00
case TYPE_x2 :
2018-08-15 23:04:46 +02:00
typePower = 12 ;
break ;
2018-08-26 21:41:47 +02:00
case TYPE_x4 :
2018-08-15 23:04:46 +02:00
typePower = 20 ;
break ;
}
break ;
}
return typePower ;
2018-08-16 22:46:02 +02:00
}
2018-08-18 00:54:18 +02:00
2019-12-21 00:52:29 +01:00
// Duplicate of GetFrontierTrainerFixedIvs
// NOTE: In CreateDomeOpponentMon a tournament trainer ID (0-15) is passed instead, resulting in all IVs of 3
2020-01-05 16:50:32 +01:00
// To fix, see CreateDomeOpponentMon
2018-08-25 19:59:47 +02:00
static u8 GetDomeTrainerMonIvs ( u16 trainerId )
2018-08-18 00:54:18 +02:00
{
u8 fixedIv ;
2019-12-21 00:52:29 +01:00
if ( trainerId < = FRONTIER_TRAINER_JILL ) // 0 - 99
2018-08-18 00:54:18 +02:00
fixedIv = 3 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_CHLOE ) // 100 - 119
2018-08-18 00:54:18 +02:00
fixedIv = 6 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_SOFIA ) // 120 - 139
2018-08-18 00:54:18 +02:00
fixedIv = 9 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_JAZLYN ) // 140 - 159
2018-08-18 00:54:18 +02:00
fixedIv = 12 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_ALISON ) // 160 - 179
2018-08-18 00:54:18 +02:00
fixedIv = 15 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_LAMAR ) // 180 - 199
2018-08-18 00:54:18 +02:00
fixedIv = 18 ;
2019-12-21 00:52:29 +01:00
else if ( trainerId < = FRONTIER_TRAINER_TESS ) // 200 - 219
2018-08-18 00:54:18 +02:00
fixedIv = 21 ;
2019-12-21 00:52:29 +01:00
else // 220+ (- 299)
2021-01-07 23:13:14 +01:00
fixedIv = MAX_PER_STAT_IVS ;
2018-08-18 00:54:18 +02:00
return fixedIv ;
}
2019-02-08 18:08:25 +01:00
static int TournamentIdOfOpponent ( int roundId , int trainerId )
2018-08-18 00:54:18 +02:00
{
2020-01-05 16:50:32 +01:00
int i , j , opponentMax ;
2018-08-18 00:54:18 +02:00
2020-01-05 16:50:32 +01:00
// Get trainer's tournament id
2018-08-18 00:54:18 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = trainerId )
2018-08-18 00:54:18 +02:00
break ;
}
2020-01-05 16:50:32 +01:00
// Get trainer's opponent's tournament id
2018-08-18 19:52:25 +02:00
if ( roundId ! = DOME_ROUND1 )
2018-08-18 00:54:18 +02:00
{
2018-08-18 19:52:25 +02:00
if ( roundId = = DOME_FINAL )
2020-01-05 16:50:32 +01:00
opponentMax = sIdToOpponentId [ i ] [ roundId ] + 8 ;
2018-08-18 00:54:18 +02:00
else
2020-01-05 16:50:32 +01:00
opponentMax = sIdToOpponentId [ i ] [ roundId ] + 4 ;
2018-08-18 00:54:18 +02:00
2020-01-05 16:50:32 +01:00
// Get first non-eliminated trainer in range of possible opponents
for ( j = sIdToOpponentId [ i ] [ roundId ] ; j < opponentMax ; j + + )
2018-08-18 00:54:18 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sTourneyTreeTrainerOpponentIds [ j ] ! = i & & ! DOME_TRAINERS [ sTourneyTreeTrainerOpponentIds [ j ] ] . isEliminated )
2018-08-18 00:54:18 +02:00
break ;
}
2020-01-05 16:50:32 +01:00
if ( j ! = opponentMax )
return sTourneyTreeTrainerOpponentIds [ j ] ;
2018-08-18 00:54:18 +02:00
else
2020-01-05 16:50:32 +01:00
return 0xFF ; // Already eliminated
2018-08-18 00:54:18 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( ! DOME_TRAINERS [ sIdToOpponentId [ i ] [ roundId ] ] . isEliminated )
2018-08-26 21:41:47 +02:00
return sIdToOpponentId [ i ] [ roundId ] ;
2018-08-18 00:54:18 +02:00
else
2020-01-05 16:50:32 +01:00
return 0xFF ; // Already eliminated
2018-08-18 00:54:18 +02:00
}
}
2019-02-08 18:08:25 +01:00
static void SetDomeOpponentId ( void )
2018-08-18 00:54:18 +02:00
{
2018-08-18 19:52:25 +02:00
gTrainerBattleOpponent_A = TrainerIdOfPlayerOpponent ( ) ;
2018-08-18 00:54:18 +02:00
}
2020-01-05 16:50:32 +01:00
// While not an issue in-game, this will overflow if called after the player's opponent for the current round has been eliminated
2018-08-25 19:59:47 +02:00
static u16 TrainerIdOfPlayerOpponent ( void )
2018-08-18 00:54:18 +02:00
{
2019-12-18 08:32:52 +01:00
return DOME_TRAINERS [ TournamentIdOfOpponent ( gSaveBlock2Ptr - > frontier . curChallengeBattleNum , TRAINER_PLAYER ) ] . trainerId ;
2018-08-18 00:54:18 +02:00
}
2019-02-08 18:08:25 +01:00
static void SetDomeOpponentGraphicsId ( void )
2018-08-18 00:54:18 +02:00
{
2018-10-21 00:06:42 +02:00
SetBattleFacilityTrainerGfxId ( gTrainerBattleOpponent_A , 0 ) ;
2018-08-18 00:54:18 +02:00
}
2019-11-29 03:09:35 +01:00
static void SaveDomeChallenge ( void )
2018-08-18 00:54:18 +02:00
{
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . challengeStatus = gSpecialVar_0x8005 ;
2018-08-18 00:54:18 +02:00
VarSet ( VAR_TEMP_0 , 0 ) ;
2019-11-24 22:58:40 +01:00
gSaveBlock2Ptr - > frontier . challengePaused = TRUE ;
SaveGameFrontier ( ) ;
2018-08-18 00:54:18 +02:00
}
2019-11-29 03:09:35 +01:00
static void IncrementDomeStreaks ( void )
2018-08-18 00:54:18 +02:00
{
2018-08-25 19:59:47 +02:00
u8 lvlMode = gSaveBlock2Ptr - > frontier . lvlMode ;
u8 battleMode = VarGet ( VAR_FRONTIER_BATTLE_MODE ) ;
2018-08-18 00:54:18 +02:00
2018-10-27 17:39:05 +02:00
if ( gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] < 999 )
gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] + + ;
if ( gSaveBlock2Ptr - > frontier . domeTotalChampionships [ battleMode ] [ lvlMode ] < 999 )
gSaveBlock2Ptr - > frontier . domeTotalChampionships [ battleMode ] [ lvlMode ] + + ;
2018-08-18 00:54:18 +02:00
2018-10-27 17:39:05 +02:00
if ( gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] > gSaveBlock2Ptr - > frontier . domeRecordWinStreaks [ battleMode ] [ lvlMode ] )
gSaveBlock2Ptr - > frontier . domeRecordWinStreaks [ battleMode ] [ lvlMode ] = gSaveBlock2Ptr - > frontier . domeWinStreaks [ battleMode ] [ lvlMode ] ;
2018-08-18 00:54:18 +02:00
}
2020-01-05 16:50:32 +01:00
// For showing the opponent info card of the upcoming trainer
2018-08-26 15:51:14 +02:00
static void ShowDomeOpponentInfo ( void )
2018-08-18 00:54:18 +02:00
{
2020-01-05 16:50:32 +01:00
u8 taskId = CreateTask ( Task_ShowTourneyInfoCard , 0 ) ;
gTasks [ taskId ] . tState = 0 ;
gTasks [ taskId ] . tTournamentId = TrainerIdToTournamentId ( TrainerIdOfPlayerOpponent ( ) ) ;
gTasks [ taskId ] . tMode = INFOCARD_NEXT_OPPONENT ;
gTasks [ taskId ] . tPrevTaskId = 0 ;
2018-08-18 00:54:18 +02:00
2020-01-05 16:50:32 +01:00
SetMainCallback2 ( CB2_TourneyTree ) ;
2018-08-18 00:54:18 +02:00
}
2020-01-05 16:50:32 +01:00
// For showing the opponent info card or the match info card
static void Task_ShowTourneyInfoCard ( u8 taskId )
2018-08-18 00:54:18 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2020-01-05 16:50:32 +01:00
int tournamentId = gTasks [ taskId ] . tTournamentId ;
int mode = gTasks [ taskId ] . tMode ;
int id = gTasks [ taskId ] . tPrevTaskId ;
2018-08-18 00:54:18 +02:00
2020-01-05 16:50:32 +01:00
switch ( gTasks [ taskId ] . tState )
2018-08-18 00:54:18 +02:00
{
case 0 :
SetHBlankCallback ( NULL ) ;
SetVBlankCallback ( NULL ) ;
EnableInterrupts ( INTR_FLAG_VBLANK ) ;
CpuFill32 ( 0 , ( void * ) VRAM , VRAM_SIZE ) ;
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
2020-01-05 16:50:32 +01:00
InitBgsFromTemplates ( 0 , sInfoCardBgTemplates , ARRAY_COUNT ( sInfoCardBgTemplates ) ) ;
InitWindows ( sInfoCardWindowTemplates ) ;
2018-08-18 00:54:18 +02:00
DeactivateAllTextPrinters ( ) ;
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
gBattle_BG3_X = 0 ;
gBattle_BG3_Y = 0 ;
2020-01-05 16:50:32 +01:00
if ( mode = = INFOCARD_MATCH )
2018-08-18 00:54:18 +02:00
gBattle_BG2_X = 0 , gBattle_BG2_Y = 0 ;
else
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = 0 , gBattle_BG2_Y = DISPLAY_HEIGHT ;
2018-08-18 00:54:18 +02:00
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-18 00:54:18 +02:00
break ;
case 1 :
SetGpuReg ( REG_OFFSET_BLDCNT , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDY , 0 ) ;
SetGpuReg ( REG_OFFSET_MOSAIC , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN0H , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN0V , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN1H , 0 ) ;
SetGpuReg ( REG_OFFSET_WIN1V , 0 ) ;
SetGpuReg ( REG_OFFSET_WININ , 0 ) ;
2019-12-18 08:32:52 +01:00
SetGpuReg ( REG_OFFSET_WINOUT , WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR ) ;
2018-08-18 00:54:18 +02:00
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
FreeAllSpritePalettes ( ) ;
gReservedSpritePaletteCount = 4 ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-18 00:54:18 +02:00
break ;
case 2 :
2020-01-05 16:50:32 +01:00
DecompressAndLoadBgGfxUsingHeap ( 2 , gDomeTourneyInfoCard_Gfx , 0x2000 , 0 , 0 ) ;
DecompressAndLoadBgGfxUsingHeap ( 2 , gDomeTourneyInfoCard_Tilemap , 0x2000 , 0 , 1 ) ;
DecompressAndLoadBgGfxUsingHeap ( 3 , gDomeTourneyInfoCardBg_Tilemap , 0x800 , 0 , 1 ) ;
LoadCompressedSpriteSheet ( sTourneyTreeButtonsSpriteSheet ) ;
LoadCompressedPalette ( gDomeTourneyTree_Pal , 0 , 0x200 ) ;
LoadCompressedPalette ( gDomeTourneyTreeButtons_Pal , 0x100 , 0x200 ) ;
2019-11-07 01:18:11 +01:00
LoadCompressedPalette ( gBattleWindowTextPalette , 0xF0 , 0x20 ) ;
2020-01-05 16:50:32 +01:00
if ( mode = = INFOCARD_MATCH )
LoadCompressedPalette ( gDomeTourneyMatchCardBg_Pal , 0x50 , 0x20 ) ; // Changes the moving info card bg to orange when in match card mode
2018-08-18 00:54:18 +02:00
CpuFill32 ( 0 , gPlttBufferFaded , 0x400 ) ;
ShowBg ( 0 ) ;
ShowBg ( 1 ) ;
ShowBg ( 2 ) ;
ShowBg ( 3 ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-18 00:54:18 +02:00
break ;
case 3 :
2020-01-05 16:50:32 +01:00
SetVBlankCallback ( VblankCb_TourneyInfoCard ) ;
sInfoCard = AllocZeroed ( sizeof ( * sInfoCard ) ) ;
for ( i = 0 ; i < NUM_INFOCARD_SPRITES ; i + + )
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ i ] = SPRITE_NONE ;
2018-08-18 00:54:18 +02:00
LoadMonIconPalettes ( ) ;
2020-01-05 16:50:32 +01:00
i = CreateTask ( Task_HandleInfoCardInput , 0 ) ;
2018-08-18 00:54:18 +02:00
gTasks [ i ] . data [ 0 ] = 0 ;
gTasks [ i ] . data [ 2 ] = 0 ;
2020-01-05 16:50:32 +01:00
gTasks [ i ] . data [ 3 ] = mode ;
gTasks [ i ] . data [ 4 ] = id ;
if ( mode = = INFOCARD_MATCH )
2018-08-18 00:54:18 +02:00
{
2020-01-05 16:50:32 +01:00
DisplayMatchInfoOnCard ( 0 , tournamentId ) ;
sInfoCard - > pos = 1 ;
2018-08-18 00:54:18 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
DisplayTrainerInfoOnCard ( 0 , tournamentId ) ;
2018-08-18 00:54:18 +02:00
}
SetGpuReg ( REG_OFFSET_DISPCNT , DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP ) ;
2020-01-05 16:50:32 +01:00
if ( mode ! = INFOCARD_NEXT_OPPONENT )
2018-08-18 00:54:18 +02:00
{
2020-01-05 16:50:32 +01:00
// Scroll up arrow
id = CreateSprite ( & sVerticalScrollArrowSpriteTemplate , 120 , 4 , 0 ) ;
StartSpriteAnim ( & gSprites [ id ] , 0 ) ;
gSprites [ id ] . data [ 0 ] = i ;
// Scroll down arrow
id = CreateSprite ( & sVerticalScrollArrowSpriteTemplate , 120 , 156 , 0 ) ;
StartSpriteAnim ( & gSprites [ id ] , 1 ) ;
gSprites [ id ] . data [ 0 ] = i ;
// Scroll left arrow
id = CreateSprite ( & sHorizontalScrollArrowSpriteTemplate , 6 , 80 , 0 ) ;
StartSpriteAnim ( & gSprites [ id ] , 0 ) ;
gSprites [ id ] . data [ 0 ] = i ;
gSprites [ id ] . data [ 1 ] = 0 ;
if ( mode = = INFOCARD_TRAINER )
gSprites [ id ] . invisible = TRUE ;
// Scroll right arrow
id = CreateSprite ( & sHorizontalScrollArrowSpriteTemplate , 234 , 80 , 0 ) ;
StartSpriteAnim ( & gSprites [ id ] , 1 ) ;
gSprites [ id ] . data [ 0 ] = i ;
gSprites [ id ] . data [ 1 ] = 1 ;
2018-08-18 00:54:18 +02:00
}
DestroyTask ( taskId ) ;
break ;
}
}
2018-08-20 22:56:05 +02:00
// Note: Card scrolling up means the current card goes down and another one appears from top.
// The same is true for scrolling left.
// That means that the sprite needs to move with the moving card in the opposite scrolling direction.
static void SpriteCb_TrainerIconCardScrollUp ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2021-07-07 15:11:52 +02:00
sprite - > y + = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y > = - 32 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 40 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y > = 192 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollDown ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2021-07-07 15:11:52 +02:00
sprite - > y - = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y < = 192 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 40 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y < = - 32 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollLeft ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2021-07-07 15:11:52 +02:00
sprite - > x + = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x > = - 32 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 64 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x > = DISPLAY_WIDTH + 32 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_TrainerIconCardScrollRight ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2021-07-07 15:11:52 +02:00
sprite - > x - = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x < = DISPLAY_WIDTH + 32 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 64 )
sprite - > callback = SpriteCallbackDummy ;
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x < = - 32 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2018-08-19 01:06:10 +02:00
FreeAndDestroyTrainerPicSprite ( sprite - > data [ 3 ] ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
# define sMonIconStill data[3]
static void SpriteCb_MonIcon ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollUp ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
2021-07-07 15:11:52 +02:00
sprite - > y + = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y > = - 16 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 40 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y > = 176 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( sprite ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollDown ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
2021-07-07 15:11:52 +02:00
sprite - > y - = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y < = 176 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 40 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > y < = - 16 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( sprite ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollLeft ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
2021-07-07 15:11:52 +02:00
sprite - > x + = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x > = - 16 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 64 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x > = DISPLAY_WIDTH + 16 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( sprite ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-20 22:56:05 +02:00
static void SpriteCb_MonIconCardScrollRight ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2018-08-20 22:56:05 +02:00
if ( ! sprite - > sMonIconStill )
2018-08-18 00:54:18 +02:00
UpdateMonIconFrame ( sprite ) ;
2021-07-07 15:11:52 +02:00
sprite - > x - = 4 ;
2018-08-18 00:54:18 +02:00
if ( sprite - > data [ 0 ] ! = 0 )
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x < = DISPLAY_WIDTH + 16 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
if ( + + sprite - > data [ 1 ] = = 64 )
2018-08-20 22:56:05 +02:00
sprite - > callback = SpriteCb_MonIcon ;
2018-08-18 00:54:18 +02:00
}
else
{
2021-07-07 15:11:52 +02:00
if ( sprite - > x < = - 16 )
2018-08-18 00:54:18 +02:00
{
2021-02-20 06:30:37 +01:00
sInfoCard - > spriteIds [ sprite - > data [ 2 ] ] = SPRITE_NONE ;
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( sprite ) ;
2018-08-18 00:54:18 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
static void SpriteCb_HorizontalScrollArrow ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2019-02-08 18:08:25 +01:00
int taskId1 = sprite - > data [ 0 ] ;
int arrId = gTasks [ gTasks [ taskId1 ] . data [ 4 ] ] . data [ 1 ] ;
int tournmanetTrainerId = sTourneyTreeTrainerIds [ arrId ] ;
int roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
2018-08-18 00:54:18 +02:00
if ( gTasks [ taskId1 ] . data [ 3 ] = = 1 )
{
if ( sprite - > data [ 1 ] )
{
2019-12-18 08:32:52 +01:00
if ( ( DOME_TRAINERS [ tournmanetTrainerId ] . isEliminated
2020-01-05 16:50:32 +01:00
& & sInfoCard - > pos - 1 < DOME_TRAINERS [ tournmanetTrainerId ] . eliminatedAt ) )
2018-08-18 00:54:18 +02:00
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
2019-12-18 08:32:52 +01:00
else if ( ! DOME_TRAINERS [ tournmanetTrainerId ] . isEliminated
2020-01-05 16:50:32 +01:00
& & sInfoCard - > pos - 1 < roundId )
2018-08-18 00:54:18 +02:00
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
}
else
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos ! = 0 )
2018-08-18 00:54:18 +02:00
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
}
}
else
{
if ( sprite - > data [ 1 ] )
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos > 1 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
else
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
}
else
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos ! = 0 )
2018-08-18 00:54:18 +02:00
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
else
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
}
}
}
2020-01-05 16:50:32 +01:00
static void SpriteCb_VerticalScrollArrow ( struct Sprite * sprite )
2018-08-18 00:54:18 +02:00
{
2019-02-08 18:08:25 +01:00
int taskId1 = sprite - > data [ 0 ] ;
2018-08-18 00:54:18 +02:00
if ( gTasks [ taskId1 ] . data [ 3 ] = = 1 )
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos ! = 0 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
else
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
}
else
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos ! = 1 )
2018-08-18 00:54:18 +02:00
{
if ( gTasks [ taskId1 ] . data [ 0 ] = = 2 )
2018-09-10 17:25:58 +02:00
sprite - > invisible = TRUE ;
2018-08-18 00:54:18 +02:00
}
else
{
2018-09-10 17:25:58 +02:00
sprite - > invisible = FALSE ;
2018-08-18 00:54:18 +02:00
}
}
}
2018-08-18 18:23:40 +02:00
2020-01-05 16:50:32 +01:00
// Task states for Task_HandleInfoCardInput
# define STATE_FADE_IN 0
# define STATE_WAIT_FADE 1
# define STATE_GET_INPUT 2
# define STATE_REACT_INPUT 3
# define STATE_MOVE_UP 4
# define STATE_MOVE_DOWN 5
# define STATE_MOVE_LEFT 6
# define STATE_MOVE_RIGHT 7
# define STATE_CLOSE_CARD 8
# define tUsingAlternateSlot data[2] // CARD_ALTERNATE_SLOT
static void Task_HandleInfoCardInput ( u8 taskId )
2018-08-18 18:23:40 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
int windowId = 0 ;
2020-01-05 16:50:32 +01:00
int mode = gTasks [ taskId ] . data [ 3 ] ;
2019-02-08 18:08:25 +01:00
int taskId2 = gTasks [ taskId ] . data [ 4 ] ;
2020-01-05 16:50:32 +01:00
int trainerTourneyId = 0 ;
2019-02-08 18:08:25 +01:00
int matchNo = 0 ;
2018-08-18 18:23:40 +02:00
2020-01-05 16:50:32 +01:00
switch ( gTasks [ taskId ] . tState )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
case STATE_FADE_IN :
2018-08-18 18:23:40 +02:00
if ( ! gPaletteFade . active )
{
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0x10 , 0 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_WAIT_FADE ;
2018-08-18 18:23:40 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_WAIT_FADE :
2018-08-18 18:23:40 +02:00
if ( ! gPaletteFade . active )
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-18 18:23:40 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_GET_INPUT :
i = Task_GetInfoCardInput ( taskId ) ;
2018-08-18 18:23:40 +02:00
switch ( i )
{
2020-01-05 16:50:32 +01:00
case INFOCARD_INPUT_AB :
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0 , 0x10 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_CLOSE_CARD ;
2018-08-18 18:23:40 +02:00
break ;
2020-01-05 16:50:32 +01:00
case TRAINERCARD_INPUT_UP . . . TRAINERCARD_INPUT_RIGHT :
case MATCHCARD_INPUT_UP . . . MATCHCARD_INPUT_RIGHT :
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = i ;
2020-01-05 16:50:32 +01:00
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-20 22:56:05 +02:00
windowId = 9 ;
2018-08-18 18:23:40 +02:00
else
2018-08-20 22:56:05 +02:00
windowId = 0 ;
2018-08-18 18:23:40 +02:00
2018-08-20 22:56:05 +02:00
for ( i = windowId ; i < windowId + 9 ; i + + )
2018-08-18 18:23:40 +02:00
{
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( i , COPYWIN_GFX ) ;
2019-03-02 23:25:39 +01:00
FillWindowPixelBuffer ( i , PIXEL_FILL ( 0 ) ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_REACT_INPUT ;
2018-08-18 18:23:40 +02:00
break ;
2020-01-05 16:50:32 +01:00
case INFOCARD_INPUT_NONE :
2018-08-18 18:23:40 +02:00
break ;
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_REACT_INPUT :
2018-08-18 18:23:40 +02:00
i = gTasks [ taskId ] . data [ 5 ] ;
switch ( i )
{
2020-01-05 16:50:32 +01:00
case TRAINERCARD_INPUT_UP :
case MATCHCARD_INPUT_UP :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_Y = DISPLAY_HEIGHT ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG0_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG0_Y = DISPLAY_HEIGHT ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( i = = TRAINERCARD_INPUT_UP )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT * 2 ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sTourneyTreeTrainerIds [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_UP , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_Y = 0 ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sTourneyTreeTrainerIds [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_UP , trainerTourneyId ) ;
sInfoCard - > pos = 0 ;
2018-08-18 18:23:40 +02:00
}
}
2020-01-05 16:50:32 +01:00
else // i == MATCHCARD_INPUT_UP
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
BufferDomeWinString ( matchNo , sInfoCard - > tournamentIds ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT * 2 ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_UP , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
else if ( sInfoCard - > pos = = 2 )
2018-08-18 18:23:40 +02:00
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
BufferDomeWinString ( matchNo , sInfoCard - > tournamentIds ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT * 2 ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_UP , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_UP , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
}
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollUp ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollUp ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollUp ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollUp ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_UP ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
2020-01-05 16:50:32 +01:00
case TRAINERCARD_INPUT_DOWN :
case MATCHCARD_INPUT_DOWN :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_Y = - DISPLAY_HEIGHT ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG0_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG0_Y = - DISPLAY_HEIGHT ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( i = = TRAINERCARD_INPUT_DOWN )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sTourneyTreeTrainerIds [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_DOWN , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 0 ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sTourneyTreeTrainerIds [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_DOWN , trainerTourneyId ) ;
sInfoCard - > pos = 0 ;
2018-08-18 18:23:40 +02:00
}
}
2020-01-05 16:50:32 +01:00
else // i == MATCHCARD_INPUT_DOWN
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
BufferDomeWinString ( matchNo , sInfoCard - > tournamentIds ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_DOWN , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
else if ( sInfoCard - > pos = = 2 )
2018-08-18 18:23:40 +02:00
{
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
BufferDomeWinString ( matchNo , sInfoCard - > tournamentIds ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_DOWN , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_Y = 0 ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_DOWN , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
}
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollDown ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollDown ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollDown ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollDown ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_DOWN ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
2020-01-05 16:50:32 +01:00
case TRAINERCARD_INPUT_LEFT :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_Y = 0 ;
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG0_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sTourneyTreeTrainerIds [ gTasks [ taskId2 ] . data [ 1 ] ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_LEFT , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG2_Y = 0 ;
2020-01-05 16:50:32 +01:00
matchNo = sIdToMatchNumber [ gTasks [ taskId2 ] . data [ 1 ] ] [ sInfoCard - > pos - 1 ] ;
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_LEFT , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_LEFT ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
2020-01-05 16:50:32 +01:00
case MATCHCARD_INPUT_LEFT :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_Y = 0 ;
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG0_X = DISPLAY_WIDTH + 16 ;
2018-08-18 18:23:40 +02:00
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 )
2018-08-18 18:23:40 +02:00
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 0 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_LEFT , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_LEFT , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollLeft ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_LEFT ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
2020-01-05 16:50:32 +01:00
case TRAINERCARD_INPUT_RIGHT :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_X = - ( DISPLAY_WIDTH + 16 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_Y = 0 ;
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG0_X = - ( DISPLAY_WIDTH + 16 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 1 )
2018-08-18 18:23:40 +02:00
{
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
gBattle_BG2_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
matchNo = sIdToMatchNumber [ gTasks [ taskId2 ] . data [ 1 ] ] [ sInfoCard - > pos - 1 ] ;
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_RIGHT , matchNo ) ;
2018-08-18 18:23:40 +02:00
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_RIGHT ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
2020-01-05 16:50:32 +01:00
case MATCHCARD_INPUT_RIGHT :
if ( gTasks [ taskId ] . tUsingAlternateSlot )
2018-08-18 18:23:40 +02:00
{
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG1_X = - ( DISPLAY_WIDTH + 16 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG1_Y = 0 ;
}
else
{
2021-04-15 08:04:01 +02:00
gBattle_BG0_X = - ( DISPLAY_WIDTH + 16 ) ;
2018-08-18 18:23:40 +02:00
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
}
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 2 )
2018-08-18 18:23:40 +02:00
{
2021-04-15 08:04:01 +02:00
gBattle_BG2_X = DISPLAY_WIDTH + 16 ;
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
trainerTourneyId = sInfoCard - > tournamentIds [ 1 ] ;
DisplayTrainerInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_RIGHT , trainerTourneyId ) ;
2018-08-18 18:23:40 +02:00
}
else
{
gBattle_BG2_X = 0 ;
2021-04-15 08:04:01 +02:00
gBattle_BG2_Y = DISPLAY_HEIGHT ;
2018-08-20 22:56:05 +02:00
matchNo = gTasks [ taskId2 ] . data [ 1 ] - 16 ;
2020-01-05 16:50:32 +01:00
DisplayMatchInfoOnCard ( gTasks [ taskId ] . tUsingAlternateSlot | MOVE_CARD_RIGHT , matchNo ) ;
2018-08-18 18:23:40 +02:00
}
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ^ 1 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_TrainerIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 3 ] = sInfoCard - > spriteIds [ i ] ;
2018-08-18 18:23:40 +02:00
}
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2018-08-18 18:23:40 +02:00
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ i ] ] . callback = SpriteCb_MonIconCardScrollRight ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 0 ] = gTasks [ taskId ] . tUsingAlternateSlot ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 1 ] = 0 ;
gSprites [ sInfoCard - > spriteIds [ i ] ] . data [ 2 ] = i ;
2018-08-18 18:23:40 +02:00
}
}
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_MOVE_RIGHT ;
2018-08-18 18:23:40 +02:00
gTasks [ taskId ] . data [ 5 ] = 0 ;
break ;
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_MOVE_UP :
2018-08-18 18:23:40 +02:00
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 41 )
{
gBattle_BG0_Y - = 4 ;
gBattle_BG1_Y - = 4 ;
gBattle_BG2_Y - = 4 ;
}
else
{
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-18 18:23:40 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_MOVE_DOWN :
2018-08-18 18:23:40 +02:00
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 41 )
{
gBattle_BG0_Y + = 4 ;
gBattle_BG1_Y + = 4 ;
gBattle_BG2_Y + = 4 ;
}
else
{
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-18 18:23:40 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_MOVE_LEFT :
2018-08-18 18:23:40 +02:00
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 65 )
{
gBattle_BG0_X - = 4 ;
gBattle_BG1_X - = 4 ;
gBattle_BG2_X - = 4 ;
}
else
{
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-18 18:23:40 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_MOVE_RIGHT :
2018-08-18 18:23:40 +02:00
if ( + + gTasks [ taskId ] . data [ 5 ] ! = 65 )
{
gBattle_BG0_X + = 4 ;
gBattle_BG1_X + = 4 ;
gBattle_BG2_X + = 4 ;
}
else
{
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-18 18:23:40 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_CLOSE_CARD :
2018-08-18 18:23:40 +02:00
if ( ! gPaletteFade . active )
{
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < NUM_INFOCARD_SPRITES / 2 ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 2 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2020-01-05 16:50:32 +01:00
FreeAndDestroyTrainerPicSprite ( sInfoCard - > spriteIds [ i ] ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( & gSprites [ sInfoCard - > spriteIds [ i ] ] ) ;
2018-08-18 18:23:40 +02:00
}
}
2020-01-05 16:50:32 +01:00
for ( i = NUM_INFOCARD_SPRITES / 2 ; i < NUM_INFOCARD_SPRITES ; i + + )
2018-08-18 18:23:40 +02:00
{
if ( i < 10 )
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2020-01-05 16:50:32 +01:00
FreeAndDestroyTrainerPicSprite ( sInfoCard - > spriteIds [ i ] ) ;
2018-08-18 18:23:40 +02:00
}
else
{
2021-02-20 06:30:37 +01:00
if ( sInfoCard - > spriteIds [ i ] ! = SPRITE_NONE )
2020-01-05 16:50:32 +01:00
FreeAndDestroyMonIconSprite ( & gSprites [ sInfoCard - > spriteIds [ i ] ] ) ;
2018-08-18 18:23:40 +02:00
}
}
FreeMonIconPalettes ( ) ;
2020-01-05 16:50:32 +01:00
FREE_AND_SET_NULL ( sInfoCard ) ;
2018-08-18 18:23:40 +02:00
FreeAllWindowBuffers ( ) ;
2020-01-05 16:50:32 +01:00
if ( mode = = INFOCARD_NEXT_OPPONENT )
2018-08-18 18:23:40 +02:00
{
SetMainCallback2 ( CB2_ReturnToFieldContinueScriptPlayMapMusic ) ;
}
else
{
2019-02-08 18:08:25 +01:00
i = CreateTask ( Task_ShowTourneyTree , 0 ) ;
2018-08-18 18:23:40 +02:00
gTasks [ i ] . data [ 0 ] = 0 ;
2020-01-05 16:50:32 +01:00
gTasks [ i ] . tNotInteractive = FALSE ;
2018-08-18 18:23:40 +02:00
gTasks [ i ] . data [ 2 ] = 3 ;
gTasks [ i ] . data [ 3 ] = gTasks [ taskId ] . data [ 4 ] ;
2020-01-05 16:50:32 +01:00
gTasks [ i ] . tIsPrevTourneyTree = gTasks [ taskId2 ] . data [ 6 ] ;
2018-08-18 18:23:40 +02:00
}
DestroyTask ( taskId ) ;
}
break ;
}
}
2018-08-18 19:52:25 +02:00
2020-01-05 16:50:32 +01:00
// undefine task states for Task_HandleInfoCardInput
# undef STATE_FADE_IN
# undef STATE_WAIT_FADE
# undef STATE_GET_INPUT
# undef STATE_REACT_INPUT
# undef STATE_MOVE_UP
# undef STATE_MOVE_DOWN
# undef STATE_MOVE_LEFT
# undef STATE_MOVE_RIGHT
# undef STATE_CLOSE_CARD
static u8 Task_GetInfoCardInput ( u8 taskId )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
u8 input = INFOCARD_INPUT_NONE ;
2019-02-08 18:08:25 +01:00
int taskId2 = gTasks [ taskId ] . data [ 4 ] ;
2020-01-05 16:50:32 +01:00
int position = gTasks [ taskId2 ] . data [ 1 ] ;
u8 tourneyId = sTourneyTreeTrainerIds [ position ] ;
2018-10-21 00:06:42 +02:00
u16 roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
2018-08-18 19:52:25 +02:00
2020-09-05 03:11:55 +02:00
if ( JOY_NEW ( A_BUTTON | B_BUTTON ) )
2020-01-05 16:50:32 +01:00
input = INFOCARD_INPUT_AB ;
2018-08-18 19:52:25 +02:00
2020-01-05 16:50:32 +01:00
// Next opponent card cant scroll
if ( gTasks [ taskId ] . data [ 3 ] = = INFOCARD_NEXT_OPPONENT )
return input ;
2018-08-19 01:06:10 +02:00
2020-01-05 16:50:32 +01:00
if ( gTasks [ taskId ] . data [ 3 ] = = INFOCARD_TRAINER )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
// For trainer info cards, pos is 0 when on a trainer info card (not viewing that trainer's match progression)
// Scrolling up/down from a trainer info card goes to other trainer info cards
2020-09-05 03:11:55 +02:00
if ( JOY_NEW ( DPAD_UP ) & & sInfoCard - > pos = = 0 )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
if ( position = = 0 )
position = DOME_TOURNAMENT_TRAINERS_COUNT - 1 ;
2018-08-19 01:06:10 +02:00
else
2020-01-05 16:50:32 +01:00
position - - ;
input = TRAINERCARD_INPUT_UP ;
2018-08-18 19:52:25 +02:00
}
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_DOWN ) & & sInfoCard - > pos = = 0 )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
if ( position = = DOME_TOURNAMENT_TRAINERS_COUNT - 1 )
position = 0 ;
2018-08-19 01:06:10 +02:00
else
2020-01-05 16:50:32 +01:00
position + + ;
input = TRAINERCARD_INPUT_DOWN ;
2018-08-19 01:06:10 +02:00
}
2020-01-05 16:50:32 +01:00
// Scrolling left can only be done after scrolling right
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_LEFT ) & & sInfoCard - > pos ! = 0 )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > pos - - ;
input = TRAINERCARD_INPUT_LEFT ;
2018-08-19 01:06:10 +02:00
}
2020-01-05 16:50:32 +01:00
// Scrolling right from a trainer info card shows their match progression
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_RIGHT ) )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
// Can only scroll right from a trainer card until the round they were eliminated
if ( DOME_TRAINERS [ tourneyId ] . isEliminated & & sInfoCard - > pos - 1 < DOME_TRAINERS [ tourneyId ] . eliminatedAt )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > pos + + ;
input = TRAINERCARD_INPUT_RIGHT ;
2018-08-18 19:52:25 +02:00
}
2020-01-05 16:50:32 +01:00
// otherwise can scroll as far right as the current round allows
if ( ! DOME_TRAINERS [ tourneyId ] . isEliminated & & sInfoCard - > pos - 1 < roundId )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > pos + + ;
input = TRAINERCARD_INPUT_RIGHT ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
}
2018-08-18 19:52:25 +02:00
2020-01-05 16:50:32 +01:00
if ( input = = INFOCARD_INPUT_AB )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos ! = 0 )
2021-11-01 23:06:15 +01:00
gTasks [ taskId2 ] . data [ 1 ] = sTrainerAndRoundToLastMatchCardNum [ position / 2 ] [ sInfoCard - > pos - 1 ] ;
2018-08-19 01:06:10 +02:00
else
2020-01-05 16:50:32 +01:00
gTasks [ taskId2 ] . data [ 1 ] = position ;
2018-08-19 01:06:10 +02:00
}
}
2020-01-05 16:50:32 +01:00
else // gTasks[taskId].data[3] == INFOCARD_MATCH
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
// For match info cards, pos is 1 when on the match card, 0 when on the left trainer, and 1 when on the right trainer
// Scrolling up/down from a match info card goes to the next/previous match
2020-09-05 03:11:55 +02:00
if ( JOY_NEW ( DPAD_UP ) & & sInfoCard - > pos = = 1 )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
if ( position = = DOME_TOURNAMENT_TRAINERS_COUNT )
position = sLastMatchCardNum [ roundId ] ;
2018-08-19 01:06:10 +02:00
else
2020-01-05 16:50:32 +01:00
position - - ;
input = MATCHCARD_INPUT_UP ;
2018-08-19 01:06:10 +02:00
}
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_DOWN ) & & sInfoCard - > pos = = 1 )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
if ( position = = sLastMatchCardNum [ roundId ] )
position = DOME_TOURNAMENT_TRAINERS_COUNT ;
2018-08-19 01:06:10 +02:00
else
2020-01-05 16:50:32 +01:00
position + + ;
input = MATCHCARD_INPUT_DOWN ;
2018-08-19 01:06:10 +02:00
}
2020-01-05 16:50:32 +01:00
// Scrolling left/right from a match info card shows the trainer info card of the competitors for that match
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_LEFT ) & & sInfoCard - > pos ! = 0 )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
input = MATCHCARD_INPUT_LEFT ;
sInfoCard - > pos - - ;
2018-08-19 01:06:10 +02:00
}
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( DPAD_RIGHT ) & & ( sInfoCard - > pos = = 0 | | sInfoCard - > pos = = 1 ) )
2018-08-19 01:06:10 +02:00
{
2020-01-05 16:50:32 +01:00
input = MATCHCARD_INPUT_RIGHT ;
sInfoCard - > pos + + ;
2018-08-18 19:52:25 +02:00
}
2020-01-05 16:50:32 +01:00
if ( input = = INFOCARD_INPUT_AB )
2018-08-18 19:52:25 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sInfoCard - > pos = = 0 ) // On left trainer info card
2021-11-01 23:06:15 +01:00
gTasks [ taskId2 ] . data [ 1 ] = sTournamentIdToPairedTrainerIds [ sInfoCard - > tournamentIds [ 0 ] ] ;
2020-01-05 16:50:32 +01:00
else if ( sInfoCard - > pos = = 2 ) // On right trainer info card
2021-11-01 23:06:15 +01:00
gTasks [ taskId2 ] . data [ 1 ] = sTournamentIdToPairedTrainerIds [ sInfoCard - > tournamentIds [ 1 ] ] ;
2020-01-05 16:50:32 +01:00
else // On match info card
gTasks [ taskId2 ] . data [ 1 ] = position ;
2018-08-18 19:52:25 +02:00
}
}
2020-01-05 16:50:32 +01:00
if ( input ! = INFOCARD_INPUT_NONE & & input ! = INFOCARD_INPUT_AB )
2018-08-19 01:06:10 +02:00
{
PlaySE ( SE_SELECT ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId2 ] . data [ 1 ] = position ;
gTasks [ taskId ] . tUsingAlternateSlot ^ = 1 ;
2018-08-19 01:06:10 +02:00
}
2020-01-05 16:50:32 +01:00
return input ;
2018-08-18 19:52:25 +02:00
}
2018-08-19 01:06:10 +02:00
2020-01-05 16:50:32 +01:00
# undef tUsingAlternateSlot
// allocatedArray below needs to be large enough to hold stat totals for each mon, or totals of each type of move points
# define ALLOC_ARRAY_SIZE (NUM_STATS * FRONTIER_PARTY_SIZE >= NUM_MOVE_POINT_TYPES ? (NUM_STATS * FRONTIER_PARTY_SIZE) : NUM_MOVE_POINT_TYPES)
static void DisplayTrainerInfoOnCard ( u8 flags , u8 trainerTourneyId )
2018-08-19 01:06:10 +02:00
{
2018-11-06 17:44:48 +01:00
struct TextPrinterTemplate textPrinter ;
2019-02-08 18:08:25 +01:00
int i , j , k ;
int trainerId = 0 ;
2018-08-19 20:21:37 +02:00
u8 nature = 0 ;
2019-02-08 18:08:25 +01:00
int arrId = 0 ;
int windowId = 0 ;
int x = 0 , y = 0 ;
2018-08-19 20:21:37 +02:00
u8 palSlot = 0 ;
2020-01-05 16:50:32 +01:00
s16 * allocatedArray = AllocZeroed ( sizeof ( s16 ) * ALLOC_ARRAY_SIZE ) ;
trainerId = DOME_TRAINERS [ trainerTourneyId ] . trainerId ;
2018-08-19 17:13:05 +02:00
2020-01-05 16:50:32 +01:00
if ( flags & CARD_ALTERNATE_SLOT )
arrId = 2 * ( FRONTIER_PARTY_SIZE + 1 ) , windowId = 9 , palSlot = 2 ;
if ( flags & MOVE_CARD_RIGHT )
2021-04-15 08:04:01 +02:00
x = DISPLAY_WIDTH + 16 ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_DOWN )
2021-04-15 08:04:01 +02:00
y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_LEFT )
2021-04-15 08:04:01 +02:00
x = - ( DISPLAY_WIDTH + 16 ) ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_UP )
2021-04-15 08:04:01 +02:00
y = - DISPLAY_HEIGHT ;
2018-08-19 17:13:05 +02:00
2019-12-21 10:27:12 +01:00
// Create trainer pic sprite
2018-08-19 17:13:05 +02:00
if ( trainerId = = TRAINER_PLAYER )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 48 , y + 64 , palSlot + 12 , TAG_NONE ) ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 48 , y + 64 , palSlot + 12 , TAG_NONE ) ;
2018-08-19 17:13:05 +02:00
else
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerId ) , TRUE , x + 48 , y + 64 , palSlot + 12 , TAG_NONE ) ;
2018-08-19 17:13:05 +02:00
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ arrId ] ] . invisible = TRUE ;
2018-08-19 17:13:05 +02:00
2019-12-21 10:27:12 +01:00
// Create party mon icons
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
{
if ( trainerId = = TRAINER_PLAYER )
2018-08-19 20:21:37 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( DOME_MONS [ trainerTourneyId ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-26 15:51:14 +02:00
x | sInfoTrainerMonX [ i ] ,
y + sInfoTrainerMonY [ i ] ,
2018-08-19 17:13:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-19 20:21:37 +02:00
}
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 20:21:37 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( DOME_MONS [ trainerTourneyId ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-26 15:51:14 +02:00
x | sInfoTrainerMonX [ i ] ,
y + sInfoTrainerMonY [ i ] ,
2018-08-19 17:13:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-19 20:21:37 +02:00
}
2018-08-19 17:13:05 +02:00
else
2018-08-19 20:21:37 +02:00
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . species ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2018-08-26 15:51:14 +02:00
x | sInfoTrainerMonX [ i ] ,
y + sInfoTrainerMonY [ i ] ,
2018-08-19 17:13:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-19 20:21:37 +02:00
}
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . invisible = TRUE ;
2018-08-19 17:13:05 +02:00
}
2020-09-02 15:49:04 +02:00
2019-12-21 10:27:12 +01:00
// Initialize the text printer
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_SHORT ;
2018-08-19 17:13:05 +02:00
textPrinter . x = 0 ;
textPrinter . y = 0 ;
2018-08-19 20:21:37 +02:00
textPrinter . currentX = textPrinter . x ;
textPrinter . currentY = textPrinter . y ;
2018-08-19 17:13:05 +02:00
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
textPrinter . unk = 0 ;
2019-12-18 08:32:52 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_5 ;
textPrinter . bgColor = TEXT_COLOR_TRANSPARENT ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2018-08-19 17:13:05 +02:00
2019-12-21 10:27:12 +01:00
// Get class and trainer name
2018-08-19 17:13:05 +02:00
i = 0 ;
if ( trainerId = = TRAINER_PLAYER )
2018-12-03 14:01:52 +01:00
j = gFacilityClassToTrainerClass [ FACILITY_CLASS_BRENDAN ] ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
j = GetDomeBrainTrainerClass ( ) ;
else
j = GetFrontierOpponentClass ( trainerId ) ;
for ( ; gTrainerClassNames [ j ] [ i ] ! = EOS ; i + + )
gStringVar1 [ i ] = gTrainerClassNames [ j ] [ i ] ;
gStringVar1 [ i ] = CHAR_SPACE ;
gStringVar1 [ i + 1 ] = EOS ;
if ( trainerId = = TRAINER_PLAYER )
{
StringAppend ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
}
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
{
CopyDomeBrainTrainerName ( gStringVar2 ) ;
StringAppend ( gStringVar1 , gStringVar2 ) ;
}
else
{
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar2 , trainerId ) ;
2018-08-19 17:13:05 +02:00
StringAppend ( gStringVar1 , gStringVar2 ) ;
}
2019-12-21 10:27:12 +01:00
// Print class and trainer name
2018-08-19 17:13:05 +02:00
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , gStringVar1 , 0xD0 , textPrinter . letterSpacing ) ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gStringVar1 ;
2018-08-19 17:13:05 +02:00
textPrinter . windowId = windowId ;
PutWindowTilemap ( windowId ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId , COPYWIN_FULL ) ;
2018-08-19 17:13:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
textPrinter . letterSpacing = 0 ;
2019-12-21 10:27:12 +01:00
// Print names of the party mons
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
{
2019-12-18 08:32:52 +01:00
textPrinter . currentY = sSpeciesNameTextYCoords [ i ] ;
2018-08-19 17:13:05 +02:00
if ( trainerId = = TRAINER_PLAYER )
2020-01-05 16:50:32 +01:00
textPrinter . currentChar = gSpeciesNames [ DOME_MONS [ trainerTourneyId ] [ i ] ] ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2020-01-05 16:50:32 +01:00
textPrinter . currentChar = gSpeciesNames [ DOME_MONS [ trainerTourneyId ] [ i ] ] ;
2018-08-19 17:13:05 +02:00
else
2020-01-05 16:50:32 +01:00
textPrinter . currentChar = gSpeciesNames [ gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . species ] ;
2018-08-19 17:13:05 +02:00
2018-08-19 20:21:37 +02:00
textPrinter . windowId = 1 + i + windowId ;
2018-08-19 17:13:05 +02:00
if ( i = = 1 )
textPrinter . currentX = 7 ;
else
textPrinter . currentX = 0 ;
2018-08-19 20:21:37 +02:00
PutWindowTilemap ( 1 + i + windowId ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( 1 + i + windowId , COPYWIN_FULL ) ;
2018-08-19 17:13:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
PutWindowTilemap ( windowId + 4 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId + 4 , COPYWIN_FULL ) ;
2019-12-21 10:27:12 +01:00
// Print text about trainers potential in the tourney
2018-08-19 17:13:05 +02:00
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2019-12-21 10:27:12 +01:00
textPrinter . currentChar = sBattleDomePotentialTexts [ DOME_TOURNAMENT_TRAINERS_COUNT ] ;
2018-08-19 17:13:05 +02:00
else
2020-01-05 16:50:32 +01:00
textPrinter . currentChar = sBattleDomePotentialTexts [ trainerTourneyId ] ;
2018-08-19 17:13:05 +02:00
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_NORMAL ;
2018-08-19 17:13:05 +02:00
textPrinter . windowId = windowId + 4 ;
textPrinter . currentX = 0 ;
textPrinter . y = 4 ;
textPrinter . currentY = 4 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
2019-12-21 10:27:12 +01:00
// Calculate move scores to determine the trainers battle style
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
{
2018-12-25 18:50:15 +01:00
for ( j = 0 ; j < MAX_MON_MOVES ; j + + )
2018-08-19 17:13:05 +02:00
{
2020-01-05 16:50:32 +01:00
for ( k = 0 ; k < NUM_MOVE_POINT_TYPES ; k + + )
2018-08-19 17:13:05 +02:00
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2020-01-05 16:50:32 +01:00
allocatedArray [ k ] + = sBattleStyleMovePoints [ GetFrontierBrainMonMove ( i , j ) ] [ k ] ;
2018-08-19 17:13:05 +02:00
else if ( trainerId = = TRAINER_PLAYER )
2020-01-05 16:50:32 +01:00
allocatedArray [ k ] + = sBattleStyleMovePoints [ gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . moves [ j ] ] [ k ] ;
2018-08-19 17:13:05 +02:00
else
2020-01-05 16:50:32 +01:00
allocatedArray [ k ] + = sBattleStyleMovePoints [ gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . moves [ j ] ] [ k ] ;
2018-08-19 17:13:05 +02:00
}
}
}
2019-12-21 10:27:12 +01:00
// Get the battle style the trainer uses
// Each element of sBattleStyleThresholds is an array of point thresholds for particular move qualities
// If all the point thresholds in the array are satisfied, the player is considered to be using that battle style
for ( i = 0 ; i < ARRAY_COUNT ( sBattleStyleThresholds ) ; i + + )
2018-08-19 17:13:05 +02:00
{
2019-12-21 10:27:12 +01:00
int thresholdStatCount = 0 ;
2018-08-19 17:13:05 +02:00
2020-01-05 16:50:32 +01:00
for ( k = 0 , j = 0 ; j < NUM_MOVE_POINT_TYPES ; j + + )
2018-08-19 17:13:05 +02:00
{
2019-12-21 10:27:12 +01:00
if ( sBattleStyleThresholds [ i ] [ j ] ! = 0 )
2018-08-19 17:13:05 +02:00
{
2019-12-21 10:27:12 +01:00
thresholdStatCount + + ;
if ( allocatedArray [ j ] ! = 0 & & allocatedArray [ j ] > = sBattleStyleThresholds [ i ] [ j ] )
k + + ; // number of point thresholds met/exceeded
2018-08-19 17:13:05 +02:00
}
}
2019-12-21 10:27:12 +01:00
if ( thresholdStatCount = = k )
break ; // All thresholds for battle style met/exceeded, player uses this battle style
2018-08-19 17:13:05 +02:00
}
2019-12-21 10:27:12 +01:00
// Print the trainers battle style
2019-02-08 18:08:25 +01:00
textPrinter . currentChar = sBattleDomeOpponentStyleTexts [ i ] ;
2018-08-19 17:13:05 +02:00
textPrinter . y = 20 ;
textPrinter . currentY = 20 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < ALLOC_ARRAY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
allocatedArray [ i ] = 0 ;
2019-12-21 10:27:12 +01:00
// Calculate EV/nature points for the stat portion of battle style
2018-08-19 17:13:05 +02:00
if ( trainerId = = TRAINER_FRONTIER_BRAIN | | trainerId = = TRAINER_PLAYER )
{
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
{
2020-01-05 16:50:32 +01:00
// Add the EVs for this mon
2019-12-18 08:32:52 +01:00
for ( j = 0 ; j < NUM_STATS ; j + + )
2018-08-19 17:13:05 +02:00
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-11-01 21:31:10 +01:00
allocatedArray [ j ] = GetFrontierBrainMonEvs ( i , j ) ;
2018-08-19 17:13:05 +02:00
else
2019-12-21 10:27:12 +01:00
allocatedArray [ j ] = gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . evs [ j ] ;
2018-08-19 17:13:05 +02:00
}
2020-01-05 16:50:32 +01:00
// HP doesnt have a nature modifier, so just add it here
allocatedArray [ NUM_STATS ] + = allocatedArray [ STAT_HP ] ;
// Add the EVs with the nature modifier for this mon and and track number of negative natures
2020-07-17 02:12:12 +02:00
for ( j = 0 ; j < NUM_NATURE_STATS ; j + + )
2018-08-19 17:13:05 +02:00
{
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
2018-11-01 21:31:10 +01:00
nature = GetFrontierBrainMonNature ( i ) ;
2018-08-19 17:13:05 +02:00
else
2019-12-21 10:27:12 +01:00
nature = gSaveBlock2Ptr - > frontier . domePlayerPartyData [ i ] . nature ;
2018-08-19 17:13:05 +02:00
if ( gNatureStatTable [ nature ] [ j ] > 0 )
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = ( allocatedArray [ j + 1 ] * 110 ) / 100 ;
2018-08-19 17:13:05 +02:00
}
else if ( gNatureStatTable [ nature ] [ j ] < 0 )
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = ( allocatedArray [ j + 1 ] * 90 ) / 100 ;
2020-07-17 02:12:12 +02:00
allocatedArray [ j + NUM_STATS + NUM_NATURE_STATS + 2 ] + + ;
2018-08-19 17:13:05 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = allocatedArray [ j + 1 ] ;
2018-08-19 17:13:05 +02:00
}
}
}
2019-12-21 10:27:12 +01:00
for ( j = 0 , i = 0 ; i < NUM_STATS ; i + + )
j + = allocatedArray [ NUM_STATS + i ] ;
for ( i = 0 ; i < NUM_STATS ; i + + )
allocatedArray [ i ] = ( allocatedArray [ NUM_STATS + i ] * 100 ) / j ;
2018-08-19 17:13:05 +02:00
}
2020-01-05 16:50:32 +01:00
// Same as above but for regular trainers instead of the frontier brain or player
2018-08-19 17:13:05 +02:00
else
{
2019-12-21 10:27:12 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-19 17:13:05 +02:00
{
2020-01-05 16:50:32 +01:00
int evBits = gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . evSpread ;
2018-11-18 20:00:36 +01:00
for ( k = 0 , j = 0 ; j < NUM_STATS ; j + + )
2018-08-19 17:13:05 +02:00
{
allocatedArray [ j ] = 0 ;
if ( evBits & 1 )
k + + ;
evBits > > = 1 ;
}
2018-08-29 20:38:54 +02:00
k = MAX_TOTAL_EVS / k ;
2020-01-05 16:50:32 +01:00
evBits = gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . evSpread ;
2018-11-18 20:00:36 +01:00
for ( j = 0 ; j < NUM_STATS ; j + + )
2018-08-19 17:13:05 +02:00
{
if ( evBits & 1 )
allocatedArray [ j ] = k ;
evBits > > = 1 ;
}
2020-01-05 16:50:32 +01:00
allocatedArray [ NUM_STATS ] + = allocatedArray [ STAT_HP ] ;
2020-07-17 02:12:12 +02:00
for ( j = 0 ; j < NUM_NATURE_STATS ; j + + )
2018-08-19 17:13:05 +02:00
{
2020-01-05 16:50:32 +01:00
nature = gFacilityTrainerMons [ DOME_MONS [ trainerTourneyId ] [ i ] ] . nature ;
2018-08-19 17:13:05 +02:00
if ( gNatureStatTable [ nature ] [ j ] > 0 )
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = ( allocatedArray [ j + 1 ] * 110 ) / 100 ;
2018-08-19 17:13:05 +02:00
}
else if ( gNatureStatTable [ nature ] [ j ] < 0 )
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = ( allocatedArray [ j + 1 ] * 90 ) / 100 ;
2020-07-17 02:12:12 +02:00
allocatedArray [ j + NUM_STATS + NUM_NATURE_STATS + 2 ] + + ;
2018-08-19 17:13:05 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
allocatedArray [ j + NUM_STATS + 1 ] + = allocatedArray [ j + 1 ] ;
2018-08-19 17:13:05 +02:00
}
}
}
2019-12-21 10:27:12 +01:00
for ( j = 0 , i = 0 ; i < NUM_STATS ; i + + )
j + = allocatedArray [ i + NUM_STATS ] ;
for ( i = 0 ; i < NUM_STATS ; i + + )
allocatedArray [ i ] = ( allocatedArray [ NUM_STATS + i ] * 100 ) / j ;
2018-08-19 17:13:05 +02:00
}
2020-01-05 16:50:32 +01:00
// Count the number of good/bad stats for the party
// i is the number of good stats, j is the number of bad stats
for ( i = 0 , j = 0 , k = 0 ; k < NUM_STATS ; k + + )
2018-08-19 17:13:05 +02:00
{
2020-01-05 16:50:32 +01:00
// Any stat above 29 EVs is considered good
2018-08-19 17:13:05 +02:00
if ( allocatedArray [ k ] > 29 )
{
2020-01-05 16:50:32 +01:00
// If 2 good stats have been found already, choose which to use
2018-08-19 17:13:05 +02:00
if ( i = = 2 )
{
if ( allocatedArray [ 6 ] < allocatedArray [ k ] )
{
if ( allocatedArray [ 7 ] < allocatedArray [ k ] )
{
if ( allocatedArray [ 6 ] < allocatedArray [ 7 ] )
{
2018-08-19 20:21:37 +02:00
allocatedArray [ 6 ] = allocatedArray [ 7 ] ;
2018-08-19 17:13:05 +02:00
allocatedArray [ 7 ] = k ;
}
else
{
allocatedArray [ 7 ] = k ;
}
}
else
{
2018-08-19 20:21:37 +02:00
allocatedArray [ 6 ] = allocatedArray [ 7 ] ;
2018-08-19 17:13:05 +02:00
allocatedArray [ 7 ] = k ;
}
}
else
{
if ( allocatedArray [ 7 ] < allocatedArray [ k ] )
allocatedArray [ 7 ] = k ;
}
}
else
{
2018-08-19 20:21:37 +02:00
allocatedArray [ i + 6 ] = k ;
2018-08-19 17:13:05 +02:00
i + + ;
}
}
2020-01-05 16:50:32 +01:00
// Any stat with 0 EVs is considered bad
2018-08-19 17:13:05 +02:00
if ( allocatedArray [ k ] = = 0 )
{
2020-01-05 16:50:32 +01:00
// If 2 bad stats have been found already, choose which to use
2018-08-19 17:13:05 +02:00
if ( j = = 2 )
{
if ( allocatedArray [ k + 12 ] > = 2
2018-08-19 20:21:37 +02:00
| | ( ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 8 ] ] = = 0 & & allocatedArray [ 12 + allocatedArray [ 9 ] ] = = 0 )
2018-08-19 17:13:05 +02:00
)
)
{
allocatedArray [ 8 ] = allocatedArray [ 9 ] ;
allocatedArray [ 9 ] = k ;
}
else if ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 8 ] ] = = 0 )
{
allocatedArray [ 8 ] = allocatedArray [ 9 ] ;
allocatedArray [ 9 ] = k ;
}
else if ( allocatedArray [ k + 12 ] = = 1 & & allocatedArray [ 12 + allocatedArray [ 9 ] ] = = 0 )
{
allocatedArray [ 9 ] = k ;
}
}
else
{
allocatedArray [ j + 8 ] = k ;
j + + ;
}
}
}
2020-01-05 16:50:32 +01:00
// Get the string ID to display which stats are good/bad
2018-08-19 17:13:05 +02:00
if ( i = = 2 )
2020-01-05 16:50:32 +01:00
i = sStatTextOffsets [ allocatedArray [ 6 ] ] + ( allocatedArray [ 7 ] - ( allocatedArray [ 6 ] + 1 ) ) + DOME_TEXT_TWO_GOOD_STATS ;
2018-08-19 17:13:05 +02:00
else if ( i = = 1 )
2020-01-05 16:50:32 +01:00
i = allocatedArray [ 6 ] + DOME_TEXT_ONE_GOOD_STAT ;
2018-08-19 17:13:05 +02:00
else if ( j = = 2 )
2020-01-05 16:50:32 +01:00
i = sStatTextOffsets [ allocatedArray [ 8 ] ] + ( allocatedArray [ 9 ] - ( allocatedArray [ 8 ] + 1 ) ) + DOME_TEXT_TWO_BAD_STATS ;
2018-08-19 17:13:05 +02:00
else if ( j = = 1 )
2020-01-05 16:50:32 +01:00
i = allocatedArray [ 8 ] + DOME_TEXT_ONE_BAD_STAT ;
2018-08-19 17:13:05 +02:00
else
2020-01-05 16:50:32 +01:00
i = DOME_TEXT_WELL_BALANCED ;
2018-08-19 01:06:10 +02:00
2020-01-05 16:50:32 +01:00
// Print the stat text
2019-02-08 18:08:25 +01:00
textPrinter . currentChar = sBattleDomeOpponentStatsTexts [ i ] ;
2018-08-19 17:13:05 +02:00
textPrinter . y = 36 ;
textPrinter . currentY = 36 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
Free ( allocatedArray ) ;
2018-08-19 01:06:10 +02:00
}
2018-08-19 22:26:07 +02:00
2020-01-05 16:50:32 +01:00
static int BufferDomeWinString ( u8 matchNum , u8 * tournamentIds )
2018-08-19 22:26:07 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-19 22:26:07 +02:00
u8 tournamentId ;
2019-12-21 10:27:12 +01:00
int winStringId = 0 ;
2019-02-08 18:08:25 +01:00
int count = 0 ;
2018-08-19 22:26:07 +02:00
2020-01-05 16:50:32 +01:00
// Get winners name
for ( i = sCompetitorRangeByMatch [ matchNum ] [ 0 ] ; i < sCompetitorRangeByMatch [ matchNum ] [ 0 ] + sCompetitorRangeByMatch [ matchNum ] [ 1 ] ; i + + )
2018-08-19 22:26:07 +02:00
{
2020-01-05 16:50:32 +01:00
tournamentId = sTourneyTreeTrainerIds2 [ i ] ;
2019-12-18 08:32:52 +01:00
if ( ! DOME_TRAINERS [ tournamentId ] . isEliminated )
2018-08-19 22:26:07 +02:00
{
2020-01-05 16:50:32 +01:00
tournamentIds [ count ] = tournamentId ;
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentId ] . trainerId = = TRAINER_PLAYER )
2018-08-19 22:26:07 +02:00
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
2019-12-18 08:32:52 +01:00
else if ( DOME_TRAINERS [ tournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 22:26:07 +02:00
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2019-12-18 08:32:52 +01:00
CopyDomeTrainerName ( gStringVar1 , DOME_TRAINERS [ tournamentId ] . trainerId ) ;
2018-08-19 22:26:07 +02:00
count + + ;
}
}
2019-12-21 10:27:12 +01:00
// Neither trainer has been eliminated, battle hasn't occurred yet
2018-08-19 22:26:07 +02:00
if ( count = = 2 )
2020-01-05 16:50:32 +01:00
return DOME_TEXT_NO_WINNER_YET ;
2018-08-19 22:26:07 +02:00
2020-01-05 16:50:32 +01:00
for ( i = sCompetitorRangeByMatch [ matchNum ] [ 0 ] ; i < sCompetitorRangeByMatch [ matchNum ] [ 0 ] + sCompetitorRangeByMatch [ matchNum ] [ 1 ] ; i + + )
2018-08-19 22:26:07 +02:00
{
2020-01-05 16:50:32 +01:00
tournamentId = sTourneyTreeTrainerIds2 [ i ] ;
2020-09-02 15:49:04 +02:00
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentId ] . isEliminated
2020-01-05 16:50:32 +01:00
& & DOME_TRAINERS [ tournamentId ] . eliminatedAt > = sCompetitorRangeByMatch [ matchNum ] [ 2 ] )
2018-08-19 22:26:07 +02:00
{
2020-01-05 16:50:32 +01:00
tournamentIds [ count ] = tournamentId ;
2018-08-19 22:26:07 +02:00
count + + ;
2020-01-05 16:50:32 +01:00
if ( DOME_TRAINERS [ tournamentId ] . eliminatedAt = = sCompetitorRangeByMatch [ matchNum ] [ 2 ] )
2018-08-19 22:26:07 +02:00
{
2020-01-05 16:50:32 +01:00
// Set initial winStringId offset
2019-12-18 08:32:52 +01:00
StringCopy ( gStringVar2 , gMoveNames [ gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId ] ] ) ;
2020-01-05 16:50:32 +01:00
winStringId = DOME_TRAINERS [ tournamentId ] . forfeited * 2 ; // (DOME_TEXT_WON_USING_MOVE - 1) or (DOME_TEXT_WON_ON_FORFEIT - 1)
2019-12-21 10:27:12 +01:00
2019-12-18 08:32:52 +01:00
if ( gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId ] = = MOVE_NONE & & DOME_TRAINERS [ tournamentId ] . forfeited = = FALSE )
2020-01-05 16:50:32 +01:00
winStringId = DOME_TEXT_WON_NO_MOVES - 1 ;
2018-08-19 22:26:07 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentId ] . trainerId = = TRAINER_PLAYER )
2018-08-19 22:26:07 +02:00
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
2019-12-18 08:32:52 +01:00
else if ( DOME_TRAINERS [ tournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
2018-08-19 22:26:07 +02:00
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2019-12-18 08:32:52 +01:00
CopyDomeTrainerName ( gStringVar1 , DOME_TRAINERS [ tournamentId ] . trainerId ) ;
2018-08-19 22:26:07 +02:00
}
}
if ( count = = 2 )
break ;
}
2020-01-05 16:50:32 +01:00
if ( matchNum = = DOME_TOURNAMENT_MATCHES_COUNT - 1 )
return winStringId + 2 ; // use DOME_TEXT_CHAMP_*
2018-08-19 22:26:07 +02:00
else
2020-01-05 16:50:32 +01:00
return winStringId + 1 ; // use DOME_TEXT_WON_*
2018-08-19 22:26:07 +02:00
}
2018-08-20 22:56:05 +02:00
2018-08-21 23:36:59 +02:00
static void DisplayMatchInfoOnCard ( u8 flags , u8 matchNo )
2018-08-20 22:56:05 +02:00
{
2018-11-06 17:44:48 +01:00
struct TextPrinterTemplate textPrinter ;
2019-02-08 18:08:25 +01:00
int tournamentIds [ 2 ] ;
int trainerIds [ 2 ] ;
2018-08-20 22:56:05 +02:00
bool32 lost [ 2 ] ;
2019-02-08 18:08:25 +01:00
int i ;
int winStringId = 0 ;
int arrId = 0 ;
int windowId = 0 ;
int x = 0 , y = 0 ;
2018-08-20 22:56:05 +02:00
u8 palSlot = 0 ;
2020-01-05 16:50:32 +01:00
if ( flags & CARD_ALTERNATE_SLOT )
arrId = 2 * ( FRONTIER_PARTY_SIZE + 1 ) , windowId = 9 , palSlot = 2 ;
if ( flags & MOVE_CARD_RIGHT )
2021-04-15 08:04:01 +02:00
x = DISPLAY_WIDTH + 16 ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_DOWN )
2021-04-15 08:04:01 +02:00
y = DISPLAY_HEIGHT ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_LEFT )
2021-04-15 08:04:01 +02:00
x = - ( DISPLAY_WIDTH + 16 ) ;
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD_UP )
2021-04-15 08:04:01 +02:00
y = - DISPLAY_HEIGHT ;
2018-08-20 22:56:05 +02:00
// Copy trainers information to handy arrays.
2020-01-05 16:50:32 +01:00
winStringId = BufferDomeWinString ( matchNo , sInfoCard - > tournamentIds ) ;
for ( i = 0 ; i < NUM_INFOCARD_TRAINERS ; i + + )
2018-08-20 22:56:05 +02:00
{
2020-01-05 16:50:32 +01:00
tournamentIds [ i ] = sInfoCard - > tournamentIds [ i ] ;
2019-12-18 08:32:52 +01:00
trainerIds [ i ] = DOME_TRAINERS [ tournamentIds [ i ] ] . trainerId ;
2020-01-05 16:50:32 +01:00
if ( DOME_TRAINERS [ tournamentIds [ i ] ] . eliminatedAt < = sCompetitorRangeByMatch [ matchNo ] [ 2 ]
2019-12-18 08:32:52 +01:00
& & DOME_TRAINERS [ tournamentIds [ i ] ] . isEliminated )
2018-08-20 22:56:05 +02:00
lost [ i ] = TRUE ;
else
lost [ i ] = FALSE ;
}
2020-01-05 16:50:32 +01:00
// Draw left trainer sprite.
2018-08-20 22:56:05 +02:00
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 48 , y + 88 , palSlot + 12 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 48 , y + 88 , palSlot + 12 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
else
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerIds [ 0 ] ) , TRUE , x + 48 , y + 88 , palSlot + 12 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ arrId ] ] . invisible = TRUE ;
2018-08-20 22:56:05 +02:00
if ( lost [ 0 ] )
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ arrId ] ] . oam . paletteNum = 3 ;
2018-08-20 22:56:05 +02:00
2020-01-05 16:50:32 +01:00
// Draw right trainer sprite.
2018-08-20 22:56:05 +02:00
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ 1 + arrId ] = CreateTrainerPicSprite ( PlayerGenderToFrontTrainerPicId ( gSaveBlock2Ptr - > playerGender ) , TRUE , x + 192 , y + 88 , palSlot + 13 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ 1 + arrId ] = CreateTrainerPicSprite ( GetDomeBrainTrainerPicId ( ) , TRUE , x + 192 , y + 88 , palSlot + 13 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
else
2021-09-14 19:14:14 +02:00
sInfoCard - > spriteIds [ 1 + arrId ] = CreateTrainerPicSprite ( GetFrontierTrainerFrontSpriteId ( trainerIds [ 1 ] ) , TRUE , x + 192 , y + 88 , palSlot + 13 , TAG_NONE ) ;
2018-08-20 22:56:05 +02:00
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ 1 + arrId ] ] . invisible = TRUE ;
2018-08-20 22:56:05 +02:00
if ( lost [ 1 ] )
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 1 + arrId ] ] . oam . paletteNum = 3 ;
2018-08-20 22:56:05 +02:00
2020-01-05 16:50:32 +01:00
// Draw left trainer's pokemon icons.
2019-12-21 10:27:12 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-20 22:56:05 +02:00
{
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( DOME_MONS [ tournamentIds [ 0 ] ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sLeftTrainerMonX [ i ] ,
y + sLeftTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( DOME_MONS [ tournamentIds [ 0 ] ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sLeftTrainerMonX [ i ] ,
y + sLeftTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 2 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ DOME_MONS [ tournamentIds [ 0 ] ] [ i ] ] . species ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sLeftTrainerMonX [ i ] ,
y + sLeftTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . invisible = TRUE ;
2018-08-20 22:56:05 +02:00
if ( lost [ 0 ] )
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . oam . paletteNum = 3 ;
gSprites [ sInfoCard - > spriteIds [ 2 + i + arrId ] ] . sMonIconStill = TRUE ;
2018-08-20 22:56:05 +02:00
}
}
2020-01-05 16:50:32 +01:00
// Draw right trainer's pokemon icons.
2019-12-21 10:27:12 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-20 22:56:05 +02:00
{
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 5 + i + arrId ] = CreateMonIcon ( DOME_MONS [ tournamentIds [ 1 ] ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sRightTrainerMonX [ i ] ,
y + sRightTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 5 + i + arrId ] = CreateMonIcon ( DOME_MONS [ tournamentIds [ 1 ] ] [ i ] ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sRightTrainerMonX [ i ] ,
y + sRightTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
sInfoCard - > spriteIds [ 5 + i + arrId ] = CreateMonIcon ( gFacilityTrainerMons [ DOME_MONS [ tournamentIds [ 1 ] ] [ i ] ] . species ,
2018-08-20 22:56:05 +02:00
SpriteCb_MonIcon ,
2020-01-05 16:50:32 +01:00
x | sRightTrainerMonX [ i ] ,
y + sRightTrainerMonY [ i ] ,
2018-08-20 22:56:05 +02:00
0 , 0 , TRUE ) ;
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . oam . priority = 0 ;
2018-08-20 22:56:05 +02:00
}
2020-01-05 16:50:32 +01:00
if ( flags & MOVE_CARD )
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . invisible = TRUE ;
2018-08-20 22:56:05 +02:00
if ( lost [ 1 ] )
{
2020-01-05 16:50:32 +01:00
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . oam . paletteNum = 3 ;
gSprites [ sInfoCard - > spriteIds [ 5 + i + arrId ] ] . sMonIconStill = TRUE ;
2018-08-20 22:56:05 +02:00
}
}
2020-01-05 16:50:32 +01:00
// Print the win string (or 'Let the battle begin!').
2018-08-20 22:56:05 +02:00
textPrinter . x = 0 ;
textPrinter . y = 2 ;
textPrinter . currentX = textPrinter . x ;
textPrinter . currentY = textPrinter . y ;
textPrinter . letterSpacing = 0 ;
textPrinter . lineSpacing = 0 ;
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
textPrinter . unk = 0 ;
2019-12-21 10:27:12 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_5 ;
textPrinter . bgColor = TEXT_COLOR_TRANSPARENT ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2019-02-08 18:08:25 +01:00
StringExpandPlaceholders ( gStringVar4 , sBattleDomeWinTexts [ winStringId ] ) ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gStringVar4 ;
2018-08-20 22:56:05 +02:00
textPrinter . windowId = windowId + 8 ;
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_NORMAL ;
2018-08-20 22:56:05 +02:00
PutWindowTilemap ( windowId + 8 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId + 8 , COPYWIN_FULL ) ;
2018-08-20 22:56:05 +02:00
textPrinter . currentX = 0 ;
textPrinter . currentY = textPrinter . y = 0 ;
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
2020-01-05 16:50:32 +01:00
// Print left trainer's name.
2018-08-20 22:56:05 +02:00
if ( trainerIds [ 0 ] = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( trainerIds [ 0 ] = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , trainerIds [ 0 ] ) ;
2018-08-20 22:56:05 +02:00
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_SHORT ;
2018-08-20 22:56:05 +02:00
textPrinter . letterSpacing = 2 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gStringVar1 ;
2018-08-20 22:56:05 +02:00
textPrinter . windowId = windowId + 6 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . currentChar , 0x40 , textPrinter . letterSpacing ) ;
2018-08-20 22:56:05 +02:00
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 6 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId + 6 , COPYWIN_FULL ) ;
2018-08-20 22:56:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
2020-01-05 16:50:32 +01:00
// Print right trainer's name.
2018-08-20 22:56:05 +02:00
if ( trainerIds [ 1 ] = = TRAINER_PLAYER )
StringCopy ( gStringVar1 , gSaveBlock2Ptr - > playerName ) ;
else if ( trainerIds [ 1 ] = = TRAINER_FRONTIER_BRAIN )
CopyDomeBrainTrainerName ( gStringVar1 ) ;
else
2018-08-25 11:55:16 +02:00
CopyDomeTrainerName ( gStringVar1 , trainerIds [ 1 ] ) ;
2018-08-20 22:56:05 +02:00
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gStringVar1 ;
2018-08-20 22:56:05 +02:00
textPrinter . windowId = windowId + 7 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . currentChar , 0x40 , textPrinter . letterSpacing ) ;
2018-08-20 22:56:05 +02:00
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 7 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId + 7 , COPYWIN_FULL ) ;
2018-08-20 22:56:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
// Print match number.
textPrinter . letterSpacing = 0 ;
2019-02-08 18:08:25 +01:00
textPrinter . currentChar = sBattleDomeMatchNumberTexts [ matchNo ] ;
2018-08-20 22:56:05 +02:00
textPrinter . windowId = windowId + 5 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . currentChar , 0xA0 , textPrinter . letterSpacing ) ;
2018-08-20 22:56:05 +02:00
textPrinter . currentY = textPrinter . y = 2 ;
PutWindowTilemap ( windowId + 5 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( windowId + 5 , COPYWIN_FULL ) ;
2018-08-20 22:56:05 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
2018-08-21 23:36:59 +02:00
2019-02-08 18:08:25 +01:00
static void ShowDomeTourneyTree ( void )
2018-08-21 23:36:59 +02:00
{
2019-02-08 18:08:25 +01:00
u8 taskId = CreateTask ( Task_ShowTourneyTree , 0 ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = 0 ;
gTasks [ taskId ] . tNotInteractive = FALSE ;
2018-08-21 23:36:59 +02:00
gTasks [ taskId ] . data [ 2 ] = 2 ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tIsPrevTourneyTree = FALSE ;
SetMainCallback2 ( CB2_TourneyTree ) ;
2018-08-21 23:36:59 +02:00
}
2020-01-05 16:50:32 +01:00
// To show the results of the last tourney on the computer in the lobby
static void ShowPreviousDomeTourneyTree ( void )
2018-08-21 23:36:59 +02:00
{
u8 taskId ;
2019-12-21 10:27:12 +01:00
SetFacilityTrainerAndMonPtrs ( ) ;
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . lvlMode = gSaveBlock2Ptr - > frontier . domeLvlMode - 1 ;
gSaveBlock2Ptr - > frontier . curChallengeBattleNum = DOME_FINAL ;
2019-02-08 18:08:25 +01:00
taskId = CreateTask ( Task_ShowTourneyTree , 0 ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = 0 ;
gTasks [ taskId ] . tNotInteractive = FALSE ;
2018-08-21 23:36:59 +02:00
gTasks [ taskId ] . data [ 2 ] = 2 ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tIsPrevTourneyTree = TRUE ;
SetMainCallback2 ( CB2_TourneyTree ) ;
2018-08-21 23:36:59 +02:00
}
2020-01-05 16:50:32 +01:00
// Task states for Task_HandleTourneyTreeInput
# define STATE_FADE_IN 0
# define STATE_WAIT_FADE 1
# define STATE_GET_INPUT 2
# define STATE_SHOW_INFOCARD_TRAINER 3
# define STATE_SHOW_INFOCARD_MATCH 5
# define STATE_CLOSE_TOURNEY_TREE 7
static void Task_HandleTourneyTreeInput ( u8 taskId )
2018-08-21 23:36:59 +02:00
{
u8 newTaskId = 0 ;
2019-02-08 18:08:25 +01:00
int spriteId = gTasks [ taskId ] . data [ 1 ] ;
2018-08-21 23:36:59 +02:00
2020-01-05 16:50:32 +01:00
switch ( gTasks [ taskId ] . tState )
2018-08-21 23:36:59 +02:00
{
2020-01-05 16:50:32 +01:00
case STATE_FADE_IN :
2018-08-21 23:36:59 +02:00
if ( ! gPaletteFade . active )
{
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0x10 , 0 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_WAIT_FADE ;
2018-08-21 23:36:59 +02:00
StartSpriteAnim ( & gSprites [ spriteId ] , 1 ) ;
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_WAIT_FADE :
2018-08-21 23:36:59 +02:00
if ( ! gPaletteFade . active )
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_GET_INPUT ;
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_GET_INPUT :
2019-02-08 18:08:25 +01:00
switch ( UpdateTourneyTreeCursor ( taskId ) )
2018-08-21 23:36:59 +02:00
{
2020-01-05 16:50:32 +01:00
case TOURNEY_TREE_SELECTED_CLOSE :
2018-08-21 23:36:59 +02:00
default :
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0 , 0x10 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_CLOSE_TOURNEY_TREE ;
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case TOURNEY_TREE_NO_SELECTION :
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case TOURNEY_TREE_SELECTED_TRAINER :
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0 , 0x10 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_SHOW_INFOCARD_TRAINER ;
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case TOURNEY_TREE_SELECTED_MATCH :
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0 , 0x10 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_SHOW_INFOCARD_MATCH ;
2018-08-21 23:36:59 +02:00
break ;
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_SHOW_INFOCARD_TRAINER :
2018-08-21 23:36:59 +02:00
if ( ! gPaletteFade . active )
{
FreeAllWindowBuffers ( ) ;
ScanlineEffect_Stop ( ) ;
2018-08-25 19:59:47 +02:00
FREE_AND_SET_NULL ( sTilemapBuffer ) ;
2020-01-05 16:50:32 +01:00
newTaskId = CreateTask ( Task_ShowTourneyInfoCard , 0 ) ;
gTasks [ newTaskId ] . tState = 0 ;
gTasks [ newTaskId ] . tTournamentId = sTourneyTreeTrainerIds [ spriteId ] ;
gTasks [ newTaskId ] . tMode = INFOCARD_TRAINER ;
gTasks [ newTaskId ] . tPrevTaskId = taskId ;
gTasks [ taskId ] . tState = STATE_SHOW_INFOCARD_TRAINER + 1 ;
sInfoCard - > pos = 0 ;
2018-08-21 23:36:59 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_SHOW_INFOCARD_TRAINER + 1 :
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_SHOW_INFOCARD_MATCH :
2018-08-21 23:36:59 +02:00
if ( ! gPaletteFade . active )
{
FreeAllWindowBuffers ( ) ;
ScanlineEffect_Stop ( ) ;
2018-08-25 19:59:47 +02:00
FREE_AND_SET_NULL ( sTilemapBuffer ) ;
2020-01-05 16:50:32 +01:00
newTaskId = CreateTask ( Task_ShowTourneyInfoCard , 0 ) ;
gTasks [ newTaskId ] . tState = 0 ;
gTasks [ newTaskId ] . tTournamentId = spriteId - DOME_TOURNAMENT_TRAINERS_COUNT ;
gTasks [ newTaskId ] . tMode = INFOCARD_MATCH ;
gTasks [ newTaskId ] . tPrevTaskId = taskId ;
2018-08-21 23:36:59 +02:00
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_SHOW_INFOCARD_MATCH + 1 ;
2018-08-21 23:36:59 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_SHOW_INFOCARD_MATCH + 1 :
2018-08-21 23:36:59 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_CLOSE_TOURNEY_TREE :
2018-08-21 23:36:59 +02:00
if ( ! gPaletteFade . active )
{
FreeAllWindowBuffers ( ) ;
ScanlineEffect_Stop ( ) ;
2018-08-25 19:59:47 +02:00
FREE_AND_SET_NULL ( sTilemapBuffer ) ;
2018-08-21 23:36:59 +02:00
SetMainCallback2 ( CB2_ReturnToFieldContinueScriptPlayMapMusic ) ;
DestroyTask ( gTasks [ taskId ] . data [ 7 ] ) ;
DestroyTask ( taskId ) ;
}
break ;
}
}
2020-01-05 16:50:32 +01:00
// undefine task states for Task_HandleTourneyTreeInput
# undef STATE_FADE_IN
# undef STATE_WAIT_FADE
# undef STATE_GET_INPUT
# undef STATE_SHOW_INFOCARD_TRAINER
# undef STATE_SHOW_INFOCARD_MATCH
# undef STATE_CLOSE_TOURNEY_TREE
# define MOVE_DIR_UP 0
# define MOVE_DIR_DOWN 1
# define MOVE_DIR_LEFT 2
# define MOVE_DIR_RIGHT 3
# define MOVE_DIR_NONE 4
// Move the tourney tree cursor
// The 'cursor' is actually just which button sprite is currently doing the 'selected' animation
2019-02-08 18:08:25 +01:00
static u8 UpdateTourneyTreeCursor ( u8 taskId )
2018-08-21 23:36:59 +02:00
{
2020-01-05 16:50:32 +01:00
u8 selection = TOURNEY_TREE_NO_SELECTION ;
int direction = MOVE_DIR_NONE ;
2019-02-08 18:08:25 +01:00
int tourneyTreeCursorSpriteId = gTasks [ taskId ] . data [ 1 ] ;
int roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
2018-08-21 23:36:59 +02:00
2020-09-05 03:11:55 +02:00
if ( gMain . newKeys = = B_BUTTON | | ( JOY_NEW ( A_BUTTON ) & & tourneyTreeCursorSpriteId = = TOURNEY_TREE_CLOSE_BUTTON ) )
2018-08-21 23:36:59 +02:00
{
PlaySE ( SE_SELECT ) ;
2020-01-05 16:50:32 +01:00
selection = TOURNEY_TREE_SELECTED_CLOSE ;
2018-08-21 23:36:59 +02:00
}
2020-09-05 03:11:55 +02:00
else if ( JOY_NEW ( A_BUTTON ) )
2018-08-21 23:36:59 +02:00
{
2019-12-18 08:32:52 +01:00
if ( tourneyTreeCursorSpriteId < DOME_TOURNAMENT_TRAINERS_COUNT )
2018-08-21 23:36:59 +02:00
{
PlaySE ( SE_SELECT ) ;
2020-01-05 16:50:32 +01:00
selection = TOURNEY_TREE_SELECTED_TRAINER ;
2018-08-21 23:36:59 +02:00
}
else
{
PlaySE ( SE_SELECT ) ;
2020-01-05 16:50:32 +01:00
selection = TOURNEY_TREE_SELECTED_MATCH ;
2018-08-21 23:36:59 +02:00
}
}
else
{
2019-02-08 18:08:25 +01:00
if ( gMain . newKeys = = DPAD_UP & & sTourneyTreeCursorMovementMap [ tourneyTreeCursorSpriteId ] [ roundId ] [ 0 ] ! = 0xFF )
2020-01-05 16:50:32 +01:00
direction = MOVE_DIR_UP ;
2019-02-08 18:08:25 +01:00
else if ( gMain . newKeys = = DPAD_DOWN & & sTourneyTreeCursorMovementMap [ tourneyTreeCursorSpriteId ] [ roundId ] [ 1 ] ! = 0xFF )
2020-01-05 16:50:32 +01:00
direction = MOVE_DIR_DOWN ;
2019-02-08 18:08:25 +01:00
else if ( gMain . newKeys = = DPAD_LEFT & & sTourneyTreeCursorMovementMap [ tourneyTreeCursorSpriteId ] [ roundId ] [ 2 ] ! = 0xFF )
2020-01-05 16:50:32 +01:00
direction = MOVE_DIR_LEFT ;
2019-02-08 18:08:25 +01:00
else if ( gMain . newKeys = = DPAD_RIGHT & & sTourneyTreeCursorMovementMap [ tourneyTreeCursorSpriteId ] [ roundId ] [ 3 ] ! = 0xFF )
2020-01-05 16:50:32 +01:00
direction = MOVE_DIR_RIGHT ;
2018-08-21 23:36:59 +02:00
}
2020-01-05 16:50:32 +01:00
if ( direction ! = MOVE_DIR_NONE )
2018-08-21 23:36:59 +02:00
{
PlaySE ( SE_SELECT ) ;
2020-01-05 16:50:32 +01:00
StartSpriteAnim ( & gSprites [ tourneyTreeCursorSpriteId ] , 0 ) ; // Do unselected sprite anim
2019-02-08 18:08:25 +01:00
tourneyTreeCursorSpriteId = sTourneyTreeCursorMovementMap [ tourneyTreeCursorSpriteId ] [ roundId ] [ direction ] ;
2020-01-05 16:50:32 +01:00
StartSpriteAnim ( & gSprites [ tourneyTreeCursorSpriteId ] , 1 ) ; // Do selected sprite anim
2019-02-08 18:08:25 +01:00
gTasks [ taskId ] . data [ 1 ] = tourneyTreeCursorSpriteId ;
2018-08-21 23:36:59 +02:00
}
2020-01-05 16:50:32 +01:00
return selection ;
2018-08-21 23:36:59 +02:00
}
2018-08-25 11:55:16 +02:00
2020-01-05 16:50:32 +01:00
# undef MOVE_DIR_UP
# undef MOVE_DIR_DOWN
# undef MOVE_DIR_LEFT
# undef MOVE_DIR_RIGHT
# undef MOVE_DIR_NONE
// Shows the results of the just-completed round for the current tourney
2019-02-08 18:08:25 +01:00
static void ShowNonInteractiveDomeTourneyTree ( void )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
u8 taskId = CreateTask ( Task_ShowTourneyTree , 0 ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = 0 ;
gTasks [ taskId ] . tNotInteractive = TRUE ;
2018-08-25 11:55:16 +02:00
gTasks [ taskId ] . data [ 2 ] = 2 ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tIsPrevTourneyTree = FALSE ;
SetMainCallback2 ( CB2_TourneyTree ) ;
2018-08-25 11:55:16 +02:00
}
2019-02-08 18:08:25 +01:00
static void ResolveDomeRoundWinners ( void )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 11:55:16 +02:00
2019-12-18 08:32:52 +01:00
if ( gSpecialVar_0x8005 = = DOME_PLAYER_WON_MATCH )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] . isEliminated = TRUE ;
DOME_TRAINERS [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] . eliminatedAt = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) ] = gBattleResults . lastUsedMovePlayer ;
2020-09-02 15:49:04 +02:00
2020-01-05 16:50:32 +01:00
// If the player's match was the final one, no NPC vs NPC matches to decide
2018-10-21 00:06:42 +02:00
if ( gSaveBlock2Ptr - > frontier . curChallengeBattleNum < DOME_FINAL )
DecideRoundWinners ( gSaveBlock2Ptr - > frontier . curChallengeBattleNum ) ;
2018-08-25 11:55:16 +02:00
}
2019-12-18 08:32:52 +01:00
else // DOME_PLAYER_LOST_MATCH or DOME_PLAYER_RETIRED
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . isEliminated = TRUE ;
DOME_TRAINERS [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . eliminatedAt = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] = gBattleResults . lastUsedMoveOpponent ;
2020-09-02 15:49:04 +02:00
2019-12-18 08:32:52 +01:00
if ( gBattleOutcome = = B_OUTCOME_FORFEITED | | gSpecialVar_0x8005 = = DOME_PLAYER_RETIRED )
DOME_TRAINERS [ TrainerIdToTournamentId ( TRAINER_PLAYER ) ] . forfeited = TRUE ;
2020-01-05 16:50:32 +01:00
// Player lost, decide remaining outcome of tournament
2018-10-21 00:06:42 +02:00
for ( i = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ; i < DOME_ROUNDS_COUNT ; i + + )
2018-08-25 18:46:15 +02:00
DecideRoundWinners ( i ) ;
2018-08-25 11:55:16 +02:00
}
}
2020-01-05 16:50:32 +01:00
// Decides the winning move of an NPC vs NPC match
2019-02-08 18:08:25 +01:00
static u16 GetWinningMove ( int winnerTournamentId , int loserTournamentId , u8 roundId )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int i , j , k ;
2019-12-18 08:32:52 +01:00
int moveScores [ MAX_MON_MOVES * FRONTIER_PARTY_SIZE ] ;
u16 moveIds [ MAX_MON_MOVES * FRONTIER_PARTY_SIZE ] ;
2018-08-25 11:55:16 +02:00
u16 bestScore = 0 ;
u16 bestId = 0 ;
2019-02-08 18:08:25 +01:00
int movePower = 0 ;
2018-10-27 00:04:18 +02:00
SetFacilityPtrsGetLevel ( ) ;
2018-08-25 11:55:16 +02:00
// Calc move points of all 4 moves for all 3 pokemon hitting all 3 target mons.
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < FRONTIER_PARTY_SIZE ; i + + )
2018-08-25 11:55:16 +02:00
{
2018-12-25 18:50:15 +01:00
for ( j = 0 ; j < MAX_MON_MOVES ; j + + )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
// TODO: Clean this up, looks like a different data structure (2D array)
moveScores [ i * MAX_MON_MOVES + j ] = 0 ;
if ( DOME_TRAINERS [ winnerTournamentId ] . trainerId = = TRAINER_FRONTIER_BRAIN )
moveIds [ i * MAX_MON_MOVES + j ] = GetFrontierBrainMonMove ( i , j ) ;
2018-08-25 11:55:16 +02:00
else
2019-12-18 08:32:52 +01:00
moveIds [ i * MAX_MON_MOVES + j ] = gFacilityTrainerMons [ DOME_MONS [ winnerTournamentId ] [ i ] ] . moves [ j ] ;
2018-08-25 11:55:16 +02:00
2019-12-18 08:32:52 +01:00
movePower = gBattleMoves [ moveIds [ i * MAX_MON_MOVES + j ] ] . power ;
2018-08-25 11:55:16 +02:00
if ( movePower = = 0 )
movePower = 40 ;
else if ( movePower = = 1 )
movePower = 60 ;
2020-09-02 15:49:04 +02:00
else if ( moveIds [ i * MAX_MON_MOVES + j ] = = MOVE_SELF_DESTRUCT
2019-12-18 08:32:52 +01:00
| | moveIds [ i * MAX_MON_MOVES + j ] = = MOVE_EXPLOSION )
2018-08-25 11:55:16 +02:00
movePower / = 2 ;
2019-12-18 08:32:52 +01:00
for ( k = 0 ; k < FRONTIER_PARTY_SIZE ; k + + )
2018-08-25 11:55:16 +02:00
{
2018-09-01 12:38:38 +02:00
u32 personality = 0 ;
2018-08-25 11:55:16 +02:00
u32 targetSpecies = 0 ;
u32 targetAbility = 0 ;
2018-09-01 12:38:38 +02:00
u32 typeMultiplier = 0 ;
2018-08-25 11:55:16 +02:00
do
{
2018-09-01 12:38:38 +02:00
personality = Random32 ( ) ;
2020-01-18 18:17:25 +01:00
} while ( gFacilityTrainerMons [ DOME_MONS [ loserTournamentId ] [ k ] ] . nature ! = GetNatureFromPersonality ( personality ) ) ;
2018-08-25 11:55:16 +02:00
2019-12-18 08:32:52 +01:00
targetSpecies = gFacilityTrainerMons [ DOME_MONS [ loserTournamentId ] [ k ] ] . species ;
2019-05-17 09:52:20 +02:00
2018-09-01 12:38:38 +02:00
if ( personality & 1 )
2019-05-14 15:42:55 +02:00
targetAbility = gBaseStats [ targetSpecies ] . abilities [ 1 ] ;
2018-08-25 11:55:16 +02:00
else
2019-05-14 15:42:55 +02:00
targetAbility = gBaseStats [ targetSpecies ] . abilities [ 0 ] ;
2018-08-25 11:55:16 +02:00
2018-09-01 12:38:38 +02:00
typeMultiplier = CalcPartyMonTypeEffectivenessMultiplier ( moveIds [ i * 4 + j ] , targetSpecies , targetAbility ) ;
if ( typeMultiplier = = UQ_4_12 ( 0 ) )
2019-12-18 08:32:52 +01:00
moveScores [ i * MAX_MON_MOVES + j ] + = 0 ;
2018-09-01 12:38:38 +02:00
else if ( typeMultiplier > = UQ_4_12 ( 2 ) )
2019-12-18 08:32:52 +01:00
moveScores [ i * MAX_MON_MOVES + j ] + = movePower * 2 ;
2018-09-01 12:38:38 +02:00
else if ( typeMultiplier < = UQ_4_12 ( 0.5 ) )
2019-12-18 08:32:52 +01:00
moveScores [ i * MAX_MON_MOVES + j ] + = movePower / 2 ;
2018-08-25 11:55:16 +02:00
else
2019-12-18 08:32:52 +01:00
moveScores [ i * MAX_MON_MOVES + j ] + = movePower ;
2018-08-25 11:55:16 +02:00
}
2019-12-18 08:32:52 +01:00
if ( bestScore < moveScores [ i * MAX_MON_MOVES + j ] )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
bestId = i * MAX_MON_MOVES + j ;
bestScore = moveScores [ i * MAX_MON_MOVES + j ] ;
2018-08-25 11:55:16 +02:00
}
2019-12-18 08:32:52 +01:00
else if ( bestScore = = moveScores [ i * MAX_MON_MOVES + j ] )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
if ( moveIds [ bestId ] < moveIds [ i * MAX_MON_MOVES + j ] ) // Why not use (Random() & 1) instead of promoting moves with a higher id?
bestId = i * MAX_MON_MOVES + j ;
2018-08-25 11:55:16 +02:00
}
}
}
j = bestId ;
2021-05-09 06:31:39 +02:00
do
2018-08-25 11:55:16 +02:00
{
2021-05-09 06:31:39 +02:00
for ( i = 0 ; i < roundId - 1 ; i + + )
2018-08-25 11:55:16 +02:00
{
2021-11-01 23:06:15 +01:00
if ( gSaveBlock2Ptr - > frontier . domeWinningMoves [ GetOpposingNPCTournamentIdByRound ( winnerTournamentId , i ) ] = = moveIds [ j ] )
2021-05-09 06:31:39 +02:00
break ;
2018-08-25 11:55:16 +02:00
}
2021-05-09 06:31:39 +02:00
if ( i ! = roundId - 1 )
2018-08-25 11:55:16 +02:00
{
moveScores [ j ] = 0 ;
bestScore = 0 ;
j = 0 ;
2019-12-18 08:32:52 +01:00
for ( k = 0 ; k < MAX_MON_MOVES * FRONTIER_PARTY_SIZE ; k + + )
2018-08-25 11:55:16 +02:00
j + = moveScores [ k ] ;
2021-05-09 06:31:39 +02:00
if ( j = = 0 )
break ;
j = 0 ;
for ( k = 0 ; k < MAX_MON_MOVES * FRONTIER_PARTY_SIZE ; k + + )
{
if ( bestScore < moveScores [ k ] )
{
j = k ;
bestScore = moveScores [ k ] ;
}
else if ( bestScore = = moveScores [ k ] & & moveIds [ j ] < moveIds [ k ] ) // Yes, these conditions are redundant
{
j = k ;
bestScore = moveScores [ k ] ;
}
}
2018-08-25 11:55:16 +02:00
}
2021-05-09 06:31:39 +02:00
} while ( i ! = roundId - 1 ) ;
2018-08-25 11:55:16 +02:00
if ( moveScores [ j ] = = 0 )
j = bestId ;
return moveIds [ j ] ;
}
2019-02-08 18:08:25 +01:00
static void Task_ShowTourneyTree ( u8 taskId )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-11-06 17:44:48 +01:00
struct TextPrinterTemplate textPrinter ;
2020-01-05 16:50:32 +01:00
int notInteractive = gTasks [ taskId ] . tNotInteractive ;
2019-02-08 18:08:25 +01:00
int r4 = gTasks [ taskId ] . data [ 2 ] ;
2018-08-25 11:55:16 +02:00
2020-01-05 16:50:32 +01:00
switch ( gTasks [ taskId ] . tState )
2018-08-25 11:55:16 +02:00
{
case 0 :
SetHBlankCallback ( NULL ) ;
SetVBlankCallback ( NULL ) ;
EnableInterrupts ( INTR_FLAG_HBLANK | INTR_FLAG_VBLANK ) ;
CpuFill32 ( 0 , ( void * ) VRAM , VRAM_SIZE ) ;
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
2019-12-21 10:27:12 +01:00
InitBgsFromTemplates ( 0 , sTourneyTreeBgTemplates , ARRAY_COUNT ( sTourneyTreeBgTemplates ) ) ;
InitWindows ( sTourneyTreeWindowTemplates ) ;
2018-08-25 11:55:16 +02:00
DeactivateAllTextPrinters ( ) ;
gBattle_BG0_X = 0 ;
gBattle_BG0_Y = 0 ;
gBattle_BG1_X = 0 ;
gBattle_BG1_Y = 0 ;
2021-11-04 04:02:06 +01:00
ChangeBgX ( 2 , 0 , BG_COORD_SET ) ;
ChangeBgY ( 2 , 0 , BG_COORD_SET ) ;
ChangeBgX ( 3 , 0 , BG_COORD_SET ) ;
ChangeBgY ( 3 , 0xB00 , BG_COORD_SET ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-25 11:55:16 +02:00
break ;
case 1 :
SetGpuReg ( REG_OFFSET_BLDCNT , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDY , 0 ) ;
SetGpuReg ( REG_OFFSET_MOSAIC , 0 ) ;
2021-04-15 08:04:01 +02:00
SetGpuReg ( REG_OFFSET_WIN0H , WIN_RANGE ( 88 , 96 ) ) ;
SetGpuReg ( REG_OFFSET_WIN0V , WIN_RANGE ( 0 , DISPLAY_HEIGHT - 1 ) ) ;
SetGpuReg ( REG_OFFSET_WIN1H , WIN_RANGE ( 144 , 152 ) ) ;
SetGpuReg ( REG_OFFSET_WIN1V , WIN_RANGE ( 0 , DISPLAY_HEIGHT - 1 ) ) ;
2018-08-25 11:55:16 +02:00
SetGpuReg ( REG_OFFSET_WININ , 0 ) ;
2019-12-18 08:32:52 +01:00
SetGpuReg ( REG_OFFSET_WINOUT , WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR ) ;
2018-08-25 11:55:16 +02:00
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
FreeAllSpritePalettes ( ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-25 11:55:16 +02:00
break ;
case 2 :
2020-08-24 00:50:57 +02:00
sTilemapBuffer = AllocZeroed ( BG_SCREEN_SIZE ) ;
2022-01-11 16:04:47 +01:00
LZDecompressWram ( gDomeTourneyTree_Tilemap , sTilemapBuffer ) ;
2018-08-25 19:59:47 +02:00
SetBgTilemapBuffer ( 1 , sTilemapBuffer ) ;
2018-08-25 11:55:16 +02:00
CopyBgTilemapBufferToVram ( 1 ) ;
2022-01-11 16:04:47 +01:00
DecompressAndLoadBgGfxUsingHeap ( 1 , gDomeTourneyTree_Gfx , 0x2000 , 0 , 0 ) ;
2020-01-05 16:50:32 +01:00
DecompressAndLoadBgGfxUsingHeap ( 2 , gDomeTourneyLine_Gfx , 0x2000 , 0 , 0 ) ;
DecompressAndLoadBgGfxUsingHeap ( 2 , gDomeTourneyLineDown_Tilemap , 0x2000 , 0 , 1 ) ;
DecompressAndLoadBgGfxUsingHeap ( 3 , gDomeTourneyLineUp_Tilemap , 0x2000 , 0 , 1 ) ;
LoadCompressedPalette ( gDomeTourneyTree_Pal , 0 , 0x200 ) ;
LoadCompressedPalette ( gDomeTourneyTreeButtons_Pal , 0x100 , 0x200 ) ;
2019-11-07 01:18:11 +01:00
LoadCompressedPalette ( gBattleWindowTextPalette , 0xF0 , 0x20 ) ;
2018-08-25 11:55:16 +02:00
CpuFill32 ( 0 , gPlttBufferFaded , 0x400 ) ;
ShowBg ( 0 ) ;
ShowBg ( 1 ) ;
ShowBg ( 2 ) ;
ShowBg ( 3 ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-25 11:55:16 +02:00
break ;
case 3 :
2020-01-05 16:50:32 +01:00
LoadCompressedSpriteSheet ( sTourneyTreeButtonsSpriteSheet ) ;
if ( notInteractive = = FALSE )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < ARRAY_COUNT ( sTourneyTreePokeballCoords ) ; i + + )
CreateSprite ( & sTourneyTreePokeballSpriteTemplate , sTourneyTreePokeballCoords [ i ] [ 0 ] , sTourneyTreePokeballCoords [ i ] [ 1 ] , 0 ) ;
2020-09-02 15:49:04 +02:00
2020-01-05 16:50:32 +01:00
if ( gTasks [ taskId ] . tIsPrevTourneyTree )
CreateSprite ( & sExitButtonSpriteTemplate , 218 , 12 , 0 ) ;
2018-08-25 11:55:16 +02:00
else
2020-01-05 16:50:32 +01:00
CreateSprite ( & sCancelButtonSpriteTemplate , 218 , 12 , 0 ) ;
2018-08-25 11:55:16 +02:00
}
SetGpuReg ( REG_OFFSET_DISPCNT , DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-25 11:55:16 +02:00
break ;
case 4 :
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_SHORT ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gText_BattleTourney ;
2018-08-25 11:55:16 +02:00
textPrinter . windowId = 2 ;
textPrinter . x = 0 ;
textPrinter . y = 0 ;
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentX = GetStringCenterAlignXOffsetWithLetterSpacing ( textPrinter . fontId , textPrinter . currentChar , 0x70 , textPrinter . letterSpacing ) ;
2018-08-25 11:55:16 +02:00
textPrinter . currentY = 1 ;
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
textPrinter . unk = 0 ;
2019-12-21 10:27:12 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_5 ;
textPrinter . bgColor = TEXT_COLOR_TRANSPARENT ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2018-08-25 11:55:16 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-02-08 18:08:25 +01:00
int roundId , var2 ;
2018-08-25 11:55:16 +02:00
2019-12-18 08:32:52 +01:00
CopyDomeTrainerName ( gDisplayedStringBattle , DOME_TRAINERS [ i ] . trainerId ) ;
2020-01-05 16:50:32 +01:00
if ( notInteractive = = TRUE )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 11:55:16 +02:00
{
2019-12-21 10:27:12 +01:00
if ( DOME_TRAINERS [ i ] . eliminatedAt ! = DOME_ROUND1 )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
var2 = DOME_TRAINERS [ i ] . eliminatedAt - 1 ;
2020-01-05 16:50:32 +01:00
DrawTourneyAdvancementLine ( i , var2 ) ;
2018-08-25 11:55:16 +02:00
}
}
2018-10-21 00:06:42 +02:00
else if ( gSaveBlock2Ptr - > frontier . curChallengeBattleNum ! = DOME_ROUND2 )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
DrawTourneyAdvancementLine ( i , gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 2 ) ;
2018-08-25 11:55:16 +02:00
}
}
2020-01-05 16:50:32 +01:00
else if ( notInteractive = = FALSE )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 11:55:16 +02:00
{
2019-12-21 10:27:12 +01:00
if ( DOME_TRAINERS [ i ] . eliminatedAt ! = DOME_ROUND1 )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
var2 = DOME_TRAINERS [ i ] . eliminatedAt - 1 ;
2020-01-05 16:50:32 +01:00
DrawTourneyAdvancementLine ( i , var2 ) ;
2018-08-25 11:55:16 +02:00
}
}
2018-10-21 00:06:42 +02:00
else if ( gSaveBlock2Ptr - > frontier . curChallengeBattleNum ! = DOME_ROUND1 )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
if ( gTasks [ taskId ] . tIsPrevTourneyTree )
2018-10-21 00:06:42 +02:00
var2 = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
2018-08-25 11:55:16 +02:00
else
2018-10-21 00:06:42 +02:00
var2 = gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 1 ;
2020-01-05 16:50:32 +01:00
DrawTourneyAdvancementLine ( i , var2 ) ;
2018-08-25 11:55:16 +02:00
}
}
2020-01-05 16:50:32 +01:00
if ( gTasks [ taskId ] . tIsPrevTourneyTree )
2018-10-21 00:06:42 +02:00
roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum ;
2018-08-25 11:55:16 +02:00
else
2018-10-21 00:06:42 +02:00
roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 1 ;
2018-08-25 11:55:16 +02:00
2020-01-05 16:50:32 +01:00
if ( ( ( notInteractive = = TRUE & & DOME_TRAINERS [ i ] . eliminatedAt < gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 1 )
| | ( notInteractive = = FALSE & & DOME_TRAINERS [ i ] . eliminatedAt < = roundId ) )
2019-12-18 08:32:52 +01:00
& & DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 11:55:16 +02:00
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = TRAINER_PLAYER )
2018-08-25 11:55:16 +02:00
{
2021-04-10 04:39:34 +02:00
textPrinter . fgColor = TEXT_COLOR_LIGHT_GRAY ;
2019-12-21 10:27:12 +01:00
textPrinter . shadowColor = TEXT_COLOR_RED ;
2018-08-25 11:55:16 +02:00
}
else
{
2019-12-21 10:27:12 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_2 ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2018-08-25 11:55:16 +02:00
}
}
else
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = TRAINER_PLAYER )
2018-08-25 11:55:16 +02:00
{
2021-04-10 04:39:34 +02:00
textPrinter . fgColor = TEXT_COLOR_LIGHT_GRAY ;
2019-12-21 10:27:12 +01:00
textPrinter . shadowColor = TEXT_COLOR_RED ;
2018-08-25 11:55:16 +02:00
}
else
{
2019-12-21 10:27:12 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_5 ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2018-08-25 11:55:16 +02:00
}
}
2020-01-05 16:50:32 +01:00
if ( sTrainerNamePositions [ i ] [ 0 ] = = 0 )
2018-08-25 11:55:16 +02:00
textPrinter . currentX = GetStringWidthDifference ( textPrinter . fontId , gDisplayedStringBattle , 0x3D , textPrinter . letterSpacing ) ;
else
textPrinter . currentX = 3 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gDisplayedStringBattle ;
2020-01-05 16:50:32 +01:00
textPrinter . windowId = sTrainerNamePositions [ i ] [ 0 ] ;
textPrinter . currentY = sTrainerNamePositions [ i ] [ 1 ] ;
2018-08-25 11:55:16 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState + + ;
2018-08-25 11:55:16 +02:00
break ;
case 5 :
PutWindowTilemap ( 0 ) ;
PutWindowTilemap ( 1 ) ;
PutWindowTilemap ( 2 ) ;
2021-11-03 20:29:18 +01:00
CopyWindowToVram ( 0 , COPYWIN_FULL ) ;
CopyWindowToVram ( 1 , COPYWIN_FULL ) ;
CopyWindowToVram ( 2 , COPYWIN_FULL ) ;
2020-01-05 16:50:32 +01:00
SetHBlankCallback ( HblankCb_TourneyTree ) ;
SetVBlankCallback ( VblankCb_TourneyTree ) ;
2018-08-25 11:55:16 +02:00
if ( r4 = = 2 )
{
2020-01-05 16:50:32 +01:00
if ( notInteractive = = FALSE )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
i = CreateTask ( Task_HandleTourneyTreeInput , 0 ) ;
gTasks [ i ] . data [ 0 ] = notInteractive ;
gTasks [ i ] . data [ 1 ] = notInteractive ;
gTasks [ i ] . data [ 6 ] = gTasks [ taskId ] . tIsPrevTourneyTree ;
2018-08-25 11:55:16 +02:00
}
else
{
2020-01-05 16:50:32 +01:00
i = CreateTask ( Task_HandleStaticTourneyTreeInput , 0 ) ;
2018-08-25 11:55:16 +02:00
gTasks [ i ] . data [ 0 ] = 0 ;
}
}
else
{
i = gTasks [ taskId ] . data [ 3 ] ;
2020-01-05 16:50:32 +01:00
gTasks [ i ] . tState = 0 ;
2018-08-25 11:55:16 +02:00
}
ScanlineEffect_Clear ( ) ;
2020-09-02 15:49:04 +02:00
2019-01-05 19:27:23 +01:00
i = 0 ;
while ( i < 91 )
{
2019-02-08 18:08:25 +01:00
gScanlineEffectRegBuffers [ 0 ] [ i ] = BGCNT_PRIORITY ( 2 ) | BGCNT_SCREENBASE ( 31 ) | BGCNT_16COLOR | BGCNT_CHARBASE ( 2 ) | BGCNT_TXT256x256 ;
gScanlineEffectRegBuffers [ 1 ] [ i ] = BGCNT_PRIORITY ( 2 ) | BGCNT_SCREENBASE ( 31 ) | BGCNT_16COLOR | BGCNT_CHARBASE ( 2 ) | BGCNT_TXT256x256 ;
2019-01-05 19:27:23 +01:00
i + + ;
}
while ( i < 160 )
{
2019-02-08 18:08:25 +01:00
gScanlineEffectRegBuffers [ 0 ] [ i ] = BGCNT_PRIORITY ( 1 ) | BGCNT_SCREENBASE ( 31 ) | BGCNT_16COLOR | BGCNT_CHARBASE ( 2 ) | BGCNT_TXT256x256 ;
gScanlineEffectRegBuffers [ 1 ] [ i ] = BGCNT_PRIORITY ( 1 ) | BGCNT_SCREENBASE ( 31 ) | BGCNT_16COLOR | BGCNT_CHARBASE ( 2 ) | BGCNT_TXT256x256 ;
2019-01-05 19:27:23 +01:00
i + + ;
}
2020-09-02 15:49:04 +02:00
2019-02-08 18:08:25 +01:00
ScanlineEffect_SetParams ( sTourneyTreeScanlineEffectParams ) ;
2018-08-25 11:55:16 +02:00
DestroyTask ( taskId ) ;
break ;
}
}
2020-01-05 16:50:32 +01:00
static void DrawTourneyAdvancementLine ( u8 tournamentId , u8 roundId )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2020-01-05 16:50:32 +01:00
const struct TourneyTreeLineSection * lineSection = sTourneyTreeLineSections [ tournamentId ] [ roundId ] ;
2018-08-25 11:55:16 +02:00
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < sTourneyTreeLineSectionArrayCounts [ tournamentId ] [ roundId ] ; i + + )
CopyToBgTilemapBufferRect_ChangePalette ( 1 , & lineSection [ i ] . src , lineSection [ i ] . x , lineSection [ i ] . y , 1 , 1 , 17 ) ;
2018-08-25 11:55:16 +02:00
CopyBgTilemapBufferToVram ( 1 ) ;
}
2020-01-05 16:50:32 +01:00
# define STATE_FADE_IN 0
# define STATE_SHOW_RESULTS 1
# define STATE_DELAY 2
# define STATE_WAIT_FOR_INPUT 3
# define STATE_CLOSE_TOURNEY_TREE 4
// The non-interactive tourney tree that's shown when a round is completed
static void Task_HandleStaticTourneyTreeInput ( u8 taskId )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-11-06 17:44:48 +01:00
struct TextPrinterTemplate textPrinter ;
2018-08-25 11:55:16 +02:00
2020-01-05 16:50:32 +01:00
switch ( gTasks [ taskId ] . tState )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
case STATE_FADE_IN :
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0x10 , 0 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_SHOW_RESULTS ;
2018-08-25 11:55:16 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_SHOW_RESULTS :
2018-08-25 11:55:16 +02:00
if ( ! gPaletteFade . active )
{
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_DELAY ;
2018-08-25 11:55:16 +02:00
gTasks [ taskId ] . data [ 3 ] = 64 ;
2021-10-30 22:47:37 +02:00
textPrinter . fontId = FONT_SHORT ;
2018-08-25 11:55:16 +02:00
textPrinter . x = 0 ;
textPrinter . y = 0 ;
textPrinter . letterSpacing = 2 ;
textPrinter . lineSpacing = 0 ;
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
textPrinter . unk = 0 ;
2019-12-21 10:27:12 +01:00
textPrinter . fgColor = TEXT_DYNAMIC_COLOR_2 ;
textPrinter . bgColor = TEXT_COLOR_TRANSPARENT ;
textPrinter . shadowColor = TEXT_DYNAMIC_COLOR_4 ;
2020-01-05 16:50:32 +01:00
// Update the advancement lines and gray out eliminated trainer names
2018-08-25 11:55:16 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
CopyDomeTrainerName ( gDisplayedStringBattle , DOME_TRAINERS [ i ] . trainerId ) ;
if ( DOME_TRAINERS [ i ] . eliminatedAt = = gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 1
& & DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 11:55:16 +02:00
{
2020-01-05 16:50:32 +01:00
if ( sTrainerNamePositions [ i ] [ 0 ] = = 0 )
2018-08-25 11:55:16 +02:00
textPrinter . currentX = GetStringWidthDifference ( textPrinter . fontId , gDisplayedStringBattle , 0x3D , textPrinter . letterSpacing ) ;
else
textPrinter . currentX = 3 ;
2018-11-06 17:44:48 +01:00
textPrinter . currentChar = gDisplayedStringBattle ;
2020-01-05 16:50:32 +01:00
textPrinter . windowId = sTrainerNamePositions [ i ] [ 0 ] ;
textPrinter . currentY = sTrainerNamePositions [ i ] [ 1 ] ;
2018-08-25 11:55:16 +02:00
AddTextPrinter ( & textPrinter , 0 , NULL ) ;
}
2019-12-18 08:32:52 +01:00
if ( ! DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 11:55:16 +02:00
{
2019-02-08 18:08:25 +01:00
int roundId = gSaveBlock2Ptr - > frontier . curChallengeBattleNum - 1 ;
2020-01-05 16:50:32 +01:00
DrawTourneyAdvancementLine ( i , roundId ) ;
2018-08-25 11:55:16 +02:00
}
}
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_DELAY :
2018-08-25 11:55:16 +02:00
if ( - - gTasks [ taskId ] . data [ 3 ] = = 0 )
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_WAIT_FOR_INPUT ;
2018-08-25 11:55:16 +02:00
break ;
2020-01-05 16:50:32 +01:00
case STATE_WAIT_FOR_INPUT :
2020-09-05 03:11:55 +02:00
if ( JOY_NEW ( A_BUTTON | B_BUTTON ) )
2018-08-25 11:55:16 +02:00
{
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade ( PALETTES_ALL , 0 , 0 , 0x10 , RGB_BLACK ) ;
2020-01-05 16:50:32 +01:00
gTasks [ taskId ] . tState = STATE_CLOSE_TOURNEY_TREE ;
2018-08-25 11:55:16 +02:00
}
break ;
2020-01-05 16:50:32 +01:00
case STATE_CLOSE_TOURNEY_TREE :
2018-08-25 11:55:16 +02:00
if ( ! gPaletteFade . active )
{
SetMainCallback2 ( CB2_ReturnToFieldContinueScriptPlayMapMusic ) ;
DestroyTask ( taskId ) ;
}
break ;
}
}
2020-01-05 16:50:32 +01:00
# undef STATE_FADE_IN
# undef STATE_SHOW_RESULTS
# undef STATE_DELAY
# undef STATE_WAIT_FOR_INPUT
# undef STATE_CLOSE_TOURNEY_TREE
static void CB2_TourneyTree ( void )
2018-08-25 11:55:16 +02:00
{
AnimateSprites ( ) ;
BuildOamBuffer ( ) ;
RunTextPrinters ( ) ;
UpdatePaletteFade ( ) ;
RunTasks ( ) ;
}
2018-08-25 18:46:15 +02:00
2020-01-05 16:50:32 +01:00
static void VblankCb_TourneyInfoCard ( void )
2018-08-25 18:46:15 +02:00
{
2021-11-04 04:02:06 +01:00
ChangeBgX ( 3 , 0x80 , BG_COORD_ADD ) ;
ChangeBgY ( 3 , 0x80 , BG_COORD_SUB ) ;
2018-08-25 18:46:15 +02:00
SetGpuReg ( REG_OFFSET_BG0HOFS , gBattle_BG0_X ) ;
SetGpuReg ( REG_OFFSET_BG0VOFS , gBattle_BG0_Y ) ;
SetGpuReg ( REG_OFFSET_BG1HOFS , gBattle_BG1_X ) ;
SetGpuReg ( REG_OFFSET_BG1VOFS , gBattle_BG1_Y ) ;
SetGpuReg ( REG_OFFSET_BG2HOFS , gBattle_BG2_X ) ;
SetGpuReg ( REG_OFFSET_BG2VOFS , gBattle_BG2_Y ) ;
LoadOam ( ) ;
ProcessSpriteCopyRequests ( ) ;
TransferPlttBuffer ( ) ;
}
# define SET_WIN0H_WIN1H(win0H, win1H) \
{ \
* ( vu32 * ) ( REG_ADDR_WIN0H ) = ( ( win0H < < 16 ) | ( win1H ) ) ; \
}
2020-01-05 16:50:32 +01:00
static void HblankCb_TourneyTree ( void )
2018-08-25 18:46:15 +02:00
{
2020-05-21 05:31:16 +02:00
u16 vCount = REG_VCOUNT ;
if ( vCount < 42 )
2018-08-25 18:46:15 +02:00
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ ;
SET_WIN0H_WIN1H ( 0 , 0 ) ;
}
else if ( vCount < 50 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 152 , 155 ) , WIN_RANGE ( 85 , 88 ) ) ;
}
else if ( vCount < 58 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ ;
SET_WIN0H_WIN1H ( 0 , 0 ) ;
}
else if ( vCount < 75 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 144 , 152 ) , WIN_RANGE ( 88 , 96 ) ) ;
}
else if ( vCount < 82 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 152 , 155 ) , WIN_RANGE ( 85 , 88 ) ) ;
}
else if ( vCount < 95 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ ;
SET_WIN0H_WIN1H ( 0 , 0 ) ;
}
else if ( vCount < 103 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 152 , 155 ) , WIN_RANGE ( 85 , 88 ) ) ;
}
else if ( vCount < 119 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 144 , 152 ) , WIN_RANGE ( 88 , 96 ) ) ;
}
else if ( vCount < 127 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ ;
SET_WIN0H_WIN1H ( 0 , 0 ) ;
}
else if ( vCount < 135 )
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR ;
SET_WIN0H_WIN1H ( WIN_RANGE ( 152 , 155 ) , WIN_RANGE ( 85 , 88 ) ) ;
}
else
{
2020-09-02 15:49:04 +02:00
REG_WININ = WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ
2020-05-21 05:31:16 +02:00
| WININ_WIN1_BG_ALL | WININ_WIN1_CLR | WININ_WIN1_OBJ ;
SET_WIN0H_WIN1H ( 0 , 0 ) ;
2018-08-25 18:46:15 +02:00
}
}
2020-01-05 16:50:32 +01:00
static void VblankCb_TourneyTree ( void )
2018-08-25 18:46:15 +02:00
{
SetGpuReg ( REG_OFFSET_BG0HOFS , gBattle_BG0_X ) ;
SetGpuReg ( REG_OFFSET_BG0VOFS , gBattle_BG0_Y ) ;
SetGpuReg ( REG_OFFSET_BG1HOFS , gBattle_BG1_X ) ;
SetGpuReg ( REG_OFFSET_BG1VOFS , gBattle_BG1_Y ) ;
2021-11-04 04:02:06 +01:00
ChangeBgY ( 2 , 0x80 , BG_COORD_SUB ) ;
ChangeBgY ( 3 , 0x80 , BG_COORD_ADD ) ;
2018-08-25 18:46:15 +02:00
LoadOam ( ) ;
ProcessSpriteCopyRequests ( ) ;
TransferPlttBuffer ( ) ;
ScanlineEffect_InitHBlankDmaTransfer ( ) ;
}
2019-12-21 10:27:12 +01:00
static void SetFacilityTrainerAndMonPtrs ( void )
2018-08-25 18:46:15 +02:00
{
gFacilityTrainerMons = gBattleFrontierMons ;
gFacilityTrainers = gBattleFrontierTrainers ;
}
2019-11-29 03:09:35 +01:00
static void ResetSketchedMoves ( void )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i , moveSlot ;
2018-08-25 18:46:15 +02:00
2020-01-05 16:50:32 +01:00
for ( i = 0 ; i < DOME_BATTLE_PARTY_SIZE ; i + + )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int playerMonId = gSaveBlock2Ptr - > frontier . selectedPartyMons [ gSelectedOrderFromParty [ i ] - 1 ] - 1 ;
int count ;
2018-08-25 18:46:15 +02:00
2018-12-25 18:50:15 +01:00
for ( moveSlot = 0 ; moveSlot < MAX_MON_MOVES ; moveSlot + + )
2018-08-25 18:46:15 +02:00
{
count = 0 ;
2018-12-25 18:50:15 +01:00
while ( count < MAX_MON_MOVES )
2018-08-25 18:46:15 +02:00
{
if ( GetMonData ( & gSaveBlock1Ptr - > playerParty [ playerMonId ] , MON_DATA_MOVE1 + count , NULL ) = = GetMonData ( & gPlayerParty [ i ] , MON_DATA_MOVE1 + moveSlot , NULL ) )
break ;
count + + ;
}
2018-12-25 18:50:15 +01:00
if ( count = = MAX_MON_MOVES )
2018-08-25 18:46:15 +02:00
SetMonMoveSlot ( & gPlayerParty [ i ] , MOVE_SKETCH , moveSlot ) ;
}
gSaveBlock1Ptr - > playerParty [ playerMonId ] = gPlayerParty [ i ] ;
}
}
2019-02-08 18:08:25 +01:00
static void RestoreDomePlayerPartyHeldItems ( void )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 18:46:15 +02:00
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < DOME_BATTLE_PARTY_SIZE ; i + + )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int playerMonId = gSaveBlock2Ptr - > frontier . selectedPartyMons [ gSelectedOrderFromParty [ i ] - 1 ] - 1 ;
2018-08-25 18:46:15 +02:00
u16 item = GetMonData ( & gSaveBlock1Ptr - > playerParty [ playerMonId ] , MON_DATA_HELD_ITEM , NULL ) ;
SetMonData ( & gPlayerParty [ i ] , MON_DATA_HELD_ITEM , & item ) ;
}
}
2019-12-18 08:32:52 +01:00
static void ReduceDomePlayerPartyToSelectedMons ( void )
2018-08-25 18:46:15 +02:00
{
2018-11-25 22:50:54 +01:00
ReducePlayerPartyToSelectedMons ( ) ;
2018-08-25 18:46:15 +02:00
}
2019-02-08 18:08:25 +01:00
static void GetPlayerSeededBeforeOpponent ( void )
2018-08-25 18:46:15 +02:00
{
2020-01-05 16:50:32 +01:00
// A higher tournament ID is a worse seed
2018-08-25 18:46:15 +02:00
if ( TrainerIdToTournamentId ( gTrainerBattleOpponent_A ) > TrainerIdToTournamentId ( TRAINER_PLAYER ) )
gSpecialVar_Result = 1 ;
else
gSpecialVar_Result = 2 ;
}
2019-02-08 18:08:25 +01:00
static void BufferLastDomeWinnerName ( void )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 18:46:15 +02:00
2019-12-21 10:27:12 +01:00
SetFacilityTrainerAndMonPtrs ( ) ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( ! DOME_TRAINERS [ i ] . isEliminated )
2018-08-25 18:46:15 +02:00
break ;
}
2019-12-18 08:32:52 +01:00
CopyDomeTrainerName ( gStringVar1 , DOME_TRAINERS [ i ] . trainerId ) ;
2018-08-25 18:46:15 +02:00
}
2019-12-18 08:32:52 +01:00
// For showing the previous tourney results before the player has entered a challenge
static void InitRandomTourneyTreeResults ( void )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i , j , k ;
int monLevel ;
2019-11-29 03:09:35 +01:00
int species [ FRONTIER_PARTY_SIZE ] ;
2019-02-08 18:08:25 +01:00
int monTypesBits ;
int trainerId ;
2020-01-05 16:50:32 +01:00
int monId ;
2021-02-14 09:51:38 +01:00
int zero1 ;
int zero2 ;
2018-08-25 18:46:15 +02:00
u8 lvlMode ;
u16 * statSums ;
2019-02-08 18:08:25 +01:00
int * statValues ;
2018-08-25 18:46:15 +02:00
u8 ivs = 0 ;
species [ 0 ] = 0 ;
species [ 1 ] = 0 ;
species [ 2 ] = 0 ;
2019-12-18 08:32:52 +01:00
if ( ( gSaveBlock2Ptr - > frontier . domeLvlMode ! = - gSaveBlock2Ptr - > frontier . domeBattleMode ) & & gSaveBlock2Ptr - > frontier . challengeStatus ! = CHALLENGE_STATUS_SAVING )
2018-08-25 18:46:15 +02:00
return ;
statSums = AllocZeroed ( sizeof ( u16 ) * DOME_TOURNAMENT_TRAINERS_COUNT ) ;
2019-11-29 03:09:35 +01:00
statValues = AllocZeroed ( sizeof ( int ) * NUM_STATS ) ;
2018-08-25 19:59:47 +02:00
lvlMode = gSaveBlock2Ptr - > frontier . lvlMode ;
2019-12-18 08:32:52 +01:00
gSaveBlock2Ptr - > frontier . lvlMode = FRONTIER_LVL_50 ;
2021-02-14 09:51:38 +01:00
zero1 = 0 ;
zero2 = 0 ;
2021-08-25 00:59:32 +02:00
2021-02-14 10:03:53 +01:00
gSaveBlock2Ptr - > frontier . domeLvlMode = zero1 + 1 ;
gSaveBlock2Ptr - > frontier . domeBattleMode = zero2 + 1 ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
do
{
if ( i < 5 )
trainerId = Random ( ) % 10 ;
else if ( i < 15 )
trainerId = Random ( ) % 20 + 10 ;
else
trainerId = Random ( ) % 10 + 30 ;
for ( j = 0 ; j < i ; j + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ j ] . trainerId = = trainerId )
2018-08-25 18:46:15 +02:00
break ;
}
} while ( j ! = i ) ;
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ i ] . trainerId = trainerId ;
2019-11-29 03:09:35 +01:00
for ( j = 0 ; j < FRONTIER_PARTY_SIZE ; j + + )
2018-08-25 18:46:15 +02:00
{
do
{
2020-01-05 16:50:32 +01:00
monId = GetRandomFrontierMonFromSet ( trainerId ) ;
2018-08-25 18:46:15 +02:00
for ( k = 0 ; k < j ; k + + )
{
2020-01-05 16:50:32 +01:00
// Make sure the mon is valid.
int alreadySelectedMonId = DOME_MONS [ i ] [ k ] ;
if ( alreadySelectedMonId = = monId
| | species [ 0 ] = = gFacilityTrainerMons [ monId ] . species
| | species [ 1 ] = = gFacilityTrainerMons [ monId ] . species
| | gFacilityTrainerMons [ alreadySelectedMonId ] . itemTableId = = gFacilityTrainerMons [ monId ] . itemTableId )
2018-08-25 18:46:15 +02:00
break ;
}
} while ( k ! = j ) ;
2020-01-05 16:50:32 +01:00
DOME_MONS [ i ] [ j ] = monId ;
species [ j ] = gFacilityTrainerMons [ monId ] . species ;
2018-08-25 18:46:15 +02:00
}
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ i ] . isEliminated = FALSE ;
DOME_TRAINERS [ i ] . eliminatedAt = 0 ;
DOME_TRAINERS [ i ] . forfeited = FALSE ;
2018-08-25 18:46:15 +02:00
}
2022-06-06 21:15:46 +02:00
monLevel = FRONTIER_MAX_LEVEL_50 ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
2018-12-05 15:31:01 +01:00
{
monTypesBits = 0 ;
statSums [ i ] = 0 ;
2019-12-18 08:32:52 +01:00
ivs = GetDomeTrainerMonIvs ( DOME_TRAINERS [ i ] . trainerId ) ;
2019-11-29 03:09:35 +01:00
for ( j = 0 ; j < FRONTIER_PARTY_SIZE ; j + + )
2018-12-05 15:31:01 +01:00
{
2019-12-18 08:32:52 +01:00
CalcDomeMonStats ( gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ,
2018-12-05 15:31:01 +01:00
monLevel , ivs ,
2019-12-18 08:32:52 +01:00
gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . evSpread ,
gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . nature ,
2018-12-05 15:31:01 +01:00
statValues ) ;
statSums [ i ] + = statValues [ STAT_ATK ] ;
statSums [ i ] + = statValues [ STAT_DEF ] ;
statSums [ i ] + = statValues [ STAT_SPATK ] ;
statSums [ i ] + = statValues [ STAT_SPDEF ] ;
statSums [ i ] + = statValues [ STAT_SPEED ] ;
statSums [ i ] + = statValues [ STAT_HP ] ;
2019-12-18 08:32:52 +01:00
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ] . type1 ] ;
monTypesBits | = gBitTable [ gBaseStats [ gFacilityTrainerMons [ DOME_MONS [ i ] [ j ] ] . species ] . type2 ] ;
2018-12-05 15:31:01 +01:00
}
// Because GF hates temporary vars, trainerId acts like monTypesCount here.
for ( trainerId = 0 , j = 0 ; j < 32 ; j + + )
{
if ( monTypesBits & 1 )
trainerId + + ;
monTypesBits > > = 1 ;
}
statSums [ i ] + = ( trainerId * monLevel ) / 20 ;
}
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT - 1 ; i + + )
{
for ( j = i + 1 ; j < DOME_TOURNAMENT_TRAINERS_COUNT ; j + + )
{
if ( statSums [ i ] < statSums [ j ] )
{
SwapDomeTrainers ( i , j , statSums ) ;
}
else if ( statSums [ i ] = = statSums [ j ] )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId > DOME_TRAINERS [ j ] . trainerId )
2018-08-25 18:46:15 +02:00
SwapDomeTrainers ( i , j , statSums ) ;
2018-12-05 15:31:01 +01:00
}
}
}
2018-08-25 18:46:15 +02:00
2018-12-05 15:31:01 +01:00
Free ( statSums ) ;
Free ( statValues ) ;
2018-08-25 18:46:15 +02:00
2019-12-18 08:32:52 +01:00
for ( i = 0 ; i < DOME_ROUNDS_COUNT ; i + + )
2018-08-25 18:46:15 +02:00
DecideRoundWinners ( i ) ;
2018-08-25 19:59:47 +02:00
gSaveBlock2Ptr - > frontier . lvlMode = lvlMode ;
2018-08-25 18:46:15 +02:00
}
2019-02-08 18:08:25 +01:00
static int TrainerIdToTournamentId ( u16 trainerId )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = trainerId )
2018-08-25 18:46:15 +02:00
break ;
}
return i ;
}
// The same as the above one, but has global scope.
2019-02-08 18:08:25 +01:00
int TrainerIdToDomeTournamentId ( u16 trainerId )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . trainerId = = trainerId )
2018-08-25 18:46:15 +02:00
break ;
}
return i ;
}
2021-11-01 23:06:15 +01:00
static u8 GetOpposingNPCTournamentIdByRound ( u8 tournamentId , u8 round )
2018-08-25 18:46:15 +02:00
{
2020-01-05 16:50:32 +01:00
u8 tournamentIds [ 2 ] ;
2021-11-01 23:06:15 +01:00
BufferDomeWinString ( sTrainerAndRoundToLastMatchCardNum [ sTournamentIdToPairedTrainerIds [ tournamentId ] / 2 ] [ round ] - 16 , tournamentIds ) ;
2020-01-05 16:50:32 +01:00
if ( tournamentId = = tournamentIds [ 0 ] )
return tournamentIds [ 1 ] ;
2018-08-25 18:46:15 +02:00
else
2020-01-05 16:50:32 +01:00
return tournamentIds [ 0 ] ;
2018-08-25 18:46:15 +02:00
}
2020-01-05 16:50:32 +01:00
// Determines which trainers won in the NPC vs NPC battles
2018-08-25 19:59:47 +02:00
static void DecideRoundWinners ( u8 roundId )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
int moveSlot , monId1 , monId2 ;
int tournamentId1 , tournamentId2 ;
int species ;
int points1 = 0 , points2 = 0 ;
2018-08-25 18:46:15 +02:00
for ( i = 0 ; i < DOME_TOURNAMENT_TRAINERS_COUNT ; i + + )
{
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ i ] . isEliminated | | DOME_TRAINERS [ i ] . trainerId = = TRAINER_PLAYER )
2018-08-25 18:46:15 +02:00
continue ;
tournamentId1 = i ;
2019-12-18 08:32:52 +01:00
tournamentId2 = TournamentIdOfOpponent ( roundId , DOME_TRAINERS [ tournamentId1 ] . trainerId ) ;
2018-08-25 18:46:15 +02:00
// Frontier Brain always wins, check tournamentId1.
2019-12-18 08:32:52 +01:00
if ( DOME_TRAINERS [ tournamentId1 ] . trainerId = = TRAINER_FRONTIER_BRAIN & & tournamentId2 ! = 0xFF )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId2 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId2 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId2 ] = GetWinningMove ( tournamentId1 , tournamentId2 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
// Frontier Brain always wins, check tournamentId2.
2019-12-18 08:32:52 +01:00
else if ( DOME_TRAINERS [ tournamentId2 ] . trainerId = = TRAINER_FRONTIER_BRAIN & & tournamentId1 ! = 0xFF )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId1 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId1 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId1 ] = GetWinningMove ( tournamentId2 , tournamentId1 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
// Decide which one of two trainers wins!
2018-12-05 15:31:01 +01:00
else if ( tournamentId2 ! = 0xFF )
2018-08-25 18:46:15 +02:00
{
// BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results.
2020-12-13 05:28:01 +01:00
# ifdef BUGFIX
points1 = 0 ;
points2 = 0 ;
# endif
2018-08-25 18:46:15 +02:00
// Calculate points for both trainers.
2019-12-18 08:32:52 +01:00
for ( monId1 = 0 ; monId1 < FRONTIER_PARTY_SIZE ; monId1 + + )
2018-08-25 18:46:15 +02:00
{
2018-12-25 18:50:15 +01:00
for ( moveSlot = 0 ; moveSlot < MAX_MON_MOVES ; moveSlot + + )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
for ( monId2 = 0 ; monId2 < FRONTIER_PARTY_SIZE ; monId2 + + )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
points1 + = GetTypeEffectivenessPoints ( gFacilityTrainerMons [ DOME_MONS [ tournamentId1 ] [ monId1 ] ] . moves [ moveSlot ] ,
2022-06-01 18:41:57 +02:00
gFacilityTrainerMons [ DOME_MONS [ tournamentId2 ] [ monId2 ] ] . species , EFFECTIVENESS_MODE_AI_VS_AI ) ;
2018-08-25 18:46:15 +02:00
}
}
2019-12-18 08:32:52 +01:00
species = gFacilityTrainerMons [ DOME_MONS [ tournamentId1 ] [ monId1 ] ] . species ;
2018-08-25 18:46:15 +02:00
points1 + = ( gBaseStats [ species ] . baseHP
+ gBaseStats [ species ] . baseAttack
+ gBaseStats [ species ] . baseDefense
+ gBaseStats [ species ] . baseSpeed
+ gBaseStats [ species ] . baseSpAttack
+ gBaseStats [ species ] . baseSpDefense ) / 10 ;
}
// Random part of the formula.
points1 + = ( Random ( ) & 0x1F ) ;
// Favor trainers with higher id;
points1 + = tournamentId1 ;
2019-12-18 08:32:52 +01:00
for ( monId1 = 0 ; monId1 < FRONTIER_PARTY_SIZE ; monId1 + + )
2018-08-25 18:46:15 +02:00
{
2018-12-25 18:50:15 +01:00
for ( moveSlot = 0 ; moveSlot < MAX_MON_MOVES ; moveSlot + + )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
for ( monId2 = 0 ; monId2 < FRONTIER_PARTY_SIZE ; monId2 + + )
2018-08-25 18:46:15 +02:00
{
2019-12-18 08:32:52 +01:00
points2 + = GetTypeEffectivenessPoints ( gFacilityTrainerMons [ DOME_MONS [ tournamentId2 ] [ monId1 ] ] . moves [ moveSlot ] ,
2022-06-01 18:41:57 +02:00
gFacilityTrainerMons [ DOME_MONS [ tournamentId1 ] [ monId2 ] ] . species , EFFECTIVENESS_MODE_AI_VS_AI ) ;
2018-08-25 18:46:15 +02:00
}
}
2019-12-18 08:32:52 +01:00
species = gFacilityTrainerMons [ DOME_MONS [ tournamentId2 ] [ monId1 ] ] . species ;
2018-08-25 18:46:15 +02:00
points2 + = ( gBaseStats [ species ] . baseHP
+ gBaseStats [ species ] . baseAttack
+ gBaseStats [ species ] . baseDefense
+ gBaseStats [ species ] . baseSpeed
+ gBaseStats [ species ] . baseSpAttack
+ gBaseStats [ species ] . baseSpDefense ) / 10 ;
}
// Random part of the formula.
points2 + = ( Random ( ) & 0x1F ) ;
// Favor trainers with higher id;
points2 + = tournamentId2 ;
if ( points1 > points2 )
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId2 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId2 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId2 ] = GetWinningMove ( tournamentId1 , tournamentId2 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
else if ( points1 < points2 )
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId1 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId1 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId1 ] = GetWinningMove ( tournamentId2 , tournamentId1 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
// Points are the same, so we favor the one with the higher id.
else if ( tournamentId1 > tournamentId2 )
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId2 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId2 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId2 ] = GetWinningMove ( tournamentId1 , tournamentId2 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
else
{
2019-12-18 08:32:52 +01:00
DOME_TRAINERS [ tournamentId1 ] . isEliminated = TRUE ;
DOME_TRAINERS [ tournamentId1 ] . eliminatedAt = roundId ;
gSaveBlock2Ptr - > frontier . domeWinningMoves [ tournamentId1 ] = GetWinningMove ( tournamentId2 , tournamentId1 , roundId ) ;
2018-08-25 18:46:15 +02:00
}
}
}
}
2019-02-08 18:08:25 +01:00
static void CopyDomeTrainerName ( u8 * str , u16 trainerId )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i = 0 ;
2018-10-27 00:04:18 +02:00
SetFacilityPtrsGetLevel ( ) ;
2018-08-25 18:46:15 +02:00
if ( trainerId = = TRAINER_FRONTIER_BRAIN )
{
2019-02-08 18:08:25 +01:00
CopyDomeBrainTrainerName ( str ) ;
2018-08-25 18:46:15 +02:00
}
else
{
if ( trainerId = = TRAINER_PLAYER )
{
2018-09-01 22:03:21 +02:00
for ( i = 0 ; i < PLAYER_NAME_LENGTH ; i + + )
2019-02-08 18:08:25 +01:00
str [ i ] = gSaveBlock2Ptr - > playerName [ i ] ;
2018-08-25 18:46:15 +02:00
}
2019-12-21 00:52:29 +01:00
else if ( trainerId < FRONTIER_TRAINERS_COUNT )
2018-08-25 18:46:15 +02:00
{
2018-10-21 00:06:42 +02:00
for ( i = 0 ; i < PLAYER_NAME_LENGTH ; i + + )
2019-02-08 18:08:25 +01:00
str [ i ] = gFacilityTrainers [ trainerId ] . trainerName [ i ] ;
2018-08-25 18:46:15 +02:00
}
2019-02-08 18:08:25 +01:00
str [ i ] = EOS ;
2018-08-25 18:46:15 +02:00
}
}
2018-08-25 19:59:47 +02:00
static u8 GetDomeBrainTrainerPicId ( void )
2018-08-25 18:46:15 +02:00
{
return gTrainers [ TRAINER_TUCKER ] . trainerPic ;
}
2018-08-25 19:59:47 +02:00
static u8 GetDomeBrainTrainerClass ( void )
2018-08-25 18:46:15 +02:00
{
return gTrainers [ TRAINER_TUCKER ] . trainerClass ;
}
2019-02-08 18:08:25 +01:00
static void CopyDomeBrainTrainerName ( u8 * str )
2018-08-25 18:46:15 +02:00
{
2019-02-08 18:08:25 +01:00
int i ;
2018-08-25 18:46:15 +02:00
2018-10-21 00:06:42 +02:00
for ( i = 0 ; i < PLAYER_NAME_LENGTH ; i + + )
2019-02-08 18:08:25 +01:00
str [ i ] = gTrainers [ TRAINER_TUCKER ] . trainerName [ i ] ;
str [ i ] = EOS ;
2018-08-25 18:46:15 +02:00
}