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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
#include <stage.h>
#include "effects.h"
#include "player.h"
// Shy Guy Settings
//
// Nybble 5: Shy Guy Types
// 0 - Walker
// 1 - Sleeper
// 2 - Jumper
// 3 - Ballooneer Horizontal
// 4 - Ballooneer Vertical
// 6 - Ballooneer Circular
// 7 - Judo Master
// 8 - Spike Thrower
// 9 - Giant
//
// Nybble 6: Colour
// 0 - Red
// 1 - Blue
// 2 - Green
// 3 - Cyan
// 4 - Purple
//
// Nybble 7: Balloon Colour
// 0 - Red
// 1 - Blue
//
// Nybble 8: Ballooneer Carries
// 0 - Nothing
// 1 - ???
//
class daShyGuy : public dEn_c {
int onCreate();
int onDelete();
int onExecute();
int onDraw();
mHeapAllocator_c allocator;
nw4r::g3d::ResFile resFile;
nw4r::g3d::ResFile anmFile;
nw4r::g3d::ResFile balloonFile;
m3d::mdl_c bodyModel;
m3d::mdl_c balloonModel;
m3d::mdl_c balloonModelB;
m3d::anmChr_c chrAnimation;
// m3d::anmChr_c animateWalk;
// m3d::anmChr_c animateJump;
// m3d::anmChr_c animateSpinJump;
// m3d::anmChr_c animateIdle;
// m3d::anmChr_c animateSleep;
// m3d::anmChr_c animateHover;
int timer;
int jumpCounter;
float Baseline;
char damage;
char renderBalloon;
Vec initialPos;
static daShyGuy *build();
void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate);
void updateModelMatrices();
USING_STATES(daShyGuy);
DECLARE_STATE(Walk);
DECLARE_STATE(Turn);
DECLARE_STATE(Jump);
DECLARE_STATE(Sleep);
DECLARE_STATE(Balloon_H);
DECLARE_STATE(Balloon_V);
DECLARE_STATE(Balloon_C);
};
daShyGuy *daShyGuy::build() {
void *buffer = AllocFromGameHeap1(sizeof(daShyGuy));
return new(buffer) daShyGuy;
}
extern "C" void *PlaySound(daShyGuy *, int soundID);
extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daShyGuy *, Vec pos);
CREATE_STATE(daShyGuy, Walk);
CREATE_STATE(daShyGuy, Turn);
CREATE_STATE(daShyGuy, Jump);
CREATE_STATE(daShyGuy, Sleep);
CREATE_STATE(daShyGuy, Balloon_H);
CREATE_STATE(daShyGuy, Balloon_V);
CREATE_STATE(daShyGuy, Balloon_C);
void daShyGuy::bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate) {
nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr(name);
this->chrAnimation.bind(&this->bodyModel, anmChr, unk);
this->bodyModel.bindAnim(&this->chrAnimation, unk2);
this->chrAnimation.setUpdateRate(rate);
}
int daShyGuy::onCreate() {
int type = this->settings >> 28 & 0xF;
int anim = this->settings >> 24 & 0xF;
int baln = this->settings >> 20 & 0xF;
if (type == 3) {this->renderBalloon = 1;}
else if (type == 0) {this->renderBalloon = 1;}
else if (type == 4) {this->renderBalloon = 1;}
else if (type == 5) {this->renderBalloon = 1;}
else {this->renderBalloon = 0;}
OSReport("Creating the ShyGuy Model\n");
allocator.link(-1, GameHeaps[0], 0, 0x20);
// Shy Guy Colours
if (anim == 0) {
this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyRed.brres");
}
else if (anim == 1) {
this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyBlue.brres");
}
else if (anim == 2) {
this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyGreen.brres");
}
else if (anim == 3) {
this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyCyan.brres");
}
else if (anim == 4) {
this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyPurple.brres");
}
nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("body_h");
bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
// Balloon Model
this->balloonFile.data = getResource("lemmy_ball", "g3d/balloon.brres");
nw4r::g3d::ResMdl mdlB = this->balloonFile.GetResMdl("ballon");
balloonModel.setup(mdlB, &allocator, 0x224, 1, 0);
balloonModelB.setup(mdlB, &allocator, 0x224, 1, 0);
// Animations start here
this->anmFile.data = getResource("lemmy_ball", "g3d/ShyGuyAnimations.brres");
nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr("c18_IDLE_R");
this->chrAnimation.setup(mdl, anmChr, &this->allocator, 0);
allocator.unlink();
OSReport("Setting ShyGuy's Size to 1.0\n");
this->scale = (Vec){20.0, 20.0, 20.0};
OSReport("Creating ShyGuy's Physics Struct\n");
ActivePhysics::Info HitMeBaby;
HitMeBaby.xDistToCenter = 0.0;
HitMeBaby.yDistToCenter = 12.0;
HitMeBaby.xDistToEdge = 14.0;
HitMeBaby.yDistToEdge = 12.0;
HitMeBaby.category1 = 0x3;
HitMeBaby.category2 = 0x0;
HitMeBaby.bitfield1 = 0x4F;
HitMeBaby.bitfield2 = 0x8828E;
HitMeBaby.unkShort1C = 0;
HitMeBaby.callback = &dEn_c::collisionCallback;
OSReport("Making the Physics Class and adding to the list\n");
this->aPhysics.initWithStruct(this, &HitMeBaby);
this->aPhysics.addToList();
OSReport("Setting up ShyGuy's Box of Goodies\n");
this->pos.y = this->pos.y + 30.0; // X is vertical axis
this->rot.x = 0; // X is vertical axis
this->rot.y = 0xD800; // Y is horizontal axis
this->rot.z = 0; // Z is ... an axis >.>
this->direction = 1; // Heading left.
this->speed.x = 0;
this->Baseline = this->pos.y;
if (type == 0) {
doStateChange(&StateID_Sleep);
}
else if (type == 1) {
doStateChange(&StateID_Sleep);
}
else if (type == 2) {
doStateChange(&StateID_Jump);
}
else if (type == 3) {
doStateChange(&StateID_Balloon_H);
}
else if (type == 4) {
doStateChange(&StateID_Balloon_V);
}
else if (type == 5) {
doStateChange(&StateID_Balloon_C);
}
else if (type == 6) {
doStateChange(&StateID_Sleep);
}
else if (type == 7) {
doStateChange(&StateID_Sleep);
}
else if (type == 8) {
doStateChange(&StateID_Sleep);
}
OSReport("Going to Execute ShyGuy\n");
this->onExecute();
return true;
}
int daShyGuy::onDelete() {
return true;
}
int daShyGuy::onExecute() {
acState.execute();
updateModelMatrices();
// if (this->aPhysics.result1 == 1) {
// char PlayerID = NearestPlayer(this);
// dStageActor_c *Player = GetSpecificPlayerActor(PlayerID);
// this->_vf220(Player);
// }
return true;
}
int daShyGuy::onDraw() {
bodyModel.scheduleForDrawing();
bodyModel._vf1C();
balloonModel.scheduleForDrawing();
balloonModelB.scheduleForDrawing();
return true;
}
void daShyGuy::updateModelMatrices() {
// This won't work with wrap because I'm lazy.
matrix.translation(pos.x, pos.y, pos.z);
matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
bodyModel.setDrawMatrix(matrix);
bodyModel.setScale(&scale);
bodyModel.calcWorld(true);
if (this->renderBalloon == 1) {
matrix.translation(pos.x, pos.y - 30.0, pos.z);
balloonModel.setDrawMatrix(matrix);
balloonModel.setScale(1.5, 1.5, 1.5);
balloonModel.calcWorld(true);
balloonModelB.setDrawMatrix(matrix);
balloonModelB.setScale(1.5, 1.5, 1.5);
balloonModelB.calcWorld(true);
}
}
void daShyGuy::beginState_Walk() {
bindAnimChr_and_setUpdateRate("c18_EV_WIN_2_R", 1, 0.0, 1.0);
}
void daShyGuy::executeState_Walk() {
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
this->pos.x = this->pos.x - 0.4;
}
void daShyGuy::endState_Walk() {
}
void daShyGuy::beginState_Turn() {
}
void daShyGuy::executeState_Turn() {
}
void daShyGuy::endState_Turn() {
}
void daShyGuy::beginState_Jump() {
this->timer = 0;
this->jumpCounter = 0;
}
void daShyGuy::executeState_Jump() {
// Always face Mario
u8 facing = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos);
if (facing != this->direction) {
this->direction = facing;
if (this->direction == 1) {
this->rot.y = 0xD800;
}
else {
this->rot.y = 0x2800;
}
}
// Shy Guy is on ground
if (this->pos.y < this->Baseline) {
bindAnimChr_and_setUpdateRate("c18_IDLE_R", 1, 0.0, 1.0);
this->timer = this->timer + 1;
// Make him wait for 0.5 seconds
if (this->timer > 30) {
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
this->speed.x = 0;
this->speed.y = 0;
}
// Then Jump!
else {
if (this->jumpCounter == 3) { this->jumpCounter = 0; }
this->pos.y = this->Baseline + 1;
this->timer = 0;
this->jumpCounter = this->jumpCounter + 1;
if (this->jumpCounter == 3) {
bindAnimChr_and_setUpdateRate("c18_NORMAL_STEAL_R", 1, 0.0, 1.0);
this->speed.y = 8.0;
PlaySound(this, SE_PLY_JUMPDAI_HIGH);
}
else {
bindAnimChr_and_setUpdateRate("c18_EV_WIN_1_R", 1, 0.0, 1.0);
this->speed.y = 6.0;
PlaySound(this, SE_PLY_JUMPDAI);
}
OSReport("Takeoff Initiated");
}
}
// While he's jumping, it's time for gravity.
else {
this->speed.y = this->speed.y - 0.12;
if (this->jumpCounter == 3) {
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
else {
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
}
this->HandleXSpeed();
this->HandleYSpeed();
this->UpdateObjectPosBasedOnSpeedValuesReal();
}
void daShyGuy::endState_Jump() {
}
void daShyGuy::beginState_Sleep() {
bindAnimChr_and_setUpdateRate("c18_EV_LOSE_2_R", 1, 0.0, 1.0);
this->rot.y = 0x0000;
}
void daShyGuy::executeState_Sleep() {
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
void daShyGuy::endState_Sleep() {
}
void daShyGuy::beginState_Balloon_H() {
bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0);
this->timer = 0;
this->initialPos = this->pos;
this->rot.x = 0xFE00;
this->rot.y = 0;
}
void daShyGuy::executeState_Balloon_H() {
// Makes him bob up and down
this->pos.y = this->initialPos.y + ( sin(this->timer * 3.14 / 60.0) * 6.0 );
// Makes him move side to side
this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 600.0) * 64.0 );
this->timer = this->timer + 1;
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
void daShyGuy::endState_Balloon_H() {
}
void daShyGuy::beginState_Balloon_V() {
bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0);
this->timer = 0;
this->initialPos = this->pos;
this->rot.x = 0xFE00;
this->rot.y = 0;
}
void daShyGuy::executeState_Balloon_V() {
// Makes him bob up and down
this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 60.0) * 6.0 );
// Makes him move side to side
this->pos.y = this->initialPos.y + ( sin(this->timer * 3.14 / 600.0) * 64.0 );
this->timer = this->timer + 1;
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
void daShyGuy::endState_Balloon_V() {
}
void daShyGuy::beginState_Balloon_C() {
bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0);
this->timer = 0;
this->initialPos = this->pos;
this->rot.x = 0xFE00;
this->rot.y = 0;
}
void daShyGuy::executeState_Balloon_C() {
// Makes him bob up and down
this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 600.0) * 64.0 );
// Makes him move side to side
this->pos.y = this->initialPos.y + ( cos(this->timer * 3.14 / 600.0) * 64.0 );
this->timer = this->timer + 1;
if(this->chrAnimation.isAnimationDone())
this->chrAnimation.setCurrentFrame(0.0);
}
void daShyGuy::endState_Balloon_C() {
}
|