summaryrefslogtreecommitdiff
path: root/src/shyguy.cpp
blob: a81143f0734d8cf4267a79d3603c92538ee105fa (plain)
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
#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 - Pacing Walker
//		1 - Sleeper
//		2 - Jumper
// 		3 - Ballooneer Horizontal
// 		4 - Ballooneer Vertical
// 		5 - Ballooneer Circular 
// 		6 - Judo Master 
// 		7 - Spike Thrower
// 		8 - Pacing Giant
// 	
// Nybble 6: Colour
// 		0 - Red
//		1 - Blue
//		2 - Green
//		3 - Cyan
//		4 - Purple
//
// Nybble 7: Balloon Colour
//		0 - Red
//		1 - Blue (not working)
//
// Nybble 8: Ballooneer Carries
//		0 - Nothing
//		1 - ???
//
// Nybble 9: Distance Moved
//		# - Distance for Pacing Walker, Pacing Giants, and Ballooneers 
//
// I_kinoko, I_fireflower, I_propeller_model, I_iceflower, I_star, I_penguin - model names
// anmChr - wait2

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;

	int timer;
	int jumpCounter;
	float Baseline;
	char damage;
	char renderBalloon;
	Vec initialPos;
	int distance;
	float XSpeed;

	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(RealWalk);
	DECLARE_STATE(RealTurn);
	DECLARE_STATE(Jump);
	DECLARE_STATE(Sleep);
	DECLARE_STATE(Balloon_H);
	DECLARE_STATE(Balloon_V);
	DECLARE_STATE(Balloon_C);
	DECLARE_STATE(Judo);
	DECLARE_STATE(Spike);
};

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);

//FIXME make this dEn_c->used...
extern "C" char usedForDeterminingStatePress_or_playerCollision(dEn_c* t, ActivePhysics *apThis, ActivePhysics *apOther, int unk1);
extern "C" int SomeStrangeModification(dStageActor_c* actor);
extern "C" void DoStuffAndMarkDead(dStageActor_c *actor, Vec vector, float unk);
extern "C" int SmoothRotation(short* rot, u16 amt, int unk2);


CREATE_STATE(daShyGuy, Walk);
CREATE_STATE(daShyGuy, Turn);
CREATE_STATE(daShyGuy, RealWalk);
CREATE_STATE(daShyGuy, RealTurn);
CREATE_STATE(daShyGuy, Jump);
CREATE_STATE(daShyGuy, Sleep);
CREATE_STATE(daShyGuy, Balloon_H);
CREATE_STATE(daShyGuy, Balloon_V);
CREATE_STATE(daShyGuy, Balloon_C);
CREATE_STATE(daShyGuy, Judo);
CREATE_STATE(daShyGuy, Spike);


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;
	this->distance = this->settings >> 12 & 0xF;

	if (type == 3) {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;

	if (type == 8 || type == 10) {
		this->scale = (Vec){40.0, 40.0, 40.0};

		HitMeBaby.xDistToCenter = 0.0;
		HitMeBaby.yDistToCenter = 24.0;

		HitMeBaby.xDistToEdge = 28.0;
		HitMeBaby.yDistToEdge = 24.0;
	}

	else {
		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();

	// Tile collider
	OSReport("Making the Tile collider Class\n");
	u8 struct_1[] = { 0, 0, 0, 1, 0xff, 0xff, 0x40, 0, 0, 0, 0xc0, 0, 0, 0, 0, 0 };
	u8 struct_3[] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0x3f, 0x2a, 0x7e, 0xfa };
	this->collMgr.Init(this, struct_1, 0, struct_3);

	// // A bunch of things that I don't understand? Megazig used em. None seem to do anything
	// char foo = this->_391;
	// this->pos_delta2.x = 0.0;
	// this->pos_delta2.y = 16.0;
	// this->pos_delta2.z = 0.0;

	// this->spriteSomeRectX = 32.0;
	// this->spriteSomeRectY = 32.0;
	// this->_320 = 0.0;
	// this->_324 = 16.0;
	// this->_328 = 80.0;
	// this->_32C = 256.0;

	// this->pos.z = (foo == 0) ? 1500.0 : -2500.0;

	// this->_518 = 2;

	// this->_120 |= 0x200;
	// this->_36D = 0;
	// this->_518 = 2;


	// Stuff I do understand
	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->speed.y = 0.0;
	this->x_speed_inc = 0.1;
	this->Baseline = this->pos.y;
	this->XSpeed = 1.0;

	
	if (type == 0) {
		doStateChange(&StateID_Walk);
	}		
	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_Judo);
	}		
	else if (type == 7) {
		doStateChange(&StateID_Spike);
	}		
	else if (type == 8) {
		doStateChange(&StateID_Walk);
	}		
	else if (type == 9) {
		doStateChange(&StateID_RealWalk);
	}		
	else if (type == 10) {
		doStateChange(&StateID_RealWalk);
	}		

	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(false);

	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(false);

		balloonModelB.setDrawMatrix(matrix);
		balloonModelB.setScale(1.5, 1.5, 1.5);
		balloonModelB.calcWorld(false);

	}
}

