2018-05-02 01:47:11 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "bg.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2018-05-02 01:47:11 +02:00
|
|
|
#include "battle.h"
|
|
|
|
#include "battle_anim.h"
|
|
|
|
#include "contest.h"
|
2020-07-12 02:25:56 +02:00
|
|
|
#include "contest_link.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-05-02 01:47:11 +02:00
|
|
|
#include "decompress.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "m4a.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "random.h"
|
2019-01-28 18:13:07 +01:00
|
|
|
#include "new_game.h"
|
2018-05-02 01:47:11 +02:00
|
|
|
#include "script.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "tv.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "util.h"
|
2020-06-19 00:01:32 +02:00
|
|
|
#include "contest_util.h"
|
2018-05-03 01:59:00 +02:00
|
|
|
#include "dma3.h"
|
2018-05-03 14:51:52 +02:00
|
|
|
#include "battle_message.h"
|
|
|
|
#include "event_scripts.h"
|
2018-05-09 01:00:23 +02:00
|
|
|
#include "event_data.h"
|
2018-05-03 14:51:52 +02:00
|
|
|
#include "strings.h"
|
|
|
|
#include "contest_effect.h"
|
2020-06-19 00:01:32 +02:00
|
|
|
#include "contest_link.h"
|
2018-05-11 00:16:58 +02:00
|
|
|
#include "international_string_util.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-12-19 17:53:43 +01:00
|
|
|
#include "contest_ai.h"
|
2020-08-16 11:07:44 +02:00
|
|
|
#include "constants/event_objects.h"
|
|
|
|
#include "constants/items.h"
|
|
|
|
#include "constants/moves.h"
|
|
|
|
#include "constants/rgb.h"
|
|
|
|
#include "constants/songs.h"
|
2018-05-02 03:27:24 +02:00
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
// This file's functions.
|
2020-07-12 02:25:56 +02:00
|
|
|
static void LoadContestPalettes(void);
|
|
|
|
static void Task_StartContestWaitFade(u8 taskId);
|
|
|
|
static void Task_TryStartLinkContest(u8 taskId);
|
|
|
|
static void Task_CommunicateMonIdxs(u8 taskId);
|
|
|
|
static void Task_EndCommunicateMonIdxs(u8 taskId);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_ReadyStartLinkContest(u8 taskId);
|
2019-04-03 23:24:32 +02:00
|
|
|
static bool8 SetupContestGraphics(u8 *stateVar);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_WaitToRaiseCurtainAtStart(u8 taskId);
|
|
|
|
static void Task_RaiseCurtainAtStart(u8 taskId);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void VBlankCB_Contest(void);
|
2019-04-03 23:24:32 +02:00
|
|
|
static void CB2_ContestMain(void);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_DisplayAppealNumberText(u8 taskId);
|
|
|
|
static void Task_TryShowMoveSelectScreen(u8 taskId);
|
|
|
|
static void Task_ShowMoveSelectScreen(u8 taskId);
|
|
|
|
static void Task_HandleMoveSelectInput(u8 taskId);
|
|
|
|
static void DrawMoveSelectArrow(s8);
|
|
|
|
static void EraseMoveSelectArrow(s8);
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_SelectedMove(u8 taskId);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_EndCommunicateMoveSelections(u8 taskId);
|
|
|
|
static void Task_HideMoveSelectScreen(u8 taskId);
|
|
|
|
static void Task_HideApplauseMeterForAppealStart(u8 taskId);
|
|
|
|
static void Task_WaitHideApplauseMeterForAppealStart(u8 taskId);
|
2020-08-13 09:09:47 +02:00
|
|
|
static void Task_AppealSetup(u8 taskId);
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_DoAppeals(u8 taskId);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_EndWaitForLink(u8);
|
|
|
|
static void SpriteCB_MonSlideIn(struct Sprite *);
|
|
|
|
static void SpriteCB_MonSlideOut(struct Sprite *);
|
|
|
|
static void Task_FinishRoundOfAppeals(u8);
|
|
|
|
static void Task_ReadyUpdateHeartSliders(u8);
|
|
|
|
static void Task_UpdateHeartSliders(u8);
|
|
|
|
static void Task_WaitForHeartSliders(u8);
|
2021-09-24 20:30:15 +02:00
|
|
|
static void Task_RestorePlttBufferUnfaded(u8);
|
2020-08-16 11:52:17 +02:00
|
|
|
static void Task_WaitPrintRoundResult(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_PrintRoundResultText(u8);
|
|
|
|
static void Task_ReUpdateHeartSliders(u8);
|
|
|
|
static void Task_WaitForHeartSlidersAgain(u8);
|
|
|
|
static void Task_DropCurtainAtRoundEnd(u8);
|
|
|
|
static void Task_TryStartNextRoundOfAppeals(u8);
|
|
|
|
static void Task_StartNewRoundOfAppeals(u8);
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_EndAppeals(u8);
|
|
|
|
static void Task_WaitForOutOfTimeMsg(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_DropCurtainAtAppealsEnd(u8);
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_TryCommunicateFinalStandings(u8);
|
|
|
|
static void Task_CommunicateFinalStandings(u8);
|
|
|
|
static void Task_EndCommunicateFinalStandings(u8);
|
|
|
|
static void Task_ContestReturnToField(u8);
|
|
|
|
static void FieldCB_ContestReturnToField(void);
|
2020-08-13 09:09:47 +02:00
|
|
|
static bool8 IsPlayerLinkLeader(void);
|
2019-04-03 23:24:32 +02:00
|
|
|
static void PrintContestantTrainerName(u8);
|
|
|
|
static void PrintContestantTrainerNameWithColor(u8 a0, u8 a1);
|
|
|
|
static void PrintContestantMonName(u8);
|
|
|
|
static void PrintContestantMonNameWithColor(u8, u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static u8 CreateJudgeSprite(void);
|
|
|
|
static u8 CreateJudgeSpeechBubbleSprite(void);
|
2020-07-24 06:14:53 +02:00
|
|
|
static u8 CreateContestantSprite(u16, u32, u32, u32);
|
2019-04-04 02:43:23 +02:00
|
|
|
static void PrintContestMoveDescription(u16);
|
2019-01-28 18:13:07 +01:00
|
|
|
static u16 SanitizeSpecies(u16);
|
2019-04-04 02:43:23 +02:00
|
|
|
static void ContestClearGeneralTextWindow(void);
|
2019-01-28 18:13:07 +01:00
|
|
|
static u16 GetChosenMove(u8);
|
2019-04-04 02:43:23 +02:00
|
|
|
static void GetAllChosenMoves(void);
|
|
|
|
static void ContestPrintLinkStandby(void);
|
2019-04-03 23:24:32 +02:00
|
|
|
static void FillContestantWindowBgs(void);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void CreateSliderHeartSprites(void);
|
|
|
|
static void SetBottomSliderHeartsInvisibility(bool8);
|
|
|
|
static void CreateNextTurnSprites(void);
|
2019-01-28 18:13:07 +01:00
|
|
|
static void CreateApplauseMeterSprite(void);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CreateJudgeAttentionEyeTask(void);
|
2020-08-16 11:07:44 +02:00
|
|
|
static void CreateUnusedBlendTask(void);
|
2019-04-03 03:51:21 +02:00
|
|
|
static void ContestDebugDoPrint(void);
|
2019-04-03 23:24:32 +02:00
|
|
|
static void DrawContestantWindows(void);
|
2019-04-03 02:46:18 +02:00
|
|
|
static void ApplyNextTurnOrder(void);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SlideApplauseMeterIn(void);
|
|
|
|
static void SlideApplauseMeterOut(void);
|
|
|
|
static void SetBgForCurtainDrop(void);
|
|
|
|
static void UpdateContestantBoxOrder(void);
|
|
|
|
static void Task_StartDropCurtainAtRoundEnd(u8);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void AnimateSliderHearts(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CreateInvisibleBattleTargetSprite(void);
|
2019-01-28 18:13:07 +01:00
|
|
|
static void Contest_StartTextPrinter(const u8 *, u32);
|
|
|
|
static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16);
|
|
|
|
static bool32 Contest_RunTextPrinters(void);
|
2019-04-03 09:00:06 +02:00
|
|
|
static void Contest_SetBgCopyFlags(u32 flagIndex);
|
2020-06-17 23:48:20 +02:00
|
|
|
static void CalculateFinalScores(void);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CalculateAppealMoveImpact(u8);
|
|
|
|
static void SetMoveAnimAttackerData(u8);
|
|
|
|
static void BlinkContestantBox(u8, u8);
|
|
|
|
static u8 CreateContestantBoxBlinkSprites(u8);
|
2019-01-28 18:13:07 +01:00
|
|
|
static u16 SanitizeMove(u16);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetMoveSpecificAnimData(u8);
|
|
|
|
static void SetMoveTargetPosition(u16);
|
|
|
|
static void ClearMoveAnimData(u8);
|
|
|
|
static void StopFlashJudgeAttentionEye(u8);
|
|
|
|
static void DrawUnnervedSymbols(void);
|
|
|
|
static void PrintAppealMoveResultText(u8, u8);
|
|
|
|
static void DoJudgeSpeechBubble(u8);
|
|
|
|
static void ShowHideNextTurnGfx(bool8);
|
|
|
|
static u8 UpdateAppealHearts(s16, s16, u8);
|
|
|
|
static bool8 UpdateConditionStars(u8, u8);
|
|
|
|
static bool8 DrawStatusSymbol(u8);
|
|
|
|
static void DrawStatusSymbols(void);
|
|
|
|
static void StartStopFlashJudgeAttentionEye(u8);
|
|
|
|
static void BlendAudienceBackground(s8, s8);
|
2019-04-03 09:00:06 +02:00
|
|
|
static void ShowAndUpdateApplauseMeter(s8 unused);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void AnimateAudience(void);
|
2019-04-03 09:00:06 +02:00
|
|
|
static void UpdateApplauseMeter(void);
|
2019-04-04 02:43:23 +02:00
|
|
|
static void RankContestants(void);
|
2020-07-24 06:14:53 +02:00
|
|
|
static void SetAttentionLevels(void);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void UpdateHeartSliders(void);
|
|
|
|
static bool8 SlidersDoneUpdating(void);
|
2019-01-28 18:13:07 +01:00
|
|
|
static void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8);
|
|
|
|
static void Contest_PrintTextToBg0WindowStd(u32, const u8 *);
|
2020-06-17 23:48:20 +02:00
|
|
|
static s16 GetContestantRound2Points(u8);
|
2019-01-28 18:13:07 +01:00
|
|
|
static void DetermineFinalStandings(void);
|
2020-08-14 01:10:23 +02:00
|
|
|
static bool8 DidContestantPlaceHigher(s32, s32, struct ContestFinalStandings *);
|
|
|
|
static void Task_UpdateAppealHearts(u8);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void SpriteCB_UpdateHeartSlider(struct Sprite *);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_FlashJudgeAttentionEye(u8);
|
|
|
|
static void Task_StopFlashJudgeAttentionEye(u8);
|
2020-08-16 11:07:44 +02:00
|
|
|
static void Task_UnusedBlend(u8);
|
|
|
|
static void InitUnusedBlendTaskData(u8);
|
|
|
|
static void UpdateBlendTaskContestantData(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_BlinkContestantBox(struct Sprite *);
|
|
|
|
static void SpriteCB_EndBlinkContestantBox(struct Sprite *sprite);
|
2019-04-03 09:00:06 +02:00
|
|
|
static u8 StartApplauseOverflowAnimation(void);
|
|
|
|
static void Task_ApplauseOverflowAnimation(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_SlideApplauseMeterIn(u8);
|
|
|
|
static void Task_SlideApplauseMeterOut(u8);
|
2019-04-03 09:00:06 +02:00
|
|
|
static void Task_ShowAndUpdateApplauseMeter(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_AnimateAudience(u8);
|
|
|
|
static void Task_BlendAudienceBackground(u8);
|
2019-01-28 18:13:07 +01:00
|
|
|
static const u8 *GetTurnOrderNumberGfx(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateCurtainDropAtRoundEnd(u8);
|
|
|
|
static void Task_ResetForNextRound(u8);
|
|
|
|
static void Task_WaitRaiseCurtainAtRoundEnd(u8);
|
|
|
|
static void Task_StartRaiseCurtainAtRoundEnd(u8);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_WaitForSliderHeartAnim(u8);
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetBattleTargetSpritePosition(void);
|
2020-08-16 11:07:44 +02:00
|
|
|
static void CalculateContestLiveUpdateData(void);
|
|
|
|
static void SetConestLiveUpdateTVData(void);
|
|
|
|
static void SetContestLiveUpdateFlags(u8);
|
2019-04-03 03:51:21 +02:00
|
|
|
static void ContestDebugPrintBitStrings(void);
|
2020-07-12 02:25:56 +02:00
|
|
|
static void StripPlayerNameForLinkContest(u8 *);
|
|
|
|
static void StripMonNameForLinkContest(u8 *, s32);
|
2019-04-04 02:43:23 +02:00
|
|
|
static void SwapMoveDescAndContestTilemaps(void);
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
// An index into a palette where the text color for each contestant is stored.
|
|
|
|
// Contestant 0 will use palette color 10, contestant 1 will use color 11, etc.
|
|
|
|
#define CONTESTANT_TEXT_COLOR_START 10
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
enum {
|
2020-07-12 02:25:56 +02:00
|
|
|
// The "{Pokemon Name} / {Trainer Name}" windows.
|
2020-08-14 01:10:23 +02:00
|
|
|
WIN_CONTESTANT0_NAME,
|
|
|
|
WIN_CONTESTANT1_NAME,
|
|
|
|
WIN_CONTESTANT2_NAME,
|
|
|
|
WIN_CONTESTANT3_NAME,
|
|
|
|
WIN_GENERAL_TEXT,
|
2020-07-12 02:25:56 +02:00
|
|
|
// The available moves, from top to bottom
|
2020-08-14 01:10:23 +02:00
|
|
|
WIN_MOVE0,
|
|
|
|
WIN_MOVE1,
|
|
|
|
WIN_MOVE2,
|
|
|
|
WIN_MOVE3,
|
2020-07-12 02:25:56 +02:00
|
|
|
// The small "/" character between the move category and the
|
|
|
|
// appeal/jam display
|
2020-08-14 01:10:23 +02:00
|
|
|
WIN_SLASH,
|
|
|
|
WIN_MOVE_DESCRIPTION
|
2020-07-12 02:25:56 +02:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
enum {
|
|
|
|
JUDGE_SYMBOL_SWIRL,
|
|
|
|
JUDGE_SYMBOL_SWIRL_UNUSED,
|
|
|
|
JUDGE_SYMBOL_ONE_EXCLAMATION,
|
|
|
|
JUDGE_SYMBOL_TWO_EXCLAMATIONS,
|
|
|
|
JUDGE_SYMBOL_NUMBER_ONE_UNUSED,
|
|
|
|
JUDGE_SYMBOL_NUMBER_ONE,
|
|
|
|
JUDGE_SYMBOL_NUMBER_FOUR,
|
|
|
|
JUDGE_SYMBOL_QUESTION_MARK,
|
|
|
|
JUDGE_SYMBOL_STAR,
|
|
|
|
};
|
2020-07-12 02:25:56 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
enum {
|
|
|
|
STAT_SYMBOL_CIRCLE,
|
|
|
|
STAT_SYMBOL_WAVE,
|
|
|
|
STAT_SYMBOL_X,
|
|
|
|
STAT_SYMBOL_SWIRL,
|
|
|
|
STAT_SYMBOL_SQUARE,
|
|
|
|
};
|
2020-07-24 06:14:53 +02:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
enum {
|
|
|
|
CONTEST_DEBUG_MODE_OFF,
|
|
|
|
CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL,
|
|
|
|
CONTEST_DEBUG_MODE_PRINT_WINNER_FLAGS,
|
|
|
|
CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define MOVE_WINDOWS_START WIN_MOVE0
|
2020-07-12 02:25:56 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define TAG_CONTEST_SYMBOLS_PAL 0xABE0
|
|
|
|
#define TAG_JUDGE_SYMBOLS_GFX 0xABE0
|
|
|
|
#define TAG_FACES_GFX 0xABE1
|
|
|
|
#define TAG_APPLAUSE_METER 0xABE2
|
2020-07-12 02:25:56 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define TAG_SLIDER_HEART 0x4E20
|
|
|
|
#define TAG_JUDGE 0x4E21
|
2020-07-12 02:25:56 +02:00
|
|
|
#define TAG_NEXT_TURN_PAL 0x4E22
|
|
|
|
#define TAG_NEXT_TURN_1_GFX 0x4E22
|
|
|
|
#define TAG_NEXT_TURN_2_GFX 0x4E23
|
|
|
|
#define TAG_NEXT_TURN_3_GFX 0x4E24
|
|
|
|
#define TAG_NEXT_TURN_4_GFX 0x4E25
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define TAG_BLINK_EFFECT_CONTESTANT0 0x80E8
|
|
|
|
#define TAG_BLINK_EFFECT_CONTESTANT1 0x80E9
|
|
|
|
#define TAG_BLINK_EFFECT_CONTESTANT2 0x80EA
|
|
|
|
#define TAG_BLINK_EFFECT_CONTESTANT3 0x80EB
|
|
|
|
|
2021-06-21 19:48:03 +02:00
|
|
|
#define TILE_FILLED_APPEAL_HEART 0x5012
|
|
|
|
#define TILE_FILLED_JAM_HEART 0x5014
|
|
|
|
#define TILE_EMPTY_APPEAL_HEART 0x5035
|
|
|
|
#define TILE_EMPTY_JAM_HEART 0x5036
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
enum {
|
|
|
|
SLIDER_HEART_ANIM_NORMAL,
|
|
|
|
SLIDER_HEART_ANIM_DISAPPEAR,
|
|
|
|
SLIDER_HEART_ANIM_APPEAR,
|
|
|
|
};
|
|
|
|
|
2020-08-16 11:52:17 +02:00
|
|
|
// States for Task_DoAppeals
|
|
|
|
enum {
|
|
|
|
APPEALSTATE_START_TURN,
|
|
|
|
APPEALSTATE_WAIT_LINK,
|
|
|
|
APPEALSTATE_CHECK_SKIP_TURN,
|
|
|
|
APPEALSTATE_SLIDE_MON_IN,
|
|
|
|
APPEALSTATE_WAIT_SLIDE_MON,
|
|
|
|
APPEALSTATE_PRINT_USED_MOVE_MSG,
|
|
|
|
APPEALSTATE_WAIT_USED_MOVE_MSG,
|
|
|
|
APPEALSTATE_MOVE_ANIM,
|
|
|
|
APPEALSTATE_WAIT_MOVE_ANIM,
|
|
|
|
APPEALSTATE_MOVE_ANIM_MULTITURN,
|
|
|
|
APPEALSTATE_SLIDE_MON_OUT,
|
|
|
|
APPEALSTATE_FREE_MON_SPRITE,
|
|
|
|
APPEALSTATE_UPDATE_MOVE_USERS_HEARTS,
|
|
|
|
APPEALSTATE_WAIT_MOVE_USERS_HEARTS,
|
|
|
|
APPEALSTATE_PRINT_COMBO_MSG,
|
|
|
|
APPEALSTATE_TRY_UPDATE_HEARTS_FROM_COMBO,
|
|
|
|
APPEALSTATE_WAIT_HEARTS_FROM_COMBO,
|
|
|
|
APPEALSTATE_CHECK_REPEATED_MOVE,
|
|
|
|
APPEALSTATE_WAIT_HEARTS_FROM_REPEAT,
|
|
|
|
APPEALSTATE_UPDATE_HEARTS_FROM_REPEAT,
|
|
|
|
APPEALSTATE_START_TURN_END_DELAY,
|
|
|
|
APPEALSTATE_TURN_END_DELAY,
|
|
|
|
APPEALSTATE_START_NEXT_TURN,
|
|
|
|
APPEALSTATE_TRY_PRINT_MOVE_RESULT,
|
|
|
|
APPEALSTATE_WAIT_MOVE_RESULT_MSG,
|
|
|
|
APPEALSTATE_UPDATE_OPPONENTS,
|
|
|
|
APPEALSTATE_UPDATE_OPPONENT,
|
|
|
|
APPEALSTATE_WAIT_OPPONENT_RESPONSE_MSG,
|
|
|
|
APPEALSTATE_UPDATE_OPPONENT_HEARTS,
|
|
|
|
APPEALSTATE_WAIT_OPPONENT_HEARTS,
|
|
|
|
APPEALSTATE_UPDATE_OPPONENT_STATUS,
|
|
|
|
APPEALSTATE_PRINT_SKIP_TURN_MSG,
|
|
|
|
APPEALSTATE_WAIT_SKIP_TURN_MSG,
|
|
|
|
APPEALSTATE_PRINT_TOO_NERVOUS_MSG,
|
|
|
|
APPEALSTATE_WAIT_TOO_NERVOUS_MSG,
|
|
|
|
APPEALSTATE_TRY_JUDGE_STAR,
|
|
|
|
APPEALSTATE_WAIT_JUDGE_STAR,
|
|
|
|
APPEALSTATE_UPDATE_MOVE_USERS_STARS,
|
|
|
|
APPEALSTATE_WAIT_MOVE_USERS_STARS,
|
|
|
|
APPEALSTATE_UPDATE_OPPONENT_STARS,
|
|
|
|
APPEALSTATE_WAIT_OPPONENT_STARS,
|
|
|
|
APPEALSTATE_UPDATE_CROWD,
|
|
|
|
APPEALSTATE_42, // Unused state
|
|
|
|
APPEALSTATE_WAIT_EXCITEMENT_HEARTS,
|
|
|
|
APPEALSTATE_44, // Unused state
|
|
|
|
APPEALSTATE_WAIT_JUDGE_COMBO,
|
|
|
|
APPEALSTATE_WAIT_JUDGE_REPEATED_MOVE,
|
|
|
|
APPEALSTATE_TRY_SHOW_NEXT_TURN_GFX,
|
|
|
|
APPEALSTATE_CHECK_TURN_ORDER_MOD,
|
|
|
|
APPEALSTATE_WAIT_JUDGE_TURN_ORDER,
|
|
|
|
APPEALSTATE_UPDATE_MOVE_USERS_STATUS,
|
|
|
|
APPEALSTATE_TRY_PRINT_SKIP_NEXT_TURN_MSG,
|
|
|
|
APPEALSTATE_WAIT_SKIP_NEXT_TURN_MSG,
|
|
|
|
APPEALSTATE_DO_CROWD_UNEXCITED,
|
|
|
|
APPEALSTATE_DO_CROWD_EXCITED,
|
|
|
|
APPEALSTATE_SLIDE_APPLAUSE_OUT,
|
|
|
|
APPEALSTATE_WAIT_SLIDE_APPLAUSE,
|
|
|
|
APPEALSTATE_PRINT_CROWD_WATCHES_MSG,
|
|
|
|
APPEALSTATE_PRINT_MON_MOVE_IGNORED_MSG,
|
|
|
|
APPEALSTATE_WAIT_MON_MOVE_IGNORED_MSG,
|
|
|
|
};
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
// EWRAM vars.
|
2019-11-11 03:54:00 +01:00
|
|
|
EWRAM_DATA struct ContestPokemon gContestMons[CONTESTANT_COUNT] = {0};
|
2020-07-24 06:14:53 +02:00
|
|
|
EWRAM_DATA s16 gContestMonRound1Points[CONTESTANT_COUNT] = {0}; // "Round 1" points are based on condition
|
|
|
|
EWRAM_DATA s16 gContestMonTotalPoints[CONTESTANT_COUNT] = {0}; // Round 1 points + Round 2 points
|
|
|
|
EWRAM_DATA s16 gContestMonAppealPointTotals[CONTESTANT_COUNT] = {0};
|
|
|
|
EWRAM_DATA s16 gContestMonRound2Points[CONTESTANT_COUNT] = {0}; // "Round 2" points are just appeal points * 2
|
2019-11-11 03:54:00 +01:00
|
|
|
EWRAM_DATA u8 gContestFinalStandings[CONTESTANT_COUNT] = {0};
|
2019-01-03 18:54:22 +01:00
|
|
|
EWRAM_DATA u8 gContestMonPartyIndex = 0;
|
2018-05-02 01:47:11 +02:00
|
|
|
EWRAM_DATA u8 gContestPlayerMonIndex = 0;
|
2019-11-11 03:54:00 +01:00
|
|
|
EWRAM_DATA u8 gContestantTurnOrder[CONTESTANT_COUNT] = {0};
|
2019-04-03 23:24:32 +02:00
|
|
|
EWRAM_DATA u8 gLinkContestFlags = 0;
|
2018-05-02 14:43:27 +02:00
|
|
|
// Bit 0: Is a link contest
|
|
|
|
// Bit 1: Link contest uses wireless adapter
|
2020-08-13 09:09:47 +02:00
|
|
|
EWRAM_DATA u8 gContestLinkLeaderIndex = 0;
|
2018-05-02 01:47:11 +02:00
|
|
|
EWRAM_DATA u16 gSpecialVar_ContestCategory = 0;
|
|
|
|
EWRAM_DATA u16 gSpecialVar_ContestRank = 0;
|
2019-01-03 18:54:22 +01:00
|
|
|
EWRAM_DATA u8 gNumLinkContestPlayers = 0;
|
|
|
|
EWRAM_DATA u8 gHighestRibbonRank = 0;
|
2019-01-28 18:13:07 +01:00
|
|
|
EWRAM_DATA struct ContestResources *gContestResources = NULL;
|
2018-05-03 01:59:00 +02:00
|
|
|
EWRAM_DATA u8 sContestBgCopyFlags = 0;
|
2019-11-10 19:46:39 +01:00
|
|
|
EWRAM_DATA struct ContestWinner gCurContestWinner = {0};
|
2021-04-22 02:04:12 +02:00
|
|
|
EWRAM_DATA bool8 gCurContestWinnerIsForArtist = 0;
|
|
|
|
EWRAM_DATA u8 gCurContestWinnerSaveIdx = 0;
|
2018-05-02 14:43:27 +02:00
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
// IWRAM common vars.
|
2018-05-02 14:43:27 +02:00
|
|
|
u32 gContestRngValue;
|
2018-05-02 01:47:11 +02:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
extern const u8 gText_LinkStandby4[];
|
2019-01-28 18:13:07 +01:00
|
|
|
extern const u8 gText_BDot[];
|
|
|
|
extern const u8 gText_CDot[];
|
2019-01-06 08:02:28 +01:00
|
|
|
extern void (*const gContestEffectFuncs[])(void);
|
2018-05-05 00:59:59 +02:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const u8 sSliderHeartYPositions[CONTESTANT_COUNT] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
36, 76, 116, 156
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
// The "Next Turn" sprites cover up the slider, so the y positions are the same as above
|
|
|
|
static const u8 sNextTurnSpriteYPositions[CONTESTANT_COUNT] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
36, 76, 116, 156
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct SpriteSheet sSpriteSheet_SliderHeart =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.data = gContestSliderHeart_Gfx,
|
2019-03-09 03:39:51 +01:00
|
|
|
.size = 0x20,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_SLIDER_HEART
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct OamData sOam_SliderHeart =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2019-03-09 03:39:51 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(8x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_SliderHeart_Normal[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
2019-03-09 03:39:51 +01:00
|
|
|
AFFINEANIMCMD_END,
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_SliderHeart_SpinDisappear[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(-10, -10, -20, 20),
|
2019-03-09 03:39:51 +01:00
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_SliderHeart_SpinAppear[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
AFFINEANIMCMD_FRAME(56, 56, 0, 0),
|
2019-03-09 03:39:51 +01:00
|
|
|
AFFINEANIMCMD_FRAME(10, 10, 20, 20),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const union AffineAnimCmd* const sAffineAnims_SliderHeart[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
[SLIDER_HEART_ANIM_NORMAL] = sAffineAnim_SliderHeart_Normal,
|
|
|
|
[SLIDER_HEART_ANIM_DISAPPEAR] = sAffineAnim_SliderHeart_SpinDisappear,
|
|
|
|
[SLIDER_HEART_ANIM_APPEAR] = sAffineAnim_SliderHeart_SpinAppear
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_SliderHeart =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_SLIDER_HEART,
|
2020-07-24 06:14:53 +02:00
|
|
|
.paletteTag = TAG_CONTEST_SYMBOLS_PAL,
|
2020-07-12 02:25:56 +02:00
|
|
|
.oam = &sOam_SliderHeart,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2020-07-12 02:25:56 +02:00
|
|
|
.affineAnims = sAffineAnims_SliderHeart,
|
2019-03-09 03:39:51 +01:00
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct CompressedSpriteSheet sSpriteSheet_NextTurn[CONTESTANT_COUNT] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.data = gContestNextTurnGfx,
|
|
|
|
.size = 0x100,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_NEXT_TURN_1_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gContestNextTurnGfx,
|
|
|
|
.size = 0x100,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_NEXT_TURN_2_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gContestNextTurnGfx,
|
|
|
|
.size = 0x100,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_NEXT_TURN_3_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gContestNextTurnGfx,
|
|
|
|
.size = 0x100,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_NEXT_TURN_4_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct SpritePalette sSpritePalette_NextTurn =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.data = gContestPal,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_NEXT_TURN_PAL
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct OamData sOam_NextTurn =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2019-03-09 03:39:51 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(32x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplates_NextTurn[CONTESTANT_COUNT] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_NEXT_TURN_1_GFX,
|
|
|
|
.paletteTag = TAG_NEXT_TURN_PAL,
|
|
|
|
.oam = &sOam_NextTurn,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_NEXT_TURN_2_GFX,
|
|
|
|
.paletteTag = TAG_NEXT_TURN_PAL,
|
|
|
|
.oam = &sOam_NextTurn,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_NEXT_TURN_3_GFX,
|
|
|
|
.paletteTag = TAG_NEXT_TURN_PAL,
|
|
|
|
.oam = &sOam_NextTurn,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
},
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_NEXT_TURN_4_GFX,
|
|
|
|
.paletteTag = TAG_NEXT_TURN_PAL,
|
|
|
|
.oam = &sOam_NextTurn,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct Subsprite sSubsprites_NextTurn[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.x = -28,
|
|
|
|
.y = -4,
|
2019-12-05 03:00:45 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 4,
|
|
|
|
.y = -4,
|
2019-12-05 03:00:45 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileOffset = 4,
|
|
|
|
.priority = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static const struct SubspriteTable sSubspriteTable_NextTurn[] =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.subspriteCount = ARRAY_COUNT(sSubsprites_NextTurn),
|
|
|
|
.subsprites = sSubsprites_NextTurn
|
2019-03-09 03:39:51 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
// Unused
|
|
|
|
static const struct CompressedSpriteSheet sSpriteSheet_Faces =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.data = gContestFaces_Gfx,
|
2019-03-09 03:39:51 +01:00
|
|
|
.size = 0x180,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_FACES_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static const struct OamData sOam_Faces =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-02 00:31:10 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(16x16),
|
2019-03-09 03:39:51 +01:00
|
|
|
.x = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(16x16),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
// Unused
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Faces =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_FACES_GFX,
|
2020-07-24 06:14:53 +02:00
|
|
|
.paletteTag = TAG_CONTEST_SYMBOLS_PAL,
|
|
|
|
.oam = &sOam_Faces,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct CompressedSpriteSheet sSpriteSheet_ApplauseMeter =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.data = gContestApplauseGfx,
|
|
|
|
.size = 0x400,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_APPLAUSE_METER
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct SpritePalette sSpritePalette_ApplauseMeter =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.data = gContestPal,
|
2020-07-12 02:25:56 +02:00
|
|
|
.tag = TAG_APPLAUSE_METER
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct OamData sOam_ApplauseMeter =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-02 00:31:10 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
2019-03-09 03:39:51 +01:00
|
|
|
.x = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(64x32),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ApplauseMeter =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
.tileTag = TAG_APPLAUSE_METER,
|
|
|
|
.paletteTag = TAG_APPLAUSE_METER,
|
2020-08-14 01:10:23 +02:00
|
|
|
.oam = &sOam_ApplauseMeter,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct OamData sOam_Judge =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-02 00:31:10 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2019-03-09 03:39:51 +01:00
|
|
|
.x = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2019-03-09 03:39:51 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.paletteNum = 2,
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct SpriteTemplate sSpriteTemplate_Judge =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
.tileTag = TAG_JUDGE,
|
|
|
|
.paletteTag = TAG_JUDGE,
|
|
|
|
.oam = &sOam_Judge,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct CompressedSpriteSheet sSpriteSheet_Judge =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.data = gContestJudgeGfx,
|
|
|
|
.size = 0x800,
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_JUDGE
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static const struct CompressedSpriteSheet sSpriteSheet_JudgeSymbols =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
|
|
|
.data = gContestJudgeSymbolsGfx,
|
|
|
|
.size = 0x380,
|
2020-07-24 06:14:53 +02:00
|
|
|
.tag = TAG_JUDGE_SYMBOLS_GFX
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct CompressedSpritePalette sSpritePalette_JudgeSymbols =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2021-10-26 22:52:23 +02:00
|
|
|
.data = gContestJudgeSymbolsPal,
|
2020-07-24 06:14:53 +02:00
|
|
|
.tag = TAG_CONTEST_SYMBOLS_PAL
|
2019-03-09 03:39:51 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct SpriteTemplate sSpriteTemplate_JudgeSpeechBubble =
|
2019-03-09 03:39:51 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
.tileTag = TAG_JUDGE_SYMBOLS_GFX,
|
|
|
|
.paletteTag = TAG_CONTEST_SYMBOLS_PAL,
|
2019-10-15 01:26:47 +02:00
|
|
|
.oam = &gOamData_AffineOff_ObjNormal_16x16,
|
2019-03-09 03:39:51 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const u16 sText_Pal[] = INCBIN_U16("graphics/contest/text.gbapal");
|
2019-03-09 03:39:51 +01:00
|
|
|
|
2019-03-09 04:33:40 +01:00
|
|
|
#include "data/contest_text_tables.h"
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static const struct BgTemplate sContestBgTemplates[] =
|
2019-03-09 06:00:10 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 0x18,
|
|
|
|
.screenSize = 2,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 0x1E,
|
|
|
|
.screenSize = 2,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 0x1C,
|
|
|
|
.screenSize = 2,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 3,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 0x1A,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.baseTile = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static const struct WindowTemplate sContestWindowTemplates[] =
|
2019-03-09 06:00:10 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_CONTESTANT0_NAME] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x200
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_CONTESTANT1_NAME] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 5,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x218
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_CONTESTANT2_NAME] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 10,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x230
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_CONTESTANT3_NAME] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x248
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_GENERAL_TEXT] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 17,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x260
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_MOVE0] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 31,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 9,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2A4
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_MOVE1] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 33,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 9,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2B6
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_MOVE2] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 35,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 9,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2C8
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_MOVE3] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 37,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 9,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2DA
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_SLASH] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 16,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 31,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 1,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2EC
|
|
|
|
},
|
2020-08-14 01:10:23 +02:00
|
|
|
[WIN_MOVE_DESCRIPTION] = {
|
2019-03-09 06:00:10 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 11,
|
2019-04-04 02:43:23 +02:00
|
|
|
.tilemapTop = 35,
|
2019-03-09 06:00:10 +01:00
|
|
|
.width = 18,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 0xF,
|
|
|
|
.baseBlock = 0x2EE
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
|
|
|
#include "data/contest_opponents.h"
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct CompressedSpriteSheet sSpriteSheets_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.data = gBlankGfxCompressed,
|
|
|
|
.size = 0x1000,
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT0
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gBlankGfxCompressed,
|
|
|
|
.size = 0x1000,
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT1
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gBlankGfxCompressed,
|
|
|
|
.size = 0x1000,
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT2
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = gBlankGfxCompressed,
|
|
|
|
.size = 0x1000,
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT3
|
2019-03-10 05:51:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Yup this is super dangerous but that's how it is here
|
2020-08-14 01:10:23 +02:00
|
|
|
static const struct SpritePalette sSpritePalettes_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.data = (u16*)(gHeap + 0x1A0A4),
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT0
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = (u16*)(gHeap + 0x1A0C4),
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT1
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = (u16*)(gHeap + 0x1A0E4),
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT2
|
2019-03-10 05:51:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.data = (u16*)(gHeap + 0x1A104),
|
2020-08-14 01:10:23 +02:00
|
|
|
.tag = TAG_BLINK_EFFECT_CONTESTANT3
|
2019-03-10 05:51:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct OamData sOam_ContestantsTurnBlinkEffect =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-02 00:31:10 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_DOUBLE,
|
|
|
|
.objMode = ST_OAM_OBJ_BLEND,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-01 02:33:25 +02:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2019-03-10 05:51:39 +01:00
|
|
|
.x = 0,
|
2019-04-01 02:33:25 +02:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2019-03-10 05:51:39 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
2019-04-02 00:31:10 +02:00
|
|
|
.affineParam = 0,
|
2019-03-10 05:51:39 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_0[] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_1[] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(3, 3, 0, 15),
|
|
|
|
AFFINEANIMCMD_FRAME(-3, -3, 0, 15),
|
|
|
|
AFFINEANIMCMD_FRAME(3, 3, 0, 15),
|
|
|
|
AFFINEANIMCMD_FRAME(-3, -3, 0, 15),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const union AffineAnimCmd *const sAffineAnims_ContestantsTurnBlinkEffect[] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
sAffineAnim_ContestantsTurnBlinkEffect_0,
|
|
|
|
sAffineAnim_ContestantsTurnBlinkEffect_1
|
2019-03-10 05:51:39 +01:00
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
const struct SpriteTemplate sSpriteTemplates_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
.tileTag = TAG_BLINK_EFFECT_CONTESTANT0,
|
|
|
|
.paletteTag = TAG_BLINK_EFFECT_CONTESTANT0,
|
|
|
|
.oam = &sOam_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2020-08-14 01:10:23 +02:00
|
|
|
.affineAnims = sAffineAnims_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
},
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
.tileTag = TAG_BLINK_EFFECT_CONTESTANT1,
|
|
|
|
.paletteTag = TAG_BLINK_EFFECT_CONTESTANT1,
|
|
|
|
.oam = &sOam_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2020-08-14 01:10:23 +02:00
|
|
|
.affineAnims = sAffineAnims_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
},
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
.tileTag = TAG_BLINK_EFFECT_CONTESTANT2,
|
|
|
|
.paletteTag = TAG_BLINK_EFFECT_CONTESTANT2,
|
|
|
|
.oam = &sOam_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2020-08-14 01:10:23 +02:00
|
|
|
.affineAnims = sAffineAnims_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
},
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
.tileTag = TAG_BLINK_EFFECT_CONTESTANT3,
|
|
|
|
.paletteTag = TAG_BLINK_EFFECT_CONTESTANT3,
|
|
|
|
.oam = &sOam_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2020-08-14 01:10:23 +02:00
|
|
|
.affineAnims = sAffineAnims_ContestantsTurnBlinkEffect,
|
2019-03-10 05:51:39 +01:00
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static const s8 gContestExcitementTable[CONTEST_CATEGORIES_COUNT][CONTEST_CATEGORIES_COUNT] =
|
2019-03-10 05:51:39 +01:00
|
|
|
{
|
2020-10-26 19:52:44 +01:00
|
|
|
[CONTEST_CATEGORY_COOL] = {
|
|
|
|
[CONTEST_CATEGORY_COOL] = +1,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = 0,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = -1,
|
|
|
|
[CONTEST_CATEGORY_SMART] = -1,
|
2020-08-14 01:10:23 +02:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = 0
|
|
|
|
},
|
2020-10-26 19:52:44 +01:00
|
|
|
[CONTEST_CATEGORY_BEAUTY] = {
|
|
|
|
[CONTEST_CATEGORY_COOL] = 0,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = +1,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = 0,
|
|
|
|
[CONTEST_CATEGORY_SMART] = -1,
|
2020-08-14 01:10:23 +02:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = -1
|
|
|
|
},
|
|
|
|
[CONTEST_CATEGORY_CUTE] = {
|
2020-10-26 19:52:44 +01:00
|
|
|
[CONTEST_CATEGORY_COOL] = -1,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = 0,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = +1,
|
|
|
|
[CONTEST_CATEGORY_SMART] = 0,
|
2020-08-14 01:10:23 +02:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = -1
|
|
|
|
},
|
|
|
|
[CONTEST_CATEGORY_SMART] = {
|
2020-10-26 19:52:44 +01:00
|
|
|
[CONTEST_CATEGORY_COOL] = -1,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = -1,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = 0,
|
|
|
|
[CONTEST_CATEGORY_SMART] = +1,
|
2020-08-14 01:10:23 +02:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = 0
|
|
|
|
},
|
2020-10-26 19:52:44 +01:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = {
|
|
|
|
[CONTEST_CATEGORY_COOL] = 0,
|
|
|
|
[CONTEST_CATEGORY_BEAUTY] = -1,
|
|
|
|
[CONTEST_CATEGORY_CUTE] = -1,
|
|
|
|
[CONTEST_CATEGORY_SMART] = 0,
|
2020-08-14 01:10:23 +02:00
|
|
|
[CONTEST_CATEGORY_TOUGH] = +1
|
|
|
|
}
|
2019-03-10 05:51:39 +01:00
|
|
|
};
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static void TaskDummy1(u8 taskId)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetLinkContestBoolean(void)
|
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
gLinkContestFlags = 0;
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static void SetupContestGpuRegs(void)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDY, 0);
|
2018-08-12 12:08:51 +02:00
|
|
|
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_BG3 | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR);
|
2018-05-02 01:47:11 +02:00
|
|
|
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON);
|
|
|
|
|
|
|
|
gBattle_BG0_X = 0;
|
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG1_X = 0;
|
|
|
|
gBattle_BG1_Y = 0;
|
|
|
|
gBattle_BG2_X = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
|
|
|
gBattle_BG3_X = 0;
|
|
|
|
gBattle_BG3_Y = 0;
|
|
|
|
gBattle_WIN0H = 0;
|
|
|
|
gBattle_WIN0V = 0;
|
|
|
|
gBattle_WIN1H = 0;
|
|
|
|
gBattle_WIN1V = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadContestBgAfterMoveAnim(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-10-26 22:52:23 +02:00
|
|
|
LZDecompressVram(gContestInterfaceGfx, (void *)VRAM);
|
2019-02-17 06:25:48 +01:00
|
|
|
LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
|
2021-10-26 22:52:23 +02:00
|
|
|
CopyToBgTilemapBuffer(3, gContestAudienceTilemap, 0, 0);
|
2018-05-02 01:47:11 +02:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
2021-10-26 22:52:23 +02:00
|
|
|
LoadCompressedPalette(gContestInterfaceAudiencePalette, 0, 0x200);
|
2020-07-12 02:25:56 +02:00
|
|
|
LoadContestPalettes();
|
2019-04-03 09:00:06 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
u32 contestantWindowId = 5 + i;
|
2018-05-02 01:47:11 +02:00
|
|
|
|
2021-04-22 20:30:45 +02:00
|
|
|
LoadPalette(eContestTempSave.cachedWindowPalettes[contestantWindowId], 16 * (5 + gContestantTurnOrder[i]), sizeof((eContestTempSave.cachedWindowPalettes[contestantWindowId])));
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static void InitContestInfoBgs(void)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2019-04-03 23:24:32 +02:00
|
|
|
InitBgsFromTemplates(0, sContestBgTemplates, ARRAY_COUNT(sContestBgTemplates));
|
2018-12-26 13:05:02 +01:00
|
|
|
SetBgAttribute(3, BG_ATTR_WRAPAROUND, 1);
|
2019-04-03 03:51:21 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
SetBgTilemapBuffer(i, gContestResources->contestBgTilemaps[i]);
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static void InitContestWindows(void)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
InitWindows(sContestWindowTemplates);
|
2018-05-02 01:47:11 +02:00
|
|
|
DeactivateAllTextPrinters();
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
gTextFlags.canABSpeedUpPrint = FALSE;
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
gTextFlags.canABSpeedUpPrint = TRUE;
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void LoadContestPalettes(void)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
LoadPalette(sText_Pal, 0xf0, 0x20);
|
2018-08-12 12:08:51 +02:00
|
|
|
FillPalette(RGB_BLACK, 0, 2);
|
2018-05-02 01:47:11 +02:00
|
|
|
for (i = 10; i < 14; i++)
|
|
|
|
LoadPalette(gPlttBufferUnfaded + 241, 240 + i, 2);
|
2018-08-12 12:08:51 +02:00
|
|
|
FillPalette(RGB(31, 17, 31), 0xF3, 2);
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
static void InitContestResources(void)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest = (struct Contest){};
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2020-08-16 11:52:17 +02:00
|
|
|
eContest.unk[i] = 0xFF;
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
eContestantStatus[i] = (struct ContestantStatus){};
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
eContestantStatus[i].ranking = 0;
|
|
|
|
eContestantStatus[i].effectStringId = CONTEST_STRING_NONE;
|
|
|
|
eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE;
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestAppealResults = (struct ContestAppealMoveResults){};
|
2019-04-03 02:00:05 +02:00
|
|
|
eContestAI = (struct ContestAIInfo){};
|
2020-08-15 20:33:08 +02:00
|
|
|
*gContestResources->excitement = (struct ContestExcitement){};
|
|
|
|
memset(eContestGfxState, 0, CONTESTANT_COUNT * sizeof(struct ContestGraphicsState));
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
|
2019-04-03 02:00:05 +02:00
|
|
|
SortContestants(FALSE);
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-02 01:47:11 +02:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
eContestantStatus[i].nextTurnOrder = 0xFF;
|
2019-04-03 03:51:21 +02:00
|
|
|
eContest.prevTurnOrder[i] = gContestantTurnOrder[i];
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
2019-04-03 03:51:21 +02:00
|
|
|
// Calling this here while all the nextTurnOrder values are 0xFF will actually
|
|
|
|
// just reverse the turn order.
|
2019-04-03 02:46:18 +02:00
|
|
|
ApplyNextTurnOrder();
|
2020-08-15 20:33:08 +02:00
|
|
|
memset(gContestResources->tv, 0, sizeof(*gContestResources->tv) * CONTESTANT_COUNT);
|
2018-05-02 01:47:11 +02:00
|
|
|
}
|
2018-05-02 03:27:24 +02:00
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
static void AllocContestResources(void)
|
2018-05-02 03:27:24 +02:00
|
|
|
{
|
|
|
|
gContestResources = AllocZeroed(sizeof(struct ContestResources));
|
2019-04-02 06:35:57 +02:00
|
|
|
gContestResources->contest = AllocZeroed(sizeof(struct Contest));
|
2019-04-03 02:00:05 +02:00
|
|
|
gContestResources->status = AllocZeroed(sizeof(struct ContestantStatus) * CONTESTANT_COUNT);
|
2020-08-15 20:33:08 +02:00
|
|
|
gContestResources->appealResults = AllocZeroed(sizeof(struct ContestAppealMoveResults));
|
2019-04-03 02:00:05 +02:00
|
|
|
gContestResources->aiData = AllocZeroed(sizeof(struct ContestAIInfo));
|
2020-08-15 20:33:08 +02:00
|
|
|
gContestResources->excitement = AllocZeroed(sizeof(struct ContestExcitement) * CONTESTANT_COUNT);
|
|
|
|
gContestResources->gfxState = AllocZeroed(sizeof(struct ContestGraphicsState) * CONTESTANT_COUNT);
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestResources->moveAnim = AllocZeroed(sizeof(struct ContestMoveAnimData));
|
2020-08-15 20:33:08 +02:00
|
|
|
gContestResources->tv = AllocZeroed(sizeof(struct ContestTV) * CONTESTANT_COUNT);
|
|
|
|
gContestResources->unused = AllocZeroed(sizeof(struct ContestUnused));
|
2019-04-03 23:24:32 +02:00
|
|
|
gContestResources->contestBgTilemaps[0] = AllocZeroed(0x1000);
|
|
|
|
gContestResources->contestBgTilemaps[1] = AllocZeroed(0x1000);
|
|
|
|
gContestResources->contestBgTilemaps[2] = AllocZeroed(0x1000);
|
|
|
|
gContestResources->contestBgTilemaps[3] = AllocZeroed(0x1000);
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestResources->boxBlinkTiles1 = AllocZeroed(0x800);
|
|
|
|
gContestResources->boxBlinkTiles2 = AllocZeroed(0x800);
|
2021-10-04 16:21:03 +02:00
|
|
|
gContestResources->animBgTileBuffer = AllocZeroed(0x2000);
|
|
|
|
gBattleAnimBgTileBuffer = gContestResources->animBgTileBuffer;
|
|
|
|
gBattleAnimBgTilemapBuffer = gContestResources->contestBgTilemaps[1];
|
2018-05-02 03:27:24 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
static void FreeContestResources(void)
|
2018-05-02 03:27:24 +02:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->contest);
|
2019-04-03 02:00:05 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->status);
|
2020-08-15 20:33:08 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->appealResults);
|
2019-04-03 02:00:05 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->aiData);
|
2020-08-15 20:33:08 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->excitement);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->gfxState);
|
2020-08-14 01:10:23 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->moveAnim);
|
2020-08-15 20:33:08 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->tv);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->unused);
|
2019-04-03 23:24:32 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[0]);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[1]);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[2]);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->contestBgTilemaps[3]);
|
2020-08-14 01:10:23 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->boxBlinkTiles1);
|
|
|
|
FREE_AND_SET_NULL(gContestResources->boxBlinkTiles2);
|
2021-10-04 16:21:03 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources->animBgTileBuffer);
|
2018-08-12 12:08:51 +02:00
|
|
|
FREE_AND_SET_NULL(gContestResources);
|
2021-10-04 16:21:03 +02:00
|
|
|
gBattleAnimBgTileBuffer = NULL;
|
|
|
|
gBattleAnimBgTilemapBuffer = NULL;
|
2018-05-02 03:27:24 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
void CB2_StartContest(void)
|
2018-05-02 03:27:24 +02:00
|
|
|
{
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case 0:
|
|
|
|
sContestBgCopyFlags = 0;
|
2019-04-03 02:00:05 +02:00
|
|
|
AllocContestResources();
|
2019-01-28 18:19:58 +01:00
|
|
|
AllocateMonSpritesGfx();
|
|
|
|
FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed);
|
|
|
|
gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x4000);
|
|
|
|
SetVBlankCallback(NULL);
|
2019-04-03 03:51:21 +02:00
|
|
|
InitContestInfoBgs();
|
|
|
|
InitContestWindows();
|
|
|
|
SetupContestGpuRegs();
|
2019-01-28 18:19:58 +01:00
|
|
|
ScanlineEffect_Clear();
|
|
|
|
ResetPaletteFade();
|
|
|
|
gPaletteFade.bufferTransferDisabled = TRUE;
|
|
|
|
ResetSpriteData();
|
|
|
|
ResetTasks();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
gReservedSpritePaletteCount = 4;
|
2019-04-03 03:51:21 +02:00
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_OFF;
|
2019-01-28 18:19:58 +01:00
|
|
|
ClearBattleMonForms();
|
2019-04-03 02:00:05 +02:00
|
|
|
InitContestResources();
|
2019-01-28 18:19:58 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-04-03 23:24:32 +02:00
|
|
|
if (SetupContestGraphics(&eContest.contestSetupState))
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
eContest.contestSetupState = 0;
|
2018-05-02 03:27:24 +02:00
|
|
|
gMain.state++;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBgForCurtainDrop();
|
2019-01-28 18:19:58 +01:00
|
|
|
gBattle_BG1_X = 0;
|
|
|
|
gBattle_BG1_Y = 0;
|
|
|
|
BeginFastPaletteFade(2);
|
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
2020-07-12 02:25:56 +02:00
|
|
|
SetVBlankCallback(VBlankCB_Contest);
|
|
|
|
eContest.mainTaskId = CreateTask(Task_StartContestWaitFade, 10);
|
2019-04-03 23:24:32 +02:00
|
|
|
SetMainCallback2(CB2_ContestMain);
|
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-04 23:05:46 +02:00
|
|
|
LoadWirelessStatusIndicatorSpriteGfx();
|
2019-01-28 18:19:58 +01:00
|
|
|
CreateWirelessStatusIndicatorSprite(8, 8);
|
|
|
|
}
|
|
|
|
break;
|
2018-05-02 03:27:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_StartContestWaitFade(u8 taskId)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_TryStartLinkContest;
|
2018-05-02 14:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:52:17 +02:00
|
|
|
// If this is a link contest try to start appeals communication
|
2020-08-14 01:10:23 +02:00
|
|
|
// Otherwise skip ahead
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_TryStartLinkContest(u8 taskId)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case 0:
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
// fallthrough
|
|
|
|
case 1:
|
|
|
|
if (IsLinkTaskFinished())
|
|
|
|
{
|
2020-08-13 09:09:47 +02:00
|
|
|
SetLinkStandbyCallback();
|
2018-05-02 14:43:27 +02:00
|
|
|
gTasks[taskId].data[0]++;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 2:
|
|
|
|
if (IsLinkTaskFinished() != TRUE)
|
2018-05-02 14:43:27 +02:00
|
|
|
return;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
2018-05-02 14:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
2019-04-03 23:24:32 +02:00
|
|
|
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS))
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2020-07-12 02:25:56 +02:00
|
|
|
CreateTask(Task_CommunicateMonIdxs, 0);
|
2018-05-02 14:43:27 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].func = TaskDummy1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_WaitToRaiseCurtainAtStart;
|
2018-05-02 14:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_CommunicateMonIdxs(u8 taskId)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
SetTaskFuncWithFollowupFunc(taskId, Task_LinkContest_CommunicateMonIdxs, Task_EndCommunicateMonIdxs);
|
2018-05-02 14:43:27 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_EndCommunicateMonIdxs(u8 taskId)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 1;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_ReadyStartLinkContest;
|
2018-05-02 14:43:27 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_ReadyStartLinkContest(u8 taskId)
|
2018-05-02 14:43:27 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
// data[0] always 1 here
|
2018-05-02 14:43:27 +02:00
|
|
|
gTasks[taskId].data[0]--;
|
|
|
|
if (gTasks[taskId].data[0] <= 0)
|
|
|
|
{
|
|
|
|
GetMultiplayerId(); // unused return value
|
|
|
|
DestroyTask(taskId);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[eContest.mainTaskId].func = Task_WaitToRaiseCurtainAtStart;
|
2018-05-02 14:43:27 +02:00
|
|
|
gRngValue = gContestRngValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static bool8 SetupContestGraphics(u8 *stateVar)
|
2018-05-03 01:59:00 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
u16 tempPalette1[16];
|
|
|
|
u16 tempPalette2[16];
|
2018-05-03 01:59:00 +02:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
switch (*stateVar)
|
2018-05-03 01:59:00 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case 0:
|
|
|
|
gPaletteFade.bufferTransferDisabled = TRUE;
|
|
|
|
RequestDma3Fill(0, (void *)VRAM, 0x8000, 1);
|
2019-02-17 06:25:48 +01:00
|
|
|
RequestDma3Fill(0, (void *)VRAM + 0x8000, 0x8000, 1);
|
|
|
|
RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1);
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-10-26 22:52:23 +02:00
|
|
|
LZDecompressVram(gContestInterfaceGfx, (void *)VRAM);
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-02-17 06:25:48 +01:00
|
|
|
LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4)));
|
2020-08-14 01:10:23 +02:00
|
|
|
DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnzippedContestAudience_Gfx, 0x2000, 0x1000);
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-10-26 22:52:23 +02:00
|
|
|
CopyToBgTilemapBuffer(3, gContestAudienceTilemap, 0, 0);
|
2019-01-28 18:19:58 +01:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-10-26 22:52:23 +02:00
|
|
|
CopyToBgTilemapBuffer(2, gContestInterfaceTilemap, 0, 0);
|
2019-01-28 18:19:58 +01:00
|
|
|
CopyBgTilemapBufferToVram(2);
|
2019-04-03 09:00:06 +02:00
|
|
|
// This is a bug, and copies random junk. savedJunk is never read.
|
2021-04-22 20:30:45 +02:00
|
|
|
DmaCopy32Defvars(3, gContestResources->contestBgTilemaps[2], eContestTempSave.savedJunk, sizeof(eContestTempSave.savedJunk));
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-10-26 22:52:23 +02:00
|
|
|
LoadCompressedPalette(gContestInterfaceAudiencePalette, 0, 0x200);
|
2019-04-03 23:24:32 +02:00
|
|
|
CpuCopy32(gPlttBufferUnfaded + 128, tempPalette1, 16 * sizeof(u16));
|
2020-08-16 11:07:44 +02:00
|
|
|
CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, tempPalette2, 16 * sizeof(u16));
|
2019-04-03 23:24:32 +02:00
|
|
|
CpuCopy32(tempPalette2, gPlttBufferUnfaded + 128, 16 * sizeof(u16));
|
2020-08-16 11:07:44 +02:00
|
|
|
CpuCopy32(tempPalette1, gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, 16 * sizeof(u16));
|
2021-04-22 20:30:45 +02:00
|
|
|
DmaCopy32Defvars(3, gPlttBufferUnfaded, eContestTempSave.cachedWindowPalettes, sizeof(eContestTempSave.cachedWindowPalettes));
|
2020-07-12 02:25:56 +02:00
|
|
|
LoadContestPalettes();
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2019-04-03 23:24:32 +02:00
|
|
|
DrawContestantWindows();
|
|
|
|
FillContestantWindowBgs();
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.judgeSpeechBubbleSpriteId = CreateJudgeSpeechBubbleSprite();
|
2020-07-12 02:25:56 +02:00
|
|
|
CreateSliderHeartSprites();
|
|
|
|
CreateNextTurnSprites();
|
2019-01-28 18:19:58 +01:00
|
|
|
CreateApplauseMeterSprite();
|
2020-08-14 01:10:23 +02:00
|
|
|
CreateJudgeAttentionEyeTask();
|
2020-08-16 11:07:44 +02:00
|
|
|
CreateUnusedBlendTask();
|
2019-09-04 23:45:04 +02:00
|
|
|
gBattlerPositions[0] = B_POSITION_PLAYER_LEFT;
|
|
|
|
gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT;
|
|
|
|
gBattlerPositions[2] = B_POSITION_OPPONENT_RIGHT;
|
|
|
|
gBattlerPositions[3] = B_POSITION_PLAYER_RIGHT;
|
2019-01-28 18:19:58 +01:00
|
|
|
gBattleTypeFlags = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gBattlerAttacker = B_POSITION_PLAYER_RIGHT;
|
|
|
|
gBattlerTarget = B_POSITION_OPPONENT_RIGHT;
|
|
|
|
// Unclear why judge sprite is assigned here
|
|
|
|
// Overwritten in APPEALSTATE_SLIDE_MON_IN with the attacking contest mon
|
|
|
|
gBattlerSpriteIds[gBattlerAttacker] = CreateJudgeSprite();
|
|
|
|
CreateInvisibleBattleTargetSprite();
|
2019-01-28 18:19:58 +01:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
ShowBg(3);
|
|
|
|
ShowBg(2);
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
break;
|
|
|
|
default:
|
2019-04-03 23:24:32 +02:00
|
|
|
*stateVar = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
return TRUE;
|
2018-05-03 01:59:00 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
(*stateVar)++;
|
2019-04-04 02:43:23 +02:00
|
|
|
return FALSE;
|
2018-05-03 01:59:00 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_WaitToRaiseCurtainAtStart(u8 taskId)
|
2018-05-03 01:59:00 +02:00
|
|
|
{
|
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_RaiseCurtainAtStart;
|
2018-05-03 01:59:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_RaiseCurtainAtStart(u8 taskId)
|
2018-05-03 01:59:00 +02:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case 0:
|
|
|
|
if (gTasks[taskId].data[1]++ <= 60)
|
2018-05-03 01:59:00 +02:00
|
|
|
break;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE12WithPanning(SE_CONTEST_CURTAIN_RISE, 0);
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-06-26 14:13:38 +02:00
|
|
|
*(s16*)&gBattle_BG1_Y += 7;
|
2021-04-15 08:04:01 +02:00
|
|
|
if ((s16)gBattle_BG1_Y <= DISPLAY_HEIGHT)
|
2018-05-03 01:59:00 +02:00
|
|
|
break;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-14 01:10:23 +02:00
|
|
|
UpdateContestantBoxOrder();
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
u16 bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT);
|
|
|
|
u16 bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT);
|
|
|
|
((struct BgCnt *)&bg0Cnt)->priority = 0;
|
|
|
|
((struct BgCnt *)&bg2Cnt)->priority = 0;
|
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt);
|
2020-08-14 01:10:23 +02:00
|
|
|
SlideApplauseMeterIn();
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
default:
|
2019-04-03 09:00:06 +02:00
|
|
|
if (eContest.applauseMeterIsMoving)
|
2018-05-03 01:59:00 +02:00
|
|
|
break;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_DisplayAppealNumberText;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2018-05-03 01:59:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void CB2_ContestMain(void)
|
2018-05-03 01:59:00 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
AnimateSprites();
|
|
|
|
RunTasks();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if ((sContestBgCopyFlags >> i) & 1)
|
|
|
|
CopyBgTilemapBufferToVram(i);
|
|
|
|
}
|
|
|
|
sContestBgCopyFlags = 0;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void VBlankCB_Contest(void)
|
2018-05-03 01:59:00 +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);
|
|
|
|
SetGpuReg(REG_OFFSET_BG3HOFS, gBattle_BG3_X);
|
|
|
|
SetGpuReg(REG_OFFSET_BG3VOFS, gBattle_BG3_Y);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0H, gBattle_WIN0H);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0V, gBattle_WIN0V);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN1H, gBattle_WIN1H);
|
|
|
|
SetGpuReg(REG_OFFSET_WIN1V, gBattle_WIN1V);
|
|
|
|
TransferPlttBuffer();
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
ScanlineEffect_InitHBlankDmaTransfer();
|
|
|
|
}
|
2018-05-03 14:51:52 +02:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_DisplayAppealNumberText(u8 taskId)
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0] == 0)
|
|
|
|
{
|
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugDoPrint();
|
2021-04-22 20:30:45 +02:00
|
|
|
DmaCopy32Defvars(3, gPlttBufferUnfaded, eContestTempSave.cachedPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2);
|
2020-07-24 06:14:53 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, eContest.appealNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
|
2018-08-15 11:43:57 +02:00
|
|
|
if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
|
2019-11-14 18:07:43 +01:00
|
|
|
StringCopy(gDisplayedStringBattle, gText_AppealNumWhichMoveWillBePlayed);
|
2018-05-03 14:51:52 +02:00
|
|
|
else
|
2019-11-14 18:07:43 +01:00
|
|
|
StringCopy(gDisplayedStringBattle, gText_AppealNumButItCantParticipate);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2018-05-03 14:51:52 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2018-05-03 14:51:52 +02:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-11 16:51:38 +02:00
|
|
|
if (!Contest_RunTextPrinters())
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_TryShowMoveSelectScreen;
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_TryShowMoveSelectScreen(u8 taskId)
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
// Wait for button press to show move select screen
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_NEW(A_BUTTON)) || (gMain.newKeys == B_BUTTON))
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-08-15 11:43:57 +02:00
|
|
|
if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
SetBottomSliderHeartsInvisibility(TRUE);
|
|
|
|
gTasks[taskId].func = Task_ShowMoveSelectScreen;
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
// Skip move selection (selected move will be MOVE_NONE)
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_SelectedMove;
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_ShowMoveSelectScreen(u8 taskId)
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2020-07-12 02:25:56 +02:00
|
|
|
u8 moveName[32];
|
2018-05-03 14:51:52 +02:00
|
|
|
|
2021-04-15 08:04:01 +02:00
|
|
|
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
|
|
|
gBattle_BG2_Y = DISPLAY_HEIGHT;
|
2018-05-03 14:51:52 +02:00
|
|
|
|
2018-12-25 18:50:15 +01:00
|
|
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
|
|
|
u16 move = gContestMons[gContestPlayerMonIndex].moves[i];
|
2020-07-12 02:25:56 +02:00
|
|
|
u8 *moveNameBuffer = moveName;
|
2018-05-03 14:51:52 +02:00
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
if (eContestantStatus[gContestPlayerMonIndex].prevMove != MOVE_NONE
|
2020-08-14 01:10:23 +02:00
|
|
|
&& IsContestantAllowedToCombo(gContestPlayerMonIndex)
|
|
|
|
&& AreMovesContestCombo(eContestantStatus[gContestPlayerMonIndex].prevMove, move)
|
2019-04-03 02:00:05 +02:00
|
|
|
&& eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention)
|
2018-05-03 14:51:52 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Highlight the text because it's a combo move
|
2021-06-10 18:36:10 +02:00
|
|
|
moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGray);
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
2020-07-12 02:25:56 +02:00
|
|
|
else if (move != MOVE_NONE
|
2019-04-03 02:00:05 +02:00
|
|
|
&& eContestantStatus[gContestPlayerMonIndex].prevMove == move
|
2018-05-03 14:51:52 +02:00
|
|
|
&& gContestMoves[move].effect != CONTEST_EFFECT_REPETITION_NOT_BORING)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Gray the text because it's a repeated move
|
2020-07-12 02:25:56 +02:00
|
|
|
moveNameBuffer = StringCopy(moveName, gText_ColorBlue);
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
2020-07-12 02:25:56 +02:00
|
|
|
moveNameBuffer = StringCopy(moveNameBuffer, gMoveNames[move]);
|
2018-05-03 14:51:52 +02:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
FillWindowPixelBuffer(i + MOVE_WINDOWS_START, PIXEL_FILL(0));
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, moveName, 5, 1, FONT_NARROW);
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
DrawMoveSelectArrow(eContest.playerMoveChoice);
|
2019-04-04 02:43:23 +02:00
|
|
|
PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]);
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_HandleMoveSelectInput;
|
2018-05-03 14:51:52 +02:00
|
|
|
}
|
2018-05-04 03:01:22 +02:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_HandleMoveSelectInput(u8 taskId)
|
2018-05-04 03:01:22 +02:00
|
|
|
{
|
|
|
|
u8 numMoves = 0;
|
|
|
|
s32 i;
|
|
|
|
|
2018-12-25 18:50:15 +01:00
|
|
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
2018-05-04 03:01:22 +02:00
|
|
|
{
|
|
|
|
if (gContestMons[gContestPlayerMonIndex].moves[i] != MOVE_NONE)
|
|
|
|
numMoves++;
|
|
|
|
}
|
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-05-04 03:01:22 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_SelectedMove;
|
2018-05-04 03:01:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (gMain.newAndRepeatedKeys)
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case B_BUTTON:
|
2020-07-12 02:25:56 +02:00
|
|
|
// Cancel move selection
|
2019-01-28 18:19:58 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2020-07-12 02:25:56 +02:00
|
|
|
SetBottomSliderHeartsInvisibility(FALSE);
|
2020-07-24 06:14:53 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, eContest.appealNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1);
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex))
|
2019-11-14 18:07:43 +01:00
|
|
|
StringCopy(gDisplayedStringBattle, gText_AppealNumWhichMoveWillBePlayed);
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2019-11-14 18:07:43 +01:00
|
|
|
StringCopy(gDisplayedStringBattle, gText_AppealNumButItCantParticipate);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2019-01-28 18:19:58 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle);
|
|
|
|
Contest_StartTextPrinter(gStringVar4, 0);
|
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_TryShowMoveSelectScreen;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case DPAD_LEFT:
|
|
|
|
case DPAD_RIGHT:
|
|
|
|
break;
|
|
|
|
case DPAD_UP:
|
2020-07-12 02:25:56 +02:00
|
|
|
EraseMoveSelectArrow(eContest.playerMoveChoice);
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.playerMoveChoice == 0)
|
|
|
|
eContest.playerMoveChoice = numMoves - 1;
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest.playerMoveChoice--;
|
2020-07-12 02:25:56 +02:00
|
|
|
DrawMoveSelectArrow(eContest.playerMoveChoice);
|
2019-04-04 02:43:23 +02:00
|
|
|
PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]);
|
2019-01-28 18:19:58 +01:00
|
|
|
if (numMoves > 1)
|
2018-05-04 03:01:22 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case DPAD_DOWN:
|
2020-07-12 02:25:56 +02:00
|
|
|
EraseMoveSelectArrow(eContest.playerMoveChoice);
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.playerMoveChoice == numMoves - 1)
|
|
|
|
eContest.playerMoveChoice = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest.playerMoveChoice++;
|
2020-07-12 02:25:56 +02:00
|
|
|
DrawMoveSelectArrow(eContest.playerMoveChoice);
|
2019-04-04 02:43:23 +02:00
|
|
|
PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]);
|
2019-01-28 18:19:58 +01:00
|
|
|
if (numMoves > 1)
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
break;
|
2018-05-04 03:01:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void DrawMoveSelectArrow(s8 moveIndex)
|
2018-05-04 03:01:22 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(2, 55, 0, 31 + moveIndex * 2, 2, 2, 17, 1);
|
2018-05-04 03:01:22 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void EraseMoveSelectArrow(s8 moveIndex)
|
2018-05-04 03:01:22 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 31 + moveIndex * 2, 2, 1, 17, 1);
|
|
|
|
ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 32 + moveIndex * 2, 2, 1, 17, 1);
|
2018-05-04 03:01:22 +02:00
|
|
|
}
|
2018-05-04 04:29:53 +02:00
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_SelectedMove(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
u16 move = GetChosenMove(gContestPlayerMonIndex);
|
2018-05-04 04:29:53 +02:00
|
|
|
u8 taskId2;
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
eContestantStatus[gContestPlayerMonIndex].currMove = move;
|
2020-07-12 02:25:56 +02:00
|
|
|
taskId2 = CreateTask(Task_LinkContest_CommunicateMoveSelections, 0);
|
|
|
|
SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateMoveSelections, Task_EndCommunicateMoveSelections);
|
2018-05-04 04:29:53 +02:00
|
|
|
gTasks[taskId].func = TaskDummy1;
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2020-07-12 02:25:56 +02:00
|
|
|
SetBottomSliderHeartsInvisibility(FALSE);
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
GetAllChosenMoves();
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_HideMoveSelectScreen;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_EndCommunicateMoveSelections(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[eContest.mainTaskId].func = Task_HideMoveSelectScreen;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_HideMoveSelectScreen(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2018-05-04 04:29:53 +02:00
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
SetBottomSliderHeartsInvisibility(FALSE);
|
2018-05-04 04:29:53 +02:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
FillWindowPixelBuffer(MOVE_WINDOWS_START + i, PIXEL_FILL(0));
|
|
|
|
PutWindowTilemap(MOVE_WINDOWS_START + i);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(MOVE_WINDOWS_START + i, COPYWIN_GFX);
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
2018-05-11 16:51:38 +02:00
|
|
|
Contest_SetBgCopyFlags(0);
|
2019-04-03 09:00:06 +02:00
|
|
|
// This seems to be a bug; it should have just copied PLTT_BUFFER_SIZE.
|
2021-04-22 20:30:45 +02:00
|
|
|
DmaCopy32Defvars(3, gPlttBufferFaded, eContestTempSave.cachedPlttBufferFaded, PLTT_BUFFER_SIZE * 2);
|
|
|
|
LoadPalette(eContestTempSave.cachedPlttBufferUnfaded, 0, PLTT_BUFFER_SIZE * 2);
|
2018-05-04 04:29:53 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_HideApplauseMeterForAppealStart;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_HideApplauseMeterForAppealStart(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
|
|
|
if (++gTasks[taskId].data[0] > 2)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
if (++gTasks[taskId].data[1] == 2)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
SlideApplauseMeterOut();
|
2020-07-12 02:25:56 +02:00
|
|
|
AnimateSliderHearts(SLIDER_HEART_ANIM_DISAPPEAR);
|
|
|
|
gTasks[taskId].func = Task_WaitHideApplauseMeterForAppealStart;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_WaitHideApplauseMeterForAppealStart(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if (!eContest.applauseMeterIsMoving && !eContest.sliderHeartsAnimating)
|
2020-08-13 09:09:47 +02:00
|
|
|
gTasks[taskId].func = Task_AppealSetup;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define tState data[0]
|
|
|
|
#define tMonSpriteId data[2]
|
|
|
|
#define tCounter data[10]
|
|
|
|
|
2020-08-13 09:09:47 +02:00
|
|
|
static void Task_AppealSetup(u8 taskId)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
|
|
|
if (++gTasks[taskId].data[0] > 19)
|
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
eContest.turnNumber = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.unusedRng = gRngValue;
|
2020-08-13 09:09:47 +02:00
|
|
|
if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) && IsPlayerLinkLeader())
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i + gNumLinkContestPlayers < CONTESTANT_COUNT; i++)
|
2018-05-04 04:29:53 +02:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
eContestantStatus[gNumLinkContestPlayers + i].currMove = GetChosenMove(gNumLinkContestPlayers + i);
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_START_TURN;
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_DoAppeals;
|
2018-05-04 04:29:53 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-05 00:59:59 +02:00
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_DoAppeals(u8 taskId)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
s32 i;
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestant = eContest.currentContestant;
|
2018-05-05 00:59:59 +02:00
|
|
|
s8 r3;
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
switch (gTasks[taskId].tState)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_START_TURN:
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugDoPrint();
|
2020-08-15 20:33:08 +02:00
|
|
|
for (i = 0; eContest.turnNumber != eContestAppealResults.turnOrder[i]; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
;
|
2020-07-24 06:14:53 +02:00
|
|
|
eContest.currentContestant = i;
|
2020-08-14 01:10:23 +02:00
|
|
|
contestant = eContest.currentContestant;
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
|
|
|
u8 taskId2;
|
2018-05-05 00:59:59 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForLink = TRUE;
|
2020-08-13 09:09:47 +02:00
|
|
|
if (IsPlayerLinkLeader())
|
2020-08-14 01:10:23 +02:00
|
|
|
CalculateAppealMoveImpact(eContest.currentContestant);
|
2020-08-15 20:33:08 +02:00
|
|
|
taskId2 = CreateTask(Task_LinkContest_CommunicateAppealsState, 0);
|
|
|
|
SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateAppealsState, Task_EndWaitForLink);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2020-08-16 11:52:17 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_LINK;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
CalculateAppealMoveImpact(eContest.currentContestant);
|
2020-08-16 11:52:17 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_SKIP_TURN;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-16 11:52:17 +02:00
|
|
|
case APPEALSTATE_WAIT_LINK:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.waitForLink)
|
2020-08-16 11:52:17 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_SKIP_TURN;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-16 11:52:17 +02:00
|
|
|
case APPEALSTATE_CHECK_SKIP_TURN:
|
2020-08-16 11:07:44 +02:00
|
|
|
SetContestLiveUpdateFlags(contestant);
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugPrintBitStrings();
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[contestant].numTurnsSkipped != 0
|
|
|
|
|| eContestantStatus[contestant].noMoreTurns)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_SKIP_TURN_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_MON_IN;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_SLIDE_MON_IN:
|
2020-07-24 06:14:53 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
gBattleMonForms[i] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
memset(gContestResources->moveAnim, 0, sizeof(*gContestResources->moveAnim));
|
|
|
|
SetMoveAnimAttackerData(eContest.currentContestant);
|
2020-07-24 06:14:53 +02:00
|
|
|
spriteId = CreateContestantSprite(
|
|
|
|
gContestMons[eContest.currentContestant].species,
|
|
|
|
gContestMons[eContest.currentContestant].otId,
|
|
|
|
gContestMons[eContest.currentContestant].personality,
|
|
|
|
eContest.currentContestant);
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].x2 = 120;
|
2020-08-14 01:10:23 +02:00
|
|
|
gSprites[spriteId].callback = SpriteCB_MonSlideIn;
|
|
|
|
gTasks[taskId].tMonSpriteId = spriteId;
|
2019-01-28 18:19:58 +01:00
|
|
|
gBattlerSpriteIds[gBattlerAttacker] = spriteId;
|
2020-08-14 01:10:23 +02:00
|
|
|
BlinkContestantBox(CreateContestantBoxBlinkSprites(eContest.currentContestant), FALSE);
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_SLIDE_MON;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_SLIDE_MON:
|
|
|
|
spriteId = gTasks[taskId].tMonSpriteId;
|
2019-01-28 18:19:58 +01:00
|
|
|
if (gSprites[spriteId].callback == SpriteCallbackDummy)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Once mon has slid in, also wait for box to finish blinking
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[contestant].boxBlinking)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_USED_MOVE_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_USED_MOVE_MSG:
|
|
|
|
if (eContestantStatus[contestant].nervous)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_TOO_NERVOUS_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
|
|
|
if (eContestantStatus[contestant].currMove < MOVES_COUNT)
|
|
|
|
StringCopy(gStringVar2, gMoveNames[eContestantStatus[contestant].currMove]);
|
2018-05-05 00:59:59 +02:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar2, sInvalidContestMoveNames[eContestantStatus[contestant].moveCategory]);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonAppealedWithMove);
|
2019-01-28 18:19:58 +01:00
|
|
|
Contest_StartTextPrinter(gStringVar4, 1);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_USED_MOVE_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_USED_MOVE_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.moveAnimTurnCount = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_MOVE_ANIM;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_MOVE_ANIM:
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
u16 move = SanitizeMove(eContestantStatus[eContest.currentContestant].currMove);
|
2020-08-14 01:10:23 +02:00
|
|
|
SetMoveSpecificAnimData(eContest.currentContestant);
|
|
|
|
SetMoveAnimAttackerData(eContest.currentContestant);
|
|
|
|
SetMoveTargetPosition(move);
|
2018-05-05 00:59:59 +02:00
|
|
|
DoMoveAnim(move);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MOVE_ANIM;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_MOVE_ANIM:
|
2019-01-28 18:19:58 +01:00
|
|
|
gAnimScriptCallback();
|
|
|
|
if (!gAnimScriptActive)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ClearMoveAnimData(contestant);
|
|
|
|
if (eContest.moveAnimTurnCount != 0)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_MOVE_ANIM_MULTITURN;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContestantStatus[contestant].hasJudgesAttention)
|
|
|
|
StopFlashJudgeAttentionEye(contestant);
|
|
|
|
DrawUnnervedSymbols();
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_PRINT_MOVE_RESULT;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_MOVE_ANIM_MULTITURN:
|
|
|
|
if (gTasks[taskId].tCounter++ > 30)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_MOVE_ANIM;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TRY_PRINT_MOVE_RESULT:
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[contestant].effectStringId != CONTEST_STRING_NONE)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
PrintAppealMoveResultText(contestant, eContestantStatus[contestant].effectStringId);
|
|
|
|
eContestantStatus[contestant].effectStringId = CONTEST_STRING_NONE;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MOVE_RESULT_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[contestant].effectStringId2 != CONTEST_STRING_NONE)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (i != contestant && eContestantStatus[i].effectStringId != CONTEST_STRING_NONE)
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
if (i == CONTESTANT_COUNT)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
PrintAppealMoveResultText(contestant, eContestantStatus[contestant].effectStringId2);
|
|
|
|
eContestantStatus[contestant].effectStringId2 = CONTEST_STRING_NONE;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MOVE_RESULT_MSG;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_TURN_ORDER_MOD;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_TURN_ORDER_MOD;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_MOVE_RESULT_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_PRINT_MOVE_RESULT;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_CHECK_TURN_ORDER_MOD:
|
|
|
|
if (eContestantStatus[contestant].turnOrderModAction == 1)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_NUMBER_ONE);
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (eContestantStatus[contestant].turnOrderModAction == 2)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_NUMBER_FOUR);
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (eContestantStatus[contestant].turnOrderModAction == 3)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_QUESTION_MARK);
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_SHOW_NEXT_TURN_GFX;
|
2018-05-05 00:59:59 +02:00
|
|
|
return;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_JUDGE_TURN_ORDER;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_JUDGE_TURN_ORDER:
|
|
|
|
if (!eContest.waitForJudgeSpeechBubble)
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_SHOW_NEXT_TURN_GFX;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TRY_SHOW_NEXT_TURN_GFX:
|
|
|
|
ShowHideNextTurnGfx(TRUE);
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_MOVE_USERS_HEARTS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_MOVE_USERS_HEARTS:
|
2020-08-16 11:52:17 +02:00
|
|
|
UpdateAppealHearts(0, eContestantStatus[contestant].appeal, contestant);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MOVE_USERS_HEARTS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_MOVE_USERS_HEARTS:
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[eContest.currentContestant].updatingAppealHearts)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_JUDGE_STAR;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TRY_JUDGE_STAR:
|
2020-08-18 17:38:50 +02:00
|
|
|
if (eContestantStatus[contestant].conditionMod == CONDITION_GAIN)
|
2020-08-14 01:10:23 +02:00
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_STAR);
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_JUDGE_STAR;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_JUDGE_STAR:
|
|
|
|
if (!eContest.waitForJudgeSpeechBubble)
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_MOVE_USERS_STARS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_MOVE_USERS_STARS:
|
|
|
|
if (UpdateConditionStars(contestant, TRUE))
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MOVE_USERS_STARS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_MOVE_USERS_STATUS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_MOVE_USERS_STARS:
|
|
|
|
if (++gTasks[taskId].tCounter > 20)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_MOVE_USERS_STATUS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_MOVE_USERS_STATUS:
|
|
|
|
if (DrawStatusSymbol(contestant))
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_ICON_CHANGE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENTS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_OPPONENTS:
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_OPPONENT:
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Update each other contestant as a result of this move appeal
|
|
|
|
s32 j = 0;
|
2018-05-05 00:59:59 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
r3 = FALSE; // Can't get this to use local variable. Should be "needsUpdate"
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = gTasks[taskId].data[1]; i < CONTESTANT_COUNT; i++)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
r3 = FALSE;
|
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (j != contestant && gContestantTurnOrder[j] == i
|
|
|
|
&& eContestantStatus[j].effectStringId != CONTEST_STRING_NONE)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
r3 = TRUE;
|
2018-05-05 00:59:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
if (r3)
|
2018-05-05 00:59:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r3)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Update contestant
|
|
|
|
gTasks[taskId].data[1] = gContestantTurnOrder[j];
|
|
|
|
PrintAppealMoveResultText(j, eContestantStatus[j].effectStringId);
|
|
|
|
eContestantStatus[j].effectStringId = CONTEST_STRING_NONE;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_OPPONENT_RESPONSE_MSG;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Done updating contestants
|
2018-05-05 00:59:59 +02:00
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_PRINT_SKIP_NEXT_TURN_MSG;
|
|
|
|
DrawStatusSymbols();
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_OPPONENT_RESPONSE_MSG:
|
|
|
|
// Wait for contestants response to current appeal
|
|
|
|
// i.e. "Contestant managed to avert its gaze"
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT_HEARTS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_OPPONENT_HEARTS:
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
;
|
2020-08-16 11:52:17 +02:00
|
|
|
UpdateAppealHearts(eContestantStatus[i].appeal + eContestantStatus[i].jam, -eContestantStatus[i].jam, i);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_OPPONENT_HEARTS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_OPPONENT_HEARTS:
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
;
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[i].updatingAppealHearts)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT_STARS;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_OPPONENT_STARS:
|
2019-04-03 02:00:05 +02:00
|
|
|
for (i = 0; gTasks[taskId].data[1] != gContestantTurnOrder[i]; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
;
|
2020-08-14 01:10:23 +02:00
|
|
|
if (UpdateConditionStars(i, TRUE))
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_OPPONENT_STARS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT_STATUS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_OPPONENT_STARS:
|
|
|
|
if (++gTasks[taskId].tCounter > 20)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT_STATUS;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_OPPONENT_STATUS:
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
if (gContestantTurnOrder[i] == gTasks[taskId].data[1])
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
if (DrawStatusSymbol(i))
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_ICON_CHANGE);
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_ICON_CLEAR);
|
2019-04-03 02:00:05 +02:00
|
|
|
if (eContestantStatus[i].judgesAttentionWasRemoved)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
StopFlashJudgeAttentionEye(i);
|
|
|
|
eContestantStatus[i].judgesAttentionWasRemoved = FALSE;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
gTasks[taskId].data[1]++;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_OPPONENT;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TRY_PRINT_SKIP_NEXT_TURN_MSG:
|
|
|
|
if (gTasks[taskId].tCounter++ > 9)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
if (eContestantStatus[contestant].numTurnsSkipped != 0
|
|
|
|
|| eContestantStatus[contestant].turnSkipped)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonCantAppealNextTurn);
|
2019-01-28 18:19:58 +01:00
|
|
|
Contest_StartTextPrinter(gStringVar4, 1);
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_SKIP_NEXT_TURN_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_SKIP_NEXT_TURN_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContestantStatus[contestant].usedComboMove)
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_REPEATED_MOVE;
|
2018-05-05 00:59:59 +02:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_COMBO_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_COMBO_MSG:
|
|
|
|
{
|
|
|
|
s8 completedCombo = eContestantStatus[contestant].completedCombo;
|
|
|
|
if (eContestantStatus[contestant].completedCombo)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Finished combo
|
|
|
|
|
|
|
|
// Looks like there were originally meant to be move combos of
|
|
|
|
// different effectivenesses. completedCombo however is only ever 0 or 1,
|
|
|
|
// so in here only "Went over well" will ever be used
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
if (completedCombo == 1)
|
2019-11-14 18:07:43 +01:00
|
|
|
Contest_StartTextPrinter(gText_AppealComboWentOverWell, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (completedCombo == 2)
|
2019-11-14 18:07:43 +01:00
|
|
|
Contest_StartTextPrinter(gText_AppealComboWentOverVeryWell, TRUE);
|
2018-05-05 00:59:59 +02:00
|
|
|
else
|
2019-11-14 18:07:43 +01:00
|
|
|
Contest_StartTextPrinter(gText_AppealComboWentOverExcellently, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
|
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_TWO_EXCLAMATIONS);
|
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_JUDGE_COMBO;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Started combo
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_JudgeLookedAtMonExpectantly);
|
2019-01-28 18:19:58 +01:00
|
|
|
Contest_StartTextPrinter(gStringVar4, 1);
|
2020-08-14 01:10:23 +02:00
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_ONE_EXCLAMATION);
|
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_JUDGE_COMBO;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
}
|
|
|
|
case APPEALSTATE_WAIT_JUDGE_COMBO:
|
|
|
|
if (!eContest.waitForJudgeSpeechBubble)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
StartStopFlashJudgeAttentionEye(eContest.currentContestant);
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_TRY_UPDATE_HEARTS_FROM_COMBO;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TRY_UPDATE_HEARTS_FROM_COMBO:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (++gTasks[taskId].tCounter > 50)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContestantStatus[contestant].hasJudgesAttention)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
UpdateAppealHearts(
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal,
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestantStatus[contestant].comboAppealBonus,
|
2020-08-14 01:10:23 +02:00
|
|
|
contestant);
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal += eContestantStatus[contestant].comboAppealBonus;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_HEARTS_FROM_COMBO;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_HEARTS_FROM_COMBO:
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[contestant].updatingAppealHearts)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_CHECK_REPEATED_MOVE;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_CHECK_REPEATED_MOVE:
|
|
|
|
if (eContestantStatus[contestant].repeatedMove)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-04-04 02:43:23 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_RepeatedAppeal);
|
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
DoJudgeSpeechBubble(JUDGE_SYMBOL_SWIRL);
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_JUDGE_REPEATED_MOVE;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_CROWD;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_JUDGE_REPEATED_MOVE:
|
|
|
|
if (!eContest.waitForJudgeSpeechBubble)
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_HEARTS_FROM_REPEAT;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_HEARTS_FROM_REPEAT:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2020-08-16 11:52:17 +02:00
|
|
|
UpdateAppealHearts(eContestantStatus[contestant].appeal, -eContestantStatus[contestant].repeatJam, contestant);
|
|
|
|
eContestantStatus[contestant].appeal -= eContestantStatus[contestant].repeatJam;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_HEARTS_FROM_REPEAT;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_HEARTS_FROM_REPEAT:
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugDoPrint();
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[contestant].updatingAppealHearts)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_UPDATE_CROWD;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_UPDATE_CROWD:
|
2020-08-15 20:33:08 +02:00
|
|
|
if (eContestExcitement.frozen && contestant != eContestExcitement.freezer)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_CROWD_WATCHES_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
r3 = eContestExcitement.moveExcitement; // Can't get this to use local variable. Should be "moveExcitement"
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[contestant].overrideCategoryExcitementMod)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
r3 = 1;
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar3, gMoveNames[eContestantStatus[contestant].currMove]);
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar3, sContestConditions[gContestMoves[eContestantStatus[contestant].currMove].contestCategory]);
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
|
|
|
|
if (r3 > 0 && eContestantStatus[contestant].repeatedMove)
|
|
|
|
r3 = 0;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest.applauseLevel += r3;
|
|
|
|
if (eContest.applauseLevel < 0)
|
|
|
|
eContest.applauseLevel = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
if (r3 == 0)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_APPLAUSE_OUT;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
if (r3 < 0)
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonsXDidntGoOverWell);
|
2019-04-02 06:35:57 +02:00
|
|
|
else if (r3 > 0 && eContest.applauseLevel <= 4)
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonsXWentOverGreat);
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonsXGotTheCrowdGoing);
|
2019-01-28 18:19:58 +01:00
|
|
|
Contest_StartTextPrinter(gStringVar4, 1);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[11] = 0;
|
|
|
|
if (r3 < 0)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_DO_CROWD_UNEXCITED;
|
2019-01-28 18:19:58 +01:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_DO_CROWD_EXCITED;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_DO_CROWD_UNEXCITED:
|
|
|
|
switch (gTasks[taskId].tCounter)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2020-08-14 01:10:23 +02:00
|
|
|
BlendAudienceBackground(-1, 1);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlayFanfare(MUS_TOO_BAD);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter++;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.waitForAudienceBlend && !Contest_RunTextPrinters())
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
ShowAndUpdateApplauseMeter(-1);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter++;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-04-03 09:00:06 +02:00
|
|
|
if (!eContest.isShowingApplauseMeter)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
if (gTasks[taskId].data[11]++ > 29)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[11] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
BlendAudienceBackground(-1, -1);
|
|
|
|
gTasks[taskId].tCounter++;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!gPaletteFade.active)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[11] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_EXCITEMENT_HEARTS;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_DO_CROWD_EXCITED:
|
|
|
|
switch (gTasks[taskId].tCounter)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-05-11 16:51:38 +02:00
|
|
|
if (!Contest_RunTextPrinters())
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
BlendAudienceBackground(1, 1);
|
|
|
|
gTasks[taskId].tCounter++;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.waitForAudienceBlend)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
AnimateAudience();
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_ENCORE2);
|
2019-04-03 09:00:06 +02:00
|
|
|
ShowAndUpdateApplauseMeter(1);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter++;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-04-03 09:00:06 +02:00
|
|
|
if (!eContest.isShowingApplauseMeter)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
if (gTasks[taskId].data[11]++ > 29)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[11] = 0;
|
2020-08-16 11:52:17 +02:00
|
|
|
UpdateAppealHearts(eContestantStatus[contestant].appeal, eContestExcitement.excitementAppealBonus, contestant);
|
|
|
|
eContestantStatus[contestant].appeal += eContestExcitement.excitementAppealBonus;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter++;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[contestant].updatingAppealHearts)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.animatingAudience)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
BlendAudienceBackground(1, -1);
|
|
|
|
gTasks[taskId].tCounter++;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!gPaletteFade.active)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[11] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_EXCITEMENT_HEARTS;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_EXCITEMENT_HEARTS:
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestGfxState[contestant].updatingAppealHearts)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_APPLAUSE_OUT;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_CROWD_WATCHES_MSG:
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-15 20:33:08 +02:00
|
|
|
StringCopy(gStringVar3, gContestMons[eContestExcitement.freezer].nickname);
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
|
|
|
StringCopy(gStringVar2, gMoveNames[eContestantStatus[contestant].currMove]);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CrowdContinuesToWatchMon);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_PRINT_MON_MOVE_IGNORED_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_MON_MOVE_IGNORED_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonsMoveIsIgnored);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_MON_MOVE_IGNORED_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_MON_MOVE_IGNORED_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_APPLAUSE_OUT;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_TOO_NERVOUS_MSG:
|
|
|
|
if (eContestantStatus[contestant].hasJudgesAttention)
|
|
|
|
eContestantStatus[contestant].hasJudgesAttention = FALSE;
|
|
|
|
StartStopFlashJudgeAttentionEye(contestant);
|
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
|
|
|
StringCopy(gStringVar2, gMoveNames[eContestantStatus[contestant].currMove]);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonWasTooNervousToMove);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_TOO_NERVOUS_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_TOO_NERVOUS_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_APPLAUSE_OUT;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_SLIDE_APPLAUSE_OUT:
|
|
|
|
SlideApplauseMeterOut();
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_SLIDE_APPLAUSE;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_SLIDE_APPLAUSE:
|
2019-04-03 09:00:06 +02:00
|
|
|
if (!eContest.applauseMeterIsMoving)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.applauseLevel > 4)
|
2018-05-05 00:59:59 +02:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest.applauseLevel = 0;
|
2019-04-03 09:00:06 +02:00
|
|
|
UpdateApplauseMeter();
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_SLIDE_MON_OUT;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_SLIDE_MON_OUT:
|
|
|
|
spriteId = gTasks[taskId].tMonSpriteId;
|
|
|
|
gSprites[spriteId].callback = SpriteCB_MonSlideOut;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_FREE_MON_SPRITE;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_FREE_MON_SPRITE:
|
|
|
|
spriteId = gTasks[taskId].tMonSpriteId;
|
2019-01-28 18:19:58 +01:00
|
|
|
if (gSprites[spriteId].invisible)
|
|
|
|
{
|
|
|
|
FreeSpriteOamMatrix(&gSprites[spriteId]);
|
|
|
|
DestroySprite(&gSprites[spriteId]);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_START_TURN_END_DELAY;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_START_TURN_END_DELAY:
|
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_TURN_END_DELAY;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_PRINT_SKIP_TURN_MSG:
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2020-08-14 01:10:23 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MonWasWatchingOthers);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_WAIT_SKIP_TURN_MSG;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_WAIT_SKIP_TURN_MSG:
|
2019-01-28 18:19:58 +01:00
|
|
|
if (!Contest_RunTextPrinters())
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_TURN_END_DELAY;
|
2019-01-28 18:19:58 +01:00
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_TURN_END_DELAY:
|
|
|
|
if (++gTasks[taskId].tCounter > 29)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tCounter = 0;
|
|
|
|
gTasks[taskId].tState = APPEALSTATE_START_NEXT_TURN;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2020-08-14 01:10:23 +02:00
|
|
|
case APPEALSTATE_START_NEXT_TURN:
|
2020-07-24 06:14:53 +02:00
|
|
|
if (++eContest.turnNumber == CONTESTANT_COUNT)
|
2019-01-28 18:19:58 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].tState = 0;
|
2019-01-28 18:19:58 +01:00
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tMonSpriteId = 0;
|
|
|
|
gTasks[taskId].func = Task_FinishRoundOfAppeals;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tState = APPEALSTATE_START_TURN;
|
2019-01-28 18:19:58 +01:00
|
|
|
}
|
|
|
|
return;
|
2018-05-05 00:59:59 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-08 01:46:48 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_EndWaitForLink(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForLink = FALSE;
|
2018-05-08 01:46:48 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_MonSlideIn(struct Sprite *sprite)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->x2 != 0)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= 2;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (++sprite->data[0] == 31)
|
|
|
|
{
|
|
|
|
sprite->data[0] = 0;
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_MonSlideOut(struct Sprite *sprite)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= 6;
|
|
|
|
if (sprite->x + sprite->x2 < -32)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
sprite->invisible = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_FinishRoundOfAppeals(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
u8 taskId2;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForLink = TRUE;
|
2020-08-13 09:09:47 +02:00
|
|
|
if (IsPlayerLinkLeader())
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
RankContestants();
|
2020-07-24 06:14:53 +02:00
|
|
|
SetAttentionLevels();
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
2020-08-15 20:33:08 +02:00
|
|
|
taskId2 = CreateTask(Task_LinkContest_CommunicateAppealsState, 0);
|
|
|
|
SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateAppealsState, Task_EndWaitForLink);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
RankContestants();
|
2020-07-24 06:14:53 +02:00
|
|
|
SetAttentionLevels();
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.waitForLink)
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_ReadyUpdateHeartSliders;
|
2018-05-08 01:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_ReadyUpdateHeartSliders(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ShowHideNextTurnGfx(FALSE);
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_UpdateHeartSliders;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateHeartSliders(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (++gTasks[taskId].data[1] > 20)
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
AnimateSliderHearts(SLIDER_HEART_ANIM_APPEAR);
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[1] = 0;
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-07-12 02:25:56 +02:00
|
|
|
if (!eContest.sliderHeartsAnimating)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
if (++gTasks[taskId].data[1] > 20)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[1] = 0;
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-07-12 02:25:56 +02:00
|
|
|
UpdateHeartSliders();
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_WaitForHeartSliders;
|
2018-05-08 01:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_WaitForHeartSliders(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if (SlidersDoneUpdating())
|
2021-09-24 20:30:15 +02:00
|
|
|
gTasks[taskId].func = Task_RestorePlttBufferUnfaded;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-24 20:30:15 +02:00
|
|
|
static void Task_RestorePlttBufferUnfaded(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2021-04-22 20:30:45 +02:00
|
|
|
DmaCopy32Defvars(3, eContestTempSave.cachedPlttBufferUnfaded, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2);
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 2;
|
2020-08-16 11:52:17 +02:00
|
|
|
gTasks[taskId].func = Task_WaitPrintRoundResult;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:52:17 +02:00
|
|
|
static void Task_WaitPrintRoundResult(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
if (++gTasks[taskId].data[0] > 2)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
if (--gTasks[taskId].data[1] == 0)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_PrintRoundResultText;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_PrintRoundResultText(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0] == 0)
|
|
|
|
{
|
2019-11-14 18:07:43 +01:00
|
|
|
u8 attention = eContestantStatus[gContestPlayerMonIndex].attentionLevel;
|
2018-05-08 01:46:48 +02:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2018-05-08 01:46:48 +02:00
|
|
|
StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, sRoundResultTexts[attention]);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2018-05-08 01:46:48 +02:00
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-11 16:51:38 +02:00
|
|
|
if (!Contest_RunTextPrinters())
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_ReUpdateHeartSliders;
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugDoPrint();
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_ReUpdateHeartSliders(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0]++ > 29)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
UpdateHeartSliders(); // ? Sliders have already been updated
|
|
|
|
gTasks[taskId].func = Task_WaitForHeartSlidersAgain;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_WaitForHeartSlidersAgain(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if (SlidersDoneUpdating())
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_DropCurtainAtRoundEnd;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_DropCurtainAtRoundEnd(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBgForCurtainDrop();
|
|
|
|
gTasks[taskId].func = Task_StartDropCurtainAtRoundEnd;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateContestantBoxOrder(u8 taskId)
|
2018-05-08 01:46:48 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
UpdateContestantBoxOrder();
|
|
|
|
gTasks[taskId].func = Task_TryStartNextRoundOfAppeals;
|
2018-05-08 01:46:48 +02:00
|
|
|
}
|
2018-05-08 02:49:23 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_TryStartNextRoundOfAppeals(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
vu16 sp0 = GetGpuReg(REG_OFFSET_BG0CNT);
|
|
|
|
vu16 sp2 = GetGpuReg(REG_OFFSET_BG2CNT);
|
|
|
|
((vBgCnt *)&sp0)->priority = 0;
|
|
|
|
((vBgCnt *)&sp2)->priority = 0;
|
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, sp0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, sp2);
|
2020-07-24 06:14:53 +02:00
|
|
|
eContest.appealNumber++;
|
|
|
|
if (eContest.appealNumber == CONTEST_NUM_APPEALS)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_EndAppeals;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
SlideApplauseMeterIn();
|
|
|
|
gTasks[taskId].func = Task_StartNewRoundOfAppeals;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_StartNewRoundOfAppeals(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
if (!eContest.applauseMeterIsMoving)
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].func = Task_DisplayAppealNumberText;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_EndAppeals(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-07-24 06:14:53 +02:00
|
|
|
gContestMonAppealPointTotals[i] = eContestantStatus[i].pointTotal;
|
2020-06-17 23:48:20 +02:00
|
|
|
CalculateFinalScores();
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2019-04-03 23:24:32 +02:00
|
|
|
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
|
2019-04-02 06:35:57 +02:00
|
|
|
BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove);
|
2018-05-08 02:49:23 +02:00
|
|
|
else
|
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
CalculateContestLiveUpdateData();
|
|
|
|
SetConestLiveUpdateTVData();
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugPrintBitStrings();
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
gContestRngValue = gRngValue;
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_AllOutOfAppealTime);
|
2019-04-04 02:43:23 +02:00
|
|
|
Contest_StartTextPrinter(gStringVar4, TRUE);
|
2018-05-08 02:49:23 +02:00
|
|
|
gTasks[taskId].data[2] = 0;
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_WaitForOutOfTimeMsg;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_WaitForOutOfTimeMsg(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2018-05-11 16:51:38 +02:00
|
|
|
if (!Contest_RunTextPrinters())
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBgForCurtainDrop();
|
2018-05-08 02:49:23 +02:00
|
|
|
gBattle_BG1_X = 0;
|
2021-04-15 08:04:01 +02:00
|
|
|
gBattle_BG1_Y = DISPLAY_HEIGHT;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE12WithPanning(SE_CONTEST_CURTAIN_FALL, 0);
|
2018-05-08 02:49:23 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_DropCurtainAtAppealsEnd;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_DropCurtainAtAppealsEnd(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
gBattle_BG1_Y -= 7;
|
2018-11-19 16:28:55 +01:00
|
|
|
if ((s16)gBattle_BG1_Y < 0)
|
2018-05-08 02:49:23 +02:00
|
|
|
gBattle_BG1_Y = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
if (gBattle_BG1_Y == 0)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_TryCommunicateFinalStandings;
|
2018-05-08 02:49:23 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_TryCommunicateFinalStandings(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0]++ >= 50)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_CommunicateFinalStandings;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[taskId].func = Task_ContestReturnToField;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_CommunicateFinalStandings(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
u8 taskId2 = CreateTask(Task_LinkContest_CommunicateFinalStandings, 0);
|
2018-05-08 02:49:23 +02:00
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateFinalStandings, Task_EndCommunicateFinalStandings);
|
2018-05-08 02:49:23 +02:00
|
|
|
gTasks[taskId].func = TaskDummy1;
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2020-07-12 02:25:56 +02:00
|
|
|
SetBottomSliderHeartsInvisibility(FALSE);
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_EndCommunicateFinalStandings(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2020-07-24 06:14:53 +02:00
|
|
|
gTasks[eContest.mainTaskId].func = Task_ContestReturnToField;
|
2018-05-08 02:49:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void Task_ContestReturnToField(u8 taskId)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
2020-07-24 06:14:53 +02:00
|
|
|
gFieldCallback = FieldCB_ContestReturnToField;
|
2018-05-08 02:49:23 +02:00
|
|
|
FreeAllWindowBuffers();
|
2019-04-03 02:00:05 +02:00
|
|
|
FreeContestResources();
|
2018-05-08 02:49:23 +02:00
|
|
|
FreeMonSpritesGfx();
|
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void FieldCB_ContestReturnToField(void)
|
2018-05-08 02:49:23 +02:00
|
|
|
{
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
2018-05-09 01:00:23 +02:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void TryPutPlayerLast(void)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
|
2020-07-12 02:25:56 +02:00
|
|
|
gContestPlayerMonIndex = CONTESTANT_COUNT - 1;
|
2018-05-09 01:00:23 +02:00
|
|
|
}
|
|
|
|
|
2020-08-13 09:09:47 +02:00
|
|
|
static bool8 IsPlayerLinkLeader(void)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
2020-08-13 09:09:47 +02:00
|
|
|
if (gContestPlayerMonIndex == gContestLinkLeaderIndex)
|
2018-05-09 01:00:23 +02:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
void CreateContestMonFromParty(u8 partyIndex)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
|
|
|
u8 name[20];
|
|
|
|
u16 heldItem;
|
|
|
|
s16 cool;
|
|
|
|
s16 beauty;
|
|
|
|
s16 cute;
|
|
|
|
s16 smart;
|
|
|
|
s16 tough;
|
|
|
|
|
|
|
|
StringCopy(name, gSaveBlock2Ptr->playerName);
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
StripPlayerNameForLinkContest(name);
|
2018-05-09 01:00:23 +02:00
|
|
|
}
|
|
|
|
memcpy(gContestMons[gContestPlayerMonIndex].trainerName, name, 8);
|
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2019-11-21 05:12:51 +01:00
|
|
|
gContestMons[gContestPlayerMonIndex].trainerGfxId = OBJ_EVENT_GFX_LINK_BRENDAN;
|
2018-05-09 01:00:23 +02:00
|
|
|
else
|
2019-11-21 05:12:51 +01:00
|
|
|
gContestMons[gContestPlayerMonIndex].trainerGfxId = OBJ_EVENT_GFX_LINK_MAY;
|
2020-08-21 20:47:55 +02:00
|
|
|
gContestMons[gContestPlayerMonIndex].aiFlags = 0;
|
2020-07-12 02:25:56 +02:00
|
|
|
gContestMons[gContestPlayerMonIndex].highestRank = 0;
|
2018-05-09 01:00:23 +02:00
|
|
|
gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES);
|
|
|
|
GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name);
|
2021-11-18 04:11:03 +01:00
|
|
|
StringGet_Nickname(name);
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
StripMonNameForLinkContest(name, GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE));
|
2018-05-09 01:00:23 +02:00
|
|
|
}
|
2018-08-11 19:04:28 +02:00
|
|
|
memcpy(gContestMons[gContestPlayerMonIndex].nickname, name, POKEMON_NAME_LENGTH + 1);
|
2018-05-09 01:00:23 +02:00
|
|
|
StringCopy(gContestMons[gContestPlayerMonIndex].nickname, name);
|
|
|
|
gContestMons[gContestPlayerMonIndex].cool = GetMonData(&gPlayerParty[partyIndex], MON_DATA_COOL);
|
|
|
|
gContestMons[gContestPlayerMonIndex].beauty = GetMonData(&gPlayerParty[partyIndex], MON_DATA_BEAUTY);
|
|
|
|
gContestMons[gContestPlayerMonIndex].cute = GetMonData(&gPlayerParty[partyIndex], MON_DATA_CUTE);
|
|
|
|
gContestMons[gContestPlayerMonIndex].smart = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SMART);
|
|
|
|
gContestMons[gContestPlayerMonIndex].tough = GetMonData(&gPlayerParty[partyIndex], MON_DATA_TOUGH);
|
|
|
|
gContestMons[gContestPlayerMonIndex].sheen = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SHEEN);
|
|
|
|
gContestMons[gContestPlayerMonIndex].moves[0] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE1);
|
|
|
|
gContestMons[gContestPlayerMonIndex].moves[1] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE2);
|
|
|
|
gContestMons[gContestPlayerMonIndex].moves[2] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE3);
|
|
|
|
gContestMons[gContestPlayerMonIndex].moves[3] = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MOVE4);
|
|
|
|
gContestMons[gContestPlayerMonIndex].personality = GetMonData(&gPlayerParty[partyIndex], MON_DATA_PERSONALITY);
|
|
|
|
gContestMons[gContestPlayerMonIndex].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID);
|
|
|
|
|
|
|
|
heldItem = GetMonData(&gPlayerParty[partyIndex], MON_DATA_HELD_ITEM);
|
|
|
|
cool = gContestMons[gContestPlayerMonIndex].cool;
|
|
|
|
beauty = gContestMons[gContestPlayerMonIndex].beauty;
|
|
|
|
cute = gContestMons[gContestPlayerMonIndex].cute;
|
|
|
|
smart = gContestMons[gContestPlayerMonIndex].smart;
|
|
|
|
tough = gContestMons[gContestPlayerMonIndex].tough;
|
|
|
|
if (heldItem == ITEM_RED_SCARF)
|
|
|
|
cool += 20;
|
|
|
|
else if (heldItem == ITEM_BLUE_SCARF)
|
|
|
|
beauty += 20;
|
|
|
|
else if (heldItem == ITEM_PINK_SCARF)
|
|
|
|
cute += 20;
|
|
|
|
else if (heldItem == ITEM_GREEN_SCARF)
|
|
|
|
smart += 20;
|
|
|
|
else if (heldItem == ITEM_YELLOW_SCARF)
|
|
|
|
tough += 20;
|
|
|
|
if (cool > 255)
|
|
|
|
cool = 255;
|
|
|
|
if (beauty > 255)
|
|
|
|
beauty = 255;
|
|
|
|
if (cute > 255)
|
|
|
|
cute = 255;
|
|
|
|
if (smart > 255)
|
|
|
|
smart = 255;
|
|
|
|
if (tough > 255)
|
|
|
|
tough = 255;
|
|
|
|
gContestMons[gContestPlayerMonIndex].cool = cool;
|
|
|
|
gContestMons[gContestPlayerMonIndex].beauty = beauty;
|
|
|
|
gContestMons[gContestPlayerMonIndex].cute = cute;
|
|
|
|
gContestMons[gContestPlayerMonIndex].smart = smart;
|
|
|
|
gContestMons[gContestPlayerMonIndex].tough = tough;
|
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
void SetContestants(u8 contestType, u8 rank)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u8 opponentsCount = 0;
|
|
|
|
u8 opponents[100];
|
2020-07-24 06:14:53 +02:00
|
|
|
bool8 allowPostgameContestants = FALSE;
|
|
|
|
const u8 * filter;
|
2018-05-09 01:00:23 +02:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
TryPutPlayerLast();
|
2018-05-09 01:00:23 +02:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
if (FlagGet(FLAG_SYS_GAME_CLEAR) && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
|
2020-07-24 06:14:53 +02:00
|
|
|
allowPostgameContestants = TRUE;
|
2018-05-09 01:00:23 +02:00
|
|
|
|
|
|
|
// Find all suitable opponents
|
2020-07-24 06:14:53 +02:00
|
|
|
filter = gPostgameContestOpponentFilter;
|
2018-05-09 01:00:23 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(gContestOpponents); i++)
|
|
|
|
{
|
|
|
|
if (rank == gContestOpponents[i].whichRank)
|
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (allowPostgameContestants == TRUE)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (filter[i] == CONTEST_FILTER_NO_POSTGAME)
|
2018-05-09 01:00:23 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (filter[i] == CONTEST_FILTER_ONLY_POSTGAME)
|
2018-05-09 01:00:23 +02:00
|
|
|
continue;
|
|
|
|
}
|
2018-05-10 23:54:30 +02:00
|
|
|
if (contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
2018-05-10 23:54:30 +02:00
|
|
|
else if (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
2018-05-10 23:54:30 +02:00
|
|
|
else if (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
2018-05-10 23:54:30 +02:00
|
|
|
else if (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
2018-05-10 23:54:30 +02:00
|
|
|
else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
|
|
|
}
|
|
|
|
}
|
2018-12-05 15:31:01 +01:00
|
|
|
opponents[opponentsCount] = 0xFF;
|
2018-05-09 01:00:23 +02:00
|
|
|
|
|
|
|
// Choose three random opponents from the list
|
2020-07-24 06:14:53 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
|
2018-05-09 01:00:23 +02:00
|
|
|
{
|
|
|
|
u16 rnd = Random() % opponentsCount;
|
|
|
|
s32 j;
|
|
|
|
|
|
|
|
gContestMons[i] = gContestOpponents[opponents[rnd]];
|
2018-12-05 15:31:01 +01:00
|
|
|
for (j = rnd; opponents[j] != 0xFF; j++)
|
2018-05-09 01:00:23 +02:00
|
|
|
opponents[j] = opponents[j + 1];
|
|
|
|
opponentsCount--;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
CreateContestMonFromParty(gContestMonPartyIndex);
|
2018-05-09 01:00:23 +02:00
|
|
|
}
|
2018-05-10 23:54:30 +02:00
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
void SetLinkAIContestants(u8 contestType, u8 rank, bool32 isPostgame)
|
2018-05-10 23:54:30 +02:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
s32 i, j;
|
2018-05-10 23:54:30 +02:00
|
|
|
u8 opponentsCount = 0;
|
|
|
|
u8 opponents[100];
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
if (gNumLinkContestPlayers == CONTESTANT_COUNT)
|
2018-05-10 23:54:30 +02:00
|
|
|
return;
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
// Find all suitable AI opponents
|
2018-05-10 23:54:30 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(gContestOpponents); i++)
|
|
|
|
{
|
|
|
|
if (rank != gContestOpponents[i].whichRank)
|
|
|
|
continue;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2018-05-10 23:54:30 +02:00
|
|
|
if (isPostgame == TRUE)
|
|
|
|
{
|
2019-03-10 04:54:17 +01:00
|
|
|
if (gPostgameContestOpponentFilter[i] == CONTEST_FILTER_NO_POSTGAME)
|
2018-05-10 23:54:30 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-10 04:54:17 +01:00
|
|
|
if (gPostgameContestOpponentFilter[i] == CONTEST_FILTER_ONLY_POSTGAME)
|
2018-05-10 23:54:30 +02:00
|
|
|
continue;
|
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
if ((contestType == CONTEST_CATEGORY_COOL && gContestOpponents[i].aiPool_Cool)
|
|
|
|
|| (contestType == CONTEST_CATEGORY_BEAUTY && gContestOpponents[i].aiPool_Beauty)
|
|
|
|
|| (contestType == CONTEST_CATEGORY_CUTE && gContestOpponents[i].aiPool_Cute)
|
|
|
|
|| (contestType == CONTEST_CATEGORY_SMART && gContestOpponents[i].aiPool_Smart)
|
|
|
|
|| (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough))
|
2018-05-10 23:54:30 +02:00
|
|
|
opponents[opponentsCount++] = i;
|
|
|
|
}
|
2018-12-05 15:31:01 +01:00
|
|
|
opponents[opponentsCount] = 0xFF;
|
2020-07-24 06:14:53 +02:00
|
|
|
|
|
|
|
// Fill remaining contestant slots with random AI opponents from the list
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT - gNumLinkContestPlayers; i++)
|
2018-05-10 23:54:30 +02:00
|
|
|
{
|
2019-11-11 03:54:00 +01:00
|
|
|
u16 rnd = GetContestRand() % opponentsCount;
|
2018-05-10 23:54:30 +02:00
|
|
|
|
2019-01-03 18:54:22 +01:00
|
|
|
gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]];
|
2020-07-12 02:25:56 +02:00
|
|
|
StripPlayerNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].trainerName);
|
|
|
|
StripMonNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].nickname, GAME_LANGUAGE);
|
2018-12-05 15:31:01 +01:00
|
|
|
for (j = rnd; opponents[j] != 0xFF; j++)
|
2018-05-10 23:54:30 +02:00
|
|
|
opponents[j] = opponents[j + 1];
|
|
|
|
opponentsCount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
u8 GetContestEntryEligibility(struct Pokemon *pkmn)
|
2018-05-10 23:54:30 +02:00
|
|
|
{
|
|
|
|
u8 ribbon;
|
2019-10-31 19:11:55 +01:00
|
|
|
u8 eligibility;
|
2018-05-10 23:54:30 +02:00
|
|
|
|
|
|
|
if (GetMonData(pkmn, MON_DATA_IS_EGG))
|
2019-10-18 01:22:03 +02:00
|
|
|
return CANT_ENTER_CONTEST_EGG;
|
2018-05-10 23:54:30 +02:00
|
|
|
if (GetMonData(pkmn, MON_DATA_HP) == 0)
|
2019-10-18 01:22:03 +02:00
|
|
|
return CANT_ENTER_CONTEST_FAINTED;
|
2018-05-10 23:54:30 +02:00
|
|
|
switch (gSpecialVar_ContestCategory)
|
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
|
|
|
ribbon = GetMonData(pkmn, MON_DATA_COOL_RIBBON);
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
|
|
|
ribbon = GetMonData(pkmn, MON_DATA_BEAUTY_RIBBON);
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
|
|
|
ribbon = GetMonData(pkmn, MON_DATA_CUTE_RIBBON);
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
|
|
|
ribbon = GetMonData(pkmn, MON_DATA_SMART_RIBBON);
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
|
|
|
ribbon = GetMonData(pkmn, MON_DATA_TOUGH_RIBBON);
|
|
|
|
break;
|
|
|
|
default:
|
2019-10-18 01:22:03 +02:00
|
|
|
return CANT_ENTER_CONTEST;
|
2018-05-10 23:54:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Couldn't get this to match any other way.
|
|
|
|
// Returns 2, 1, or 0 respectively if ribbon's rank is above, equal, or below
|
|
|
|
// the current contest rank.
|
|
|
|
if (ribbon > gSpecialVar_ContestRank)
|
2019-10-31 19:11:55 +01:00
|
|
|
eligibility = CAN_ENTER_CONTEST_HIGH_RANK;
|
2018-05-10 23:54:30 +02:00
|
|
|
else if (ribbon >= gSpecialVar_ContestRank)
|
2019-10-31 19:11:55 +01:00
|
|
|
eligibility = CAN_ENTER_CONTEST_EQUAL_RANK;
|
2018-05-10 23:54:30 +02:00
|
|
|
else
|
2019-10-31 19:11:55 +01:00
|
|
|
eligibility = CANT_ENTER_CONTEST;
|
|
|
|
return eligibility;
|
2018-05-10 23:54:30 +02:00
|
|
|
}
|
2018-05-11 00:16:58 +02:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void DrawContestantWindowText(void)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
FillWindowPixelBuffer(gContestantTurnOrder[i], PIXEL_FILL(0));
|
2019-04-03 23:24:32 +02:00
|
|
|
PrintContestantTrainerName(i);
|
|
|
|
PrintContestantMonName(i);
|
2018-05-11 00:16:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static u8 *Contest_CopyStringWithColor(const u8 *string, u8 color)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
|
|
|
u8 * ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent);
|
2019-04-03 23:24:32 +02:00
|
|
|
ptr[-1] = color; // Overwrites the "{COLOR TRANSPARENT}" part of the string.
|
|
|
|
ptr = StringCopy(ptr, string);
|
2018-05-11 00:16:58 +02:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void PrintContestantTrainerName(u8 contestant)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
PrintContestantTrainerNameWithColor(contestant, contestant + CONTESTANT_TEXT_COLOR_START);
|
2018-05-11 00:16:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void PrintContestantTrainerNameWithColor(u8 contestant, u8 color)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
|
|
|
u8 buffer[32];
|
|
|
|
s32 offset;
|
|
|
|
|
|
|
|
StringCopy(buffer, gText_Slash);
|
2019-04-03 23:24:32 +02:00
|
|
|
StringAppend(buffer, gContestMons[contestant].trainerName);
|
|
|
|
Contest_CopyStringWithColor(buffer, color);
|
2021-10-30 22:47:37 +02:00
|
|
|
offset = GetStringRightAlignXOffset(FONT_NARROW, gDisplayedStringBattle, 0x60);
|
2018-05-11 00:16:58 +02:00
|
|
|
if (offset > 55)
|
|
|
|
offset = 55;
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, offset, 1, FONT_NARROW);
|
2018-05-11 00:16:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void PrintContestantMonName(u8 contestant)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
PrintContestantMonNameWithColor(contestant, contestant + CONTESTANT_TEXT_COLOR_START);
|
2018-05-11 00:16:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void PrintContestantMonNameWithColor(u8 contestant, u8 color)
|
2018-05-11 00:16:58 +02:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
Contest_CopyStringWithColor(gContestMons[contestant].nickname, color);
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, 5, 1, FONT_NARROW);
|
2018-05-11 00:16:58 +02:00
|
|
|
}
|
2018-05-11 01:28:52 +02:00
|
|
|
|
2020-08-13 09:09:47 +02:00
|
|
|
static u16 CalculateContestantRound1Points(u8 who, u8 contestCategory)
|
2018-05-11 01:28:52 +02:00
|
|
|
{
|
|
|
|
u8 statMain;
|
|
|
|
u8 statSub1;
|
|
|
|
u8 statSub2;
|
|
|
|
|
|
|
|
switch (contestCategory)
|
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case CONTEST_CATEGORY_COOL:
|
|
|
|
statMain = gContestMons[who].cool;
|
|
|
|
statSub1 = gContestMons[who].tough;
|
|
|
|
statSub2 = gContestMons[who].beauty;
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
|
|
|
statMain = gContestMons[who].beauty;
|
|
|
|
statSub1 = gContestMons[who].cool;
|
|
|
|
statSub2 = gContestMons[who].cute;
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
|
|
|
statMain = gContestMons[who].cute;
|
|
|
|
statSub1 = gContestMons[who].beauty;
|
|
|
|
statSub2 = gContestMons[who].smart;
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
|
|
|
statMain = gContestMons[who].smart;
|
|
|
|
statSub1 = gContestMons[who].cute;
|
|
|
|
statSub2 = gContestMons[who].tough;
|
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
|
|
|
default:
|
|
|
|
statMain = gContestMons[who].tough;
|
|
|
|
statSub1 = gContestMons[who].smart;
|
|
|
|
statSub2 = gContestMons[who].cool;
|
|
|
|
break;
|
2018-05-11 01:28:52 +02:00
|
|
|
}
|
|
|
|
return statMain + (statSub1 + statSub2 + gContestMons[who].sheen) / 2;
|
|
|
|
}
|
|
|
|
|
2020-08-13 09:09:47 +02:00
|
|
|
void CalculateRound1Points(u8 contestCategory)
|
2018-05-11 01:28:52 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-13 09:09:47 +02:00
|
|
|
gContestMonRound1Points[i] = CalculateContestantRound1Points(i, contestCategory);
|
2018-05-11 01:28:52 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u8 CreateJudgeSprite(void)
|
2018-05-11 01:28:52 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
LoadCompressedSpriteSheet(&sSpriteSheet_Judge);
|
2018-05-11 01:28:52 +02:00
|
|
|
LoadCompressedPalette(gContest2Pal, 0x110, 32);
|
2020-08-14 01:10:23 +02:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_Judge, 112, 36, 30);
|
2018-05-11 01:28:52 +02:00
|
|
|
gSprites[spriteId].oam.paletteNum = 1;
|
|
|
|
gSprites[spriteId].callback = SpriteCallbackDummy;
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u8 CreateJudgeSpeechBubbleSprite(void)
|
2018-05-11 01:28:52 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
LoadCompressedSpriteSheet(&sSpriteSheet_JudgeSymbols);
|
2020-08-14 01:10:23 +02:00
|
|
|
LoadCompressedSpritePalette(&sSpritePalette_JudgeSymbols);
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_JudgeSpeechBubble, 96, 10, 29);
|
2018-05-11 01:28:52 +02:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
gSprites[spriteId].data[0] = gSprites[spriteId].oam.tileNum;
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static u8 CreateContestantSprite(u16 species, u32 otId, u32 personality, u32 index)
|
2018-05-11 01:28:52 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
2019-01-06 08:02:28 +01:00
|
|
|
species = SanitizeSpecies(species);
|
2018-05-11 01:28:52 +02:00
|
|
|
|
|
|
|
if (index == gContestPlayerMonIndex)
|
2021-10-03 05:47:59 +02:00
|
|
|
HandleLoadSpecialPokePic_2(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], species, personality);
|
2018-05-11 01:28:52 +02:00
|
|
|
else
|
2021-10-03 05:47:59 +02:00
|
|
|
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], species, personality);
|
2018-05-11 01:28:52 +02:00
|
|
|
|
2019-07-25 18:56:08 +02:00
|
|
|
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x120, 0x20);
|
2021-10-03 05:47:59 +02:00
|
|
|
SetMultiuseSpriteTemplateToPokemon(species, B_POSITION_PLAYER_LEFT);
|
2018-05-11 01:28:52 +02:00
|
|
|
|
2018-10-06 23:04:53 +02:00
|
|
|
spriteId = CreateSprite(&gMultiuseSpriteTemplate, 0x70, GetBattlerSpriteFinal_Y(2, species, FALSE), 30);
|
2018-05-11 01:28:52 +02:00
|
|
|
gSprites[spriteId].oam.paletteNum = 2;
|
|
|
|
gSprites[spriteId].oam.priority = 2;
|
2018-12-18 05:08:08 +01:00
|
|
|
gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(2);
|
2018-05-11 01:28:52 +02:00
|
|
|
gSprites[spriteId].callback = SpriteCallbackDummy;
|
|
|
|
gSprites[spriteId].data[0] = gSprites[spriteId].oam.paletteNum;
|
|
|
|
gSprites[spriteId].data[2] = species;
|
|
|
|
if (IsSpeciesNotUnown(species))
|
2021-04-25 05:29:49 +02:00
|
|
|
gSprites[spriteId].affineAnims = gAffineAnims_BattleSpriteContest;
|
2018-05-11 01:28:52 +02:00
|
|
|
else
|
2021-01-23 05:22:37 +01:00
|
|
|
gSprites[spriteId].affineAnims = gAffineAnims_BattleSpriteOpponentSide;
|
2021-04-25 05:29:49 +02:00
|
|
|
StartSpriteAffineAnim(&gSprites[spriteId], BATTLER_AFFINE_NORMAL);
|
2018-05-11 01:28:52 +02:00
|
|
|
|
|
|
|
return spriteId;
|
|
|
|
}
|
2018-05-11 14:44:21 +02:00
|
|
|
|
|
|
|
bool8 IsSpeciesNotUnown(u16 species)
|
|
|
|
{
|
|
|
|
if (species == SPECIES_UNOWN)
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
// The contestant info windows and general-purpose text box are drawn on one half, while
|
|
|
|
// the moves and move description windows are drawn on another screen. Only the first 32 * 20
|
|
|
|
// tiles are actually drawn on screen.
|
|
|
|
static void SwapMoveDescAndContestTilemaps(void)
|
2018-05-11 14:44:21 +02:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
CpuCopy16(gContestResources->contestBgTilemaps[0], gContestResources->contestBgTilemaps[0] + 0x500, 32 * 20);
|
|
|
|
CpuCopy16(gContestResources->contestBgTilemaps[2], gContestResources->contestBgTilemaps[2] + 0x500, 32 * 20);
|
2018-05-11 14:44:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Functionally unused
|
|
|
|
static u16 GetMoveEffectSymbolTileOffset(u16 move, u8 contestant)
|
2018-05-11 14:44:21 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 offset;
|
2018-05-11 14:44:21 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
switch (gContestEffects[gContestMoves[move].effect].effectType)
|
2018-05-11 14:44:21 +02:00
|
|
|
{
|
2019-01-28 18:19:58 +01:00
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 8:
|
2020-08-14 01:10:23 +02:00
|
|
|
offset = 0x9082;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2020-08-14 01:10:23 +02:00
|
|
|
offset = 0x9088;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-08-14 01:10:23 +02:00
|
|
|
offset = 0x9086;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2018-05-11 14:44:21 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
offset += 0x9000 + (contestant << 12);
|
|
|
|
return offset;
|
2018-05-11 14:44:21 +02:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void PrintContestMoveDescription(u16 a)
|
2018-05-11 14:44:21 +02:00
|
|
|
{
|
|
|
|
u8 category;
|
|
|
|
u16 categoryTile;
|
|
|
|
u8 numHearts;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
// The contest category icon is implemented as a 5x2 group of tiles.
|
2018-05-11 14:44:21 +02:00
|
|
|
category = gContestMoves[a].contestCategory;
|
|
|
|
if (category == CONTEST_CATEGORY_COOL)
|
|
|
|
categoryTile = 0x4040;
|
|
|
|
else if (category == CONTEST_CATEGORY_BEAUTY)
|
|
|
|
categoryTile = 0x4045;
|
|
|
|
else if (category == CONTEST_CATEGORY_CUTE)
|
|
|
|
categoryTile = 0x404A;
|
|
|
|
else if (category == CONTEST_CATEGORY_SMART)
|
|
|
|
categoryTile = 0x406A;
|
|
|
|
else
|
|
|
|
categoryTile = 0x408A;
|
|
|
|
|
2018-05-11 16:51:38 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
|
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
|
2018-05-11 14:44:21 +02:00
|
|
|
|
2021-06-21 19:48:03 +02:00
|
|
|
// Appeal hearts
|
2018-12-05 15:31:01 +01:00
|
|
|
if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF)
|
2018-05-11 14:44:21 +02:00
|
|
|
numHearts = 0;
|
|
|
|
else
|
|
|
|
numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10;
|
2021-06-21 19:48:03 +02:00
|
|
|
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
|
|
|
|
numHearts = MAX_CONTEST_MOVE_HEARTS;
|
|
|
|
ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
|
|
|
|
ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11);
|
2018-05-11 14:44:21 +02:00
|
|
|
|
2021-06-21 19:48:03 +02:00
|
|
|
// Jam hearts
|
2018-12-05 15:31:01 +01:00
|
|
|
if (gContestEffects[gContestMoves[a].effect].jam == 0xFF)
|
2018-05-11 14:44:21 +02:00
|
|
|
numHearts = 0;
|
|
|
|
else
|
|
|
|
numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;
|
2021-06-21 19:48:03 +02:00
|
|
|
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
|
|
|
|
numHearts = MAX_CONTEST_MOVE_HEARTS;
|
|
|
|
ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
|
|
|
|
ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11);
|
2018-05-11 14:44:21 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
|
|
|
|
Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]);
|
|
|
|
Contest_PrintTextToBg0WindowStd(WIN_SLASH, gText_Slash);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DrawMoveEffectSymbol(u16 move, u8 contestant)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestantOffset = gContestantTurnOrder[contestant] * 5 + 2;
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!Contest_IsMonsTurnDisabled(contestant) && move != MOVE_NONE)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 tile = GetMoveEffectSymbolTileOffset(move, contestant);
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, tile, 20, contestantOffset, 2, 1, 17, 1);
|
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, tile + 16, 20, contestantOffset + 1, 2, 1, 17, 1);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithTile(0, 0, 20, contestantOffset, 2, 2, 17);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Unused
|
|
|
|
static void DrawMoveEffectSymbols(void)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-14 01:10:23 +02:00
|
|
|
DrawMoveEffectSymbol(eContestantStatus[i].currMove, i);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u16 GetStarTileOffset(void)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
|
|
|
return 0x2034;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static bool8 UpdateConditionStars(u8 contestantIdx, bool8 resetMod)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestantOffset;
|
|
|
|
s32 numStars;
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2020-08-18 17:38:50 +02:00
|
|
|
if (eContestantStatus[contestantIdx].conditionMod == CONDITION_NO_CHANGE)
|
2018-05-11 16:51:38 +02:00
|
|
|
return FALSE;
|
2020-08-14 01:10:23 +02:00
|
|
|
contestantOffset = gContestantTurnOrder[contestantIdx] * 5 + 2;
|
|
|
|
numStars = eContestantStatus[contestantIdx].condition / 10;
|
2020-08-18 17:38:50 +02:00
|
|
|
if (eContestantStatus[contestantIdx].conditionMod == CONDITION_GAIN)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithTile(0, GetStarTileOffset(), 19, contestantOffset, 1, numStars, 17);
|
2018-05-11 16:51:38 +02:00
|
|
|
if (resetMod)
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_EXP_MAX);
|
2020-08-18 17:38:50 +02:00
|
|
|
eContestantStatus[contestantIdx].conditionMod = CONDITION_NO_CHANGE;
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-18 17:38:50 +02:00
|
|
|
else // CONDITION_LOSE
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithTile(0, 0, 19, contestantOffset + numStars, 1, 3 - numStars, 17);
|
2018-05-11 16:51:38 +02:00
|
|
|
if (resetMod)
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_CONDITION_LOSE);
|
2020-08-18 17:38:50 +02:00
|
|
|
eContestantStatus[contestantIdx].conditionMod = CONDITION_NO_CHANGE;
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DrawConditionStars(void)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-08-14 01:10:23 +02:00
|
|
|
s32 numStars;
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestantOffset = gContestantTurnOrder[i] * 5 + 2;
|
|
|
|
u16 starOffset = GetStarTileOffset();
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
numStars = eContestantStatus[i].condition / 10;
|
|
|
|
ContestBG_FillBoxWithTile(0, starOffset, 19, contestantOffset, 1, numStars, 17);
|
|
|
|
ContestBG_FillBoxWithTile(0, 0, 19, contestantOffset + numStars, 1, 3 - numStars, 17);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u16 GetStatusSymbolTileOffset(u8 status)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 offset = 0;
|
2018-05-11 16:51:38 +02:00
|
|
|
|
|
|
|
switch (status)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
case STAT_SYMBOL_CIRCLE: // For resistant
|
|
|
|
offset = 0x80;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case STAT_SYMBOL_WAVE: // For nervous
|
|
|
|
offset = 0x84;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case STAT_SYMBOL_X: // For turn skipped
|
|
|
|
offset = 0x86;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case STAT_SYMBOL_SWIRL: // For jammed/unnerved
|
|
|
|
offset = 0x88;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case STAT_SYMBOL_SQUARE: // Never used
|
|
|
|
offset = 0x82;
|
2019-01-28 18:19:58 +01:00
|
|
|
break;
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
offset += 0x9000;
|
|
|
|
return offset;
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static bool8 DrawStatusSymbol(u8 contestant)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
bool8 statused = TRUE;
|
|
|
|
u16 symbolOffset = 0;
|
|
|
|
u8 contestantOffset = gContestantTurnOrder[contestant] * 5 + 2;
|
2018-05-11 16:51:38 +02:00
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
if (eContestantStatus[contestant].resistant
|
|
|
|
|| eContestantStatus[contestant].immune
|
|
|
|
|| eContestantStatus[contestant].jamSafetyCount != 0
|
2020-08-14 01:10:23 +02:00
|
|
|
|| eContestantStatus[contestant].jamReduction != 0)
|
|
|
|
symbolOffset = GetStatusSymbolTileOffset(STAT_SYMBOL_CIRCLE);
|
|
|
|
else if (eContestantStatus[contestant].nervous)
|
|
|
|
symbolOffset = GetStatusSymbolTileOffset(STAT_SYMBOL_WAVE);
|
|
|
|
else if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns)
|
|
|
|
symbolOffset = GetStatusSymbolTileOffset(STAT_SYMBOL_X);
|
2018-05-11 16:51:38 +02:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
statused = FALSE;
|
|
|
|
|
|
|
|
if (statused)
|
2018-05-11 16:51:38 +02:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, symbolOffset, 20, contestantOffset, 2, 1, 17, 1);
|
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, symbolOffset + 16, 20, contestantOffset + 1, 2, 1, 17, 1);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithTile(0, 0, 20, contestantOffset, 2, 2, 17);
|
2018-05-11 16:51:38 +02:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
return statused;
|
2018-05-11 14:44:21 +02:00
|
|
|
}
|
2018-12-19 17:53:43 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DrawStatusSymbols(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-14 01:10:23 +02:00
|
|
|
DrawStatusSymbol(i);
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void ContestClearGeneralTextWindow(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
FillWindowPixelBuffer(WIN_GENERAL_TEXT, PIXEL_FILL(0));
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(WIN_GENERAL_TEXT, COPYWIN_GFX);
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_SetBgCopyFlags(0);
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static u16 GetChosenMove(u8 contestant)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
if (Contest_IsMonsTurnDisabled(contestant))
|
2020-07-12 02:25:56 +02:00
|
|
|
return MOVE_NONE;
|
2019-04-04 02:43:23 +02:00
|
|
|
if (contestant == gContestPlayerMonIndex)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
return gContestMons[contestant].moves[eContest.playerMoveChoice];
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u8 moveChoice;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestAI_ResetAI(contestant);
|
2018-12-19 17:53:43 +01:00
|
|
|
moveChoice = ContestAI_GetActionToUse();
|
2019-04-04 02:43:23 +02:00
|
|
|
return gContestMons[contestant].moves[moveChoice];
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void GetAllChosenMoves(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-01-06 08:02:28 +01:00
|
|
|
s32 i;
|
2018-12-19 17:53:43 +01:00
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].currMove = GetChosenMove(i);
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void RankContestants(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
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
|
|
|
s32 i;
|
|
|
|
s32 j;
|
2019-04-04 02:43:23 +02:00
|
|
|
s16 arr[CONTESTANT_COUNT];
|
2018-12-19 17:53:43 +01:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[i].pointTotal += eContestantStatus[i].appeal;
|
2019-04-02 06:35:57 +02:00
|
|
|
arr[i] = eContestantStatus[i].pointTotal;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
2019-04-02 06:35:57 +02:00
|
|
|
|
|
|
|
// Sort the point totals using bubble-sort.
|
2020-08-14 01:10:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
for (j = CONTESTANT_COUNT - 1; j > i; j--)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
if (arr[j - 1] < arr[j])
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 temp;
|
|
|
|
SWAP(arr[j], arr[j - 1], temp);
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-02 06:35:57 +02:00
|
|
|
|
|
|
|
// For each contestant, find the best rank with their point total.
|
|
|
|
// Normally, each point total is different, and this will output the
|
|
|
|
// rankings as expected. However, if two pokemon are tied, then they
|
|
|
|
// both get the best rank for that point total.
|
|
|
|
//
|
|
|
|
// For example if the point totals are [100, 80, 80, 50], the ranks will
|
|
|
|
// be [1, 2, 2, 4]. The pokemon with a point total of 80 stop looking
|
|
|
|
// when they see the first 80 in the array, so they both share the '2'
|
|
|
|
// rank.
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[i].pointTotal == arr[j])
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].ranking = j;
|
2018-12-19 17:53:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
SortContestants(TRUE);
|
2019-04-03 02:46:18 +02:00
|
|
|
ApplyNextTurnOrder();
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
static void SetAttentionLevels(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
u8 attentionLevel;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[i].currMove == MOVE_NONE)
|
2018-12-19 17:53:43 +01:00
|
|
|
attentionLevel = 5;
|
2020-08-16 11:52:17 +02:00
|
|
|
else if (eContestantStatus[i].appeal <= 0)
|
2018-12-19 17:53:43 +01:00
|
|
|
attentionLevel = 0;
|
2020-08-16 11:52:17 +02:00
|
|
|
else if (eContestantStatus[i].appeal < 30)
|
2018-12-19 17:53:43 +01:00
|
|
|
attentionLevel = 1;
|
2020-08-16 11:52:17 +02:00
|
|
|
else if (eContestantStatus[i].appeal < 60)
|
2018-12-19 17:53:43 +01:00
|
|
|
attentionLevel = 2;
|
2020-08-16 11:52:17 +02:00
|
|
|
else if (eContestantStatus[i].appeal < 80)
|
2018-12-19 17:53:43 +01:00
|
|
|
attentionLevel = 3;
|
|
|
|
else
|
|
|
|
attentionLevel = 4;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].attentionLevel = attentionLevel;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static bool8 ContestantCanUseTurn(u8 contestant)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns)
|
2018-12-19 17:53:43 +01:00
|
|
|
return FALSE;
|
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
|
|
|
else
|
|
|
|
return TRUE;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-08-21 08:36:48 +02:00
|
|
|
static void SetContestantStatusesForNextRound(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[i].appeal = 0;
|
|
|
|
eContestantStatus[i].baseAppeal = 0;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].jamSafetyCount = 0;
|
|
|
|
if (eContestantStatus[i].numTurnsSkipped > 0)
|
|
|
|
eContestantStatus[i].numTurnsSkipped--;
|
|
|
|
eContestantStatus[i].jam = 0;
|
|
|
|
eContestantStatus[i].resistant = 0;
|
|
|
|
eContestantStatus[i].jamReduction = 0;
|
|
|
|
eContestantStatus[i].immune = 0;
|
|
|
|
eContestantStatus[i].moreEasilyStartled = 0;
|
|
|
|
eContestantStatus[i].usedRepeatableMove = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
eContestantStatus[i].nervous = FALSE;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].effectStringId = CONTEST_STRING_NONE;
|
|
|
|
eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE;
|
2020-08-18 17:38:50 +02:00
|
|
|
eContestantStatus[i].conditionMod = CONDITION_NO_CHANGE;
|
2020-07-12 02:25:56 +02:00
|
|
|
eContestantStatus[i].repeatedPrevMove = eContestantStatus[i].repeatedMove;
|
|
|
|
eContestantStatus[i].repeatedMove = FALSE;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].turnOrderModAction = 0;
|
|
|
|
eContestantStatus[i].appealTripleCondition = 0;
|
|
|
|
if (eContestantStatus[i].turnSkipped)
|
|
|
|
{
|
|
|
|
eContestantStatus[i].numTurnsSkipped = 1;
|
|
|
|
eContestantStatus[i].turnSkipped = 0;
|
|
|
|
}
|
|
|
|
if (eContestantStatus[i].exploded)
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
eContestantStatus[i].noMoreTurns = TRUE;
|
|
|
|
eContestantStatus[i].exploded = FALSE;
|
2019-04-02 06:35:57 +02:00
|
|
|
}
|
|
|
|
eContestantStatus[i].overrideCategoryExcitementMod = 0;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].prevMove = eContestantStatus[i].currMove;
|
2020-07-24 06:14:53 +02:00
|
|
|
eContest.moveHistory[eContest.appealNumber][i] = eContestantStatus[i].currMove;
|
|
|
|
eContest.excitementHistory[eContest.appealNumber][i] = Contest_GetMoveExcitement(eContestantStatus[i].currMove);
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].currMove = MOVE_NONE;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestExcitement.frozen = FALSE;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-07-24 06:14:53 +02:00
|
|
|
bool8 Contest_IsMonsTurnDisabled(u8 contestant)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (eContestantStatus[contestant].numTurnsSkipped != 0 || eContestantStatus[contestant].noMoreTurns)
|
2018-12-19 17:53:43 +01:00
|
|
|
return TRUE;
|
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
|
|
|
else
|
|
|
|
return FALSE;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
static void CalculateTotalPointsForContestant(u8 contestant)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-06-17 23:48:20 +02:00
|
|
|
gContestMonRound2Points[contestant] = GetContestantRound2Points(contestant);
|
2020-07-24 06:14:53 +02:00
|
|
|
gContestMonTotalPoints[contestant] = gContestMonRound1Points[contestant] + gContestMonRound2Points[contestant];
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
static void CalculateFinalScores(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-06-17 23:48:20 +02:00
|
|
|
CalculateTotalPointsForContestant(i);
|
2018-12-19 17:53:43 +01:00
|
|
|
DetermineFinalStandings();
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:48:20 +02:00
|
|
|
static s16 GetContestantRound2Points(u8 contestant)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
return gContestMonAppealPointTotals[contestant] * 2;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static void DetermineFinalStandings(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
u16 randomOrdering[CONTESTANT_COUNT] = {0};
|
2020-08-14 01:10:23 +02:00
|
|
|
struct ContestFinalStandings standings[CONTESTANT_COUNT];
|
2018-12-19 17:53:43 +01:00
|
|
|
s32 i;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Seed random order in case of ties
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
s32 j;
|
2019-04-04 02:43:23 +02:00
|
|
|
randomOrdering[i] = Random();
|
2020-08-14 01:10:23 +02:00
|
|
|
for (j = 0; j < i; j++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (randomOrdering[i] == randomOrdering[j])
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Init data for ranking contestants
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
standings[i].totalPoints = gContestMonTotalPoints[i];
|
|
|
|
standings[i].round1Points = gContestMonRound1Points[i];
|
|
|
|
standings[i].random = randomOrdering[i];
|
|
|
|
standings[i].contestant = i;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Rank contestants
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
s32 j;
|
|
|
|
for (j = CONTESTANT_COUNT - 1; j > i; j--)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (DidContestantPlaceHigher(j - 1, j, standings))
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Swap contestants in array
|
|
|
|
struct ContestFinalStandings temp;
|
|
|
|
|
|
|
|
temp.totalPoints = standings[j - 1].totalPoints;
|
|
|
|
temp.round1Points = standings[j - 1].round1Points;
|
|
|
|
temp.random = standings[j - 1].random;
|
|
|
|
temp.contestant = standings[j - 1].contestant;
|
|
|
|
|
|
|
|
standings[j - 1].totalPoints = standings[j].totalPoints;
|
|
|
|
standings[j - 1].round1Points = standings[j].round1Points;
|
|
|
|
standings[j - 1].random = standings[j].random;
|
|
|
|
standings[j - 1].contestant = standings[j].contestant;
|
|
|
|
|
|
|
|
standings[j].totalPoints = temp.totalPoints;
|
|
|
|
standings[j].round1Points = temp.round1Points;
|
|
|
|
standings[j].random = temp.random;
|
|
|
|
standings[j].contestant = temp.contestant;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Assign placements. i is the placing (0 is 1st, 1 is 2nd...)
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestFinalStandings[standings[i].contestant] = i;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
void SaveLinkContestResults(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] =
|
2019-01-28 05:21:30 +01:00
|
|
|
((gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1) > 9999) ? 9999 :
|
2018-12-19 17:53:43 +01:00
|
|
|
(gSaveBlock2Ptr->contestLinkResults[gSpecialVar_ContestCategory][gContestFinalStandings[gContestPlayerMonIndex]] + 1);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static bool8 DidContestantPlaceHigher(s32 a, s32 b, struct ContestFinalStandings *standings)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-01-06 08:02:28 +01:00
|
|
|
bool8 retVal;
|
2018-12-19 17:53:43 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Rank contestants first based on total points
|
|
|
|
if (standings[a].totalPoints < standings[b].totalPoints)
|
2018-12-19 17:53:43 +01:00
|
|
|
retVal = TRUE;
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (standings[a].totalPoints > standings[b].totalPoints)
|
2018-12-19 17:53:43 +01:00
|
|
|
retVal = FALSE;
|
2020-08-14 01:10:23 +02:00
|
|
|
// If tied, rank on round 1 points
|
|
|
|
else if (standings[a].round1Points < standings[b].round1Points)
|
2018-12-19 17:53:43 +01:00
|
|
|
retVal = TRUE;
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (standings[a].round1Points > standings[b].round1Points)
|
2018-12-19 17:53:43 +01:00
|
|
|
retVal = FALSE;
|
2020-08-14 01:10:23 +02:00
|
|
|
// If tied again, choose randomly
|
|
|
|
else if (standings[a].random < standings[b].random)
|
2018-12-19 17:53:43 +01:00
|
|
|
retVal = TRUE;
|
|
|
|
else
|
|
|
|
retVal = FALSE;
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
static void ContestPrintLinkStandby(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-01-06 08:02:28 +01:00
|
|
|
gBattle_BG0_Y = 0;
|
|
|
|
gBattle_BG2_Y = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2019-04-03 23:24:32 +02:00
|
|
|
Contest_StartTextPrinter(gText_LinkStandby4, 0);
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void FillContestantWindowBgs(void)
|
2018-12-19 17:53:43 +01:00
|
|
|
{
|
2019-01-06 08:02:28 +01:00
|
|
|
int i;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
for(i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-20 20:39:00 +01:00
|
|
|
ContestBG_FillBoxWithTile(0, 0, 0x16, 2 + i * 5, 8, 2, 0x11);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u16 GetAppealHeartTileOffset(u8 contestant)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 offset;
|
2018-12-20 20:39:00 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (contestant == 0)
|
|
|
|
offset = 0x5011;
|
|
|
|
else if (contestant == 1)
|
|
|
|
offset = 0x6011;
|
|
|
|
else if (contestant == 2)
|
|
|
|
offset = 0x7011;
|
2018-12-20 20:39:00 +01:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
offset = 0x8011;
|
|
|
|
return offset + 1;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static s8 GetNumHeartsFromAppealPoints(s16 appeal)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
s8 hearts = appeal / 10;
|
2018-12-20 20:39:00 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (hearts > 16)
|
|
|
|
hearts = 16;
|
|
|
|
else if (hearts < -16)
|
|
|
|
hearts = -16;
|
|
|
|
return hearts;
|
2018-12-19 17:53:43 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define tNumHearts data[0]
|
|
|
|
#define tHeartsDelta data[1]
|
|
|
|
#define tHeartsSign data[2]
|
|
|
|
#define tContestant data[3]
|
|
|
|
#define tDelayTimer data[10]
|
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
static u8 UpdateAppealHearts(s16 startAppeal, s16 appealDelta, u8 contestant)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
2020-08-14 01:10:23 +02:00
|
|
|
s8 startHearts;
|
|
|
|
s8 heartsDelta;
|
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[contestant].updatingAppealHearts = TRUE;
|
2020-08-14 01:10:23 +02:00
|
|
|
taskId = CreateTask(Task_UpdateAppealHearts, 20);
|
|
|
|
startHearts = GetNumHeartsFromAppealPoints(startAppeal);
|
2020-08-15 20:33:08 +02:00
|
|
|
heartsDelta = GetNumHeartsFromAppealPoints(startAppeal + appealDelta) - startHearts;
|
2020-08-14 01:10:23 +02:00
|
|
|
GetAppealHeartTileOffset(contestant); // unused return value
|
|
|
|
gTasks[taskId].tNumHearts = abs(startHearts);
|
|
|
|
gTasks[taskId].tHeartsDelta = heartsDelta;
|
|
|
|
if (startHearts > 0 || (startHearts == 0 && heartsDelta > 0))
|
|
|
|
gTasks[taskId].tHeartsSign = 1;
|
2018-12-20 20:39:00 +01:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tHeartsSign = -1;
|
|
|
|
gTasks[taskId].tContestant = contestant;
|
2019-01-06 08:02:28 +01:00
|
|
|
return taskId;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateAppealHearts(u8 taskId)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestant = gTasks[taskId].tContestant;
|
|
|
|
s16 startHearts = gTasks[taskId].tNumHearts;
|
|
|
|
s16 heartsDelta = gTasks[taskId].tHeartsDelta;
|
2018-12-20 20:39:00 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (++gTasks[taskId].tDelayTimer > 14)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 heartOffset;
|
|
|
|
u8 newNumHearts;
|
|
|
|
u8 pitchMod;
|
|
|
|
bool8 onSecondLine;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tDelayTimer = 0;
|
|
|
|
if (gTasks[taskId].tHeartsDelta == 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// No more hearts to add/remove, end
|
2018-12-20 20:39:00 +01:00
|
|
|
DestroyTask(taskId);
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[contestant].updatingAppealHearts = FALSE;
|
2018-12-20 20:39:00 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
else if (startHearts == 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (heartsDelta < 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Losing hearts, get black heart offset
|
|
|
|
heartOffset = GetAppealHeartTileOffset(contestant) + 2;
|
|
|
|
gTasks[taskId].tHeartsDelta++;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Gaining hearts, get red heart offset
|
|
|
|
heartOffset = GetAppealHeartTileOffset(contestant);
|
|
|
|
gTasks[taskId].tHeartsDelta--;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
newNumHearts = gTasks[taskId].tNumHearts++;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].tHeartsSign < 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Hearts currently black (negative)
|
|
|
|
if (heartsDelta < 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Losing points, add black heart
|
|
|
|
newNumHearts = gTasks[taskId].tNumHearts++;
|
|
|
|
gTasks[taskId].tHeartsDelta++;
|
|
|
|
heartOffset = GetAppealHeartTileOffset(contestant) + 2;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Gaining points, remove black heart
|
|
|
|
newNumHearts = --gTasks[taskId].tNumHearts;
|
|
|
|
heartOffset = 0;
|
|
|
|
gTasks[taskId].tHeartsDelta--;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Hearts currently red (positive)
|
|
|
|
if (heartsDelta < 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Losing points, remove red heart
|
|
|
|
newNumHearts = --gTasks[taskId].tNumHearts;
|
|
|
|
heartOffset = 0;
|
|
|
|
gTasks[taskId].tHeartsDelta++;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Gaining points, add red heart
|
|
|
|
newNumHearts = gTasks[taskId].tNumHearts++;
|
|
|
|
gTasks[taskId].tHeartsDelta--;
|
|
|
|
heartOffset = GetAppealHeartTileOffset(contestant);
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
pitchMod = newNumHearts;
|
|
|
|
onSecondLine = FALSE;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Check if wrapping to second line of hearts
|
|
|
|
if (newNumHearts > 7)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
onSecondLine = TRUE;
|
|
|
|
newNumHearts -= 8;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithTile(0, heartOffset, newNumHearts + 22, gContestantTurnOrder[contestant] * 5 + 2 + onSecondLine, 1, 1, 17);
|
|
|
|
if (heartsDelta > 0)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_HEART);
|
2018-12-20 20:39:00 +01:00
|
|
|
m4aMPlayImmInit(&gMPlayInfo_SE1);
|
2021-10-09 17:33:37 +02:00
|
|
|
m4aMPlayPitchControl(&gMPlayInfo_SE1, TRACKS_ALL, pitchMod * 256);
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
else
|
2019-01-28 05:48:18 +01:00
|
|
|
{
|
2018-12-20 20:39:00 +01:00
|
|
|
PlaySE(SE_BOO);
|
2019-01-28 05:48:18 +01:00
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!onSecondLine && newNumHearts == 0 && heartOffset == 0)
|
|
|
|
gTasks[taskId].tHeartsSign = -gTasks[taskId].tHeartsSign;
|
2018-12-20 20:39:00 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void CreateSliderHeartSprites(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
LoadSpriteSheet(&sSpriteSheet_SliderHeart);
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
u8 y = sSliderHeartYPositions[gContestantTurnOrder[i]];
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[i].sliderHeartSpriteId = CreateSprite(&sSpriteTemplate_SliderHeart, 180, y, 1);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
#define sContestant data[0]
|
|
|
|
#define sTargetX data[1]
|
|
|
|
#define sMoveX data[2]
|
|
|
|
|
|
|
|
static void UpdateHeartSlider(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
2020-07-12 02:25:56 +02:00
|
|
|
s16 slideTarget;
|
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[contestant].sliderUpdating = TRUE;
|
|
|
|
spriteId = eContestGfxState[contestant].sliderHeartSpriteId;
|
2020-07-12 02:25:56 +02:00
|
|
|
slideTarget = eContestantStatus[contestant].pointTotal / 10 * 2;
|
|
|
|
if (slideTarget > 56)
|
|
|
|
slideTarget = 56;
|
|
|
|
else if (slideTarget < 0)
|
|
|
|
slideTarget = 0;
|
2018-12-25 00:10:36 +01:00
|
|
|
gSprites[spriteId].invisible = FALSE;
|
2020-07-12 02:25:56 +02:00
|
|
|
gSprites[spriteId].sContestant = contestant;
|
|
|
|
gSprites[spriteId].sTargetX = slideTarget;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (gSprites[spriteId].sTargetX > gSprites[spriteId].x2)
|
2020-07-12 02:25:56 +02:00
|
|
|
gSprites[spriteId].sMoveX = 1;
|
2018-12-25 00:10:36 +01:00
|
|
|
else
|
2020-07-12 02:25:56 +02:00
|
|
|
gSprites[spriteId].sMoveX = -1;
|
|
|
|
gSprites[spriteId].callback = SpriteCB_UpdateHeartSlider;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void UpdateHeartSliders(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-07-12 02:25:56 +02:00
|
|
|
UpdateHeartSlider(i);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static bool8 SlidersDoneUpdating(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
if (eContestGfxState[i].sliderUpdating)
|
2018-12-25 00:10:36 +01:00
|
|
|
break;
|
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
if (i == CONTESTANT_COUNT)
|
2018-12-25 00:10:36 +01:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void SpriteCB_UpdateHeartSlider(struct Sprite *sprite)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->x2 == sprite->sTargetX)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[sprite->sContestant].sliderUpdating = FALSE;
|
2018-12-25 00:10:36 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += sprite->sMoveX;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
#undef sContestant
|
|
|
|
#undef sTargetX
|
|
|
|
#undef sMoveX
|
|
|
|
|
|
|
|
// Y positions change as the contestants change order
|
|
|
|
static void UpdateSliderHeartSpriteYPositions(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].y = sSliderHeartYPositions[gContestantTurnOrder[i]];
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
// Used to hide (or subsequently reshow) the bottom two slider hearts that get hidden by text windows by moving them offscreen
|
|
|
|
static void SetBottomSliderHeartsInvisibility(bool8 invisible)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Skip the top two contestants sliders
|
2019-04-03 02:00:05 +02:00
|
|
|
if (gContestantTurnOrder[i] > 1)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if (!invisible)
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].x = 180;
|
2018-12-25 00:10:36 +01:00
|
|
|
else
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].x = 256;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void CreateNextTurnSprites(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
LoadSpritePalette(&sSpritePalette_NextTurn);
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
LoadCompressedSpriteSheet(&sSpriteSheet_NextTurn[i]);
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[i].nextTurnSpriteId = CreateSprite(&sSpriteTemplates_NextTurn[i],
|
2019-01-28 12:29:47 +01:00
|
|
|
204,
|
2020-07-12 02:25:56 +02:00
|
|
|
sNextTurnSpriteYPositions[gContestantTurnOrder[i]],
|
2019-01-28 05:48:18 +01:00
|
|
|
0);
|
2020-08-15 20:33:08 +02:00
|
|
|
SetSubspriteTables(&gSprites[eContestGfxState[i].nextTurnSpriteId], sSubspriteTable_NextTurn);
|
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].invisible = TRUE;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static void CreateApplauseMeterSprite(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
LoadCompressedSpriteSheet(&sSpriteSheet_ApplauseMeter);
|
|
|
|
LoadSpritePalette(&sSpritePalette_ApplauseMeter);
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_ApplauseMeter, 30, 44, 1);
|
2018-12-25 00:10:36 +01:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContest.applauseMeterSpriteId = spriteId;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CreateJudgeAttentionEyeTask(void)
|
2018-12-20 20:39:00 +01:00
|
|
|
{
|
2018-12-25 00:10:36 +01:00
|
|
|
u8 i;
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 taskId = CreateTask(Task_FlashJudgeAttentionEye, 30);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.judgeAttentionTaskId = taskId;
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
gTasks[taskId].data[i * 4] = 0xFF;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void StartFlashJudgeAttentionEye(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 0] = 0;
|
|
|
|
gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 1] = 0;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void StopFlashJudgeAttentionEye(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 taskId = CreateTask(Task_StopFlashJudgeAttentionEye, 31);
|
|
|
|
gTasks[taskId].data[0] = contestant;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_StopFlashJudgeAttentionEye(u8 taskId)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 contestant = gTasks[taskId].data[0];
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 0] == 0
|
|
|
|
|| gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 0] == 0xFF)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 0] = 0xFF;
|
|
|
|
gTasks[eContest.judgeAttentionTaskId].data[contestant * 4 + 1] = 0;
|
2020-08-16 11:07:44 +02:00
|
|
|
BlendPalette((eContest.prevTurnOrder[contestant] + 5) * 16 + 6, 2, 0, RGB(31, 31, 18));
|
2018-12-25 00:10:36 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_FlashJudgeAttentionEye(u8 taskId)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 offset = i * 4;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].data[offset + 0] != 0xFF)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].data[offset + 1] == 0)
|
|
|
|
gTasks[taskId].data[offset + 0]++;
|
2018-12-25 00:10:36 +01:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].data[offset + 0]--;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].data[offset + 0] == 16
|
|
|
|
|| gTasks[taskId].data[offset + 0] == 0)
|
|
|
|
gTasks[taskId].data[offset + 1] ^= 1;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
BlendPalette((eContest.prevTurnOrder[i] + 5) * 16 + 6, 2, gTasks[taskId].data[offset + 0], RGB(31, 31, 18));
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Note: While the below task is run for the entire Appeals portion of the contest,
|
|
|
|
// because data[i * 4] is always 0xFF it never does anything
|
|
|
|
// If turned on by setting that data between 0 and 16, it blends
|
|
|
|
// an odd selection of palette colors (e.g. the text box, the appeal hearts
|
|
|
|
// for only one contestant, the heart outlines in the move selection box, etc)
|
|
|
|
// Given the similarities, it's possible this was an incorrect attempt
|
|
|
|
// at something similar to what CreateJudgeAttentionEyeTask does
|
|
|
|
static void CreateUnusedBlendTask(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
eContest.blendTaskId = CreateTask(Task_UnusedBlend, 30);
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-16 11:07:44 +02:00
|
|
|
InitUnusedBlendTaskData(i);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void InitUnusedBlendTaskData(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gTasks[eContest.blendTaskId].data[contestant * 4] = 0xFF;
|
|
|
|
gTasks[eContest.blendTaskId].data[contestant * 4 + 1] = 0;
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void UpdateBlendTaskContestantsData(void)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-16 11:07:44 +02:00
|
|
|
UpdateBlendTaskContestantData(i);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void UpdateBlendTaskContestantData(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
u32 palOffset1;
|
|
|
|
u32 palOffset2;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
InitUnusedBlendTaskData(contestant);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
palOffset1 = contestant + 5;
|
2019-01-28 12:29:47 +01:00
|
|
|
DmaCopy16Defvars(3,
|
2020-08-16 11:07:44 +02:00
|
|
|
gPlttBufferUnfaded + palOffset1 * 16 + 10,
|
|
|
|
gPlttBufferFaded + palOffset1 * 16 + 10,
|
2019-01-28 05:48:18 +01:00
|
|
|
2);
|
2020-08-16 11:07:44 +02:00
|
|
|
palOffset2 = (contestant + 5) * 16 + 12 + contestant;
|
2019-01-28 12:29:47 +01:00
|
|
|
DmaCopy16Defvars(3,
|
2020-08-16 11:07:44 +02:00
|
|
|
gPlttBufferUnfaded + palOffset2,
|
|
|
|
gPlttBufferFaded + palOffset2,
|
2019-01-28 05:48:18 +01:00
|
|
|
2);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// See comments on CreateUnusedBlendTask
|
|
|
|
static void Task_UnusedBlend(u8 taskId)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 idx = i * 4;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Below is never true
|
|
|
|
if (gTasks[taskId].data[idx] != 0xFF)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (++gTasks[taskId].data[idx + 2] > 2)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].data[idx + 2] = 0;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].data[idx + 1] == 0)
|
2020-08-16 11:07:44 +02:00
|
|
|
gTasks[taskId].data[idx]++;
|
2018-12-25 00:10:36 +01:00
|
|
|
else
|
2020-08-16 11:07:44 +02:00
|
|
|
gTasks[taskId].data[idx]--;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
if (gTasks[taskId].data[idx] == 16
|
|
|
|
|| gTasks[taskId].data[idx] == 0)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].data[idx + 1] ^= 1;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
BlendPalette((i + 5) * 16 + 10, 1, gTasks[taskId].data[idx + 0], RGB(31, 31, 18));
|
|
|
|
BlendPalette((i + 5) * 16 + 12 + i, 1, gTasks[taskId].data[idx + 0], RGB(31, 31, 18));
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void StartStopFlashJudgeAttentionEye(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
if (eContestantStatus[contestant].hasJudgesAttention)
|
2020-08-14 01:10:23 +02:00
|
|
|
StartFlashJudgeAttentionEye(contestant);
|
2018-12-25 00:10:36 +01:00
|
|
|
else
|
2020-08-14 01:10:23 +02:00
|
|
|
StopFlashJudgeAttentionEye(contestant);
|
2018-12-25 00:10:36 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static u8 CreateContestantBoxBlinkSprites(u8 contestant)
|
2018-12-25 00:10:36 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
u8 spriteId1, spriteId2;
|
2019-04-04 02:43:23 +02:00
|
|
|
u8 x = gContestantTurnOrder[contestant] * 40 + 32;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
LoadCompressedSpriteSheet(&sSpriteSheets_ContestantsTurnBlinkEffect[contestant]);
|
|
|
|
LoadSpritePalette(&sSpritePalettes_ContestantsTurnBlinkEffect[contestant]);
|
|
|
|
spriteId1 = CreateSprite(&sSpriteTemplates_ContestantsTurnBlinkEffect[contestant], 184, x, 29);
|
|
|
|
spriteId2 = CreateSprite(&sSpriteTemplates_ContestantsTurnBlinkEffect[contestant], 248, x, 29);
|
2019-01-28 12:29:47 +01:00
|
|
|
gSprites[spriteId2].oam.tileNum += 64;
|
|
|
|
|
|
|
|
CopySpriteTiles(0,
|
|
|
|
3,
|
|
|
|
(void *)VRAM,
|
2019-04-04 02:43:23 +02:00
|
|
|
(u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[contestant] * 5 * 64 + 0x26),
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestResources->boxBlinkTiles1);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
|
|
|
CopySpriteTiles(0,
|
|
|
|
3, (void *)VRAM,
|
2019-04-04 02:43:23 +02:00
|
|
|
(u16 *)(BG_SCREEN_ADDR(28) + gContestantTurnOrder[contestant] * 5 * 64 + 0x36),
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestResources->boxBlinkTiles2);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
CpuFill32(0, gContestResources->boxBlinkTiles1 + 0x500, 0x300);
|
|
|
|
CpuFill32(0, gContestResources->boxBlinkTiles2 + 0x500, 0x300);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
RequestDma3Copy(gContestResources->boxBlinkTiles1,
|
2020-09-02 20:14:29 +02:00
|
|
|
(u8 *)(OBJ_VRAM0 + gSprites[spriteId1].oam.tileNum * 32),
|
2019-01-28 12:29:47 +01:00
|
|
|
0x800,
|
|
|
|
1);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
RequestDma3Copy(gContestResources->boxBlinkTiles2,
|
2020-09-02 20:14:29 +02:00
|
|
|
(u8 *)(OBJ_VRAM0 + gSprites[spriteId2].oam.tileNum * 32),
|
2019-01-28 12:29:47 +01:00
|
|
|
0x800,
|
|
|
|
1);
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2019-01-28 12:29:47 +01:00
|
|
|
gSprites[spriteId1].data[0] = spriteId2;
|
|
|
|
gSprites[spriteId2].data[0] = spriteId1;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
gSprites[spriteId1].data[1] = contestant;
|
|
|
|
gSprites[spriteId2].data[1] = contestant;
|
2018-12-25 00:10:36 +01:00
|
|
|
|
2019-01-28 12:29:47 +01:00
|
|
|
return spriteId1;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DestroyContestantBoxBlinkSprites(u8 spriteId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
u8 spriteId2 = gSprites[spriteId].data[0];
|
|
|
|
|
|
|
|
FreeSpriteOamMatrix(&gSprites[spriteId2]);
|
|
|
|
DestroySprite(&gSprites[spriteId2]);
|
|
|
|
DestroySpriteAndFreeResources(&gSprites[spriteId]);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetBlendForContestantBoxBlink(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 05:48:18 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
|
2019-01-28 05:54:21 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 9));
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void ResetBlendForContestantBoxBlink(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// To indicate whose turn is up
|
|
|
|
static void BlinkContestantBox(u8 spriteId, bool8 b)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 spriteId2;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBlendForContestantBoxBlink();
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[gSprites[spriteId].data[1]].boxBlinking = TRUE;
|
2020-08-14 01:10:23 +02:00
|
|
|
spriteId2 = gSprites[spriteId].data[0];
|
|
|
|
StartSpriteAffineAnim(&gSprites[spriteId], 1);
|
|
|
|
StartSpriteAffineAnim(&gSprites[spriteId2], 1);
|
|
|
|
gSprites[spriteId].callback = SpriteCB_BlinkContestantBox;
|
|
|
|
gSprites[spriteId2].callback = SpriteCallbackDummy;
|
2019-01-06 08:02:28 +01:00
|
|
|
if (b == FALSE)
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_MONS_TURN);
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
|
|
|
PlaySE(SE_PC_LOGIN);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_BlinkContestantBox(struct Sprite *sprite)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (sprite->affineAnimEnded)
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 spriteId2 = sprite->data[0];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gSprites[spriteId2].affineAnimEnded)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
sprite->invisible = TRUE;
|
2020-08-14 01:10:23 +02:00
|
|
|
gSprites[spriteId2].invisible = TRUE;
|
|
|
|
sprite->callback = SpriteCB_EndBlinkContestantBox;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_EndBlinkContestantBox(struct Sprite *sprite)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestGfxState[sprite->data[1]].boxBlinking = FALSE;
|
2020-08-14 01:10:23 +02:00
|
|
|
DestroyContestantBoxBlinkSprites(sprite->data[0]);
|
|
|
|
ResetBlendForContestantBoxBlink();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
// Unused.
|
2019-04-03 03:51:21 +02:00
|
|
|
static void ContestDebugTogglePointTotal(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
if(eContestDebugMode == CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL)
|
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_OFF;
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
2019-04-03 03:51:21 +02:00
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
if(eContestDebugMode == CONTEST_DEBUG_MODE_OFF)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
DrawContestantWindowText();
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
2019-01-28 05:48:18 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugDoPrint();
|
2019-01-28 05:48:18 +01:00
|
|
|
}
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static void ContestDebugDoPrint(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
u8 i;
|
|
|
|
s16 value;
|
|
|
|
u8 *txtPtr;
|
|
|
|
u8 text[8];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
if (!gEnableContestDebugging)
|
2019-01-28 12:29:47 +01:00
|
|
|
return;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
switch (eContestDebugMode)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
case CONTEST_DEBUG_MODE_OFF:
|
2019-01-28 12:29:47 +01:00
|
|
|
break;
|
2020-08-16 11:07:44 +02:00
|
|
|
case CONTEST_DEBUG_MODE_PRINT_WINNER_FLAGS:
|
|
|
|
case CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS:
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugPrintBitStrings();
|
2019-01-28 12:29:47 +01:00
|
|
|
break;
|
2019-04-03 03:51:21 +02:00
|
|
|
// The only other possible value is 1, which is only set by ContestDebugTogglePointTotal.
|
|
|
|
//
|
|
|
|
// case CONTEST_DEBUG_MODE_PRINT_POINT_TOTAL:
|
2019-01-28 12:29:47 +01:00
|
|
|
default:
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
value = eContestantStatus[i].pointTotal;
|
2019-01-28 12:29:47 +01:00
|
|
|
txtPtr = text;
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[i].pointTotal < 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
value *= -1;
|
|
|
|
txtPtr = StringCopy(txtPtr, gText_OneDash);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4);
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 55, 1, FONT_NARROW);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-16 11:52:17 +02:00
|
|
|
value = eContestantStatus[i].appeal;
|
2019-01-28 12:29:47 +01:00
|
|
|
txtPtr = text;
|
2020-08-16 11:52:17 +02:00
|
|
|
if (eContestantStatus[i].appeal < 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
value *= -1;
|
|
|
|
txtPtr = StringCopy(txtPtr, gText_OneDash);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4);
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 5, 1, FONT_NARROW);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2019-01-28 12:29:47 +01:00
|
|
|
break;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
void SortContestants(bool8 useRanking)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
u8 scratch[CONTESTANT_COUNT];
|
|
|
|
u16 randomOrdering[CONTESTANT_COUNT] = {0};
|
2019-01-06 08:02:28 +01:00
|
|
|
s32 i;
|
2019-04-03 02:00:05 +02:00
|
|
|
s32 v3;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
// Generate a unique random number for each contestant.
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
s32 j;
|
|
|
|
randomOrdering[i] = Random();
|
|
|
|
|
|
|
|
// Loop through all the numbers generated so far.
|
|
|
|
for (j = 0; j < i; j++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
if (randomOrdering[i] == randomOrdering[j])
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
// This number isn't unique; try generating again.
|
2019-01-06 08:02:28 +01:00
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
if (!useRanking)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
// Order based on the results of the Conditions round using Insertion Sort.
|
|
|
|
// Use the randomOrdering to break ties.
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
// Append this contestant to the list.
|
|
|
|
gContestantTurnOrder[i] = i;
|
|
|
|
|
|
|
|
// Determine where the contestant should be ordered.
|
|
|
|
for (v3 = 0; v3 < i; v3++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (gContestMonRound1Points[gContestantTurnOrder[v3]] < gContestMonRound1Points[i]
|
|
|
|
|| (gContestMonRound1Points[gContestantTurnOrder[v3]] == gContestMonRound1Points[i] && randomOrdering[gContestantTurnOrder[v3]] < randomOrdering[i]))
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
// Shift everything larger up to make room.
|
|
|
|
s32 j;
|
|
|
|
for (j = i; j > v3; j--)
|
|
|
|
gContestantTurnOrder[j] = gContestantTurnOrder[j - 1];
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
// Insert into the new spot.
|
|
|
|
gContestantTurnOrder[v3] = i;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
|
|
|
|
// This is redundant.
|
|
|
|
// Perhaps GF switched from true insertion sort to in-place insertion sort, and forgot to
|
|
|
|
// remove this check?
|
|
|
|
if (v3 == i)
|
|
|
|
gContestantTurnOrder[i] = i;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
|
|
|
|
// Invert gContestantTurnOrder; above, it was a list of contestant IDs. Now it's a list of turn orderings.
|
2021-08-25 00:59:32 +02:00
|
|
|
//
|
2019-04-03 02:00:05 +02:00
|
|
|
// For example, if contestant 3 had the first turn, then `gContestantTurnOrder[1] = 3`. The turn is the index,
|
|
|
|
// the contestant is the data. After inverting the list, `gContestantTurnOrder[3] = 1`. The contestant is the index,
|
|
|
|
// and the turn is the data.
|
|
|
|
memcpy(scratch, gContestantTurnOrder, sizeof(scratch));
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
|
|
|
gContestantTurnOrder[scratch[i]] = i;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
// Order contestants based on their ranking.
|
|
|
|
// If contestants have tied ranking, fill in the next available slot.
|
|
|
|
//
|
|
|
|
// Note that ranking is calculated so that shared places still take up a ranking
|
|
|
|
// space. A ranking like [1, 2, 2, 3] is not possible; it would be [1, 2, 2, 4]
|
|
|
|
// instead.
|
|
|
|
memset(scratch, 0xFF, sizeof(scratch));
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
u8 j = eContestantStatus[i].ranking;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
u8 *ptr = &scratch[j];
|
2019-01-06 08:02:28 +01:00
|
|
|
if (*ptr == 0xFF)
|
|
|
|
{
|
|
|
|
*ptr = i;
|
2019-04-03 02:00:05 +02:00
|
|
|
gContestantTurnOrder[i] = j;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
j++;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
|
|
|
|
// Randomize the order of contestants with tied rankings using Selection Sort.
|
2021-08-25 00:59:32 +02:00
|
|
|
//
|
2019-04-03 02:00:05 +02:00
|
|
|
// Look through the array for tied ranks, and use randomOrdering to break the tie.
|
|
|
|
// This ensures that contestants with the same rank will be randomly ordered. This
|
|
|
|
// uses an in-place slection sort, which involves a lot of extra swapping.
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
for (v3 = CONTESTANT_COUNT - 1; v3 > i; v3--)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
if (eContestantStatus[v3 - 1].ranking == eContestantStatus[v3].ranking
|
|
|
|
&& gContestantTurnOrder[v3 - 1] < gContestantTurnOrder[v3]
|
|
|
|
&& randomOrdering[v3 - 1] < randomOrdering[v3])
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
u8 temp = gContestantTurnOrder[v3];
|
|
|
|
gContestantTurnOrder[v3] = gContestantTurnOrder[v3 - 1];
|
|
|
|
gContestantTurnOrder[v3 - 1] = temp;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void DrawContestantWindows(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
s32 windowId = i + 5;
|
2021-04-22 20:30:45 +02:00
|
|
|
LoadPalette(eContestTempSave.cachedWindowPalettes[windowId], (gContestantTurnOrder[i] + 5) * 16, sizeof(eContestTempSave.cachedWindowPalettes[0]));
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-03 23:24:32 +02:00
|
|
|
DrawContestantWindowText();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CalculateAppealMoveImpact(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
u16 move;
|
|
|
|
u8 effect;
|
|
|
|
u8 rnd;
|
2019-01-06 08:02:28 +01:00
|
|
|
s32 i;
|
|
|
|
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal = 0;
|
|
|
|
eContestantStatus[contestant].baseAppeal = 0;
|
2020-08-13 09:09:47 +02:00
|
|
|
if (!ContestantCanUseTurn(contestant))
|
2019-01-28 12:29:47 +01:00
|
|
|
return;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
move = eContestantStatus[contestant].currMove;
|
2019-01-28 12:29:47 +01:00
|
|
|
effect = gContestMoves[move].effect;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[contestant].moveCategory = gContestMoves[eContestantStatus[contestant].currMove].contestCategory;
|
|
|
|
if (eContestantStatus[contestant].currMove == eContestantStatus[contestant].prevMove && eContestantStatus[contestant].currMove != MOVE_NONE)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
eContestantStatus[contestant].repeatedMove = TRUE;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[contestant].moveRepeatCount++;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[contestant].moveRepeatCount = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].baseAppeal = gContestEffects[effect].appeal;
|
|
|
|
eContestantStatus[contestant].appeal = eContestantStatus[contestant].baseAppeal;
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestAppealResults.jam = gContestEffects[effect].jam;
|
|
|
|
eContestAppealResults.jam2 = eContestAppealResults.jam;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestAppealResults.contestant = contestant;
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].jam = 0;
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestAppealResults.unnervedPokes[i] = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[contestant].hasJudgesAttention
|
|
|
|
&& !AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove))
|
2020-08-14 01:10:23 +02:00
|
|
|
eContestantStatus[contestant].hasJudgesAttention = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-01-28 12:29:47 +01:00
|
|
|
gContestEffectFuncs[effect]();
|
|
|
|
|
2020-08-18 17:38:50 +02:00
|
|
|
if (eContestantStatus[contestant].conditionMod == CONDITION_GAIN)
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal += eContestantStatus[contestant].condition - 10;
|
2019-04-02 06:35:57 +02:00
|
|
|
else if (eContestantStatus[contestant].appealTripleCondition)
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal += eContestantStatus[contestant].condition * 3;
|
2019-01-28 12:29:47 +01:00
|
|
|
else
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal += eContestantStatus[contestant].condition;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
eContestantStatus[contestant].completedCombo = FALSE;
|
|
|
|
eContestantStatus[contestant].usedComboMove = FALSE;
|
|
|
|
if (IsContestantAllowedToCombo(contestant))
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
bool8 completedCombo = AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (completedCombo && eContestantStatus[contestant].hasJudgesAttention)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContestantStatus[contestant].completedCombo = completedCombo;
|
|
|
|
eContestantStatus[contestant].usedComboMove = TRUE;
|
|
|
|
eContestantStatus[contestant].hasJudgesAttention = FALSE;
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].comboAppealBonus = eContestantStatus[contestant].baseAppeal * eContestantStatus[contestant].completedCombo;
|
2020-08-21 08:36:48 +02:00
|
|
|
eContestantStatus[contestant].completedComboFlag = TRUE; // Redundant with completedCombo, used by AI
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
if (gContestMoves[eContestantStatus[contestant].currMove].comboStarterId != 0)
|
|
|
|
{
|
|
|
|
eContestantStatus[contestant].hasJudgesAttention = TRUE;
|
|
|
|
eContestantStatus[contestant].usedComboMove = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eContestantStatus[contestant].hasJudgesAttention = FALSE;
|
|
|
|
}
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2020-07-12 02:25:56 +02:00
|
|
|
if (eContestantStatus[contestant].repeatedMove)
|
2020-08-16 11:07:44 +02:00
|
|
|
eContestantStatus[contestant].repeatJam = (eContestantStatus[contestant].moveRepeatCount + 1) * 10;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[contestant].nervous)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContestantStatus[contestant].hasJudgesAttention = FALSE;
|
2020-08-16 11:52:17 +02:00
|
|
|
eContestantStatus[contestant].appeal = 0;
|
|
|
|
eContestantStatus[contestant].baseAppeal = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestExcitement.moveExcitement = Contest_GetMoveExcitement(eContestantStatus[contestant].currMove);
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[contestant].overrideCategoryExcitementMod)
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestExcitement.moveExcitement = 1;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
if (eContestExcitement.moveExcitement > 0)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
if (eContest.applauseLevel + eContestExcitement.moveExcitement > 4)
|
|
|
|
eContestExcitement.excitementAppealBonus = 60;
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestExcitement.excitementAppealBonus = 10;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestExcitement.excitementAppealBonus = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
// Transform and Role Play require a visible target mon
|
|
|
|
// so randomly choose a contestant to be the "target"
|
2020-07-12 02:25:56 +02:00
|
|
|
rnd = Random() % (CONTESTANT_COUNT - 1);
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Target can't be the attacker
|
2019-01-28 12:29:47 +01:00
|
|
|
if (i != contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-01-28 12:29:47 +01:00
|
|
|
if (rnd == 0)
|
|
|
|
break;
|
|
|
|
rnd--;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
eContestantStatus[contestant].contestantAnimTarget = i;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetContestantEffectStringID(u8 a, u8 b)
|
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[a].effectStringId = b;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetContestantEffectStringID2(u8 a, u8 b)
|
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[a].effectStringId2 = b;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetStartledString(u8 contestant, u8 jam)
|
|
|
|
{
|
|
|
|
if (jam >= 60)
|
|
|
|
SetContestantEffectStringID(contestant, CONTEST_STRING_TRIPPED_OVER);
|
|
|
|
else if (jam >= 40)
|
|
|
|
SetContestantEffectStringID(contestant, CONTEST_STRING_LEAPT_UP);
|
|
|
|
else if (jam >= 30)
|
|
|
|
SetContestantEffectStringID(contestant, CONTEST_STRING_UTTER_CRY);
|
|
|
|
else if (jam >= 20)
|
|
|
|
SetContestantEffectStringID(contestant, CONTEST_STRING_TURNED_BACK);
|
|
|
|
else if (jam >= 10)
|
|
|
|
SetContestantEffectStringID(contestant, CONTEST_STRING_LOOKED_DOWN);
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void PrintAppealMoveResultText(u8 contestant, u8 stringId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
StringCopy(gStringVar1, gContestMons[contestant].nickname);
|
2019-04-02 06:35:57 +02:00
|
|
|
StringCopy(gStringVar2, gMoveNames[eContestantStatus[contestant].currMove]);
|
2020-08-15 20:33:08 +02:00
|
|
|
if (gContestMoves[eContestantStatus[eContestAppealResults.contestant].currMove].contestCategory == CONTEST_CATEGORY_COOL)
|
2019-01-06 08:02:28 +01:00
|
|
|
StringCopy(gStringVar3, gText_Contest_Shyness);
|
2020-08-15 20:33:08 +02:00
|
|
|
else if (gContestMoves[eContestantStatus[eContestAppealResults.contestant].currMove].contestCategory == CONTEST_CATEGORY_BEAUTY)
|
2019-01-06 08:02:28 +01:00
|
|
|
StringCopy(gStringVar3, gText_Contest_Anxiety);
|
2020-08-15 20:33:08 +02:00
|
|
|
else if (gContestMoves[eContestantStatus[eContestAppealResults.contestant].currMove].contestCategory == CONTEST_CATEGORY_CUTE)
|
2019-01-06 08:02:28 +01:00
|
|
|
StringCopy(gStringVar3, gText_Contest_Laziness);
|
2020-08-15 20:33:08 +02:00
|
|
|
else if (gContestMoves[eContestantStatus[eContestAppealResults.contestant].currMove].contestCategory == CONTEST_CATEGORY_SMART)
|
2019-01-06 08:02:28 +01:00
|
|
|
StringCopy(gStringVar3, gText_Contest_Hesitancy);
|
|
|
|
else
|
|
|
|
StringCopy(gStringVar3, gText_Contest_Fear);
|
2019-11-14 18:07:43 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, sAppealResultTexts[stringId]);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestClearGeneralTextWindow();
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_StartTextPrinter(gStringVar4, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MakeContestantNervous(u8 p)
|
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
eContestantStatus[p].nervous = TRUE;
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[p].currMove = MOVE_NONE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 02:46:18 +02:00
|
|
|
// This function calculates the new turn order for the next round. The
|
|
|
|
// algorithm first checks for explicit turn assignments in the
|
|
|
|
// ContestantStatus::nextTurnOrder field of each contestant. The remaining
|
|
|
|
// turns are assigned such that the turn order will reverse.
|
|
|
|
//
|
|
|
|
// For example, if no pokemon have a defined nextTurnOrder, then the 4th
|
|
|
|
// will become 1st, the 3rd will become 2nd, etc.
|
|
|
|
//
|
|
|
|
// Note: This function assumes that multiple pokemon cannot have the same
|
|
|
|
// nextTurnOrder value.
|
|
|
|
static void ApplyNextTurnOrder(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
u8 nextContestant = 0;
|
2019-01-06 08:02:28 +01:00
|
|
|
s32 i;
|
|
|
|
s32 j;
|
2019-04-03 02:46:18 +02:00
|
|
|
u8 newTurnOrder[CONTESTANT_COUNT];
|
|
|
|
bool8 isContestantOrdered[CONTESTANT_COUNT];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-04-03 02:46:18 +02:00
|
|
|
// Copy the current turn order.
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
newTurnOrder[i] = gContestantTurnOrder[i];
|
|
|
|
isContestantOrdered[i] = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 02:46:18 +02:00
|
|
|
// For each turn, assign a contestant to that turn.
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
// Look for explicit turn assignments.
|
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[j].nextTurnOrder == i)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
newTurnOrder[j] = i;
|
|
|
|
isContestantOrdered[j] = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 02:46:18 +02:00
|
|
|
|
|
|
|
if (j == CONTESTANT_COUNT)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
// No contestant was assigned to this turn. Look for the unassigned contestant
|
|
|
|
// with the highest turn order.
|
|
|
|
//
|
|
|
|
// First, look for the first unassigned contestant.
|
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
nextContestant = j;
|
2019-01-06 08:02:28 +01:00
|
|
|
j++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 02:46:18 +02:00
|
|
|
|
|
|
|
// Then, look for a better candidate, with a higher turn order.
|
|
|
|
for (; j < CONTESTANT_COUNT; j++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 02:46:18 +02:00
|
|
|
if (!isContestantOrdered[j] && eContestantStatus[j].nextTurnOrder == 0xFF
|
|
|
|
&& gContestantTurnOrder[nextContestant] > gContestantTurnOrder[j])
|
|
|
|
nextContestant = j;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-03 02:46:18 +02:00
|
|
|
|
|
|
|
// Assign the contestant to this turn.
|
|
|
|
newTurnOrder[nextContestant] = i;
|
|
|
|
isContestantOrdered[nextContestant] = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 02:46:18 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
eContestAppealResults.turnOrder[i] = newTurnOrder[i];
|
2019-04-02 06:35:57 +02:00
|
|
|
eContestantStatus[i].nextTurnOrder = 0xFF;
|
|
|
|
eContestantStatus[i].turnOrderMod = 0;
|
2019-04-03 02:46:18 +02:00
|
|
|
gContestantTurnOrder[i] = newTurnOrder[i];
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SpriteCB_JudgeSpeechBubble(struct Sprite *sprite)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[1]++ > 84)
|
|
|
|
{
|
|
|
|
sprite->data[1] = 0;
|
|
|
|
sprite->invisible = TRUE;
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForJudgeSpeechBubble = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DoJudgeSpeechBubble(u8 symbolId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 spriteId = eContest.judgeSpeechBubbleSpriteId;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
switch (symbolId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_SWIRL:
|
|
|
|
case JUDGE_SYMBOL_SWIRL_UNUSED:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0];
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_ONE_EXCLAMATION:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 4;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_SUCCESS);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_TWO_EXCLAMATIONS:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 8;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_SUCCESS);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_NUMBER_ONE_UNUSED: // Identical to JUDGE_SYMBOL_NUMBER_ONE
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 12;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_WARP_IN);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_NUMBER_ONE:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 12;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_WARP_IN);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_NUMBER_FOUR:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 16;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_WARP_IN);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_STAR:
|
2019-01-06 08:02:28 +01:00
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 24;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_HEAL_BELL);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
2020-08-14 01:10:23 +02:00
|
|
|
case JUDGE_SYMBOL_QUESTION_MARK:
|
2019-01-06 08:02:28 +01:00
|
|
|
default:
|
|
|
|
gSprites[spriteId].oam.tileNum = gSprites[spriteId].data[0] + 20;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_WARP_IN);
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
gSprites[spriteId].data[1] = 0;
|
|
|
|
gSprites[spriteId].invisible = FALSE;
|
2020-08-14 01:10:23 +02:00
|
|
|
gSprites[spriteId].callback = SpriteCB_JudgeSpeechBubble;
|
|
|
|
eContest.waitForJudgeSpeechBubble = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static void UpdateApplauseMeter(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
for (i = 0; i < APPLAUSE_METER_SIZE; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
const u8 *src;
|
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (i < eContest.applauseLevel)
|
2019-04-03 09:00:06 +02:00
|
|
|
src = &gContestApplauseMeterGfx[64];
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
|
|
|
src = gContestApplauseMeterGfx;
|
2020-09-02 20:14:29 +02:00
|
|
|
CpuCopy32(src, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 17 + i) * 32), 32);
|
|
|
|
CpuCopy32(src + 32, (void *)(OBJ_VRAM0 + (gSprites[eContest.applauseMeterSpriteId].oam.tileNum + 25 + i) * 32), 32);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.applauseLevel > 4)
|
2019-04-03 09:00:06 +02:00
|
|
|
StartApplauseOverflowAnimation();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 Contest_GetMoveExcitement(u16 move)
|
|
|
|
{
|
|
|
|
return gContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory];
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static u8 StartApplauseOverflowAnimation(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
u8 taskId = CreateTask(Task_ApplauseOverflowAnimation, 10);
|
2019-01-06 08:02:28 +01:00
|
|
|
|
|
|
|
gTasks[taskId].data[1] = 1;
|
2020-07-12 02:25:56 +02:00
|
|
|
gTasks[taskId].data[2] = IndexOfSpritePaletteTag(TAG_APPLAUSE_METER);
|
2019-01-06 08:02:28 +01:00
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static void Task_ApplauseOverflowAnimation(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
// Skip every other frame.
|
2019-01-06 08:02:28 +01:00
|
|
|
if (++gTasks[taskId].data[0] == 1)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
// Alternate between normal colors and white.
|
2019-01-06 08:02:28 +01:00
|
|
|
if (gTasks[taskId].data[3] == 0)
|
|
|
|
gTasks[taskId].data[4]++;
|
|
|
|
else
|
|
|
|
gTasks[taskId].data[4]--;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, gTasks[taskId].data[4], RGB_WHITE);
|
|
|
|
|
|
|
|
// At the maximum or minimum blending, switch directions.
|
2019-01-06 08:02:28 +01:00
|
|
|
if (gTasks[taskId].data[4] == 0 || gTasks[taskId].data[4] == 16)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[3] ^= 1;
|
2019-04-03 09:00:06 +02:00
|
|
|
|
|
|
|
// Continue the animation until the applause meter is cleared.
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.applauseLevel < 5)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
BlendPalette(264 + gTasks[taskId].data[2] * 16, 1, 0, RGB_RED);
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SlideApplauseMeterIn(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
CreateTask(Task_SlideApplauseMeterIn, 10);
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].x2 = -70;
|
2019-04-02 06:35:57 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].invisible = FALSE;
|
2019-04-03 09:00:06 +02:00
|
|
|
eContest.applauseMeterIsMoving = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_SlideApplauseMeterIn(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
|
|
|
gTasks[taskId].data[10] += 1664;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += gTasks[taskId].data[10] >> 8;
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[10] = gTasks[taskId].data[10] & 0xFF;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->x2 > 0)
|
|
|
|
sprite->x2 = 0;
|
|
|
|
if (sprite->x2 == 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
eContest.applauseMeterIsMoving = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SlideApplauseMeterOut(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
if (gSprites[eContest.applauseMeterSpriteId].invisible == TRUE)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
eContest.applauseMeterIsMoving = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
CreateTask(Task_SlideApplauseMeterOut, 10);
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].x2 = 0;
|
2019-04-03 09:00:06 +02:00
|
|
|
eContest.applauseMeterIsMoving = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_SlideApplauseMeterOut(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
struct Sprite *sprite = &gSprites[eContest.applauseMeterSpriteId];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
|
|
|
gTasks[taskId].data[10] += 1664;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= gTasks[taskId].data[10] >> 8;
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[10] = gTasks[taskId].data[10] & 0xFF;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->x2 < -70)
|
|
|
|
sprite->x2 = -70;
|
|
|
|
if (sprite->x2 == -70)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
sprite->invisible = TRUE;
|
2019-04-03 09:00:06 +02:00
|
|
|
eContest.applauseMeterIsMoving = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static void ShowAndUpdateApplauseMeter(s8 unused)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
u8 taskId = CreateTask(Task_ShowAndUpdateApplauseMeter, 5);
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
gTasks[taskId].data[0] = unused;
|
|
|
|
eContest.isShowingApplauseMeter = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static void Task_ShowAndUpdateApplauseMeter(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[10])
|
|
|
|
{
|
|
|
|
case 0:
|
2020-08-14 01:10:23 +02:00
|
|
|
SlideApplauseMeterIn();
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[10]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-04-03 09:00:06 +02:00
|
|
|
if (!eContest.applauseMeterIsMoving)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
gTasks[taskId].data[10]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (gTasks[taskId].data[11]++ > 20)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[11] = 0;
|
2019-04-03 09:00:06 +02:00
|
|
|
UpdateApplauseMeter();
|
|
|
|
eContest.isShowingApplauseMeter = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
// Unused.
|
2020-07-12 02:25:56 +02:00
|
|
|
static void HideApplauseMeterNoAnim(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].x2 = 0;
|
2019-04-02 06:35:57 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].invisible = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
// Unused.
|
2020-07-12 02:25:56 +02:00
|
|
|
static void ShowApplauseMeterNoAnim(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
gSprites[eContest.applauseMeterSpriteId].invisible = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define tDelay data[10]
|
|
|
|
#define tFrame data[11]
|
|
|
|
#define tCycles data[12]
|
|
|
|
|
|
|
|
static void AnimateAudience(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
CreateTask(Task_AnimateAudience, 15);
|
|
|
|
eContest.animatingAudience = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_AnimateAudience(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].tDelay++ > 6)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tDelay = 0;
|
|
|
|
if (gTasks[taskId].tFrame == 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
RequestDma3Copy(eContestAudienceFrame2_Gfx, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
RequestDma3Copy(eUnzippedContestAudience_Gfx, (void *)(BG_SCREEN_ADDR(4)), 0x1000, 1);
|
|
|
|
gTasks[taskId].tCycles++;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tFrame ^= 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].tCycles == 9)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.animatingAudience = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#undef tDelay
|
|
|
|
#undef tFrame
|
|
|
|
#undef tCycles
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
#define tBlendColor data[0]
|
|
|
|
#define tBlendCoeff data[1]
|
|
|
|
#define tBlendDir data[2]
|
|
|
|
#define tTargetBlendCoeff data[3]
|
|
|
|
#define tBlendDelay data[10]
|
|
|
|
|
|
|
|
static void BlendAudienceBackground(s8 excitementDir, s8 blendDir)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 taskId = CreateTask(Task_BlendAudienceBackground, 10);
|
2019-01-06 08:02:28 +01:00
|
|
|
u16 blendColor;
|
|
|
|
u8 blendCoeff;
|
2020-08-14 01:10:23 +02:00
|
|
|
u8 targetBlendCoeff;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (excitementDir > 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
blendColor = RGB(30, 27, 8);
|
2020-08-14 01:10:23 +02:00
|
|
|
if (blendDir > 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Blend to yellow (amount depends on applause meter)
|
2019-01-06 08:02:28 +01:00
|
|
|
blendCoeff = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
targetBlendCoeff = eContest.applauseLevel * 3;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Blend back to original
|
2019-04-02 06:35:57 +02:00
|
|
|
blendCoeff = eContest.applauseLevel * 3;
|
2020-08-14 01:10:23 +02:00
|
|
|
targetBlendCoeff = 0;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
blendColor = RGB_BLACK;
|
|
|
|
if (blendDir > 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Blend to black
|
2019-01-06 08:02:28 +01:00
|
|
|
blendCoeff = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
targetBlendCoeff = 12;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
// Black back to original
|
2019-01-06 08:02:28 +01:00
|
|
|
blendCoeff = 12;
|
2020-08-14 01:10:23 +02:00
|
|
|
targetBlendCoeff = 0;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gTasks[taskId].tBlendColor = blendColor;
|
|
|
|
gTasks[taskId].tBlendCoeff = blendCoeff;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tBlendDir = blendDir;
|
|
|
|
gTasks[taskId].tTargetBlendCoeff = targetBlendCoeff;
|
|
|
|
// Because this isn't set to TRUE here, the main task doesn't wait for the color blend
|
|
|
|
// Unclear if this was intentional or not (perhaps waiting added too much delay). In any case it does nothing now
|
|
|
|
eContest.waitForAudienceBlend = FALSE;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_BlendAudienceBackground(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (gTasks[taskId].tBlendDelay++ >= 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].tBlendDelay = 0;
|
|
|
|
if (gTasks[taskId].tBlendDir > 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].tBlendCoeff++;
|
|
|
|
else
|
|
|
|
gTasks[taskId].tBlendCoeff--;
|
2020-08-14 01:10:23 +02:00
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
BlendPalette(17, 1, gTasks[taskId].tBlendCoeff, gTasks[taskId].tBlendColor);
|
|
|
|
BlendPalette(26, 1, gTasks[taskId].tBlendCoeff, gTasks[taskId].tBlendColor);
|
2020-08-14 01:10:23 +02:00
|
|
|
|
|
|
|
if (gTasks[taskId].tBlendCoeff == gTasks[taskId].tTargetBlendCoeff)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForAudienceBlend = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef tBlendColor
|
|
|
|
#undef tBlendCoeff
|
2020-08-14 01:10:23 +02:00
|
|
|
#undef tTargetBlendCoeff
|
|
|
|
#undef tBlendDelay
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void ShowHideNextTurnGfx(bool8 show)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[i].turnOrderMod != 0 && show)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-11-03 00:43:11 +01:00
|
|
|
CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(OBJ_VRAM0 + (gSprites[eContestGfxState[i].nextTurnSpriteId].oam.tileNum + 6) * 32), 32);
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].y = sNextTurnSpriteYPositions[gContestantTurnOrder[i]];
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].invisible = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].invisible = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static const u8 *GetTurnOrderNumberGfx(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContestantStatus[contestant].turnOrderMod != 1)
|
2019-01-06 08:02:28 +01:00
|
|
|
return gContestNextTurnRandomGfx;
|
|
|
|
else
|
2019-04-02 06:35:57 +02:00
|
|
|
return gContestNextTurnNumbersGfx + eContestantStatus[contestant].nextTurnOrder * 32;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void DrawUnnervedSymbols(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
s32 i = 0;
|
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
if (eContestAppealResults.unnervedPokes[i] != 0 && !Contest_IsMonsTurnDisabled(i))
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
u32 contestantOffset = gContestantTurnOrder[i] * 5 + 2;
|
|
|
|
u16 symbolOffset = GetStatusSymbolTileOffset(STAT_SYMBOL_SWIRL);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, symbolOffset, 20, contestantOffset, 2, 1, 17, 1);
|
|
|
|
symbolOffset += 16;
|
|
|
|
ContestBG_FillBoxWithIncrementingTile(0, symbolOffset, 20, contestantOffset + 1, 2, 1, 17, 1);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_CONTEST_ICON_CHANGE);
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
bool8 IsContestantAllowedToCombo(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if (eContestantStatus[contestant].repeatedMove || eContestantStatus[contestant].nervous)
|
2019-01-06 08:02:28 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetBgForCurtainDrop(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2019-01-28 12:29:47 +01:00
|
|
|
u16 bg0Cnt, bg1Cnt, bg2Cnt;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
|
|
|
bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT);
|
2019-01-28 12:29:47 +01:00
|
|
|
((vBgCnt *)&bg1Cnt)->priority = 0;
|
|
|
|
((vBgCnt *)&bg1Cnt)->screenSize = 2;
|
|
|
|
((vBgCnt *)&bg1Cnt)->areaOverflowMode = 0;
|
|
|
|
((vBgCnt *)&bg1Cnt)->charBaseBlock = 0;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
bg0Cnt = GetGpuReg(REG_OFFSET_BG0CNT);
|
|
|
|
bg2Cnt = GetGpuReg(REG_OFFSET_BG2CNT);
|
2019-01-28 12:29:47 +01:00
|
|
|
((vBgCnt *)&bg0Cnt)->priority = 1;
|
|
|
|
((vBgCnt *)&bg2Cnt)->priority = 1;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, bg0Cnt);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, bg2Cnt);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
gBattle_BG1_X = DISPLAY_WIDTH;
|
|
|
|
gBattle_BG1_Y = DISPLAY_HEIGHT;
|
2019-01-28 12:29:47 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
|
|
|
|
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2021-10-26 22:52:23 +02:00
|
|
|
CopyToBgTilemapBuffer(1, gContestCurtainTilemap, 0, 0);
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_SetBgCopyFlags(1);
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].oam.priority = 1;
|
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].oam.priority = 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void UpdateContestantBoxOrder(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u16 bg1Cnt;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
RequestDma3Fill(0,(void *)(BG_CHAR_ADDR(2)), 0x2000, 1);
|
2019-04-03 23:24:32 +02:00
|
|
|
CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000);
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_SetBgCopyFlags(1);
|
|
|
|
bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT);
|
2019-01-28 12:29:47 +01:00
|
|
|
((vBgCnt *) &bg1Cnt)->priority = 1;
|
|
|
|
((vBgCnt *) &bg1Cnt)->screenSize = 0;
|
|
|
|
((vBgCnt *) &bg1Cnt)->areaOverflowMode = 0;
|
|
|
|
((vBgCnt *) &bg1Cnt)->charBaseBlock = 2;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt);
|
|
|
|
|
|
|
|
gBattle_BG1_X = 0;
|
|
|
|
gBattle_BG1_Y = 0;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].oam.priority = 0;
|
|
|
|
gSprites[eContestGfxState[i].nextTurnSpriteId].oam.priority = 0;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_StartDropCurtainAtRoundEnd(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
gBattle_BG1_X = 0;
|
|
|
|
gBattle_BG1_Y = DISPLAY_HEIGHT;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE12WithPanning(SE_CONTEST_CURTAIN_FALL, 0);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_UpdateCurtainDropAtRoundEnd;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateCurtainDropAtRoundEnd(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if ((s16)(gBattle_BG1_Y -= 7) < 0)
|
|
|
|
gBattle_BG1_Y = 0;
|
|
|
|
if (gBattle_BG1_Y == 0)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
|
|
|
gTasks[taskId].data[2] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_ResetForNextRound;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_ResetForNextRound(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
2019-04-03 23:24:32 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-04-03 03:51:21 +02:00
|
|
|
eContest.prevTurnOrder[i] = gContestantTurnOrder[i];
|
2019-04-03 23:24:32 +02:00
|
|
|
FillContestantWindowBgs();
|
2020-08-16 11:07:44 +02:00
|
|
|
UpdateBlendTaskContestantsData();
|
2020-08-14 01:10:23 +02:00
|
|
|
DrawConditionStars();
|
2019-04-03 23:24:32 +02:00
|
|
|
DrawContestantWindows();
|
2020-08-14 01:10:23 +02:00
|
|
|
ShowHideNextTurnGfx(TRUE);
|
2020-07-12 02:25:56 +02:00
|
|
|
UpdateSliderHeartSpriteYPositions();
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
u8 taskId2;
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.waitForLink = TRUE;
|
2020-08-13 09:09:47 +02:00
|
|
|
if (IsPlayerLinkLeader())
|
2020-08-21 08:36:48 +02:00
|
|
|
SetContestantStatusesForNextRound();
|
2020-08-15 20:33:08 +02:00
|
|
|
taskId2 = CreateTask(Task_LinkContest_CommunicateAppealsState, 0);
|
|
|
|
SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateAppealsState, Task_EndWaitForLink);
|
2019-04-04 02:43:23 +02:00
|
|
|
ContestPrintLinkStandby();
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[0] = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-21 08:36:48 +02:00
|
|
|
SetContestantStatusesForNextRound();
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[0] = 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (!eContest.waitForLink)
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[0] = 3;
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-14 01:10:23 +02:00
|
|
|
DrawStatusSymbols();
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2019-01-06 08:02:28 +01:00
|
|
|
gTasks[taskId].data[0] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_WaitRaiseCurtainAtRoundEnd;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_UpdateRaiseCurtainAtRoundEnd(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if ((s16)(gBattle_BG1_Y += 7) > DISPLAY_HEIGHT)
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_UpdateContestantBoxOrder;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_WaitRaiseCurtainAtRoundEnd(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[2] < 10)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[2]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[1] == 0)
|
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0] == 16)
|
|
|
|
gTasks[taskId].data[1]++;
|
|
|
|
else
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[0] == 0)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[1] = 0;
|
|
|
|
gTasks[taskId].data[2] = 0;
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_StartRaiseCurtainAtRoundEnd;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[0]--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void Task_StartRaiseCurtainAtRoundEnd(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (gTasks[taskId].data[2] < 10)
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[2]++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gTasks[taskId].data[2] = 0;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE12WithPanning(SE_CONTEST_CURTAIN_RISE, 0);
|
2020-08-14 01:10:23 +02:00
|
|
|
gTasks[taskId].func = Task_UpdateRaiseCurtainAtRoundEnd;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
#define tAnimId data[0]
|
|
|
|
|
|
|
|
static void AnimateSliderHearts(u8 animId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u8 taskId;
|
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].oam.matrixNum = AllocOamMatrix();
|
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
|
|
|
StartSpriteAffineAnim(&gSprites[eContestGfxState[i].sliderHeartSpriteId], animId);
|
2020-07-12 02:25:56 +02:00
|
|
|
if (animId == SLIDER_HEART_ANIM_APPEAR)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-15 20:33:08 +02:00
|
|
|
AnimateSprite(&gSprites[eContestGfxState[i].sliderHeartSpriteId]);
|
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].invisible = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
2020-07-12 02:25:56 +02:00
|
|
|
taskId = CreateTask(Task_WaitForSliderHeartAnim, 5);
|
|
|
|
gTasks[taskId].tAnimId = animId;
|
|
|
|
eContest.sliderHeartsAnimating = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void Task_WaitForSliderHeartAnim(u8 taskId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
if (gSprites[eContestGfxState[0].sliderHeartSpriteId].affineAnimEnded)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
if ((u8)gTasks[taskId].tAnimId == SLIDER_HEART_ANIM_DISAPPEAR)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-15 20:33:08 +02:00
|
|
|
gSprites[eContestGfxState[i].sliderHeartSpriteId].invisible = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2020-08-15 20:33:08 +02:00
|
|
|
FreeSpriteOamMatrix(&gSprites[eContestGfxState[i].sliderHeartSpriteId]);
|
2020-07-12 02:25:56 +02:00
|
|
|
eContest.sliderHeartsAnimating = FALSE;
|
2019-01-06 08:02:28 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
#undef tAnimId
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static u16 SanitizeMove(u16 move)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (move >= MOVES_COUNT)
|
|
|
|
move = MOVE_POUND;
|
|
|
|
return move;
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static u16 SanitizeSpecies(u16 species)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
if (species >= NUM_SPECIES)
|
|
|
|
species = SPECIES_NONE;
|
|
|
|
return species;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetMoveSpecificAnimData(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-08-14 01:10:23 +02:00
|
|
|
u16 move = SanitizeMove(eContestantStatus[contestant].currMove);
|
|
|
|
u16 species = SanitizeSpecies(gContestMons[contestant].species);
|
|
|
|
u8 targetContestant;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
memset(&gContestResources->moveAnim->species, 0, 20);
|
2019-01-06 08:02:28 +01:00
|
|
|
ClearBattleAnimationVars();
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
gBattleMonForms[i] = 0;
|
|
|
|
switch (move)
|
|
|
|
{
|
|
|
|
case MOVE_CURSE:
|
|
|
|
if (gBaseStats[species].type1 == TYPE_GHOST || gBaseStats[species].type2 == TYPE_GHOST)
|
|
|
|
gAnimMoveTurn = 0;
|
|
|
|
else
|
|
|
|
gAnimMoveTurn = 1;
|
|
|
|
break;
|
|
|
|
case MOVE_TRANSFORM:
|
|
|
|
case MOVE_ROLE_PLAY:
|
2020-08-14 01:10:23 +02:00
|
|
|
targetContestant = eContestantStatus[contestant].contestantAnimTarget;
|
|
|
|
gContestResources->moveAnim->targetSpecies = SanitizeSpecies(gContestMons[targetContestant].species);
|
|
|
|
gContestResources->moveAnim->targetPersonality = gContestMons[targetContestant].personality;
|
|
|
|
gContestResources->moveAnim->hasTargetAnim = TRUE;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case MOVE_RETURN:
|
2019-12-18 08:32:52 +01:00
|
|
|
gAnimFriendship = MAX_FRIENDSHIP;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case MOVE_FRUSTRATION:
|
|
|
|
gAnimFriendship = 0;
|
|
|
|
break;
|
|
|
|
case MOVE_SOLAR_BEAM:
|
|
|
|
case MOVE_RAZOR_WIND:
|
|
|
|
case MOVE_SKULL_BASH:
|
|
|
|
case MOVE_SKY_ATTACK:
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContest.moveAnimTurnCount == 0)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
eContest.moveAnimTurnCount = 2;
|
2019-01-06 08:02:28 +01:00
|
|
|
gAnimMoveTurn = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gAnimMoveTurn = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBattleTargetSpritePosition();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void ClearMoveAnimData(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
memset(gContestResources->moveAnim, 0, sizeof(struct ContestMoveAnimData));
|
|
|
|
if (eContest.moveAnimTurnCount != 0)
|
|
|
|
eContest.moveAnimTurnCount--;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetMoveAnimAttackerData(u8 contestant)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gContestResources->moveAnim->contestant = contestant;
|
|
|
|
gContestResources->moveAnim->species = SanitizeSpecies(gContestMons[contestant].species);
|
|
|
|
gContestResources->moveAnim->personality = gContestMons[contestant].personality;
|
|
|
|
gContestResources->moveAnim->otId = gContestMons[contestant].otId;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void CreateInvisibleBattleTargetSprite(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
gBattlerSpriteIds[B_POSITION_OPPONENT_RIGHT] = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy);
|
2019-01-06 08:02:28 +01:00
|
|
|
InitSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattlerTarget]]);
|
2020-08-14 01:10:23 +02:00
|
|
|
SetBattleTargetSpritePosition();
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetBattleTargetSpritePosition(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2020-08-14 01:10:23 +02:00
|
|
|
struct Sprite *sprite = &gSprites[gBattlerSpriteIds[B_POSITION_OPPONENT_RIGHT]];
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
|
|
|
sprite->y2 = 0;
|
|
|
|
sprite->x = GetBattlerSpriteCoord(B_POSITION_OPPONENT_RIGHT, BATTLER_COORD_X);
|
|
|
|
sprite->y = GetBattlerSpriteCoord(B_POSITION_OPPONENT_RIGHT, BATTLER_COORD_Y);
|
2019-01-06 08:02:28 +01:00
|
|
|
sprite->invisible = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
static void SetMoveTargetPosition(u16 move)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
switch (gBattleMoves[move].target)
|
|
|
|
{
|
|
|
|
case MOVE_TARGET_USER_OR_SELECTED:
|
|
|
|
case MOVE_TARGET_USER:
|
2020-08-14 01:10:23 +02:00
|
|
|
gBattlerTarget = B_POSITION_PLAYER_RIGHT;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case MOVE_TARGET_SELECTED:
|
|
|
|
case MOVE_TARGET_RANDOM:
|
|
|
|
case MOVE_TARGET_BOTH:
|
|
|
|
case MOVE_TARGET_FOES_AND_ALLY:
|
|
|
|
default:
|
2020-08-14 01:10:23 +02:00
|
|
|
gBattlerTarget = B_POSITION_OPPONENT_RIGHT;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void Contest_PrintTextToBg0WindowStd(u32 windowId, const u8 *b)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
struct TextPrinterTemplate printerTemplate;
|
|
|
|
|
|
|
|
printerTemplate.currentChar = b;
|
2020-08-16 11:07:44 +02:00
|
|
|
printerTemplate.windowId = windowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
printerTemplate.fontId = FONT_NORMAL;
|
2019-01-06 08:02:28 +01:00
|
|
|
printerTemplate.x = 0;
|
|
|
|
printerTemplate.y = 1;
|
|
|
|
printerTemplate.currentX = 0;
|
|
|
|
printerTemplate.currentY = 1;
|
|
|
|
printerTemplate.letterSpacing = 0;
|
|
|
|
printerTemplate.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
|
|
|
printerTemplate.unk = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
printerTemplate.fgColor = 15;
|
|
|
|
printerTemplate.bgColor = 0;
|
|
|
|
printerTemplate.shadowColor = 8;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
AddTextPrinter(&printerTemplate, 0, 0);
|
2020-08-16 11:07:44 +02:00
|
|
|
PutWindowTilemap(windowId);
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_SetBgCopyFlags(0);
|
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
|
|
|
|
void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
struct TextPrinterTemplate printerTemplate;
|
|
|
|
|
2019-01-28 12:29:47 +01:00
|
|
|
printerTemplate.currentChar = currChar;
|
|
|
|
printerTemplate.windowId = windowId;
|
|
|
|
printerTemplate.fontId = fontId;
|
|
|
|
printerTemplate.x = x;
|
|
|
|
printerTemplate.y = y;
|
|
|
|
printerTemplate.currentX = x;
|
|
|
|
printerTemplate.currentY = y;
|
2019-01-06 08:02:28 +01:00
|
|
|
printerTemplate.letterSpacing = 0;
|
|
|
|
printerTemplate.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
|
|
|
printerTemplate.unk = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
printerTemplate.fgColor = 15;
|
|
|
|
printerTemplate.bgColor = 0;
|
|
|
|
printerTemplate.shadowColor = 8;
|
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
AddTextPrinter(&printerTemplate, 0, 0);
|
2019-01-28 12:29:47 +01:00
|
|
|
PutWindowTilemap(windowId);
|
2019-01-06 08:02:28 +01:00
|
|
|
Contest_SetBgCopyFlags(0);
|
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static void Contest_StartTextPrinter(const u8 *currChar, bool32 b)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
struct TextPrinterTemplate printerTemplate;
|
2019-01-28 12:29:47 +01:00
|
|
|
u8 speed;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2019-01-28 12:29:47 +01:00
|
|
|
printerTemplate.currentChar = currChar;
|
|
|
|
printerTemplate.windowId = 4;
|
2021-10-30 22:47:37 +02:00
|
|
|
printerTemplate.fontId = FONT_NORMAL;
|
2019-01-06 08:02:28 +01:00
|
|
|
printerTemplate.x = 0;
|
|
|
|
printerTemplate.y = 1;
|
|
|
|
printerTemplate.currentX = 0;
|
|
|
|
printerTemplate.currentY = 1;
|
|
|
|
printerTemplate.letterSpacing = 0;
|
|
|
|
printerTemplate.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
|
|
|
printerTemplate.unk = 0;
|
2019-01-28 12:29:47 +01:00
|
|
|
printerTemplate.fgColor = 1;
|
|
|
|
printerTemplate.bgColor = 0;
|
|
|
|
printerTemplate.shadowColor = 8;
|
|
|
|
|
|
|
|
if (!b)
|
|
|
|
{
|
|
|
|
AddTextPrinter(&printerTemplate, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2019-01-28 12:29:47 +01:00
|
|
|
speed = 4;
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
2019-01-28 12:29:47 +01:00
|
|
|
speed = GetPlayerTextSpeedDelay();
|
|
|
|
AddTextPrinter(&printerTemplate, speed, 0);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-01-06 08:02:28 +01:00
|
|
|
PutWindowTilemap(4);
|
|
|
|
Contest_SetBgCopyFlags(0);
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void ContestBG_FillBoxWithIncrementingTile(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumData)
|
2019-01-28 12:29:47 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
WriteSequenceToBgTilemapBuffer(bg, firstTileNum, x, y, width, height, paletteSlot, tileNumData);
|
|
|
|
Contest_SetBgCopyFlags(bg);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:24:32 +02:00
|
|
|
static void ContestBG_FillBoxWithTile(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
ContestBG_FillBoxWithIncrementingTile(bg, firstTileNum, x, y, width, height, paletteSlot, 0);
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
2019-01-28 18:13:07 +01:00
|
|
|
static bool32 Contest_RunTextPrinters(void)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
RunTextPrinters();
|
|
|
|
return IsTextPrinterActive(4);
|
|
|
|
}
|
|
|
|
|
2019-04-03 09:00:06 +02:00
|
|
|
static void Contest_SetBgCopyFlags(u32 flagIndex)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-04-03 09:00:06 +02:00
|
|
|
sContestBgCopyFlags |= 1 << flagIndex;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetContestLinkResults(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
s32 j;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for(i = 0; i < CONTEST_CATEGORIES_COUNT; i++)
|
2020-07-12 02:25:56 +02:00
|
|
|
for(j = 0; j < CONTESTANT_COUNT; j++)
|
2019-01-06 08:02:28 +01:00
|
|
|
gSaveBlock2Ptr->contestLinkResults[i][j] = 0;
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
bool8 SaveContestWinner(u8 rank)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2021-04-22 02:04:12 +02:00
|
|
|
u8 captionId = Random() % NUM_PAINTING_CAPTIONS;
|
2019-01-06 08:02:28 +01:00
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
// Get the index of the winner among the contestants
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT - 1; i++)
|
2019-01-06 08:02:28 +01:00
|
|
|
if (gContestFinalStandings[i] == 0)
|
|
|
|
break;
|
2021-04-22 02:04:12 +02:00
|
|
|
|
|
|
|
// Exit if attempting to save a Pokémon other than the player's to the museum
|
|
|
|
if (rank == CONTEST_SAVE_FOR_MUSEUM && i != gContestPlayerMonIndex)
|
2019-01-06 08:02:28 +01:00
|
|
|
return FALSE;
|
2021-04-22 02:04:12 +02:00
|
|
|
|
|
|
|
// Adjust the random painting caption depending on the category
|
2019-01-06 08:02:28 +01:00
|
|
|
switch (gSpecialVar_ContestCategory)
|
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
2021-04-22 02:04:12 +02:00
|
|
|
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
2021-04-22 02:04:12 +02:00
|
|
|
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_CUTE:
|
2021-04-22 02:04:12 +02:00
|
|
|
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_SMART:
|
2021-04-22 02:04:12 +02:00
|
|
|
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
2021-04-22 02:04:12 +02:00
|
|
|
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH;
|
2019-01-06 08:02:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
if (rank != CONTEST_SAVE_FOR_ARTIST)
|
|
|
|
{
|
|
|
|
// Save winner in the saveblock
|
|
|
|
// Used to save any winner for the Contest Hall or the Museum
|
|
|
|
// but excludes the temporary save used by the artist
|
|
|
|
u8 id = GetContestWinnerSaveIdx(rank, TRUE);
|
2020-06-17 23:48:20 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[id].personality = gContestMons[i].personality;
|
|
|
|
gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species;
|
|
|
|
gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId;
|
|
|
|
StringCopy(gSaveBlock1Ptr->contestWinners[id].monName, gContestMons[i].nickname);
|
|
|
|
StringCopy(gSaveBlock1Ptr->contestWinners[id].trainerName, gContestMons[i].trainerName);
|
2019-04-03 23:24:32 +02:00
|
|
|
if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
|
2020-06-17 23:48:20 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[id].contestRank = CONTEST_RANK_LINK;
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
2020-06-17 23:48:20 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank;
|
2019-01-28 12:29:47 +01:00
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
if (rank != CONTEST_SAVE_FOR_MUSEUM)
|
2020-06-17 23:48:20 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory;
|
2019-01-06 08:02:28 +01:00
|
|
|
else
|
2021-04-22 02:04:12 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[id].contestCategory = captionId;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
// Set the most recent winner so the artist can show the player their painting
|
2019-11-10 19:46:39 +01:00
|
|
|
gCurContestWinner.personality = gContestMons[i].personality;
|
|
|
|
gCurContestWinner.trainerId = gContestMons[i].otId;
|
|
|
|
gCurContestWinner.species = gContestMons[i].species;
|
|
|
|
StringCopy(gCurContestWinner.monName, gContestMons[i].nickname);
|
|
|
|
StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName);
|
2021-04-22 02:04:12 +02:00
|
|
|
gCurContestWinner.contestCategory = captionId;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
// Rank is either a regular contest rank (for saving winners to show in the Contest Hall)
|
|
|
|
// Or one of two special IDs listed below (for saving winners to show in Museum, or from the artist)
|
|
|
|
// If just retrieving the index where the winner *would* go, shift is FALSE
|
|
|
|
// If actually preparing to insert the winner into the saveblock, shift is TRUE
|
|
|
|
u8 GetContestWinnerSaveIdx(u8 rank, bool8 shift)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
switch (rank)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2019-11-11 03:54:00 +01:00
|
|
|
case CONTEST_RANK_NORMAL:
|
|
|
|
case CONTEST_RANK_SUPER:
|
|
|
|
case CONTEST_RANK_HYPER:
|
|
|
|
case CONTEST_RANK_MASTER:
|
2021-04-22 02:04:12 +02:00
|
|
|
if (shift)
|
2019-01-06 08:02:28 +01:00
|
|
|
{
|
2021-04-22 02:04:12 +02:00
|
|
|
for (i = NUM_CONTEST_HALL_WINNERS - 1; i > 0; i--)
|
2019-01-06 08:02:28 +01:00
|
|
|
memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner));
|
|
|
|
}
|
2021-04-22 02:04:12 +02:00
|
|
|
return CONTEST_WINNER_HALL_1 - 1;
|
2020-06-17 23:48:20 +02:00
|
|
|
default:
|
2021-04-22 02:04:12 +02:00
|
|
|
// case CONTEST_SAVE_FOR_MUSEUM:
|
|
|
|
// case CONTEST_SAVE_FOR_ARTIST:
|
2019-01-06 08:02:28 +01:00
|
|
|
switch (gSpecialVar_ContestCategory)
|
|
|
|
{
|
|
|
|
case CONTEST_CATEGORY_COOL:
|
2020-06-17 23:48:20 +02:00
|
|
|
return CONTEST_WINNER_MUSEUM_COOL - 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
case CONTEST_CATEGORY_BEAUTY:
|
2020-06-17 23:48:20 +02:00
|
|
|
return CONTEST_WINNER_MUSEUM_BEAUTY - 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
case CONTEST_CATEGORY_CUTE:
|
2020-06-17 23:48:20 +02:00
|
|
|
return CONTEST_WINNER_MUSEUM_CUTE - 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
case CONTEST_CATEGORY_SMART:
|
2020-06-17 23:48:20 +02:00
|
|
|
return CONTEST_WINNER_MUSEUM_SMART - 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
case CONTEST_CATEGORY_TOUGH:
|
|
|
|
default:
|
2020-06-17 23:48:20 +02:00
|
|
|
return CONTEST_WINNER_MUSEUM_TOUGH - 1;
|
2019-01-06 08:02:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearContestWinnerPicsInContestHall(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-22 02:04:12 +02:00
|
|
|
for (i = 0; i < MUSEUM_CONTEST_WINNERS_START; i++)
|
2020-08-21 20:47:55 +02:00
|
|
|
gSaveBlock1Ptr->contestWinners[i] = gDefaultContestWinners[i];
|
2019-01-28 12:29:47 +01:00
|
|
|
}
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void SetContestLiveUpdateFlags(u8 contestant)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestExcitement.frozen
|
|
|
|
&& eContestExcitement.moveExcitement > 0
|
2020-07-12 02:25:56 +02:00
|
|
|
&& !eContestantStatus[contestant].repeatedMove)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_EXCITING_APPEAL;
|
|
|
|
gContestResources->tv[contestant].madeExcitingAppeal = TRUE;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
if (eContestantStatus[contestant].nervous)
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_GOT_NERVOUS;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-15 20:33:08 +02:00
|
|
|
if (!eContestExcitement.frozen
|
|
|
|
&& eContestExcitement.moveExcitement != 0
|
|
|
|
&& eContestExcitement.excitementAppealBonus == 60)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_MAXED_EXCITEMENT;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-14 01:10:23 +02:00
|
|
|
if (eContestantStatus[contestant].usedComboMove
|
|
|
|
&& eContestantStatus[contestant].completedCombo)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_USED_COMBO;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2019-04-03 02:00:05 +02:00
|
|
|
if (i != contestant && eContestantStatus[i].jam != 0)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_STARTLED_OTHER;
|
|
|
|
gContestResources->tv[i].winnerFlags |= CONTESTLIVE_FLAG_GOT_STARTLED;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 02:00:05 +02:00
|
|
|
if (eContestantStatus[contestant].numTurnsSkipped != 0
|
|
|
|
|| eContestantStatus[contestant].noMoreTurns)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_SKIPPED_TURN;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
2019-04-03 02:00:05 +02:00
|
|
|
else if (!eContestantStatus[contestant].nervous)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].winnerFlags |= CONTESTLIVE_FLAG_MADE_APPEAL;
|
|
|
|
gContestResources->tv[contestant].madeAppeal = TRUE;
|
|
|
|
gContestResources->tv[contestant].appeals[eContest.appealNumber] = eContestantStatus[contestant].currMove;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
if (eContestantStatus[contestant].repeatedMove)
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].loserFlags |= CONTESTLIVE_FLAG_REPEATED_MOVE;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2019-04-02 06:35:57 +02:00
|
|
|
if (eContest.applauseLevel == 4
|
2020-08-15 20:33:08 +02:00
|
|
|
&& !eContestExcitement.frozen
|
|
|
|
&& eContestExcitement.moveExcitement < 0)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[contestant].loserFlags |= CONTESTLIVE_FLAG_MISSED_EXCITEMENT;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void CalculateContestLiveUpdateData(void)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
u8 loser;
|
2019-01-28 18:13:07 +01:00
|
|
|
s32 i, j;
|
2020-08-16 11:07:44 +02:00
|
|
|
bool32 notLastInRound1, notLastInRound2;
|
|
|
|
u16 appealMoves[CONTEST_NUM_APPEALS + 1];
|
|
|
|
u8 numMoveUses[CONTEST_NUM_APPEALS + 1];
|
|
|
|
u16 moveCandidates[CONTEST_NUM_APPEALS];
|
|
|
|
u8 winner;
|
|
|
|
u8 mostUses;
|
|
|
|
u8 numMoveCandidates;
|
|
|
|
|
|
|
|
loser = 0;
|
|
|
|
winner = 0;
|
|
|
|
|
|
|
|
// Get loser/winner ids
|
2019-11-11 03:54:00 +01:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
if (gContestFinalStandings[i] == 0)
|
2020-08-16 11:07:44 +02:00
|
|
|
winner = i;
|
|
|
|
else if (gContestFinalStandings[i] == CONTESTANT_COUNT - 1)
|
|
|
|
loser = i;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Set flags for commenting on loser
|
|
|
|
gContestResources->tv[loser].loserFlags |= CONTESTLIVE_FLAG_LOST;
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (i != winner && gContestMonTotalPoints[winner] - gContestMonTotalPoints[i] <= 50)
|
|
|
|
gContestResources->tv[i].loserFlags |= CONTESTLIVE_FLAG_LOST_SMALL_MARGIN;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
if (!gContestResources->tv[i].madeExcitingAppeal)
|
|
|
|
gContestResources->tv[i].loserFlags |= CONTESTLIVE_FLAG_NO_EXCITEMENT;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2019-04-04 02:43:23 +02:00
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (gContestMonRound1Points[i] < gContestMonRound1Points[j])
|
2019-01-28 18:13:07 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
if (j == CONTESTANT_COUNT && gContestFinalStandings[i] != 0)
|
|
|
|
gContestResources->tv[i].loserFlags |= CONTESTLIVE_FLAG_BLEW_LEAD;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
notLastInRound1 = FALSE;
|
|
|
|
notLastInRound2 = FALSE;
|
2019-11-11 03:54:00 +01:00
|
|
|
for (j = 0; j < CONTESTANT_COUNT; j++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-07-24 06:14:53 +02:00
|
|
|
if (gContestMonRound1Points[i] > gContestMonRound1Points[j])
|
2020-08-16 11:07:44 +02:00
|
|
|
notLastInRound1 = TRUE;
|
2020-06-17 23:48:20 +02:00
|
|
|
if (gContestMonRound2Points[i] > gContestMonRound2Points[j])
|
2020-08-16 11:07:44 +02:00
|
|
|
notLastInRound2 = TRUE;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
if (!notLastInRound1 && !notLastInRound2)
|
|
|
|
gContestResources->tv[i].loserFlags |= CONTESTLIVE_FLAG_LAST_BOTH_ROUNDS;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
if (!gContestResources->tv[i].madeAppeal)
|
|
|
|
gContestResources->tv[i].loserFlags |= CONTESTLIVE_FLAG_NO_APPEALS;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Get what moves the winner used and how many times they used them
|
|
|
|
for (i = 0; i < CONTEST_NUM_APPEALS; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
appealMoves[i] = MOVE_NONE;
|
|
|
|
numMoveUses[i] = 0;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
appealMoves[CONTEST_NUM_APPEALS] = 0xFFFF;
|
|
|
|
numMoveUses[CONTEST_NUM_APPEALS] = 0;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
for (i = 0; i < CONTEST_NUM_APPEALS; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (gContestResources->tv[winner].appeals[i] != MOVE_NONE)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
for (j = 0; j < CONTEST_NUM_APPEALS; j++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (gContestResources->tv[winner].appeals[i] != appealMoves[j])
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (appealMoves[j] == MOVE_NONE)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
appealMoves[j] = gContestResources->tv[winner].appeals[i];
|
|
|
|
numMoveUses[j]++;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
numMoveUses[j]++;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Choose an appeal move to comment on for the winner (most commonly used)
|
|
|
|
moveCandidates[0] = appealMoves[0];
|
|
|
|
mostUses = numMoveUses[0];
|
|
|
|
numMoveCandidates = 0;
|
|
|
|
for (i = 1; appealMoves[i] != 0xFFFF; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (mostUses < numMoveUses[i])
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
moveCandidates[0] = appealMoves[i];
|
|
|
|
mostUses = numMoveUses[i];
|
|
|
|
numMoveCandidates = 1;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
else if (mostUses == numMoveUses[i])
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
moveCandidates[numMoveCandidates] = appealMoves[i];
|
|
|
|
numMoveCandidates++;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
gContestResources->tv[winner].move = moveCandidates[Random() % numMoveCandidates];
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
static void SetConestLiveUpdateTVData(void)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2020-08-16 11:07:44 +02:00
|
|
|
u32 flags;
|
|
|
|
u8 winner;
|
|
|
|
u8 round1Placing, round2Placing;
|
2019-01-28 18:13:07 +01:00
|
|
|
u8 count;
|
2020-08-16 11:07:44 +02:00
|
|
|
u8 randAction;
|
|
|
|
u8 numLoserCandidates;
|
|
|
|
u8 flagId;
|
|
|
|
u16 winnerFlag;
|
|
|
|
u8 loserFlag;
|
|
|
|
u8 loser;
|
|
|
|
u8 loserCandidates[CONTESTANT_COUNT - 1];
|
|
|
|
|
|
|
|
// Players mon didn't win, don't generate show
|
2019-01-28 18:13:07 +01:00
|
|
|
if (gContestFinalStandings[gContestPlayerMonIndex] != 0)
|
|
|
|
return;
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Get winner id (unnecessary, we now know it's gContestPlayerMonIndex)
|
|
|
|
winner = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
if (gContestFinalStandings[i] == 0)
|
2020-08-16 11:07:44 +02:00
|
|
|
winner = i;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Get winner's placement in Round 1 and 2
|
|
|
|
round1Placing = 0;
|
|
|
|
round2Placing = 0;
|
2019-04-04 02:43:23 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (gContestMonRound1Points[winner] < gContestMonRound1Points[i])
|
|
|
|
round1Placing++;
|
|
|
|
if (gContestMonRound2Points[winner] < gContestMonRound2Points[i])
|
|
|
|
round2Placing++;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Count how many TV comment-worthy actions the winner took
|
|
|
|
flags = gContestResources->tv[winner].winnerFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
count = 0;
|
2020-08-16 11:07:44 +02:00
|
|
|
for (i = 0; i < 8; flags >>= 1, i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (flags & 1)
|
2019-01-28 18:13:07 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Randomly choose one of these actions to comment on
|
|
|
|
randAction = Random() % count;
|
|
|
|
flags = gContestResources->tv[winner].winnerFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
count = 0;
|
2020-08-16 11:07:44 +02:00
|
|
|
flagId = 0;
|
|
|
|
for (i = 0; i < 8; flags >>= 1, flagId++, i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (!(flags & 1))
|
2019-01-28 18:13:07 +01:00
|
|
|
continue;
|
2020-08-16 11:07:44 +02:00
|
|
|
if (randAction == count)
|
2019-01-28 18:13:07 +01:00
|
|
|
break;
|
|
|
|
count++;
|
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
winnerFlag = 1 << flagId;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Pick a losing player with the highest severity of bad actions to comment on
|
|
|
|
if (winner == 0)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
loserCandidates[0] = 1;
|
|
|
|
loserFlag = gContestResources->tv[1].loserFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
loserCandidates[0] = 0;
|
|
|
|
loserFlag = gContestResources->tv[0].loserFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
numLoserCandidates = 1;
|
2019-04-04 02:43:23 +02:00
|
|
|
for (; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (i != winner)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (loserFlag < gContestResources->tv[i].loserFlags)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
// Losing player currently has the worst (highest) set of flags, only candidate
|
|
|
|
loserCandidates[0] = i;
|
|
|
|
loserFlag = gContestResources->tv[i].loserFlags;
|
|
|
|
numLoserCandidates = 1;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
else if (loserFlag == gContestResources->tv[i].loserFlags)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
// Tie, increment number of loser candidates
|
|
|
|
loserCandidates[numLoserCandidates] = i;
|
|
|
|
numLoserCandidates++;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
loser = loserCandidates[Random() % numLoserCandidates];
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
// Choose the "worst" action to comment on (flag with highest value)
|
|
|
|
flagId = CONTESTLIVE_FLAG_NO_APPEALS;
|
|
|
|
for (i = 0; i < 8; flagId >>= 1, i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
loserFlag = gContestResources->tv[loser].loserFlags & flagId;
|
|
|
|
if (loserFlag)
|
2019-01-28 18:13:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
ContestLiveUpdates_Init(round1Placing);
|
|
|
|
ContestLiveUpdates_SetRound2Placing(round2Placing);
|
|
|
|
ContestLiveUpdates_SetWinnerAppealFlag(winnerFlag);
|
|
|
|
ContestLiveUpdates_SetWinnerMoveUsed(gContestResources->tv[winner].move);
|
|
|
|
ContestLiveUpdates_SetLoserData(loserFlag, loser);
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unused
|
2020-08-16 11:07:44 +02:00
|
|
|
void ContestDebugToggleBitfields(bool8 loserFlags)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2020-08-16 11:07:44 +02:00
|
|
|
if (!loserFlags)
|
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_WINNER_FLAGS;
|
2019-01-28 18:13:07 +01:00
|
|
|
else
|
2020-08-16 11:07:44 +02:00
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
eContestDebugMode = CONTEST_DEBUG_MODE_OFF;
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
if (eContestDebugMode == CONTEST_DEBUG_MODE_OFF)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2019-04-03 23:24:32 +02:00
|
|
|
DrawContestantWindowText();
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
ContestDebugPrintBitStrings();
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
static void ContestDebugPrintBitStrings(void)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
s8 j;
|
|
|
|
u8 text1[20];
|
|
|
|
u8 text2[20];
|
|
|
|
u8 *txtPtr;
|
|
|
|
u32 bits;
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
if (!gEnableContestDebugging)
|
2019-01-28 18:13:07 +01:00
|
|
|
return;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
if (eContestDebugMode != CONTEST_DEBUG_MODE_PRINT_WINNER_FLAGS && eContestDebugMode != CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS)
|
2019-01-28 18:13:07 +01:00
|
|
|
return;
|
|
|
|
|
2019-04-03 03:51:21 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-08-16 11:07:44 +02:00
|
|
|
if (eContestDebugMode == CONTEST_DEBUG_MODE_PRINT_WINNER_FLAGS)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
txtPtr = StringCopy(text1, gText_CDot);
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, FONT_NARROW);
|
2020-08-16 11:07:44 +02:00
|
|
|
bits = gContestResources->tv[i].winnerFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
for (j = 7; j > -1; j--) // Weird loop.
|
|
|
|
{
|
|
|
|
txtPtr = ConvertIntToDecimalStringN(txtPtr, bits & 1, STR_CONV_MODE_LEFT_ALIGN, 1);
|
|
|
|
bits >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
text2[j] = text1[j];
|
|
|
|
|
|
|
|
text2[j] = EOS;
|
2019-04-03 02:00:05 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, 7);
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, FONT_NARROW);
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-16 11:07:44 +02:00
|
|
|
else // CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
2019-04-03 03:51:21 +02:00
|
|
|
for (i = 0; i < CONTESTANT_COUNT; i++)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
StringCopy(text1, gText_BDot);
|
2020-08-16 11:07:44 +02:00
|
|
|
bits = gContestResources->tv[i].loserFlags;
|
2019-01-28 18:13:07 +01:00
|
|
|
txtPtr = &text1[2];
|
|
|
|
for (j = 7; j > -1; j--) // Weird loop.
|
|
|
|
{
|
|
|
|
txtPtr = ConvertIntToDecimalStringN(txtPtr, bits & 1, STR_CONV_MODE_LEFT_ALIGN, 1);
|
|
|
|
bits >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
text2[j] = text1[j];
|
|
|
|
|
|
|
|
text2[j] = EOS;
|
2021-10-30 22:47:37 +02:00
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, FONT_NARROW);
|
|
|
|
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, FONT_NARROW);
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-04 02:43:23 +02:00
|
|
|
SwapMoveDescAndContestTilemaps();
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static u8 GetMonNicknameLanguage(u8 *nickname)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
u8 ret = GAME_LANGUAGE;
|
|
|
|
|
|
|
|
if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN)
|
2021-02-05 18:08:49 +01:00
|
|
|
return GAME_LANGUAGE;
|
2019-01-28 18:13:07 +01:00
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
if (StringLength(nickname) < PLAYER_NAME_LENGTH - 1)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
while (*nickname != EOS)
|
|
|
|
{
|
|
|
|
if ((*nickname >= CHAR_A && *nickname <= CHAR_z)
|
|
|
|
|| (*nickname >= CHAR_0 && *nickname <= CHAR_9)
|
|
|
|
|| *nickname == CHAR_SPACE
|
|
|
|
|| *nickname == CHAR_PERIOD
|
|
|
|
|| *nickname == CHAR_COMMA
|
|
|
|
|| *nickname == CHAR_EXCL_MARK
|
|
|
|
|| *nickname == CHAR_QUESTION_MARK
|
|
|
|
|| *nickname == CHAR_MALE
|
|
|
|
|| *nickname == CHAR_FEMALE
|
|
|
|
|| *nickname == CHAR_SLASH
|
|
|
|
|| *nickname == CHAR_HYPHEN
|
|
|
|
|| *nickname == CHAR_ELLIPSIS
|
2021-10-30 22:19:10 +02:00
|
|
|
|| *nickname == CHAR_DBL_QUOTE_LEFT
|
|
|
|
|| *nickname == CHAR_DBL_QUOTE_RIGHT
|
|
|
|
|| *nickname == CHAR_SGL_QUOTE_LEFT
|
|
|
|
|| *nickname == CHAR_DBL_QUOTE_LEFT) // Most likely a typo, CHAR_SGL_QUOTE_RIGHT should be here instead.
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
nickname++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = LANGUAGE_JAPANESE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void StripPlayerNameForLinkContest(u8 *playerName)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
u8 chr = playerName[5];
|
|
|
|
|
|
|
|
playerName[5] = EOS;
|
|
|
|
playerName[PLAYER_NAME_LENGTH] = chr;
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
static void StripMonNameForLinkContest(u8 *monName, s32 language)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
u8 chr;
|
|
|
|
|
|
|
|
StripExtCtrlCodes(monName);
|
|
|
|
if (language == LANGUAGE_JAPANESE)
|
|
|
|
{
|
|
|
|
monName[5] = EOS;
|
|
|
|
monName[POKEMON_NAME_LENGTH] = EXT_CTRL_CODE_BEGIN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chr = monName[5];
|
|
|
|
monName[5] = EOS;
|
|
|
|
monName[POKEMON_NAME_LENGTH] = chr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 02:25:56 +02:00
|
|
|
void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language)
|
2019-01-28 18:13:07 +01:00
|
|
|
{
|
|
|
|
u8 *name = mon->nickname;
|
|
|
|
|
|
|
|
if (language == LANGUAGE_JAPANESE)
|
|
|
|
{
|
2020-07-12 02:25:56 +02:00
|
|
|
ConvertInternationalString(name, GetMonNicknameLanguage(name));
|
2019-01-28 18:13:07 +01:00
|
|
|
}
|
|
|
|
else if (name[POKEMON_NAME_LENGTH] == EXT_CTRL_CODE_BEGIN)
|
|
|
|
{
|
|
|
|
ConvertInternationalString(name, LANGUAGE_JAPANESE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name[5] = name[POKEMON_NAME_LENGTH];
|
|
|
|
name[POKEMON_NAME_LENGTH] = EOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = mon->trainerName;
|
|
|
|
if (language == LANGUAGE_JAPANESE)
|
|
|
|
{
|
|
|
|
name[PLAYER_NAME_LENGTH] = EOS;
|
|
|
|
name[6] = name[4];
|
|
|
|
name[5] = name[3];
|
|
|
|
name[4] = name[2];
|
|
|
|
name[3] = name[1];
|
|
|
|
name[2] = mon->trainerName[0];
|
|
|
|
name[1] = EXT_CTRL_CODE_JPN;
|
|
|
|
name[0] = EXT_CTRL_CODE_BEGIN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name[5] = name[PLAYER_NAME_LENGTH];
|
|
|
|
name[PLAYER_NAME_LENGTH] = EOS;
|
|
|
|
}
|
|
|
|
}
|
2019-04-02 00:31:10 +02:00
|
|
|
|