Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Cutscene/CutsceneHBH.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: CutsceneHBH Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectCutsceneHBH *CutsceneHBH;
11
12
void CutsceneHBH_Update(void)
13
{
14
RSDK_THIS(CutsceneHBH);
15
16
if (self->oscillate)
17
self->position.y += RSDK.Sin256(4 * (self->curAngle + self->angleOffset)) << 7;
18
19
if (self->noGlobalTimer)
20
self->curAngle = (self->curAngle + 1) & 0x7FFF;
21
else
22
self->curAngle = Zone->timer;
23
24
StateMachine_Run(self->state);
25
26
RSDK.ProcessAnimation(&self->mainAnimator);
27
RSDK.ProcessAnimation(&self->fxAnimator);
28
}
29
30
void CutsceneHBH_LateUpdate(void) {}
31
32
void CutsceneHBH_StaticUpdate(void) {}
33
34
void CutsceneHBH_Draw(void)
35
{
36
RSDK_THIS(CutsceneHBH);
37
38
if (self->useCustomPalettes)
39
CutsceneHBH_SetupPalettes();
40
41
RSDK.DrawSprite(&self->fxAnimator, NULL, false);
42
RSDK.DrawSprite(&self->mainAnimator, NULL, false);
43
44
if (self->useCustomPalettes)
45
CutsceneHBH_RestorePalette();
46
}
47
48
void CutsceneHBH_Create(void *data)
49
{
50
RSDK_THIS(CutsceneHBH);
51
52
self->active = ACTIVE_BOUNDS;
53
self->drawGroup = Zone->objectDrawGroup[1];
54
self->visible = !self->hiddenAtStart;
55
self->aniFrames = 0;
56
self->startPos = self->position;
57
self->drawFX = FX_FLIP;
58
self->updateRange.x = 0x800000;
59
self->updateRange.y = 0x800000;
60
self->angleOffset = RSDK.Rand(0, 256);
61
62
CutsceneHBH_LoadSprites();
63
CutsceneHBH_SetupColors();
64
65
if (RSDK.CheckSceneFolder("MSZ"))
66
self->noGlobalTimer = true;
67
else
68
self->useCustomPalettes = true;
69
}
70
71
void CutsceneHBH_StageLoad(void) { CutsceneHBH_StorePalette(); }
72
73
// Bug Details:
74
// any graphical bugs from 1.04 onwards (such as Heavy Shinobi's shoes not having the right colours)
75
// are due to these colour tables not being updated for plus, they're copies of the heavies' respective stage palettes for pre-plus
76
// so the changes that were applied when encore mode palettes & etc were applied are not accounted for
77
// example: in the case of heavy shinobi's shoes, they now occupy the indices at the end now, which are all 0x000000 in these tables
78
// this results in the shoes having shades of black instead of orange as intended
79
80
void CutsceneHBH_SetupColors(void)
81
{
82
RSDK_THIS(CutsceneHBH);
83
switch (self->characterID) {
84
case HBH_GUNNER: {
85
self->colorSet = 0;
86
color tempPal[0x80] = { 0x200020, 0x400040, 0x500050, 0x700070, 0x880088, 0xB000B0, 0xC800C8, 0xF000F0, 0x300040, 0x480070, 0x5000A0,
87
0x4828F0, 0x3850F0, 0x5898F0, 0x98C8F0, 0xD8E8F0, 0x080078, 0x1000C0, 0x0028F0, 0x0040F0, 0x00A8F0, 0x40F0F0,
88
0xC8F0F0, 0xF0F0F0, 0x280068, 0x280098, 0x3010D0, 0x2830F0, 0x1880F0, 0x48B8F0, 0x98E0F0, 0xD0F0F0, 0xA80810,
89
0xE04830, 0xF08840, 0xF0B850, 0xF0D860, 0xF0E870, 0xF0F090, 0x300060, 0x480068, 0x580070, 0x700078, 0x880880,
90
0xB00880, 0xD81870, 0xF030F0, 0xF048F0, 0x082888, 0x1848D0, 0x2070E0, 0x3890F0, 0x50B0F0, 0x68C8F0, 0x90D8F0,
91
0xC8E8F0, 0x200060, 0x280068, 0x300080, 0x4008A0, 0x080010, 0x100038, 0x100068, 0x080878, 0x003820, 0x005840,
92
0x008040, 0x00A058, 0x08C080, 0x30F0B8, 0x081828, 0x182850, 0x204078, 0x3868A8, 0x0080B8, 0x10A0E8, 0xE8F040,
93
0xE8F098, 0x78E8F0, 0x78F0F0, 0x100038, 0x181038, 0x181048, 0x182868, 0x204090, 0x4878B0, 0x58A8D0, 0x78D0E0,
94
0x200038, 0x400038, 0x881038, 0xC03010, 0xC86020, 0xC08038, 0xE00058, 0xE89850, 0x100060, 0x280070, 0x400088,
95
0x5800C8, 0x8810C8, 0xC830C8, 0x98F068, 0xA8F070, 0x100848, 0x101048, 0x102050, 0x102858, 0x180838, 0x201038,
96
0x282038, 0x302838, 0x0070E0, 0x00A0C0, 0x80D810, 0x28C010, 0xF04040, 0xF05050, 0x48A0E8, 0x60B0F0, 0x380028,
97
0x580030, 0x780830, 0x981830, 0xB83030, 0x000000, 0x000000, 0xFFFFFF };
98
memcpy(self->colors, tempPal, sizeof(self->colors));
99
break;
100
}
101
102
case HBH_SHINOBI: {
103
self->colorSet = 1;
104
color tempPal[0x80] = { 0x000000, 0x083048, 0x005848, 0x107858, 0x309060, 0x50A868, 0x68B868, 0x80D068, 0xA8E088, 0xC8E8A0, 0x481878,
105
0x6020B0, 0x9830C0, 0xC050E8, 0xF080F0, 0xF0A8F0, 0x506870, 0x607080, 0x887868, 0xA09078, 0xB8B090, 0xD0D0A8,
106
0xE0E0C0, 0xF0F0D8, 0x602030, 0x781818, 0x983810, 0xB05010, 0xC07818, 0xD89840, 0xF0C078, 0xF0E0B8, 0x282060,
107
0x500880, 0x880090, 0xB80888, 0xD80848, 0xE83850, 0xE86880, 0x000000, 0x284058, 0x385078, 0x5068A0, 0x6878B0,
108
0x8890C0, 0xA0A8D8, 0xB8C0E0, 0x000000, 0x204888, 0x4070C0, 0x5898D0, 0x78B8E0, 0xA0D8F0, 0xB8F0F0, 0xD8F0F0,
109
0xF0F0F0, 0x081840, 0x103058, 0x305870, 0x487080, 0x589088, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
110
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
111
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
112
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
113
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
114
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
115
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xFFFFFF };
116
memcpy(self->colors, tempPal, sizeof(self->colors));
117
break;
118
}
119
120
case HBH_MYSTIC:
121
case HBH_ROGUE_FANG:
122
case HBH_ROGUE_BEAN:
123
case HBH_ROGUE_BARK: {
124
self->colorSet = 2;
125
color tempPal[0x80] = { 0x200000, 0x300010, 0x400030, 0x600038, 0x800030, 0x901038, 0xA81038, 0xB82020, 0xB83828, 0xC04020, 0xC85020,
126
0xD06020, 0xD88020, 0xE0A028, 0xE0C030, 0xE8D038, 0x004000, 0x086000, 0x087800, 0x209000, 0x38A800, 0x60C000,
127
0x80E008, 0xE0E0A0, 0x780080, 0xA00880, 0xC018A0, 0xE040C0, 0xE068D0, 0xE0A0E0, 0x000000, 0x000000, 0x201030,
128
0x182050, 0x203880, 0x2850A0, 0x2878B8, 0x30B8F0, 0x60E8F0, 0x88F0F0, 0xB0F0F0, 0x402000, 0x603000, 0x804000,
129
0xA05000, 0xC06000, 0xD07810, 0x3060A0, 0x1090D8, 0x3098E8, 0x58A0E8, 0x78A0F0, 0x98A8F0, 0xB8B0F0, 0xD0C0F0,
130
0xF0D8F0, 0xF0F0F0, 0x801860, 0x982070, 0xA83070, 0xB83868, 0xD05068, 0x000000, 0x000000, 0xD86858, 0xE88858,
131
0xE8B060, 0xF0D860, 0xF0E878, 0xF0F0A8, 0x505828, 0x587028, 0x788030, 0x909030, 0xA89038, 0xC0A040, 0x180080,
132
0x5000A8, 0x6000D8, 0x8820F0, 0x000000, 0x000080, 0x0038C0, 0x0068F0, 0x1888F0, 0x30A0F0, 0x68D0F0, 0xF0F000,
133
0xF0B000, 0x182050, 0x2828A8, 0x4038D0, 0x5848E8, 0x8868F0, 0xB8B0F0, 0x80E008, 0xFF00FF, 0xFF00FF, 0xFF00FF,
134
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
135
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF,
136
0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFFFFFF };
137
memcpy(self->colors, tempPal, sizeof(self->colors));
138
break;
139
}
140
141
case HBH_RIDER:
142
case HBH_KING:
143
case HBH_KINGTMZ2: {
144
self->colorSet = 3;
145
color tempPal[0x80] = { 0x000000, 0x202020, 0x202040, 0x302070, 0x4020A0, 0x4030B0, 0x4040C0, 0x6060D1, 0x8080E0, 0x90A0E0, 0xA0C0E0,
146
0xB0D0E0, 0xC0E0E0, 0x783810, 0xA06040, 0xC07020, 0x203060, 0x204080, 0x2050A0, 0x2060C0, 0x3080C0, 0x40A0C0,
147
0x50C0D0, 0x60E0E0, 0x205060, 0x206040, 0x308060, 0x40A080, 0x60C0A0, 0x80E0C0, 0x404000, 0xE0E000, 0x302060,
148
0x402080, 0x4030A0, 0x4040C0, 0x7030D0, 0xA020E0, 0xC060E0, 0xE0A0E0, 0xD0C0E0, 0x202030, 0x302040, 0x302050,
149
0x402060, 0x303070, 0x000000, 0x000000, 0x501010, 0x800000, 0xB00000, 0xE00000, 0xE04000, 0xE08000, 0xE09000,
150
0xE0A000, 0xE0C070, 0xE0E0E0, 0xA00000, 0xE00000, 0xE06000, 0xE0A000, 0xE0E000, 0x000000, 0x606080, 0x8080A0,
151
0xA0A0C0, 0xB0B0D0, 0xC0C0E0, 0x202020, 0x301818, 0x381810, 0x482010, 0x482810, 0x584008, 0x806010, 0x907828,
152
0xB89848, 0xD8C070, 0xE0E0C0, 0x202020, 0x383040, 0x484868, 0x587090, 0x80A0B0, 0x98C0C8, 0xB0D8D8, 0xC8E8E0,
153
0x402040, 0x582040, 0x802060, 0xA020A0, 0xE14FB1, 0xE02080, 0xE080C0, 0xE0A0E0, 0xE00000, 0xE06000, 0xE0A000,
154
0xE0E000, 0x202040, 0x302060, 0x402080, 0x503070, 0x604080, 0x8050A0, 0xA060C0, 0xB080D0, 0xC0A0E0, 0xD0C0E0,
155
0xE0E0E0, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
156
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xFFFFFF };
157
memcpy(self->colors, tempPal, sizeof(self->colors));
158
break;
159
}
160
161
case HBH_KINGDAMAGED:
162
case HBH_PILE: {
163
self->colorSet = 4;
164
color tempPal[0x80] = { 0x883801, 0xB86801, 0xE09060, 0xF0B090, 0xA06040, 0xE08008, 0xE0A008, 0xE0C070, 0x085848, 0x107858, 0x309060,
165
0x50A868, 0x68B868, 0x80D068, 0xA8E088, 0xC8E8A0, 0x400101, 0x900101, 0xE00101, 0xE04830, 0xF08840, 0xF0D860,
166
0xF0E870, 0xF0F090, 0x302060, 0x402080, 0x4030A0, 0x7030D0, 0xA020E0, 0xC060E0, 0xE0A0E0, 0x013048, 0xA09078,
167
0xB8B090, 0xD0D0A8, 0xF0F0D8, 0x2850A0, 0x2878B8, 0x30B8F0, 0x60E8F0, 0x603001, 0x804001, 0xA05001, 0x584008,
168
0x806010, 0x907828, 0xB89848, 0x082888, 0x1848D0, 0x2070E0, 0x3890F0, 0x50B0F0, 0x68C8F0, 0xC8E8F0, 0xC06001,
169
0xD07810, 0xE0A028, 0xE8B048, 0xE0C030, 0xE8D038, 0xD8C070, 0xE0E0C0, 0x301801, 0x482001, 0x704008, 0xB07008,
170
0xD09818, 0xE0C020, 0xF0E060, 0x380118, 0x580120, 0x800110, 0xA80101, 0xC02001, 0xE85820, 0x000000, 0x000000,
171
0x000000, 0x000000, 0x000000, 0x400168, 0x700178, 0x900188, 0xB80188, 0xF00198, 0xF060B0, 0xF0A0C8, 0xB00801,
172
0xD82001, 0xF03001, 0xF06818, 0xF0D050, 0xF0E888, 0xF0F0E8, 0xC8D0F0, 0xD0F0F0, 0x181001, 0x301808, 0x502010,
173
0x803018, 0xB05030, 0xD08850, 0xE8B858, 0xF0D898, 0x480808, 0x701001, 0xA82008, 0xD03808, 0xE86818, 0xF0A020,
174
0xF0D068, 0xF0E0B8, 0x100828, 0x180840, 0x201050, 0x281068, 0x381880, 0x682098, 0x803098, 0xB038A8, 0xC858B8,
175
0x500120, 0x800120, 0xB80110, 0xE01001, 0xB8A0E0, 0xC0B8E8, 0xFFFFFF };
176
memcpy(self->colors, tempPal, sizeof(self->colors));
177
break;
178
}
179
180
default: break;
181
}
182
}
183
184
void CutsceneHBH_SetupPalettes(void)
185
{
186
RSDK_THIS(CutsceneHBH);
187
188
for (int32 c = 0; c < 0x80; ++c) RSDK.SetPaletteEntry(0, c + 0x80, self->colors[c]);
189
}
190
void CutsceneHBH_StorePalette(void)
191
{
192
for (int32 c = 0; c < 0x80; ++c) CutsceneHBH->paletteColors[c] = RSDK.GetPaletteEntry(0, c + 0x80);
193
}
194
void CutsceneHBH_RestorePalette(void)
195
{
196
for (int32 c = 0; c < 0x80; ++c) RSDK.SetPaletteEntry(0, c + 0x80, CutsceneHBH->paletteColors[c]);
197
}
198
199
void CutsceneHBH_LoadSprites(void)
200
{
201
RSDK_THIS(CutsceneHBH);
202
203
switch (self->characterID) {
204
case HBH_GUNNER:
205
if (!self->aniFrames)
206
self->aniFrames = RSDK.LoadSpriteAnimation("SPZ1/Boss.bin", SCOPE_STAGE);
207
208
RSDK.SetSpriteAnimation(self->aniFrames, 5, &self->mainAnimator, true, 0);
209
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
210
break;
211
212
case HBH_SHINOBI:
213
if (!self->aniFrames)
214
self->aniFrames = RSDK.LoadSpriteAnimation("PSZ2/Shinobi.bin", SCOPE_STAGE);
215
216
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
217
RSDK.SetSpriteAnimation(self->aniFrames, 5, &self->fxAnimator, true, 0);
218
break;
219
220
case HBH_MYSTIC:
221
if (!self->aniFrames)
222
self->aniFrames = RSDK.LoadSpriteAnimation("MSZ/HeavyMystic.bin", SCOPE_STAGE);
223
224
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
225
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
226
break;
227
228
case HBH_RIDER:
229
if (!self->aniFrames)
230
self->aniFrames = RSDK.LoadSpriteAnimation("LRZ3/HeavyRider.bin", SCOPE_STAGE);
231
232
RSDK.SetSpriteAnimation(self->aniFrames, 3, &self->mainAnimator, true, 0);
233
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
234
break;
235
236
case HBH_KING:
237
if (!self->aniFrames)
238
self->aniFrames = RSDK.LoadSpriteAnimation("LRZ3/HeavyKing.bin", SCOPE_STAGE);
239
240
RSDK.SetSpriteAnimation(self->aniFrames, 7, &self->mainAnimator, true, 0);
241
RSDK.SetSpriteAnimation(self->aniFrames, 16, &self->fxAnimator, true, 0);
242
break;
243
244
case HBH_ROGUE_FANG:
245
if (!self->aniFrames)
246
self->aniFrames = RSDK.LoadSpriteAnimation("MSZ/Rogues.bin", SCOPE_STAGE);
247
248
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
249
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
250
break;
251
252
case HBH_ROGUE_BEAN:
253
if (!self->aniFrames)
254
self->aniFrames = RSDK.LoadSpriteAnimation("MSZ/Rogues.bin", SCOPE_STAGE);
255
256
RSDK.SetSpriteAnimation(self->aniFrames, 5, &self->mainAnimator, true, 0);
257
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
258
break;
259
260
case HBH_ROGUE_BARK:
261
if (!self->aniFrames)
262
self->aniFrames = RSDK.LoadSpriteAnimation("MSZ/Rogues.bin", SCOPE_STAGE);
263
264
RSDK.SetSpriteAnimation(self->aniFrames, 12, &self->mainAnimator, true, 0);
265
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
266
break;
267
268
case HBH_KINGDAMAGED:
269
if (!self->aniFrames)
270
self->aniFrames = RSDK.LoadSpriteAnimation("Cutscene/DamagedKing.bin", SCOPE_STAGE);
271
272
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
273
RSDK.SetSpriteAnimation(self->aniFrames, 1, &self->fxAnimator, true, 0);
274
break;
275
276
case HBH_PILE:
277
if (!self->aniFrames)
278
self->aniFrames = RSDK.LoadSpriteAnimation("Cutscene/HBHPile.bin", SCOPE_STAGE);
279
280
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
281
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
282
break;
283
284
case HBH_KINGTMZ2:
285
if (!self->aniFrames)
286
self->aniFrames = RSDK.LoadSpriteAnimation("Cutscene/KingTMZ2.bin", SCOPE_STAGE);
287
288
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
289
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
290
break;
291
292
default: break;
293
}
294
}
295
296
EntityCutsceneHBH *CutsceneHBH_GetEntity(uint8 charID)
297
{
298
EntityCutsceneHBH *hbh = NULL;
299
300
foreach_all(CutsceneHBH, cutsceneHBH)
301
{
302
if (cutsceneHBH->characterID == charID)
303
hbh = cutsceneHBH;
304
}
305
306
return hbh;
307
}
308
309
void CutsceneHBH_ShinobiJumpSetup(void)
310
{
311
EntityCutsceneHBH *hbh = CutsceneHBH_GetEntity(HBH_SHINOBI);
312
313
if (hbh) {
314
RSDK.SetSpriteAnimation(hbh->aniFrames, 3, &hbh->mainAnimator, true, 0);
315
316
hbh->velocity.x = 0x10000;
317
hbh->velocity.y = -0x60000;
318
hbh->direction ^= FLIP_X;
319
hbh->drawGroup = Zone->objectDrawGroup[1] + 2;
320
hbh->state = CutsceneHBH_State_ShinobiJump;
321
322
EntityFXTrail *trail = CREATE_ENTITY(FXTrail, hbh, hbh->position.x, hbh->position.y);
323
trail->animatorPtr = &hbh->mainAnimator;
324
}
325
}
326
327
void CutsceneHBH_ShinobiBounceSetup(void)
328
{
329
EntityCutsceneHBH *hbh = CutsceneHBH_GetEntity(HBH_SHINOBI);
330
331
if (hbh) {
332
RSDK.SetSpriteAnimation(hbh->aniFrames, 1, &hbh->mainAnimator, true, 0);
333
RSDK.SetSpriteAnimation(-1, 0, &hbh->fxAnimator, true, 0);
334
335
hbh->state = CutsceneHBH_State_ShinobiBounce;
336
}
337
}
338
339
void CutsceneHBH_RiderSetup(void)
340
{
341
EntityCutsceneHBH *hbh = CutsceneHBH_GetEntity(HBH_RIDER);
342
343
if (hbh) {
344
RSDK.SetSpriteAnimation(hbh->aniFrames, 0, &hbh->mainAnimator, true, 0);
345
RSDK.SetSpriteAnimation(-1, 0, &hbh->fxAnimator, true, 0);
346
347
hbh->timer = 0;
348
hbh->originPos.x = hbh->position.x;
349
hbh->originPos.y = hbh->position.y;
350
hbh->velocity.x = 0x30000;
351
hbh->state = CutsceneHBH_State_RiderMove;
352
}
353
}
354
355
void CutsceneHBH_KingSetup(void)
356
{
357
EntityCutsceneHBH *hbh = CutsceneHBH_GetEntity(HBH_KING);
358
359
if (hbh) {
360
RSDK.SetSpriteAnimation(hbh->aniFrames, 0, &hbh->mainAnimator, true, 0);
361
RSDK.SetSpriteAnimation(hbh->aniFrames, 9, &hbh->fxAnimator, true, 0);
362
}
363
}
364
365
void CutsceneHBH_KingTMZ2Setup(void)
366
{
367
EntityCutsceneHBH *hbh = CutsceneHBH_GetEntity(HBH_KINGTMZ2);
368
369
if (hbh) {
370
RSDK.SetSpriteAnimation(hbh->aniFrames, 1, &hbh->mainAnimator, true, 0);
371
372
hbh->timer = 0;
373
hbh->velocity.x = 0;
374
hbh->velocity.y = 0;
375
hbh->state = CutsceneHBH_State_KingTMZ2_Fall;
376
}
377
}
378
379
void CutsceneHBH_State_GunnerExit(void)
380
{
381
RSDK_THIS(CutsceneHBH);
382
383
self->velocity.y -= 0x2000;
384
self->position.y += self->velocity.y;
385
386
if (!RSDK.CheckOnScreen(self, NULL))
387
destroyEntity(self);
388
}
389
390
void CutsceneHBH_State_ShinobiBounce(void)
391
{
392
RSDK_THIS(CutsceneHBH);
393
394
if (self->timer <= 0) {
395
self->velocity.y += 0x2000;
396
self->position.y += self->velocity.y;
397
398
if (RSDK.ObjectTileCollision(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x2E0000, true)) {
399
RSDK.SetSpriteAnimation(self->aniFrames, 1, &self->mainAnimator, true, 0);
400
self->velocity.y = -0x20000;
401
self->timer = 3;
402
}
403
}
404
else {
405
self->timer--;
406
}
407
408
foreach_active(PhantomRuby, phantomRuby)
409
{
410
if (phantomRuby->velocity.y >= 0 && phantomRuby->position.y > self->position.y - 0x200000) {
411
phantomRuby->velocity.y = -(5 * abs(self->velocity.y) >> 1);
412
}
413
}
414
}
415
416
void CutsceneHBH_State_ShinobiJump(void)
417
{
418
RSDK_THIS(CutsceneHBH);
419
420
self->velocity.y += 0x4000;
421
self->position.x += self->velocity.x;
422
self->position.y += self->velocity.y;
423
424
if (!RSDK.CheckOnScreen(self, NULL))
425
destroyEntity(self);
426
}
427
428
void CutsceneHBH_State_MysticExit(void)
429
{
430
RSDK_THIS(CutsceneHBH);
431
432
self->velocity.x += 0x4000;
433
self->position.x += self->velocity.x;
434
435
if (!RSDK.CheckOnScreen(self, NULL))
436
destroyEntity(self);
437
}
438
439
void CutsceneHBH_State_RiderMove(void)
440
{
441
RSDK_THIS(CutsceneHBH);
442
443
self->position.x += self->velocity.x;
444
445
if (!self->timer) {
446
if (self->velocity.x < 0x30000)
447
self->velocity.x += 0x4000;
448
449
if (self->direction == FLIP_NONE) {
450
if (self->position.x - self->originPos.x > 0x300000) {
451
self->timer = 1;
452
RSDK.SetSpriteAnimation(self->aniFrames, 2, &self->mainAnimator, true, 0);
453
}
454
455
RSDK.ObjectTileGrip(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x300000, 8);
456
}
457
else {
458
if (self->mainAnimator.frameID == self->mainAnimator.frameCount - 1) {
459
self->direction = FLIP_NONE;
460
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
461
}
462
463
RSDK.ObjectTileGrip(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x300000, 8);
464
}
465
}
466
else {
467
if (self->velocity.x > -0x30000)
468
self->velocity.x -= 0x4000;
469
470
if (self->direction != FLIP_X) {
471
if (self->mainAnimator.frameID == self->mainAnimator.frameCount - 1) {
472
self->direction = FLIP_X;
473
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
474
}
475
476
RSDK.ObjectTileGrip(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x300000, 8);
477
}
478
else {
479
if (self->position.x - self->originPos.x < -0x300000) {
480
self->timer = 0;
481
RSDK.SetSpriteAnimation(self->aniFrames, 2, &self->mainAnimator, true, 0);
482
}
483
484
RSDK.ObjectTileGrip(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x300000, 8);
485
}
486
}
487
}
488
489
void CutsceneHBH_State_RiderExit(void)
490
{
491
RSDK_THIS(CutsceneHBH);
492
493
self->position.x += self->velocity.x;
494
495
if (self->velocity.x < 0x60000)
496
self->velocity.x += 0x4000;
497
498
if (self->direction == FLIP_X && self->mainAnimator.frameID == self->mainAnimator.frameCount - 1) {
499
self->direction = FLIP_NONE;
500
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
501
}
502
503
RSDK.ObjectTileGrip(self, Zone->collisionLayers, CMODE_FLOOR, 0, 0, 0x300000, 8);
504
505
if (!RSDK.CheckOnScreen(self, NULL))
506
destroyEntity(self);
507
}
508
509
void CutsceneHBH_State_KingExit(void)
510
{
511
RSDK_THIS(CutsceneHBH);
512
513
if (++self->timer == 16) {
514
RSDK.SetSpriteAnimation(self->aniFrames, 3, &self->mainAnimator, true, 0);
515
}
516
else if (self->timer > 16 && self->mainAnimator.frameID > 4) {
517
self->velocity.x = 0x28000;
518
self->velocity.y = -0x60000;
519
self->state = CutsceneHBH_State_KingFall;
520
RSDK.SetSpriteAnimation(-1, 0, &self->fxAnimator, true, 0);
521
}
522
}
523
524
void CutsceneHBH_State_KingFall(void)
525
{
526
RSDK_THIS(CutsceneHBH);
527
528
self->velocity.y += 0x3800;
529
self->position.x += self->velocity.x;
530
self->position.y += self->velocity.y;
531
532
if (!RSDK.CheckOnScreen(self, NULL))
533
destroyEntity(self);
534
}
535
536
void CutsceneHBH_State_KingTMZ2_Fall(void)
537
{
538
RSDK_THIS(CutsceneHBH);
539
540
self->velocity.y += 0x3800;
541
self->position.x += self->velocity.x;
542
self->position.y += self->velocity.y;
543
544
if (RSDK.ObjectTileCollision(self, Zone->collisionLayers, CMODE_FLOOR, self->collisionPlane, 0, 0x2C0000, true)) {
545
RSDK.SetSpriteAnimation(self->aniFrames, 2, &self->mainAnimator, true, 0);
546
547
self->velocity.y = 0;
548
self->state = CutsceneHBH_State_KingTMZ2_Land;
549
Camera_ShakeScreen(0, 0, 4);
550
}
551
}
552
553
void CutsceneHBH_State_KingTMZ2_Land(void)
554
{
555
RSDK_THIS(CutsceneHBH);
556
557
if (self->mainAnimator.frameID != self->mainAnimator.frameCount - 1) {
558
RSDK.SetSpriteAnimation(self->aniFrames, 0, &self->mainAnimator, true, 0);
559
self->state = StateMachine_None;
560
}
561
}
562
563
#if GAME_INCLUDE_EDITOR
564
void CutsceneHBH_EditorDraw(void)
565
{
566
RSDK_THIS(CutsceneHBH);
567
568
RSDK.SetSpriteAnimation(CutsceneHBH->aniFrames, self->characterID, &self->mainAnimator, true, 0);
569
RSDK.DrawSprite(&self->mainAnimator, NULL, false);
570
}
571
572
void CutsceneHBH_EditorLoad(void)
573
{
574
CutsceneHBH->aniFrames = RSDK.LoadSpriteAnimation("Editor/CutsceneHBH.bin", SCOPE_STAGE);
575
576
RSDK_ACTIVE_VAR(CutsceneHBH, direction);
577
RSDK_ENUM_VAR("No Flip", FLIP_NONE);
578
RSDK_ENUM_VAR("Flipped", FLIP_X);
579
580
RSDK_ACTIVE_VAR(CutsceneHBH, characterID);
581
RSDK_ENUM_VAR("Gunner", HBH_GUNNER);
582
RSDK_ENUM_VAR("Shinobi", HBH_SHINOBI);
583
RSDK_ENUM_VAR("Magician", HBH_MYSTIC);
584
RSDK_ENUM_VAR("Rider", HBH_RIDER);
585
RSDK_ENUM_VAR("King", HBH_KING);
586
RSDK_ENUM_VAR("Fang", HBH_ROGUE_FANG);
587
RSDK_ENUM_VAR("Bean", HBH_ROGUE_BEAN);
588
RSDK_ENUM_VAR("Bark", HBH_ROGUE_BARK);
589
RSDK_ENUM_VAR("King (Damaged)", HBH_KINGDAMAGED);
590
RSDK_ENUM_VAR("Pile", HBH_PILE);
591
RSDK_ENUM_VAR("King (TMZ2)", HBH_KINGTMZ2);
592
}
593
#endif
594
595
void CutsceneHBH_Serialize(void)
596
{
597
RSDK_EDITABLE_VAR(CutsceneHBH, VAR_UINT8, direction);
598
RSDK_EDITABLE_VAR(CutsceneHBH, VAR_UINT8, characterID);
599
RSDK_EDITABLE_VAR(CutsceneHBH, VAR_BOOL, oscillate);
600
RSDK_EDITABLE_VAR(CutsceneHBH, VAR_BOOL, hiddenAtStart);
601
}
602
603