///////////////
// Walk State
///////////////
	void daShyGuy::beginState_Walk() { 
		bindAnimChr_and_setUpdateRate("c18_EV_WIN_2_R", 1, 0.0, 1.5); 
		this->timer = 0;
		if (this->direction == 1) { this->rot.y = 0xD800; }
		else 					  { this->rot.y = 0x2800; }
	}
	void daShyGuy::executeState_Walk() { 

		if (this->direction == 1) { this->pos.x -= 0.5; }
		else 					  { this->pos.x += 0.5; }

		if(this->chrAnimation.isAnimationDone())
			if (this->timer > (this->distance * 32)) {
				doStateChange(&StateID_Turn);
			}
			else {
				this->chrAnimation.setCurrentFrame(0.0);
			}

		this->timer = this->timer + 1;
	}
	void daShyGuy::endState_Walk() { 
	}

///////////////
// Turn State
///////////////
	void daShyGuy::beginState_Turn() { 
		bindAnimChr_and_setUpdateRate("c18_IDLE_R", 1, 0.0, 1.0);
		this->timer = 0;
	}
	void daShyGuy::executeState_Turn() { 

		int modifier = sin(this->timer * 3.14 / 30.0) * 0x5000;

		if (this->direction == 1) { this->rot.y = 0xD800 + modifier; }
		else 					  { this->rot.y = 0x2800 - modifier; }

		if (this->timer >= 15) { 
			doStateChange(&StateID_Walk);
		}

		if(this->chrAnimation.isAnimationDone()) {
			this->chrAnimation.setCurrentFrame(0.0);
		}

		this->timer += 1;
	}
	void daShyGuy::endState_Turn() { 
		if (this->direction == 1) { this->direction = 0; }
		else 					  { this->direction = 1; }
	}

///////////////
// Jump State
///////////////
	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.15; 

			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() { 
	}

///////////////
// Sleep State
///////////////
	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() { 
	}

///////////////
// Balloon H State
///////////////
	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) * (float)this->distance * 8.0);

		this->timer = this->timer + 1;

		if(this->chrAnimation.isAnimationDone())
			this->chrAnimation.setCurrentFrame(0.0);

	}
	void daShyGuy::endState_Balloon_H() { 
	}

///////////////
// Balloon V State
///////////////
	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) * (float)this->distance * 8.0 );

		this->timer = this->timer + 1;

		if(this->chrAnimation.isAnimationDone())
			this->chrAnimation.setCurrentFrame(0.0);
	}
	void daShyGuy::endState_Balloon_V() { 
	}

///////////////
// Balloon C State
///////////////
	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) * (float)this->distance * 8.0 );

		// Makes him move side to side
		this->pos.y = this->initialPos.y + ( cos(this->timer * 3.14 / 600.0) * (float)this->distance * 8.0 );

		this->timer = this->timer + 1;

		if(this->chrAnimation.isAnimationDone())
			this->chrAnimation.setCurrentFrame(0.0);
	}
	void daShyGuy::endState_Balloon_C() { 
	}

///////////////
// Judo State
///////////////
	void daShyGuy::beginState_Judo() { 
		this->timer = 0;
	}
	void daShyGuy::executeState_Judo() { 

	// chargin 476? 673? 760? 768? 808? 966?
		if (this->timer == 0) { bindAnimChr_and_setUpdateRate("c18_OB_IDLE_R", 1, 0.0, 1.0); }

		this->timer = this->timer + 1;

		if (this->timer == 80) { 
			if (this->direction == 1) { 
				CreateEffect(&(Vec){this->pos.x + 7.0, this->pos.y + 14.0, this->pos.z + 5600.0}, &(S16Vec){0,0,0}, &(Vec){0.8, 0.8, 0.8}, 966); 
			}
			else {
				CreateEffect(&(Vec){this->pos.x - 7.0, this->pos.y + 14.0, this->pos.z}, &(S16Vec){0,0,0}, &(Vec){0.8, 0.8, 0.8}, 966); 
			}	
		}

		if (this->timer < 120) {
			// 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;
				}
			}


			if(this->chrAnimation.isAnimationDone())
				this->chrAnimation.setCurrentFrame(0.0);
		}

		else if (this->timer == 120) {
			bindAnimChr_and_setUpdateRate("c18_H_CUT_R", 1, 0.0, 1.0);
			
		}

		else if (this->timer == 132) {
			PlaySound(this, SE_EMY_CRASHER_PUNCH);

			if (this->direction == 1) { 
				CreateEffect(&(Vec){this->pos.x - 18.0, this->pos.y + 16.0, this->pos.z}, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}, 123); 
				changeActivePhysicsRect(this, 0.0, 12.0, 54.0, 12.0);
			}
			else {
				CreateEffect(&(Vec){this->pos.x + 18.0, this->pos.y + 16.0, this->pos.z}, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}, 124); 
				changeActivePhysicsRect(this, 20.0, 12.0, 34.0, 12.0);
			}	
		}

		else {

			if(this->chrAnimation.isAnimationDone()) {
				if (this->direction == 1) { 
					CreateEffect(&(Vec){this->pos.x - 38.0, this->pos.y + 16.0, this->pos.z}, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}, 171);
				}
				else {
					CreateEffect(&(Vec){this->pos.x + 38.0, this->pos.y + 16.0, this->pos.z}, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}, 171);
				}

				this->timer = 0;
				PlaySound(this, SE_EMY_BIG_PAKKUN_DAMAGE_1);
				changeActivePhysicsRect(this, 0.0, 12.0, 14.0, 12.0);
			}
		}
	}
	void daShyGuy::endState_Judo() { 
	}

