forked from rh-hideout/pokeemerald-expansion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontest.h
363 lines (340 loc) · 10.1 KB
/
contest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#ifndef GUARD_CONTEST_H
#define GUARD_CONTEST_H
#include "palette.h"
#include "constants/contest.h"
#include "random.h" // for rng_value_t
enum
{
CONTEST_STRING_MORE_CONSCIOUS,
CONTEST_STRING_NO_APPEAL,
CONTEST_STRING_SETTLE_DOWN,
CONTEST_STRING_OBLIVIOUS_TO_OTHERS,
CONTEST_STRING_LESS_AWARE,
CONTEST_STRING_STOPPED_CARING,
CONTEST_STRING_STARTLE_ATTEMPT,
CONTEST_STRING_DAZZLE_ATTEMPT,
CONTEST_STRING_JUDGE_LOOK_AWAY2,
CONTEST_STRING_UNNERVE_ATTEMPT,
CONTEST_STRING_NERVOUS,
CONTEST_STRING_UNNERVE_WAITING,
CONTEST_STRING_TAUNT_WELL,
CONTEST_STRING_REGAINED_FORM,
CONTEST_STRING_JAM_WELL,
CONTEST_STRING_HUSTLE_STANDOUT,
CONTEST_STRING_WORK_HARD_UNNOTICED,
CONTEST_STRING_WORK_BEFORE,
CONTEST_STRING_APPEAL_NOT_WELL,
CONTEST_STRING_WORK_PRECEDING,
CONTEST_STRING_APPEAL_NOT_WELL2,
CONTEST_STRING_APPEAL_NOT_SHOWN_WELL,
CONTEST_STRING_APPEAL_SLIGHTLY_WELL,
CONTEST_STRING_APPEAL_PRETTY_WELL,
CONTEST_STRING_APPEAL_EXCELLENTLY,
CONTEST_STRING_APPEAL_DUD,
CONTEST_STRING_APPEAL_NOT_VERY_WELL,
CONTEST_STRING_APPEAL_SLIGHTLY_WELL2,
CONTEST_STRING_APPEAL_PRETTY_WELL2,
CONTEST_STRING_APPEAL_VERY_WELL,
CONTEST_STRING_APPEAL_EXCELLENTLY2,
CONTEST_STRING_SAME_TYPE_GOOD,
CONTEST_STRING_DIFF_TYPE_GOOD,
CONTEST_STRING_STOOD_OUT_AS_MUCH,
CONTEST_STRING_NOT_AS_WELL,
CONTEST_STRING_CONDITION_ROSE,
CONTEST_STRING_HOT_STATUS,
CONTEST_STRING_MOVE_UP_LINE,
CONTEST_STRING_MOVE_BACK_LINE,
CONTEST_STRING_SCRAMBLE_ORDER,
CONTEST_STRING_JUDGE_EXPECTANTLY2,
CONTEST_STRING_WENT_OVER_WELL,
CONTEST_STRING_WENT_OVER_VERY_WELL,
CONTEST_STRING_APPEAL_COMBO_EXCELLENTLY,
CONTEST_STRING_AVERT_GAZE,
CONTEST_STRING_AVOID_SEEING,
CONTEST_STRING_NOT_FAZED,
CONTEST_STRING_LITTLE_DISTRACTED,
CONTEST_STRING_ATTEMPT_STARTLE,
CONTEST_STRING_LOOKED_DOWN,
CONTEST_STRING_TURNED_BACK,
CONTEST_STRING_UTTER_CRY,
CONTEST_STRING_LEAPT_UP,
CONTEST_STRING_TRIPPED_OVER,
CONTEST_STRING_MESSED_UP2,
CONTEST_STRING_FAILED_TARGET_NERVOUS,
CONTEST_STRING_FAILED_ANYONE_NERVOUS,
CONTEST_STRING_IGNORED,
CONTEST_STRING_NO_CONDITION_IMPROVE,
CONTEST_STRING_BAD_CONDITION_WEAK_APPEAL,
CONTEST_STRING_UNAFFECTED,
CONTEST_STRING_ATTRACTED_ATTENTION,
CONTEST_STRING_NONE = 255
};
enum {
CONTEST_FILTER_NONE,
CONTEST_FILTER_NO_POSTGAME,
CONTEST_FILTER_ONLY_POSTGAME
};
// Constants for changing in-contest Condition (the stars that appear during appeals)
enum {
CONDITION_NO_CHANGE,
CONDITION_GAIN,
CONDITION_LOSE,
};
struct ContestPokemon
{
u16 species;
u8 nickname[POKEMON_NAME_LENGTH + 1];
u8 trainerName[PLAYER_NAME_LENGTH + 1];
u8 trainerGfxId;
u32 aiFlags;
u8 whichRank:2;
u8 aiPool_Cool:1;
u8 aiPool_Beauty:1;
u8 aiPool_Cute:1;
u8 aiPool_Smart:1;
u8 aiPool_Tough:1;
u16 moves[MAX_MON_MOVES];
u8 cool;
u8 beauty;
u8 cute;
u8 smart;
u8 tough;
u8 sheen;
u8 highestRank;
bool8 gameCleared;
u8 isShiny:1;
u8 unused1:7;
u32 personality;
u32 otId;
u8 filter;
};
struct ContestTempSave
{
u16 cachedWindowPalettes[16][16]; // Saved palette data before a move happens?
u16 cachedPlttBufferUnfaded[PLTT_BUFFER_SIZE];
u16 cachedPlttBufferFaded[PLTT_BUFFER_SIZE];
u8 savedJunk[0x800];
};
struct ContestMoveAnimData
{
u16 species;
u16 targetSpecies;
bool8 hasTargetAnim:1;
u8 isShiny:1;
u8 targetIsShiny:1;
u8 contestant;
u32 personality;
u32 otId;
u32 targetPersonality;
};
struct Contest
{
u8 playerMoveChoice;
u8 appealNumber;
u8 unk[CONTESTANT_COUNT]; // never read
bool16 unused1:1;
bool16 unused2:1;
bool16 unused3:1;
bool16 unused4:1;
bool16 waitForJudgeSpeechBubble:1;
bool16 isShowingApplauseMeter:1;
bool16 applauseMeterIsMoving:1;
bool16 animatingAudience:1;
bool16 waitForAudienceBlend:1;
bool16 sliderHeartsAnimating:1; // When the slider heart is appearing/disappearing
bool16 waitForLink:1;
u8 mainTaskId;
u8 filler1[4];
u8 judgeAttentionTaskId;
u8 blendTaskId;
u8 filler2;
u8 turnNumber;
u8 currentContestant;
u8 judgeSpeechBubbleSpriteId;
s8 applauseLevel;
u8 prevTurnOrder[CONTESTANT_COUNT];
u32 unusedRng;
u16 moveHistory[CONTEST_NUM_APPEALS][CONTESTANT_COUNT];
u8 excitementHistory[CONTEST_NUM_APPEALS][CONTESTANT_COUNT];
u8 applauseMeterSpriteId;
u8 contestSetupState;
u8 moveAnimTurnCount;
};
struct ContestantStatus
{
s16 baseAppeal;
s16 appeal;
s16 pointTotal;
u16 currMove;
u16 prevMove;
u8 moveCategory;
u8 ranking:2;
u8 unused1:2;
u8 moveRepeatCount:3;
bool8 noMoreTurns:1; // used a one-time move?
bool8 nervous:1;
u8 numTurnsSkipped:2;
s8 condition;
u8 jam;
u8 jamReduction;
// Flags set by move effect
bool8 resistant:1;
bool8 immune:1;
bool8 moreEasilyStartled:1;
bool8 usedRepeatableMove:1;
u8 conditionMod:2; // 1: just raised condition; 2: appeal greatly improved by condition
u8 turnOrderMod:2; // 1: defined; 2: random
u8 turnOrderModAction:2; // 1: made first; 2: made last; 3: made random
bool8 turnSkipped:1;
bool8 exploded:1;
bool8 overrideCategoryExcitementMod:1;
bool8 appealTripleCondition:1;
u8 jamSafetyCount;
u8 effectStringId; // status action?
u8 effectStringId2;
bool8 repeatedMove:1;
bool8 unused2:1;
bool8 repeatedPrevMove:1; // never read
bool8 completedComboFlag:1;
bool8 hasJudgesAttention:1;
bool8 judgesAttentionWasRemoved:1;
bool8 usedComboMove:1;
bool8 completedCombo;
u8 comboAppealBonus;
u8 repeatJam;
u8 nextTurnOrder; // turn position
u8 attentionLevel; // How much the Pokémon "stood out"
u8 contestantAnimTarget;
};
struct ContestAppealMoveResults
{
u8 turnOrder[CONTESTANT_COUNT];
s16 jam;
s16 jam2;
u8 jamQueue[5];
u8 unnervedPokes[CONTESTANT_COUNT];
u8 contestant;
};
struct ContestAIInfo
{
/*0x00*/ u8 aiState;
/*0x02*/ u16 nextMove;
/*0x04*/ u8 nextMoveIndex;
/*0x05*/ u8 moveScores[MAX_MON_MOVES];
/*0x09*/ u8 aiAction;
/*0x0A*/ u8 filler[6];
/*0x10*/ u8 currentAIFlag;
/*0x14*/ u32 aiFlags;
/*0x18*/ s16 scriptResult;
/*0x1A*/ s16 vars[3];
/*0x20*/ const u8 *stack[8];
/*0x40*/ u8 stackSize;
/*0x41*/ u8 contestantId;
};
struct ContestExcitement
{
s8 moveExcitement;
u8 frozen:1;
u8 freezer:3;
s8 excitementAppealBonus;
};
struct ContestGraphicsState
{
u8 sliderHeartSpriteId;
u8 nextTurnSpriteId;
bool8 sliderUpdating:1;
bool8 boxBlinking:1;
bool8 updatingAppealHearts:1;
};
struct ContestFinalStandings
{
s32 totalPoints;
s32 round1Points;
s32 random;
s32 contestant;
};
struct ContestTV
{
u16 appeals[CONTEST_NUM_APPEALS];
s16 move;
u8 winnerFlags;
u8 loserFlags;
bool8 madeAppeal:1;
bool8 madeExcitingAppeal:1;
};
struct ContestUnused
{
u8 filler[12];
};
struct ContestResources
{
struct Contest *contest;
struct ContestantStatus *status;
struct ContestAppealMoveResults *appealResults;
struct ContestAIInfo *aiData;
struct ContestExcitement *excitement;
struct ContestGraphicsState *gfxState;
struct ContestMoveAnimData *moveAnim;
struct ContestTV *tv;
struct ContestUnused * unused;
u8 *contestBgTilemaps[CONTESTANT_COUNT];
void * boxBlinkTiles1;
void * boxBlinkTiles2;
void * animBgTileBuffer;
};
#define eContest (*gContestResources->contest)
#define eContestantStatus (gContestResources->status)
#define eContestAppealResults (*gContestResources->appealResults)
#define eContestAI (*gContestResources->aiData)
#define eContestExcitement (*gContestResources->excitement)
#define eContestGfxState (gContestResources->gfxState)
#define eUnzippedContestAudience_Gfx (gHeap + 0x18000)
#define eContestAudienceFrame2_Gfx (gHeap + 0x19000)
#define eContestDebugMode (gHeap[0x1a000])
#define eContestTempSave (*(struct ContestTempSave *)(gHeap + 0x1a004))
extern struct ContestPokemon gContestMons[CONTESTANT_COUNT];
extern s16 gContestMonRound1Points[CONTESTANT_COUNT];
extern s16 gContestMonTotalPoints[CONTESTANT_COUNT];
extern s16 gContestMonAppealPointTotals[CONTESTANT_COUNT];
extern s16 gContestMonRound2Points[CONTESTANT_COUNT];
extern u8 gContestFinalStandings[CONTESTANT_COUNT];
extern u8 gContestMonPartyIndex;
extern u8 gContestPlayerMonIndex;
extern u8 gContestantTurnOrder[CONTESTANT_COUNT];
extern u8 gLinkContestFlags;
extern u8 gContestLinkLeaderIndex;
extern u16 gSpecialVar_ContestCategory;
extern u16 gSpecialVar_ContestRank;
extern u8 gNumLinkContestPlayers;
extern u8 gHighestRibbonRank;
extern struct ContestResources *gContestResources;
extern struct ContestWinner gCurContestWinner;
extern u8 gCurContestWinnerIsForArtist;
extern u8 gCurContestWinnerSaveIdx;
extern rng_value_t gContestRngValue;
// contest.c
void ResetLinkContestBoolean(void);
void LoadContestBgAfterMoveAnim(void);
void CB2_StartContest(void);
void CreateContestMonFromParty(u8 partyIndex);
void SetContestants(u8 contestType, u8 rank);
void SetLinkAIContestants(u8 contestType, u8 rank, bool32 isPostgame);
u8 GetContestEntryEligibility(struct Pokemon *pkmn);
void CalculateRound1Points(u8 contestCategory);
bool8 IsSpeciesNotUnown(u16 species);
bool8 Contest_IsMonsTurnDisabled(u8 contestant);
void SaveLinkContestResults(void);
void SortContestants(bool8 useRanking);
void SetContestantEffectStringID(u8 contestant, u8 effectStringId);
void SetContestantEffectStringID2(u8 contestant, u8 effectStringId);
void SetStartledString(u8 contestant, u8 jam);
void MakeContestantNervous(u8 p);
s8 Contest_GetMoveExcitement(u16 move);
bool8 IsContestantAllowedToCombo(u8 contestant);
void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s32 fontId);
void ResetContestLinkResults(void);
bool8 SaveContestWinner(u8 rank);
u8 GetContestWinnerSaveIdx(u8 rank, bool8 shift);
void ClearContestWinnerPicsInContestHall(void);
void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language);
#endif //GUARD_CONTEST_H