pokeemerald/src/contest_effect.c

1084 lines
37 KiB
C
Raw Normal View History

2018-08-12 23:20:17 +02:00
#include "global.h"
#include "random.h"
2018-08-13 21:24:11 +02:00
#include "constants/moves.h"
2018-08-12 23:20:17 +02:00
#include "contest.h"
#include "contest_effect.h"
static void ContestEffect_HighlyAppealing(void);
static void ContestEffect_UserMoreEasilyStartled(void);
static void ContestEffect_GreatAppealButNoMoreMoves(void);
static void ContestEffect_RepetitionNotBoring(void);
static void ContestEffect_AvoidStartleOnce(void);
static void ContestEffect_AvoidStartle(void);
static void ContestEffect_AvoidStartleSlightly(void);
static void ContestEffect_UserLessEasilyStartled(void);
static void ContestEffect_StartleFrontMon(void);
static void ContestEffect_StartlePrevMons(void);
static void ContestEffect_StartlePrevMon2(void);
static void ContestEffect_StartlePrevMons2(void);
static void ContestEffect_ShiftJudgeAttention(void);
static void ContestEffect_StartleMonWithJudgesAttention(void);
static void ContestEffect_JamsOthersButMissOneTurn(void);
static void ContestEffect_StartleMonsSameTypeAppeal(void);
static void ContestEffect_StartleMonsCoolAppeal(void);
static void ContestEffect_StartleMonsBeautyAppeal(void);
static void ContestEffect_StartleMonsCuteAppeal(void);
static void ContestEffect_StartleMonsSmartAppeal(void);
static void ContestEffect_StartleMonsToughAppeal(void);
static void ContestEffect_MakeFollowingMonNervous(void);
static void ContestEffect_MakeFollowingMonsNervous(void);
static void ContestEffect_WorsenConditionOfPrevMons(void);
static void ContestEffect_BadlyStartlesMonsInGoodCondition(void);
static void ContestEffect_BetterIfFirst(void);
static void ContestEffect_BetterIfLast(void);
static void ContestEffect_AppealAsGoodAsPrevOnes(void);
static void ContestEffect_AppealAsGoodAsPrevOne(void);
static void ContestEffect_BetterWhenLater(void);
static void ContestEffect_QualityDependsOnTiming(void);
static void ContestEffect_BetterIfSameType(void);
static void ContestEffect_BetterIfDiffType(void);
static void ContestEffect_AffectedByPrevAppeal(void);
static void ContestEffect_ImproveConditionPreventNervousness(void);
static void ContestEffect_BetterWithGoodCondition(void);
static void ContestEffect_NextAppealEarlier(void);
static void ContestEffect_NextAppealLater(void);
static void ContestEffect_MakeScramblingTurnOrderEasier(void);
static void ContestEffect_ScrambleNextTurnOrder(void);
static void ContestEffect_ExciteAudienceInAnyContest(void);
static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void);
static void ContestEffect_BetterWhenAudienceExcited(void);
static void ContestEffect_DontExciteAudience(void);
static void JamByMoveCategory(u8);
static bool8 CanUnnerveContestant(u8);
static u8 WasAtLeastOneOpponentJammed(void);
static void JamContestant(u8, u8);
static s16 RoundTowardsZero(s16);
static s16 RoundUp(s16);
#include "data/contest_moves.h"
bool8 AreMovesContestCombo(u16 lastMove, u16 nextMove)
{
2020-08-27 12:01:28 +02:00
int i;
2018-08-12 23:20:17 +02:00
u8 lastMoveComboStarterId = gContestMoves[lastMove].comboStarterId;
if (lastMoveComboStarterId == 0)
{
return FALSE;
}
else
{
for (i = 0; i < MAX_COMBO_MOVES; i++)
{
if (lastMoveComboStarterId == gContestMoves[nextMove].comboMoves[i])
return TRUE;
}
return FALSE;
}
2018-08-12 23:20:17 +02:00
}
// A highly appealing move.
static void ContestEffect_HighlyAppealing(void)
{
}
// After this move, the user is more easily startled.
static void ContestEffect_UserMoreEasilyStartled(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].moreEasilyStartled = TRUE;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_MORE_CONSCIOUS);
2018-08-12 23:20:17 +02:00
}
// Makes a great appeal, but allows no more to the end.
static void ContestEffect_GreatAppealButNoMoreMoves(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].exploded = TRUE;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_NO_APPEAL);
2018-08-12 23:20:17 +02:00
}
// Can be used repeatedly without boring the JUDGE.
static void ContestEffect_RepetitionNotBoring(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].usedRepeatableMove = TRUE;
eContestantStatus[eContestAppealResults.contestant].repeatedMove = FALSE;
eContestantStatus[eContestAppealResults.contestant].moveRepeatCount = 0;
2018-08-12 23:20:17 +02:00
}
// Can avoid being startled by others once.
static void ContestEffect_AvoidStartleOnce(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].jamSafetyCount = 1;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_SETTLE_DOWN);
2018-08-12 23:20:17 +02:00
}
// Can avoid being startled by others.
static void ContestEffect_AvoidStartle(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].immune = TRUE;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_OBLIVIOUS_TO_OTHERS);
2018-08-12 23:20:17 +02:00
}
// Can avoid being startled by others a little.
static void ContestEffect_AvoidStartleSlightly(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].jamReduction = 20;
SetContestantEffectStringID(eContestAppealResults.contestant,CONTEST_STRING_LESS_AWARE);
2018-08-12 23:20:17 +02:00
}
// After this move, the user is less likely to be startled.
static void ContestEffect_UserLessEasilyStartled(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].resistant = TRUE;
SetContestantEffectStringID(eContestAppealResults.contestant,CONTEST_STRING_STOPPED_CARING);
2018-08-12 23:20:17 +02:00
}
// Slightly startles the POK<4F>MON in front.
static void ContestEffect_StartleFrontMon(void)
{
u8 idx = 0;
2020-08-15 20:33:08 +02:00
u8 a = eContestAppealResults.contestant;
2018-08-12 23:20:17 +02:00
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[a] != 0) {
2018-08-12 23:20:17 +02:00
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[a] - 1 == eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
break;
}
2020-08-15 20:33:08 +02:00
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
idx = WasAtLeastOneOpponentJammed();
}
if (idx == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Slightly startles those that have made appeals.
static void ContestEffect_StartlePrevMons(void)
{
u8 idx = 0;
2020-08-15 20:33:08 +02:00
u8 contestant = eContestAppealResults.contestant;
2018-08-12 23:20:17 +02:00
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[contestant] != 0)
2018-08-13 21:24:11 +02:00
{
int i, j;
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (i = 0, j = 0; i < CONTESTANT_COUNT; i++)
2018-08-13 21:24:11 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[contestant] > eContestAppealResults.turnOrder[i])
eContestAppealResults.jamQueue[j++] = i;
2018-08-13 21:24:11 +02:00
}
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[j] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
idx = WasAtLeastOneOpponentJammed();
}
if (idx == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Startles the POK<4F>MON that appealed before the user.
static void ContestEffect_StartlePrevMon2(void)
{
u8 rval = Random() % 10;
int jam;
if (rval < 2)
jam = 20;
else if (rval < 8)
jam = 40;
else
jam = 60;
2018-08-13 21:24:11 +02:00
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = jam;
2018-08-12 23:20:17 +02:00
ContestEffect_StartleFrontMon();
}
// Startles all POK<4F>MON that appealed before the user.
static void ContestEffect_StartlePrevMons2(void)
{
u8 numStartled = 0;
2020-08-15 20:33:08 +02:00
u8 contestant = eContestAppealResults.contestant;
u8 turnOrder = eContestAppealResults.turnOrder[contestant];
2018-08-12 23:20:17 +02:00
2018-08-15 00:25:19 +02:00
if (turnOrder != 0)
2018-08-12 23:20:17 +02:00
{
int i;
for (i = 0; i < 4; i++)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[contestant] > eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2018-08-13 21:24:11 +02:00
u8 rval, jam;
2020-08-15 20:33:08 +02:00
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-13 21:24:11 +02:00
rval = Random() % 10;
2018-08-12 23:20:17 +02:00
if (rval == 0)
jam = 0;
else if (rval <= 2)
jam = 10;
else if (rval <= 4)
jam = 20;
else if (rval <= 6)
jam = 30;
else if (rval <= 8)
jam = 40;
else
jam = 60;
2018-08-13 21:24:11 +02:00
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = jam;
2018-08-13 21:24:11 +02:00
2018-08-12 23:20:17 +02:00
if (WasAtLeastOneOpponentJammed())
numStartled++;
}
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
if (numStartled == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
2018-12-07 23:01:14 +01:00
// Shifts the JUDGE's attention from others.
2018-08-12 23:20:17 +02:00
static void ContestEffect_ShiftJudgeAttention(void)
{
bool32 hitAny = FALSE;
2020-08-15 20:33:08 +02:00
u8 contestant = eContestAppealResults.contestant;
2018-08-12 23:20:17 +02:00
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 0)
2018-08-12 23:20:17 +02:00
{
int i;
for (i = 0; i < 4; i++)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[contestant] > eContestAppealResults.turnOrder[i] &&
2019-04-02 06:35:57 +02:00
eContestantStatus[i].hasJudgesAttention &&
2018-08-12 23:20:17 +02:00
CanUnnerveContestant(i))
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].hasJudgesAttention = FALSE;
eContestantStatus[i].judgesAttentionWasRemoved = TRUE;
2018-08-12 23:20:17 +02:00
SetContestantEffectStringID(i, CONTEST_STRING_JUDGE_LOOK_AWAY2);
hitAny = TRUE;
}
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant,CONTEST_STRING_DAZZLE_ATTEMPT);
2018-08-12 23:20:17 +02:00
if (!hitAny)
{
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
}
2018-12-07 23:01:14 +01:00
// Startles the POK<4F>MON that has the JUDGE's attention.
2018-08-12 23:20:17 +02:00
static void ContestEffect_StartleMonWithJudgesAttention(void)
{
u8 numStartled = 0;
2020-08-15 20:33:08 +02:00
u8 contestant = eContestAppealResults.contestant;
2018-08-12 23:20:17 +02:00
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 0)
2018-08-12 23:20:17 +02:00
{
int i;
for (i = 0; i < 4; i++)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[contestant] > eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
if (eContestantStatus[i].hasJudgesAttention)
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 50;
2018-08-12 23:20:17 +02:00
else
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 10;
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
if (WasAtLeastOneOpponentJammed())
numStartled++;
}
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
if (numStartled == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
// Jams the others, and misses one turn of appeals.
static void ContestEffect_JamsOthersButMissOneTurn(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].turnSkipped = TRUE;
2018-08-12 23:20:17 +02:00
ContestEffect_StartlePrevMons();
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Startles POK<4F>MON that made a same-type appeal.
static void ContestEffect_StartleMonsSameTypeAppeal(void)
{
2020-08-15 20:33:08 +02:00
u16 move = eContestantStatus[eContestAppealResults.contestant].currMove;
2018-08-12 23:20:17 +02:00
JamByMoveCategory(gContestMoves[move].contestCategory);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON that made COOL appeals.
static void ContestEffect_StartleMonsCoolAppeal(void)
{
JamByMoveCategory(CONTEST_CATEGORY_COOL);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON that made BEAUTY appeals.
static void ContestEffect_StartleMonsBeautyAppeal(void)
{
JamByMoveCategory(CONTEST_CATEGORY_BEAUTY);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON that made CUTE appeals.
static void ContestEffect_StartleMonsCuteAppeal(void)
{
JamByMoveCategory(CONTEST_CATEGORY_CUTE);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON that made SMART appeals.
static void ContestEffect_StartleMonsSmartAppeal(void)
{
JamByMoveCategory(CONTEST_CATEGORY_SMART);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON that made TOUGH appeals.
static void ContestEffect_StartleMonsToughAppeal(void)
{
JamByMoveCategory(CONTEST_CATEGORY_TOUGH);
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// Makes one POK<4F>MON after the user nervous.
static void ContestEffect_MakeFollowingMonNervous(void)
{
bool32 hitAny = FALSE;
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 3)
2018-08-12 23:20:17 +02:00
{
int i;
for (i = 0; i < 4; i++)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] + 1 == eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
if (CanUnnerveContestant(i))
{
MakeContestantNervous(i);
SetContestantEffectStringID(i, CONTEST_STRING_NERVOUS);
hitAny = TRUE;
}
else
{
SetContestantEffectStringID(i, CONTEST_STRING_UNAFFECTED);
hitAny = TRUE;
}
}
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_UNNERVE_ATTEMPT);
2018-08-12 23:20:17 +02:00
if (!hitAny)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
// Makes all POK<4F>MON after the user nervous.
static void ContestEffect_MakeFollowingMonsNervous(void)
{
u8 numUnnerved = 0;
bool32 contestantUnnerved = FALSE;
u8 contestantIds[5];
int i;
int numAfter;
2020-07-12 02:25:56 +02:00
s16 oddsMod[CONTESTANT_COUNT];
s16 odds[CONTESTANT_COUNT];
2018-08-12 23:20:17 +02:00
2023-08-10 07:21:38 +02:00
memset(contestantIds, CONTESTANT_NONE, ARRAY_COUNT(contestantIds));
2020-07-12 02:25:56 +02:00
for (i = 0, numAfter = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] < eContestAppealResults.turnOrder[i] &&
2019-04-02 06:35:57 +02:00
!eContestantStatus[i].nervous && !Contest_IsMonsTurnDisabled(i))
2018-08-12 23:20:17 +02:00
contestantIds[numAfter++] = i;
}
if (numAfter == 1)
{
odds[0] = 60;
}
else if (numAfter == 2)
{
odds[0] = 30;
odds[1] = 30;
}
else if (numAfter == 3)
{
odds[0] = 20;
odds[1] = 20;
odds[2] = 20;
}
else
{
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
odds[i] = 0;
}
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-14 01:10:23 +02:00
if (eContestantStatus[i].hasJudgesAttention && IsContestantAllowedToCombo(i))
oddsMod[i] = gContestMoves[eContestantStatus[i].prevMove].comboStarterId == 0 ? 0 : 10;
2018-08-12 23:20:17 +02:00
else
oddsMod[i] = 0;
2019-04-02 06:35:57 +02:00
oddsMod[i] -= (eContestantStatus[i].condition / 10) * 10;
2018-08-12 23:20:17 +02:00
}
if (odds[0] != 0)
{
2023-08-10 07:21:38 +02:00
for (i = 0; contestantIds[i] != CONTESTANT_NONE; i++)
2018-08-12 23:20:17 +02:00
{
if (Random() % 100 < odds[i] + oddsMod[contestantIds[i]])
{
if (CanUnnerveContestant(contestantIds[i]))
{
MakeContestantNervous(contestantIds[i]);
SetContestantEffectStringID(contestantIds[i], CONTEST_STRING_NERVOUS);
numUnnerved++;
2018-08-16 22:55:36 +02:00
}
else
{
2018-08-12 23:20:17 +02:00
contestantUnnerved = TRUE;
2018-08-16 22:55:36 +02:00
}
}
else
{
2018-08-12 23:20:17 +02:00
contestantUnnerved = TRUE;
2018-08-16 22:55:36 +02:00
}
2018-08-12 23:20:17 +02:00
if (contestantUnnerved)
{
contestantUnnerved = FALSE;
SetContestantEffectStringID(contestantIds[i], CONTEST_STRING_UNAFFECTED);
numUnnerved++;
}
2020-08-15 20:33:08 +02:00
eContestAppealResults.unnervedPokes[contestantIds[i]] = 1;
2018-08-12 23:20:17 +02:00
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_UNNERVE_WAITING);
2018-08-12 23:20:17 +02:00
if (numUnnerved == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
// Worsens the condition of those that made appeals.
static void ContestEffect_WorsenConditionOfPrevMons(void)
{
u8 numHit = 0;
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] > eContestAppealResults.turnOrder[i] &&
2019-04-02 06:35:57 +02:00
eContestantStatus[i].condition > 0 &&
2018-08-12 23:20:17 +02:00
CanUnnerveContestant(i))
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].condition = 0;
2020-08-18 17:38:50 +02:00
eContestantStatus[i].conditionMod = CONDITION_LOSE;
2018-08-12 23:20:17 +02:00
SetContestantEffectStringID(i, CONTEST_STRING_REGAINED_FORM);
numHit++;
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_TAUNT_WELL);
2018-08-12 23:20:17 +02:00
if (numHit == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_IGNORED);
2018-08-12 23:20:17 +02:00
}
// Badly startles POK<4F>MON in good condition.
static void ContestEffect_BadlyStartlesMonsInGoodCondition(void)
{
u8 numHit = 0;
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] > eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
if (eContestantStatus[i].condition > 0)
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 40;
2018-08-12 23:20:17 +02:00
else
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 10;
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
if (WasAtLeastOneOpponentJammed())
numHit++;
}
}
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_JAM_WELL);
2018-08-12 23:20:17 +02:00
if (numHit == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_IGNORED);
2018-08-12 23:20:17 +02:00
}
// The appeal works great if performed first.
static void ContestEffect_BetterIfFirst(void)
{
2020-08-15 20:33:08 +02:00
if (gContestantTurnOrder[eContestAppealResults.contestant] == 0)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
u16 move = eContestantStatus[eContestAppealResults.contestant].currMove;
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += 2 * gContestEffects[gContestMoves[move].effect].appeal;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_HUSTLE_STANDOUT);
2018-08-12 23:20:17 +02:00
}
}
// The appeal works great if performed last.
static void ContestEffect_BetterIfLast(void)
{
2020-08-15 20:33:08 +02:00
if (gContestantTurnOrder[eContestAppealResults.contestant] == 3)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
u16 move = eContestantStatus[eContestAppealResults.contestant].currMove;
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += 2 * gContestEffects[gContestMoves[move].effect].appeal;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_WORK_HARD_UNNOTICED);
2018-08-12 23:20:17 +02:00
}
}
// Makes the appeal as good as those before it.
static void ContestEffect_AppealAsGoodAsPrevOnes(void)
{
int i;
int appealSum;
2020-07-12 02:25:56 +02:00
for (i = 0, appealSum = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] > eContestAppealResults.turnOrder[i])
2020-08-16 11:52:17 +02:00
appealSum += eContestantStatus[i].appeal;
2018-08-12 23:20:17 +02:00
}
if (appealSum < 0)
appealSum = 0;
2018-08-16 22:55:36 +02:00
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] == 0 || appealSum == 0)
2018-08-16 22:55:36 +02:00
{
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_NOT_WELL);
2018-08-16 22:55:36 +02:00
}
2018-08-12 23:20:17 +02:00
else
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += appealSum / 2;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_WORK_BEFORE);
2018-08-12 23:20:17 +02:00
}
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = RoundTowardsZero(eContestantStatus[eContestAppealResults.contestant].appeal);
2018-08-12 23:20:17 +02:00
}
// Makes the appeal as good as the one before it.
static void ContestEffect_AppealAsGoodAsPrevOne(void)
{
s16 appeal = 0;
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 0)
2018-08-12 23:20:17 +02:00
{
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] - 1 == eContestAppealResults.turnOrder[i])
2020-08-16 11:52:17 +02:00
appeal = eContestantStatus[i].appeal;
2018-08-12 23:20:17 +02:00
}
}
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] == 0 || appeal <= 0)
2018-08-16 22:55:36 +02:00
{
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_NOT_WELL2);
2018-08-16 22:55:36 +02:00
}
2018-08-12 23:20:17 +02:00
else
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += appeal;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_WORK_PRECEDING);
2018-08-12 23:20:17 +02:00
}
}
// The appeal works better the later it is performed.
static void ContestEffect_BetterWhenLater(void)
{
2020-08-15 20:33:08 +02:00
u8 whichTurn = eContestAppealResults.turnOrder[eContestAppealResults.contestant];
2018-08-12 23:20:17 +02:00
if (whichTurn == 0)
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = 10;
2018-08-12 23:20:17 +02:00
else
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = 20 * whichTurn;
2018-08-12 23:20:17 +02:00
if (whichTurn == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_NOT_SHOWN_WELL);
2018-08-12 23:20:17 +02:00
else if (whichTurn == 1)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL);
2018-08-12 23:20:17 +02:00
else if (whichTurn == 2)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL);
2018-08-12 23:20:17 +02:00
else
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY);
2018-08-12 23:20:17 +02:00
}
2018-12-07 23:01:14 +01:00
// The appeal's quality varies depending on its timing.
2018-08-12 23:20:17 +02:00
static void ContestEffect_QualityDependsOnTiming(void)
{
u8 rval = Random() % 10;
s16 appeal;
if (rval < 3)
{
appeal = 10;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL);
2018-08-12 23:20:17 +02:00
} else if (rval < 6)
{
appeal = 20;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2);
2018-08-12 23:20:17 +02:00
} else if (rval < 8)
{
appeal = 40;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2);
2018-08-12 23:20:17 +02:00
} else if (rval < 9)
{
appeal = 60;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_VERY_WELL);
2018-08-12 23:20:17 +02:00
}
else
{
appeal = 80;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2);
2018-08-12 23:20:17 +02:00
}
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = appeal;
2018-08-12 23:20:17 +02:00
}
static void ContestEffect_BetterIfSameType(void)
{
2020-08-15 20:33:08 +02:00
s8 turnOrder = eContestAppealResults.turnOrder[eContestAppealResults.contestant];
2018-08-14 22:28:25 +02:00
s8 i = turnOrder - 1, j;
u16 move;
2018-08-12 23:20:17 +02:00
2018-08-14 22:28:25 +02:00
if (turnOrder == 0)
return;
while (1)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (j = 0; j < CONTESTANT_COUNT; j++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[j] == i)
2018-08-12 23:20:17 +02:00
break;
}
2019-04-02 06:35:57 +02:00
if (eContestantStatus[j].noMoreTurns || eContestantStatus[j].nervous || eContestantStatus[j].numTurnsSkipped)
2018-08-14 22:28:25 +02:00
{
if (--i < 0)
return;
}
else
2018-08-12 23:20:17 +02:00
{
break;
}
}
2018-08-14 22:28:25 +02:00
2020-08-15 20:33:08 +02:00
move = eContestantStatus[eContestAppealResults.contestant].currMove;
2019-04-02 06:35:57 +02:00
if (gContestMoves[move].contestCategory == gContestMoves[eContestantStatus[j].currMove].contestCategory)
2018-08-14 22:28:25 +02:00
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += gContestEffects[gContestMoves[move].effect].appeal * 2;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_SAME_TYPE_GOOD);
2018-08-14 22:28:25 +02:00
}
2018-08-12 23:20:17 +02:00
}
// Works well if different in type than the one before.
static void ContestEffect_BetterIfDiffType(void)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 0)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
u16 move = eContestantStatus[eContestAppealResults.contestant].currMove;
2018-08-12 23:20:17 +02:00
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] - 1 == eContestAppealResults.turnOrder[i] &&
2019-04-02 06:35:57 +02:00
gContestMoves[move].contestCategory != gContestMoves[eContestantStatus[i].currMove].contestCategory)
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal += gContestEffects[gContestMoves[move].effect].appeal * 2;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_DIFF_TYPE_GOOD);
2018-08-12 23:20:17 +02:00
break;
}
}
}
}
// Affected by how well the appeal in front goes.
static void ContestEffect_AffectedByPrevAppeal(void)
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] != 0)
2018-08-12 23:20:17 +02:00
{
int i;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] - 1 == eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
if (eContestantStatus[eContestAppealResults.contestant].appeal > eContestantStatus[i].appeal)
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal *= 2;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_STOOD_OUT_AS_MUCH);
2018-08-12 23:20:17 +02:00
}
2020-08-16 11:52:17 +02:00
else if (eContestantStatus[eContestAppealResults.contestant].appeal < eContestantStatus[i].appeal)
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = 0;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_NOT_AS_WELL);
2018-08-12 23:20:17 +02:00
}
}
}
}
}
2018-12-07 23:01:14 +01:00
// Ups the user's condition. Helps prevent nervousness.
2018-08-12 23:20:17 +02:00
static void ContestEffect_ImproveConditionPreventNervousness(void)
{
2020-08-15 20:33:08 +02:00
if (eContestantStatus[eContestAppealResults.contestant].condition < 30)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].condition += 10;
2020-08-18 17:38:50 +02:00
eContestantStatus[eContestAppealResults.contestant].conditionMod = CONDITION_GAIN;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_CONDITION_ROSE);
2018-08-12 23:20:17 +02:00
}
else
2018-08-16 22:55:36 +02:00
{
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_NO_CONDITION_IMPROVE);
2018-08-16 22:55:36 +02:00
}
2018-08-12 23:20:17 +02:00
}
2018-12-07 23:01:14 +01:00
// The appeal works well if the user's condition is good.
2018-08-12 23:20:17 +02:00
static void ContestEffect_BetterWithGoodCondition(void)
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].appealTripleCondition = TRUE;
if (eContestantStatus[eContestAppealResults.contestant].condition != 0)
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_HOT_STATUS);
2018-08-12 23:20:17 +02:00
else
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_BAD_CONDITION_WEAK_APPEAL);
2018-08-12 23:20:17 +02:00
}
// The next appeal can be made earlier next turn.
static void ContestEffect_NextAppealEarlier(void)
{
s8 i;
s8 j;
2020-07-12 02:25:56 +02:00
u8 turnOrder[CONTESTANT_COUNT];
2018-08-12 23:20:17 +02:00
2020-07-24 06:14:53 +02:00
if (eContest.appealNumber != CONTEST_LAST_APPEAL)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2019-04-02 06:35:57 +02:00
turnOrder[i] = eContestantStatus[i].nextTurnOrder;
2018-08-12 23:20:17 +02:00
2023-08-10 07:21:38 +02:00
turnOrder[eContestAppealResults.contestant] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (j = 0; j < CONTESTANT_COUNT; j++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (j != eContestAppealResults.contestant &&
2018-08-12 23:20:17 +02:00
i == turnOrder[j] &&
2019-04-02 06:35:57 +02:00
turnOrder[j] == eContestantStatus[j].nextTurnOrder)
2018-08-12 23:20:17 +02:00
{
turnOrder[j]++;
break;
}
}
2020-07-12 02:25:56 +02:00
if (j == CONTESTANT_COUNT)
2018-08-12 23:20:17 +02:00
break;
}
2020-08-15 20:33:08 +02:00
turnOrder[eContestAppealResults.contestant] = 0;
eContestantStatus[eContestAppealResults.contestant].turnOrderMod = 1;
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].nextTurnOrder = turnOrder[i];
2018-08-12 23:20:17 +02:00
}
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].turnOrderModAction = 1;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_MOVE_UP_LINE);
2018-08-12 23:20:17 +02:00
}
}
// The next appeal can be made later next turn.
static void ContestEffect_NextAppealLater(void)
{
s8 i;
s8 j;
2020-07-12 02:25:56 +02:00
u8 turnOrder[CONTESTANT_COUNT];
2018-08-12 23:20:17 +02:00
2020-07-24 06:14:53 +02:00
if (eContest.appealNumber != CONTEST_LAST_APPEAL)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2019-04-02 06:35:57 +02:00
turnOrder[i] = eContestantStatus[i].nextTurnOrder;
2018-08-12 23:20:17 +02:00
2023-08-10 07:21:38 +02:00
turnOrder[eContestAppealResults.contestant] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (i = CONTESTANT_COUNT - 1; i > -1; i--)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (j = 0; j < CONTESTANT_COUNT; j++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (j != eContestAppealResults.contestant &&
2018-08-12 23:20:17 +02:00
i == turnOrder[j] &&
2019-04-02 06:35:57 +02:00
turnOrder[j] == eContestantStatus[j].nextTurnOrder)
2018-08-12 23:20:17 +02:00
{
turnOrder[j]--;
break;
}
}
2020-07-12 02:25:56 +02:00
if (j == CONTESTANT_COUNT)
2018-08-12 23:20:17 +02:00
break;
}
2020-08-15 20:33:08 +02:00
turnOrder[eContestAppealResults.contestant] = CONTESTANT_COUNT - 1;
eContestantStatus[eContestAppealResults.contestant].turnOrderMod = 1;
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].nextTurnOrder = turnOrder[i];
2018-08-12 23:20:17 +02:00
}
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].turnOrderModAction = 2;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_MOVE_BACK_LINE);
2018-08-12 23:20:17 +02:00
}
}
2018-12-07 23:01:14 +01:00
// Makes the next turn's order more easily scrambled.
2018-08-12 23:20:17 +02:00
static void ContestEffect_MakeScramblingTurnOrderEasier(void)
{
// dummied out?
}
// Scrambles the order of appeals on the next turn.
static void ContestEffect_ScrambleNextTurnOrder(void)
{
s8 i;
s8 j;
2020-07-12 02:25:56 +02:00
u8 turnOrder[CONTESTANT_COUNT];
u8 unselectedContestants[CONTESTANT_COUNT];
2018-08-12 23:20:17 +02:00
2020-07-24 06:14:53 +02:00
if (eContest.appealNumber != CONTEST_LAST_APPEAL)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
turnOrder[i] = eContestantStatus[i].nextTurnOrder;
2018-08-12 23:20:17 +02:00
unselectedContestants[i] = i;
}
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-07-12 02:25:56 +02:00
u8 rval = Random() % (CONTESTANT_COUNT - i);
2018-08-12 23:20:17 +02:00
2020-07-12 02:25:56 +02:00
for (j = 0; j < CONTESTANT_COUNT; j++)
2018-08-12 23:20:17 +02:00
{
2023-08-10 07:21:38 +02:00
if (unselectedContestants[j] != CONTESTANT_NONE)
2018-08-12 23:20:17 +02:00
{
if (rval == 0)
{
turnOrder[j] = i;
2023-08-10 07:21:38 +02:00
unselectedContestants[j] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
break;
}
else
rval--;
}
}
}
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].nextTurnOrder = turnOrder[i];
eContestantStatus[i].turnOrderMod = 2;
2018-08-12 23:20:17 +02:00
}
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].turnOrderModAction = 3;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_SCRAMBLE_ORDER);
2018-08-12 23:20:17 +02:00
}
}
// An appeal that excites the audience in any CONTEST.
static void ContestEffect_ExciteAudienceInAnyContest(void)
{
2020-08-15 20:33:08 +02:00
if (gContestMoves[eContestantStatus[eContestAppealResults.contestant].currMove].contestCategory != gSpecialVar_ContestCategory)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
eContestantStatus[eContestAppealResults.contestant].overrideCategoryExcitementMod = TRUE;
2018-08-12 23:20:17 +02:00
}
}
// Badly startles all POK<4F>MON that made good appeals.
static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void)
{
int i;
u8 numJammed = 0;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] > eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
if (eContestantStatus[i].appeal > 0)
2018-08-12 23:20:17 +02:00
{
2020-08-16 11:52:17 +02:00
eContestAppealResults.jam = eContestantStatus[i].appeal / 2;
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = RoundUp(eContestAppealResults.jam);
2018-08-12 23:20:17 +02:00
}
else
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 10;
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
if (WasAtLeastOneOpponentJammed())
numJammed++;
}
}
if (numJammed == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTEMPT_STARTLE);
2018-08-12 23:20:17 +02:00
}
// The appeal works best the more the crowd is excited.
static void ContestEffect_BetterWhenAudienceExcited(void)
{
s16 appeal;
2019-04-02 06:35:57 +02:00
if (eContest.applauseLevel == 0)
2018-08-12 23:20:17 +02:00
{
appeal = 10;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_NOT_VERY_WELL);
2018-08-12 23:20:17 +02:00
}
2019-04-02 06:35:57 +02:00
else if (eContest.applauseLevel == 1)
2018-08-12 23:20:17 +02:00
{
appeal = 20;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_SLIGHTLY_WELL2);
2018-08-12 23:20:17 +02:00
}
2019-04-02 06:35:57 +02:00
else if (eContest.applauseLevel == 2)
2018-08-12 23:20:17 +02:00
{
appeal = 30;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_PRETTY_WELL2);
2018-08-12 23:20:17 +02:00
}
2019-04-02 06:35:57 +02:00
else if (eContest.applauseLevel == 3)
2018-08-12 23:20:17 +02:00
{
appeal = 50;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_VERY_WELL);
2018-08-12 23:20:17 +02:00
}
else
{
appeal = 60;
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_APPEAL_EXCELLENTLY2);
2018-08-12 23:20:17 +02:00
}
2020-08-16 11:52:17 +02:00
eContestantStatus[eContestAppealResults.contestant].appeal = appeal;
2018-08-12 23:20:17 +02:00
}
// Temporarily stops the crowd from growing excited.
static void ContestEffect_DontExciteAudience(void)
{
2020-08-15 20:33:08 +02:00
if (!eContestExcitement.frozen)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
eContestExcitement.frozen = TRUE;
eContestExcitement.freezer = eContestAppealResults.contestant;
SetContestantEffectStringID(eContestAppealResults.contestant, CONTEST_STRING_ATTRACTED_ATTENTION);
2018-08-12 23:20:17 +02:00
}
}
static void JamByMoveCategory(u8 category)
{
int i;
int numJammed = 0;
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
if (eContestAppealResults.turnOrder[eContestAppealResults.contestant] > eContestAppealResults.turnOrder[i])
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
if (category == gContestMoves[eContestantStatus[i].currMove].contestCategory)
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 40;
2018-08-12 23:20:17 +02:00
else
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam = 10;
eContestAppealResults.jamQueue[0] = i;
2023-08-10 07:21:38 +02:00
eContestAppealResults.jamQueue[1] = CONTESTANT_NONE;
2018-08-12 23:20:17 +02:00
if (WasAtLeastOneOpponentJammed())
numJammed++;
}
}
if (numJammed == 0)
2020-08-15 20:33:08 +02:00
SetContestantEffectStringID2(eContestAppealResults.contestant, CONTEST_STRING_MESSED_UP2);
2018-08-12 23:20:17 +02:00
}
static bool8 CanUnnerveContestant(u8 i)
{
2020-08-15 20:33:08 +02:00
eContestAppealResults.unnervedPokes[i] = 1;
2019-04-02 06:35:57 +02:00
if (eContestantStatus[i].immune)
2018-08-12 23:20:17 +02:00
{
SetContestantEffectStringID(i, CONTEST_STRING_AVOID_SEEING);
return FALSE;
}
2019-04-02 06:35:57 +02:00
else if (eContestantStatus[i].jamSafetyCount != 0)
2018-08-12 23:20:17 +02:00
{
2019-04-02 06:35:57 +02:00
eContestantStatus[i].jamSafetyCount--;
2018-08-12 23:20:17 +02:00
SetContestantEffectStringID(i, CONTEST_STRING_AVERT_GAZE);
return FALSE;
}
2019-04-02 06:35:57 +02:00
else if (!eContestantStatus[i].noMoreTurns && eContestantStatus[i].numTurnsSkipped == 0)
2018-08-12 23:20:17 +02:00
{
return TRUE;
}
2018-08-16 22:55:36 +02:00
else
{
return FALSE;
}
2018-08-12 23:20:17 +02:00
}
static bool8 WasAtLeastOneOpponentJammed(void)
{
2020-07-12 02:25:56 +02:00
s16 jamBuffer[CONTESTANT_COUNT] = {0};
2018-08-12 23:20:17 +02:00
int i;
2023-08-10 07:21:38 +02:00
for (i = 0; eContestAppealResults.jamQueue[i] != CONTESTANT_NONE; i++)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
u8 contestant = eContestAppealResults.jamQueue[i];
2018-08-12 23:20:17 +02:00
if (CanUnnerveContestant(contestant))
{
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam2 = eContestAppealResults.jam;
2019-04-02 06:35:57 +02:00
if (eContestantStatus[contestant].moreEasilyStartled)
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam2 *= 2;
2019-04-02 06:35:57 +02:00
if (eContestantStatus[contestant].resistant)
2018-08-12 23:20:17 +02:00
{
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam2 = 10;
2018-08-12 23:20:17 +02:00
SetContestantEffectStringID(contestant, CONTEST_STRING_LITTLE_DISTRACTED);
}
else
{
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam2 -= eContestantStatus[contestant].jamReduction;
if (eContestAppealResults.jam2 <= 0)
2018-08-13 21:24:11 +02:00
{
2020-08-15 20:33:08 +02:00
eContestAppealResults.jam2 = 0;
2018-08-13 21:24:11 +02:00
SetContestantEffectStringID(contestant, CONTEST_STRING_NOT_FAZED);
}
else
{
2020-08-15 20:33:08 +02:00
JamContestant(contestant, eContestAppealResults.jam2);
SetStartledString(contestant, eContestAppealResults.jam2);
jamBuffer[contestant] = eContestAppealResults.jam2;
2018-08-13 21:24:11 +02:00
}
2018-08-12 23:20:17 +02:00
}
}
}
2020-07-12 02:25:56 +02:00
for (i = 0; i < CONTESTANT_COUNT; i++)
2018-08-12 23:20:17 +02:00
{
if (jamBuffer[i] != 0)
return TRUE;
}
return FALSE;
}
static void JamContestant(u8 i, u8 jam)
{
2020-08-16 11:52:17 +02:00
eContestantStatus[i].appeal -= jam;
2019-04-02 06:35:57 +02:00
eContestantStatus[i].jam += jam;
2018-08-12 23:20:17 +02:00
}
static s16 RoundTowardsZero(s16 score)
{
s16 absScore = abs(score) % 10;
if (score < 0)
{
if (absScore != 0)
score -= 10 - absScore;
}
else
score -= absScore;
return score;
}
static s16 RoundUp(s16 score)
{
s16 absScore = abs(score) % 10;
if (absScore != 0)
score += 10 - absScore;
return score;
}