///////////////
// Spike State
///////////////
	void daShyGuy::beginState_Spike() { 
		this->timer = 0;
	}
	void daShyGuy::executeState_Spike() {

		if (this->timer == 0) { bindAnimChr_and_setUpdateRate("c18_OB_IDLE_R", 1, 0.0, 1.0); }

		this->timer = this->timer + 1;

		if (this->timer < 120) {
			// 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;
				}
			}

			if(this->chrAnimation.isAnimationDone())
				this->chrAnimation.setCurrentFrame(0.0);
		}

		else if (this->timer == 120) {
			bindAnimChr_and_setUpdateRate("c18_H_SHOT_R", 1, 0.0, 1.0);
			
		}

		else if (this->timer == 160) {
			PlaySound(this, SE_EMY_KANIBO_THROW);

			Vec pos;
			pos.x = this->pos.x;
			pos.y = this->pos.y;
			pos.z = this->pos.z;
		
			if (this->direction == 1) { 
				dStageActor_c *spawned = CreateActor(89, 0x2, pos, 0, 0);
				spawned->scale.x = 0.5;
				spawned->scale.y = 0.5;
				spawned->scale.z = 0.5;

				spawned->speed.x = -2.0;
				spawned->speed.y = 2.0;
			}
			else {
				dStageActor_c *spawned = CreateActor(89, 0x12, pos, 0, 0);
				spawned->scale.x = 0.5;
				spawned->scale.y = 0.5;
				spawned->scale.z = 0.5;

				spawned->speed.x = 2.0;
				spawned->speed.y = 2.0;
			}
		}

		else {

			if(this->chrAnimation.isAnimationDone()) {
				this->timer = 0;
			}
		}
	}
	void daShyGuy::endState_Spike() { 
	}

///////////////
// Real Walk State
///////////////
	void daShyGuy::beginState_RealWalk() {
		//inline this piece of code
		bindAnimChr_and_setUpdateRate("c18_EV_WIN_2_R", 1, 0.0, 1.5); 
		this->max_speed.y = -4.0;
		this->speed.x = this->speed.z = 0.0;
		this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed;
		this->speed.y = -4.0;
		this->y_speed_inc = -0.1875;
	}
	void daShyGuy::executeState_RealWalk() { 
		this->HandleXSpeed();
		this->HandleYSpeed();
		this->doSpriteMovement();

		u16 amt = (this->direction == 0) ? 0x2800 : 0xD800;
		SmoothRotation(&this->rot.y, amt, 0x200);

		int ret = SomeStrangeModification(this);
		if(ret & 1)
			this->speed.y = 0.0;

		u32 bitfield = this->collMgr.bitfield_for_checks;
		if(bitfield & (0x15<<this->direction)) {
			this->pos.x = this->last_pos.x;
			this->doStateChange(&StateID_RealTurn);
		}

		// collisionMgr_c ??? Seems like a useful function, not sure if it's mapped in game.h as something else, though
		
		u32 bitfield2 = this->collMgr.directional_bitfields[this->direction];
		if(bitfield2) {
			this->doStateChange(&StateID_RealTurn);
		}

		DoStuffAndMarkDead(this, this->pos, 1.0);

		if(this->chrAnimation.isAnimationDone()) {
			this->chrAnimation.setCurrentFrame(0.0);
		}
	}
	void daShyGuy::endState_RealWalk() { }

///////////////
// Real Turn State
///////////////
	void daShyGuy::beginState_RealTurn() {
		bindAnimChr_and_setUpdateRate("c18_IDLE_R", 1, 0.0, 1.0);

		this->direction ^= 1;
		this->speed.x = 0.0;
	}
	void daShyGuy::executeState_RealTurn() { 

		if(this->chrAnimation.isAnimationDone()) {
			this->chrAnimation.setCurrentFrame(0.0);
		}

		this->HandleYSpeed();
		this->doSpriteMovement();

		int ret = SomeStrangeModification(this);

		if(ret & 1)
			this->speed.y = 0.0;
		if(ret & 4)
			this->pos.x = this->last_pos.x;
		DoStuffAndMarkDead(this, this->pos, 1.0);

		u16 amt = (this->direction == 0) ? 0x2800 : 0xD800;
		int done = SmoothRotation(&this->rot.y, amt, 0x200);

		if(done) {
			this->doStateChange(&StateID_RealWalk);
		}
	}
	void daShyGuy::endState_RealTurn() {
		this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed;
	}