diff --git a/include/constants/global.h b/include/constants/global.h index 9b0c46ce40..1cece79753 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -86,6 +86,7 @@ #define EASY_CHAT_BATTLE_WORDS_COUNT 6 #define MOVE_NAME_LENGTH 12 #define NUM_QUESTIONNAIRE_WORDS 4 +#define QUIZ_QUESTION_LEN 9 #define MALE 0 #define FEMALE 1 diff --git a/include/constants/lilycove_lady.h b/include/constants/lilycove_lady.h index 11b9b31e93..e6327904d3 100644 --- a/include/constants/lilycove_lady.h +++ b/include/constants/lilycove_lady.h @@ -20,8 +20,6 @@ #define QUIZ_AUTHOR_NAME_LADY 0 #define QUIZ_AUTHOR_NAME_PLAYER 1 #define QUIZ_AUTHOR_NAME_OTHER_PLAYER 2 - -#define QUIZ_QUESTION_LEN 9 // Constants for how many good Pokéblocks the Contest Lady was given // This determines how her performance is described when her TV show comes on diff --git a/include/global.h b/include/global.h index e4c11f9ef2..db4a17f1be 100644 --- a/include/global.h +++ b/include/global.h @@ -761,7 +761,7 @@ struct LilycoveLadyQuiz { /*0x000*/ u8 id; /*0x001*/ u8 state; - /*0x002*/ u16 question[9]; + /*0x002*/ u16 question[QUIZ_QUESTION_LEN]; /*0x014*/ u16 correctAnswer; /*0x016*/ u16 playerAnswer; /*0x018*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; diff --git a/src/data/lilycove_lady.h b/src/data/lilycove_lady.h index 818a5fd5f3..74c049059f 100644 --- a/src/data/lilycove_lady.h +++ b/src/data/lilycove_lady.h @@ -20,7 +20,7 @@ static const u16 sLilycoveLadyGfxId[] = }; // Quiz Lady data -static const u16 sQuizLadyQuestion1[] = +static const u16 sQuizLadyQuestion1[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_STORES, @@ -33,7 +33,7 @@ static const u16 sQuizLadyQuestion1[] = EC_WORD_POKENAV }; -static const u16 sQuizLadyQuestion2[] = +static const u16 sQuizLadyQuestion2[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_ISN_T, @@ -46,7 +46,7 @@ static const u16 sQuizLadyQuestion2[] = EC_WORD_DARK }; -static const u16 sQuizLadyQuestion3[] = +static const u16 sQuizLadyQuestion3[QUIZ_QUESTION_LEN] = { EC_WORD_HOW, EC_WORD_DO, @@ -59,7 +59,7 @@ static const u16 sQuizLadyQuestion3[] = EC_WORD_CUTE_CHARM }; -static const u16 sQuizLadyQuestion4[] = +static const u16 sQuizLadyQuestion4[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_IS, @@ -72,7 +72,7 @@ static const u16 sQuizLadyQuestion4[] = EC_WORD_MACHINE }; -static const u16 sQuizLadyQuestion5[] = +static const u16 sQuizLadyQuestion5[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_ITEM, @@ -85,7 +85,7 @@ static const u16 sQuizLadyQuestion5[] = EC_WORD_PHONE }; -static const u16 sQuizLadyQuestion6[] = +static const u16 sQuizLadyQuestion6[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_WILL, @@ -98,7 +98,7 @@ static const u16 sQuizLadyQuestion6[] = EC_WORD_SWIFT_SWIM }; -static const u16 sQuizLadyQuestion7[] = +static const u16 sQuizLadyQuestion7[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_OF, @@ -111,7 +111,7 @@ static const u16 sQuizLadyQuestion7[] = EC_WORD_ROCK }; -static const u16 sQuizLadyQuestion8[] = +static const u16 sQuizLadyQuestion8[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_WILL, @@ -124,7 +124,7 @@ static const u16 sQuizLadyQuestion8[] = EC_WORD_WONDER_GUARD }; -static const u16 sQuizLadyQuestion9[] = +static const u16 sQuizLadyQuestion9[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_WILL, @@ -137,7 +137,7 @@ static const u16 sQuizLadyQuestion9[] = EC_WORD_SHED_SKIN }; -static const u16 sQuizLadyQuestion10[] = +static const u16 sQuizLadyQuestion10[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_GOES, @@ -150,7 +150,7 @@ static const u16 sQuizLadyQuestion10[] = EC_WORD_POKENAV }; -static const u16 sQuizLadyQuestion11[] = +static const u16 sQuizLadyQuestion11[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_STORES, @@ -163,7 +163,7 @@ static const u16 sQuizLadyQuestion11[] = EC_WORD_TELEVISION }; -static const u16 sQuizLadyQuestion12[] = +static const u16 sQuizLadyQuestion12[QUIZ_QUESTION_LEN] = { EC_WORD_WHICH, EC_WORD_MACHINE, @@ -176,7 +176,7 @@ static const u16 sQuizLadyQuestion12[] = EC_WORD_TELEVISION }; -static const u16 sQuizLadyQuestion13[] = +static const u16 sQuizLadyQuestion13[QUIZ_QUESTION_LEN] = { EC_WORD_A, EC_WORD_POKEMON, @@ -189,7 +189,7 @@ static const u16 sQuizLadyQuestion13[] = EC_WORD_LETTER }; -static const u16 sQuizLadyQuestion14[] = +static const u16 sQuizLadyQuestion14[QUIZ_QUESTION_LEN] = { EC_WORD_STEEL, EC_WORD_IS, @@ -202,7 +202,7 @@ static const u16 sQuizLadyQuestion14[] = EC_EMPTY_WORD }; -static const u16 sQuizLadyQuestion15[] = +static const u16 sQuizLadyQuestion15[QUIZ_QUESTION_LEN] = { EC_WORD_DARK, EC_WORD_IS, @@ -215,7 +215,7 @@ static const u16 sQuizLadyQuestion15[] = EC_EMPTY_WORD }; -static const u16 sQuizLadyQuestion16[] = +static const u16 sQuizLadyQuestion16[QUIZ_QUESTION_LEN] = { EC_WORD_GHOST, EC_WORD_IS, diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index 6fa8ba4eb4..d65502eb43 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -65,15 +65,15 @@ void InitLilycoveLady(void) id >>= 1; switch (id) { - case LILYCOVE_LADY_QUIZ: - InitLilycoveQuizLady(); - break; - case LILYCOVE_LADY_FAVOR: - InitLilycoveFavorLady(); - break; - case LILYCOVE_LADY_CONTEST: - InitLilycoveContestLady(); - break; + case LILYCOVE_LADY_QUIZ: + InitLilycoveQuizLady(); + break; + case LILYCOVE_LADY_FAVOR: + InitLilycoveFavorLady(); + break; + case LILYCOVE_LADY_CONTEST: + InitLilycoveContestLady(); + break; } } @@ -81,15 +81,15 @@ void ResetLilycoveLadyForRecordMix(void) { switch (GetLilycoveLadyId()) { - case LILYCOVE_LADY_QUIZ: - ResetQuizLadyForRecordMix(); - break; - case LILYCOVE_LADY_FAVOR: - ResetFavorLadyForRecordMix(); - break; - case LILYCOVE_LADY_CONTEST: - ResetContestLadyForRecordMix(); - break; + case LILYCOVE_LADY_QUIZ: + ResetQuizLadyForRecordMix(); + break; + case LILYCOVE_LADY_FAVOR: + ResetFavorLadyForRecordMix(); + break; + case LILYCOVE_LADY_CONTEST: + ResetContestLadyForRecordMix(); + break; } } @@ -100,15 +100,15 @@ void InitLilycoveLadyRandomly(void) switch (lady) { - case LILYCOVE_LADY_QUIZ: - InitLilycoveQuizLady(); - break; - case LILYCOVE_LADY_FAVOR: - InitLilycoveFavorLady(); - break; - case LILYCOVE_LADY_CONTEST: - InitLilycoveContestLady(); - break; + case LILYCOVE_LADY_QUIZ: + InitLilycoveQuizLady(); + break; + case LILYCOVE_LADY_FAVOR: + InitLilycoveFavorLady(); + break; + case LILYCOVE_LADY_CONTEST: + InitLilycoveContestLady(); + break; } } @@ -119,10 +119,10 @@ void Script_GetLilycoveLadyId(void) static u8 GetNumAcceptedItems(const u16 *itemsArray) { - u8 items; + u8 numItems; - for (items = 0; *itemsArray != ITEM_NONE; items ++, itemsArray ++); - return items; + for (numItems = 0; *itemsArray != ITEM_NONE; numItems++, itemsArray++); + return numItems; } static void FavorLadyPickFavorAndBestItem(void) @@ -160,17 +160,11 @@ u8 GetFavorLadyState(void) { sFavorLadyPtr = &gSaveBlock1Ptr->lilycoveLady.favor; if (sFavorLadyPtr->state == LILYCOVE_LADY_STATE_PRIZE) - { return LILYCOVE_LADY_STATE_PRIZE; - } else if (sFavorLadyPtr->state == LILYCOVE_LADY_STATE_COMPLETED) - { return LILYCOVE_LADY_STATE_COMPLETED; - } else - { return LILYCOVE_LADY_STATE_READY; - } } static const u8 *GetFavorLadyRequest(u8 idx) @@ -209,7 +203,7 @@ void BufferFavorLadyItemName(void) static void SetFavorLadyPlayerName(const u8 *src, u8 *dest) { - memset(dest, 0xFF, 8); + memset(dest, EOS, PLAYER_NAME_LENGTH + 1); StringCopy7(dest, src); } @@ -254,9 +248,7 @@ static bool8 DoesFavorLadyLikeItem(u16 itemId) sFavorLadyPtr->numItemsGiven++; sFavorLadyPtr->likedItem = TRUE; if (sFavorLadyPtr->bestItem == itemId) - { sFavorLadyPtr->numItemsGiven = LILYCOVE_LADY_GIFT_THRESHOLD; - } break; } sFavorLadyPtr->likedItem = FALSE; @@ -312,9 +304,7 @@ static void QuizLadyPickQuestion(void) questionId = Random() % ARRAY_COUNT(sQuizLadyQuizQuestions); for (i = 0; i < QUIZ_QUESTION_LEN; i ++) - { sQuizLadyPtr->question[i] = sQuizLadyQuizQuestions[questionId][i]; - } sQuizLadyPtr->correctAnswer = sQuizLadyQuizAnswers[questionId]; sQuizLadyPtr->prize = sQuizLadyPrizes[questionId]; sQuizLadyPtr->questionId = questionId; @@ -328,16 +318,16 @@ static void InitLilycoveQuizLady(void) sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; sQuizLadyPtr->id = LILYCOVE_LADY_QUIZ; sQuizLadyPtr->state = LILYCOVE_LADY_STATE_READY; + for (i = 0; i < QUIZ_QUESTION_LEN; i ++) - { - sQuizLadyPtr->question[i] = -1; - } - sQuizLadyPtr->correctAnswer = -1; - sQuizLadyPtr->playerAnswer = -1; + sQuizLadyPtr->question[i] = EC_EMPTY_WORD; + + sQuizLadyPtr->correctAnswer = EC_EMPTY_WORD; + sQuizLadyPtr->playerAnswer = EC_EMPTY_WORD; + for (i = 0; i < TRAINER_ID_LENGTH; i ++) - { sQuizLadyPtr->playerTrainerId[i] = 0; - } + sQuizLadyPtr->prize = ITEM_NONE; sQuizLadyPtr->waitingForChallenger = FALSE; sQuizLadyPtr->prevQuestionId = ARRAY_COUNT(sQuizLadyQuizQuestions); @@ -351,48 +341,37 @@ static void ResetQuizLadyForRecordMix(void) sQuizLadyPtr->id = LILYCOVE_LADY_QUIZ; sQuizLadyPtr->state = LILYCOVE_LADY_STATE_READY; sQuizLadyPtr->waitingForChallenger = FALSE; - sQuizLadyPtr->playerAnswer = -1; + sQuizLadyPtr->playerAnswer = EC_EMPTY_WORD; } u8 GetQuizLadyState(void) { sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; if (sQuizLadyPtr->state == LILYCOVE_LADY_STATE_PRIZE) - { return LILYCOVE_LADY_STATE_PRIZE; - } else if (sQuizLadyPtr->state == LILYCOVE_LADY_STATE_COMPLETED) - { return LILYCOVE_LADY_STATE_COMPLETED; - } else - { return LILYCOVE_LADY_STATE_READY; - } } u8 GetQuizAuthor(void) { - int i; - int j; + s32 i, j; u8 authorNameId; - struct LilycoveLadyQuiz *quiz; + struct LilycoveLadyQuiz *quiz = &gSaveBlock1Ptr->lilycoveLady.quiz; - quiz = &gSaveBlock1Ptr->lilycoveLady.quiz; if (IsEasyChatAnswerUnlocked(quiz->correctAnswer) == FALSE) { i = quiz->questionId; do { - if (++ i >= (int)(ARRAY_COUNT(sQuizLadyQuizQuestions))) - { + if (++i >= (int)ARRAY_COUNT(sQuizLadyQuizQuestions)) i = 0; - } } while (IsEasyChatAnswerUnlocked(sQuizLadyQuizAnswers[i]) == FALSE); - for (j = 0; j < QUIZ_QUESTION_LEN; j ++) - { + + for (j = 0; j < QUIZ_QUESTION_LEN; j++) quiz->question[j] = sQuizLadyQuizQuestions[i][j]; - } quiz->correctAnswer = sQuizLadyQuizAnswers[i]; quiz->prize = sQuizLadyPrizes[i]; quiz->questionId = i; @@ -400,17 +379,11 @@ u8 GetQuizAuthor(void) } authorNameId = BufferQuizAuthorName(); if (authorNameId == QUIZ_AUTHOR_NAME_LADY) - { return QUIZ_AUTHOR_LADY; - } else if (authorNameId == QUIZ_AUTHOR_NAME_OTHER_PLAYER || IsQuizTrainerIdNotPlayer()) - { return QUIZ_AUTHOR_OTHER_PLAYER; - } else - { return QUIZ_AUTHOR_PLAYER; - } } static u8 BufferQuizAuthorName(void) @@ -434,7 +407,7 @@ static u8 BufferQuizAuthorName(void) if (nameLen == GetPlayerNameLength(gSaveBlock2Ptr->playerName)) { u8 *name = sQuizLadyPtr->playerName; - for (i = 0; i < nameLen; i ++) + for (i = 0; i < nameLen; i++) { name = sQuizLadyPtr->playerName; if (name[i] != gSaveBlock2Ptr->playerName[i]) @@ -456,7 +429,7 @@ static bool8 IsQuizTrainerIdNotPlayer(void) sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; notPlayer = FALSE; - for (i = 0; i < TRAINER_ID_LENGTH; i ++) + for (i = 0; i < TRAINER_ID_LENGTH; i++) { if (sQuizLadyPtr->playerTrainerId[i] != gSaveBlock2Ptr->playerTrainerId[i]) { @@ -472,7 +445,7 @@ static u8 GetPlayerNameLength(const u8 *playerName) u8 len; const u8 *ptr; - for (len = 0, ptr = playerName; *ptr != EOS; len ++, ptr ++); + for (len = 0, ptr = playerName; *ptr != EOS; len++, ptr++); return len; } @@ -532,7 +505,7 @@ void SetQuizLadyState_GivePrize(void) void ClearQuizLadyPlayerAnswer(void) { sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; - sQuizLadyPtr->playerAnswer = -1; + sQuizLadyPtr->playerAnswer = EC_EMPTY_WORD; } void Script_QuizLadyOpenBagMenu(void) @@ -544,13 +517,9 @@ void QuizLadyPickNewQuestion(void) { sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; if (BufferQuizAuthorNameAndCheckIfLady()) - { sQuizLadyPtr->prevQuestionId = sQuizLadyPtr->questionId; - } else - { sQuizLadyPtr->prevQuestionId = ARRAY_COUNT(sQuizLadyQuizQuestions); - } QuizLadyPickQuestion(); } @@ -559,11 +528,9 @@ void ClearQuizLadyQuestionAndAnswer(void) u8 i; sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; - for (i = 0; i < QUIZ_QUESTION_LEN; i ++) - { - sQuizLadyPtr->question[i] = -1; - } - sQuizLadyPtr->correctAnswer = -1; + for (i = 0; i < QUIZ_QUESTION_LEN; i++) + sQuizLadyPtr->question[i] = EC_EMPTY_WORD; + sQuizLadyPtr->correctAnswer = EC_EMPTY_WORD; } void QuizLadySetCustomQuestion(void) @@ -583,10 +550,8 @@ void QuizLadyRecordCustomQuizData(void) sQuizLadyPtr = &gSaveBlock1Ptr->lilycoveLady.quiz; sQuizLadyPtr->prize = gSpecialVar_ItemId; - for (i = 0; i < TRAINER_ID_LENGTH; i ++) - { + for (i = 0; i < TRAINER_ID_LENGTH; i++) sQuizLadyPtr->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; - } StringCopy7(sQuizLadyPtr->playerName, gSaveBlock2Ptr->playerName); sQuizLadyPtr->language = gGameLanguage; } @@ -617,18 +582,15 @@ void QuizLadyClearQuestionForRecordMix(const LilycoveLady *lilycoveLady) if (lilycoveLady->quiz.prevQuestionId < ARRAY_COUNT(sQuizLadyQuizQuestions) && sQuizLadyPtr->id == LILYCOVE_LADY_QUIZ) { - for (i = 0; i < 4; i ++) + for (i = 0; i < 4; i++) { if (lilycoveLady->quiz.prevQuestionId != sQuizLadyPtr->questionId) - { break; - } sQuizLadyPtr->questionId = Random() % ARRAY_COUNT(sQuizLadyQuizQuestions); } if (lilycoveLady->quiz.prevQuestionId == sQuizLadyPtr->questionId) - { - sQuizLadyPtr->questionId = (sQuizLadyPtr->questionId + 1) % (int)(ARRAY_COUNT(sQuizLadyQuizQuestions)); - } + sQuizLadyPtr->questionId = (sQuizLadyPtr->questionId + 1) % (int)ARRAY_COUNT(sQuizLadyQuizQuestions); + sQuizLadyPtr->prevQuestionId = lilycoveLady->quiz.prevQuestionId; } } @@ -656,11 +618,10 @@ static void ResetContestLadyForRecordMix(void) sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; sContestLadyPtr->id = LILYCOVE_LADY_CONTEST; sContestLadyPtr->givenPokeblock = FALSE; + if (sContestLadyPtr->numGoodPokeblocksGiven == LILYCOVE_LADY_GIFT_THRESHOLD || sContestLadyPtr->numOtherPokeblocksGiven == LILYCOVE_LADY_GIFT_THRESHOLD) - { ResetContestLadyContestData(); - } } static void ContestLadySavePlayerNameIfHighSheen(u8 sheen) @@ -683,41 +644,41 @@ bool8 GivePokeblockToContestLady(struct Pokeblock *pokeblock) sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; switch (sContestLadyPtr->category) { - case CONTEST_CATEGORY_COOL: - if (pokeblock->spicy != 0) - { - sheen = pokeblock->spicy; - correctFlavor = TRUE; - } - break; - case CONTEST_CATEGORY_BEAUTY: - if (pokeblock->dry != 0) - { - sheen = pokeblock->dry; - correctFlavor = TRUE; - } - break; - case CONTEST_CATEGORY_CUTE: - if (pokeblock->sweet != 0) - { - sheen = pokeblock->sweet; - correctFlavor = TRUE; - } - break; - case CONTEST_CATEGORY_SMART: - if (pokeblock->bitter != 0) - { - sheen = pokeblock->bitter; - correctFlavor = TRUE; - } - break; - case CONTEST_CATEGORY_TOUGH: - if (pokeblock->sour != 0) - { - sheen = pokeblock->sour; - correctFlavor = TRUE; - } - break; + case CONTEST_CATEGORY_COOL: + if (pokeblock->spicy != 0) + { + sheen = pokeblock->spicy; + correctFlavor = TRUE; + } + break; + case CONTEST_CATEGORY_BEAUTY: + if (pokeblock->dry != 0) + { + sheen = pokeblock->dry; + correctFlavor = TRUE; + } + break; + case CONTEST_CATEGORY_CUTE: + if (pokeblock->sweet != 0) + { + sheen = pokeblock->sweet; + correctFlavor = TRUE; + } + break; + case CONTEST_CATEGORY_SMART: + if (pokeblock->bitter != 0) + { + sheen = pokeblock->bitter; + correctFlavor = TRUE; + } + break; + case CONTEST_CATEGORY_TOUGH: + if (pokeblock->sour != 0) + { + sheen = pokeblock->sour; + correctFlavor = TRUE; + } + break; } if (correctFlavor == TRUE) { @@ -731,18 +692,18 @@ bool8 GivePokeblockToContestLady(struct Pokeblock *pokeblock) return correctFlavor; } -static void BufferContestLadyCategoryAndMonName(u8 *dest1, u8 *dest2) +static void BufferContestLadyCategoryAndMonName(u8 *category, u8 *nickname) { sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; - StringCopy(dest1, sContestLadyCategoryNames[sContestLadyPtr->category]); - StringCopy10(dest2, sContestLadyMonNames[sContestLadyPtr->category]); + StringCopy(category, sContestLadyCategoryNames[sContestLadyPtr->category]); + StringCopy10(nickname, sContestLadyMonNames[sContestLadyPtr->category]); } -void BufferContestLadyMonName(u8 *dest1, u8 *dest2) +void BufferContestLadyMonName(u8 *category, u8 *nickname) { sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; - *dest1 = sContestLadyPtr->category; - StringCopy(dest2, sContestLadyMonNames[sContestLadyPtr->category]); + *category = sContestLadyPtr->category; + StringCopy(nickname, sContestLadyMonNames[sContestLadyPtr->category]); } void BufferContestLadyPlayerName(u8 *dest) @@ -779,9 +740,7 @@ bool8 HasPlayerGivenContestLadyPokeblock(void) { sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; if (sContestLadyPtr->givenPokeblock == TRUE) - { return TRUE; - } return FALSE; } @@ -792,9 +751,8 @@ bool8 ShouldContestLadyShowGoOnAir(void) sContestLadyPtr = &gSaveBlock1Ptr->lilycoveLady.contest; if (sContestLadyPtr->numGoodPokeblocksGiven >= LILYCOVE_LADY_GIFT_THRESHOLD || sContestLadyPtr->numOtherPokeblocksGiven >= LILYCOVE_LADY_GIFT_THRESHOLD) - { putOnAir = TRUE; - } + return putOnAir; }