summaryrefslogtreecommitdiff
path: root/src/bossMegaGoomba.cpp
blob: 3dde8a687a079cb967b819e0443e7a923250c60a (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
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
#include "boss.h"

extern "C" void *ShakeScreen(void *, unsigned int, unsigned int, unsigned int, unsigned int);
extern "C" void *ShakePlayers(dEn_c *);
extern "C" void *StopPlayerShake(dEn_c *);
extern "C" void *StageScreen;

const char* MGarcNameList [] = {
	"kuriboBig",
	"kuriboBoss",
	NULL	
};

//Enable this if you're fixing it
void setNewActivePhysicsRect(dStageActor_c* actor, Vec* scale) {
	float amtX = scale->x;
	float amtY = scale->y;

	// 0, 20.0, 18.0, 20.0
	ActivePhysics::Info info;
	// info.xDistToCenter = 0.0;
	// info.yDistToCenter = 7.65 * amtY;
	// info.xDistToEdge   = 8.0 * amtX;
	// info.yDistToEdge   = 8.7 * amtY;

	info.xDistToCenter = 0.0;
	info.yDistToCenter = 22.0 * amtY;
	info.xDistToEdge   = 18.0 * amtX;
	info.yDistToEdge   = 24.0 * amtY;

	info.category1  = actor->aPhysics.info.category1;
	info.category2  = actor->aPhysics.info.category2;
	info.bitfield1  = actor->aPhysics.info.bitfield1;
	info.bitfield2  = actor->aPhysics.info.bitfield2;
	info.unkShort1C = actor->aPhysics.info.unkShort1C;
	info.callback   = actor->aPhysics.info.callback;

	//OSReport("Making new Physics Class and adding to the list\n");
	actor->aPhysics.removeFromList();
	actor->aPhysics.initWithStruct(actor, &info);
	actor->aPhysics.addToList();
}

class daMegaGoomba_c : public dEn_c {
	int onCreate();
	int onDelete();
	int onExecute();
	int onDraw();

	mHeapAllocator_c allocator;
	nw4r::g3d::ResFile resFile;
	m3d::mdl_c bodyModel;
	m3d::anmChr_c animationChr;
	nw4r::g3d::ResAnmTexPat resTexPat;
	m3d::anmTexPat_c animationPat;

	float timer;
	float dying;
	
	HermiteKey keysX[0x10];
	unsigned int Xkey_count;
	HermiteKey keysY[0x10];
	unsigned int Ykey_count;

	char life;
	bool already_hit;

	float XSpeed;
	float JumpHeight;
	float JumpDist;
	float JumpTime;

	char isBigBoss;
	char isPanic;

	bool takeHit(char count);

	void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate);
	
	void dieFall_Begin();
	void dieFall_Execute();
	static daMegaGoomba_c *build();

	void setupBodyModel();
	void setupCollision();

	void updateModelMatrices();

	// bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
	// bool prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
//	bool preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);

//	bool stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther);
	void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
	void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
//	void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);

	void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
	bool collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
	// void collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
	void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
	void addScoreWhenHit(void *other);
	void _vf120(ActivePhysics *apThis, ActivePhysics *apOther);
	void _vf110(ActivePhysics *apThis, ActivePhysics *apOther);
	void _vf108(ActivePhysics *apThis, ActivePhysics *apOther);

	USING_STATES(daMegaGoomba_c);
	// DECLARE_STATE(Grow);
	DECLARE_STATE(Shrink);
	DECLARE_STATE(Walk);
	DECLARE_STATE(Turn);
	// DECLARE_STATE(Jump);
	// DECLARE_STATE(Launch);

	// DECLARE_STATE(Kameck);
	// DECLARE_STATE(Outro);	
};

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 };
	// last 4 bytes not needed. float for scale

daMegaGoomba_c *daMegaGoomba_c::build() {
	void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c));
	return new(buffer) daMegaGoomba_c;
}


//FIXME make this dEn_c->used...
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(daMegaGoomba_c, Grow);
CREATE_STATE(daMegaGoomba_c, Shrink);
CREATE_STATE(daMegaGoomba_c, Walk);
CREATE_STATE(daMegaGoomba_c, Turn);
// CREATE_STATE(daMegaGoomba_c, Jump);
// CREATE_STATE(daMegaGoomba_c, Launch);
// CREATE_STATE(daMegaGoomba_c, Outro);


//TODO better fix for possible bug with sign (ex. life=120; count=-9;)
bool daMegaGoomba_c::takeHit(char count) {
	if(!this->already_hit) {
		int c = count;
		int l = this->life;
		if(l - c > 127) {
			c = 127 - l;
		}
		this->life -= c;
		// this->XSpeed += 0.10;

		// float rate = this->animationChr.getUpdateRate();
		// this->animationChr.setUpdateRate(rate+0.05);
		this->JumpHeight += 12.0;
		this->JumpDist += 12.0;
		this->JumpTime += 5.0;
		doStateChange(&StateID_Shrink);
		this->already_hit = true;
	}
	return (life <= 0) ? true : false;
}

#define ACTIVATE	1
#define DEACTIVATE	0

extern "C" void *EN_LandbarrelPlayerCollision(dEn_c* t, ActivePhysics *apThis, ActivePhysics *apOther);
void daMegaGoomba_c::spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
	//HE'S TOO BADASS TO STOP FOR SMALLER GOOMBAS
	#if 0
		float me = apThis->firstFloatArray[3];
		if(((this->direction == 1) && (me > 0.0)) || ((this->direction == 0) && (me < 0.0))) {
			dStateBase_c* state = this->acState.getCurrentState();
			if(!state->isEqual(&StateID_Turn)) {
				doStateChange(&StateID_Turn);
			}
		}
	#endif
}
void daMegaGoomba_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { 

	/* * * * * * * * * * * * * * * * * * * * *
	 * 0=normal??,1=dontHit,2=dontKill
	 * daEnBrosBase_c ::player = 0
	 * daEnBrosBase_c::yoshi   = 0
	 * daEnPipePirahna::player = 1
	 * daEnPipePirahna::yoshi  = 1
	 * daEnKuriboBase_c::player = 0
	 * daEnKuriboBase_c::yoshi  = 0
	 * daEnLargeKuribo_c::player = 0
	 * daEnLargeKuribo_c::yoshi  = 2
	 * daEnNokonoko_c::player = 0
	 * daEnNokonoko_c::yoshi  = 0
	 * daEnSubBoss_c     = 2
	 *
	 * * * * * * * * * * * * * * * * * * * * */
	//FIXME rename and make part of dStageActor_c
	//unk=0 does _vfs, unk=1 does playSeCmnStep
	//char ret = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 0);

	char ret = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 2);
	if(ret == 1) {	// regular jump
		apOther->someFlagByte |= 2;
		if(this->takeHit(1))
			doStateChange(&StateID_DieFall);
	} else if(ret == 3) {	// spinning
		apOther->someFlagByte |= 2;
		if(this->takeHit(1))
			doStateChange(&StateID_DieFall);
	} else if(ret == 0) {
		this->dEn_c::playerCollision(apThis, apOther);
		this->_vf220(apOther->owner);
	} else if(ret == 2) {
	} else {
	}

	//FIXME hack to make multiple playerCollisions work
	this->isDead = 0;
	this->flags_4FC |= (1<<(31-7));
	this->counter_504[apOther->owner->which_player] = 0;
}
void daMegaGoomba_c::collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther) { 
	OSReport("Ground Pounded");
	apOther->someFlagByte |= 2;

	if(this->takeHit(1))
		doStateChange(&StateID_DieFall);

	// dEn_c *mario = (dEn_c*)apOther->owner;
	// mario->speed.y = 6.0;

	// EN_LandbarrelPlayerCollision(this, apThis, apOther);

	// mario->speed.x += 16.0;

	this->isDead = 0;
	this->flags_4FC |= (1<<(31-7));
	this->counter_504[apOther->owner->which_player] = 0;
}
void daMegaGoomba_c::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) {}
bool daMegaGoomba_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) { return false; }
void daMegaGoomba_c::collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_DieFall); }
// void daMegaGoomba_c::collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther) { }
void daMegaGoomba_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) {
	if(this->takeHit(1))
		doStateChange(&StateID_DieFall);
}
void daMegaGoomba_c::collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther) {}
void daMegaGoomba_c::collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther) { }
void daMegaGoomba_c::collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther) {}
void daMegaGoomba_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) {
	if(this->takeHit(1))
		doStateChange(&StateID_DieFall);
}
void daMegaGoomba_c::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) {
	if(this->takeHit(1))
		doStateChange(&StateID_DieFall);
}
void daMegaGoomba_c::addScoreWhenHit(void *other) {}
void daMegaGoomba_c::_vf120(ActivePhysics *apThis, ActivePhysics *apOther) { }
void daMegaGoomba_c::_vf110(ActivePhysics *apThis, ActivePhysics *apOther) { }
void daMegaGoomba_c::_vf108(ActivePhysics *apThis, ActivePhysics *apOther) { }

void daMegaGoomba_c::bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate) {
	nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr(name);
	this->animationChr.bind(&this->bodyModel, anmChr, unk);
	this->bodyModel.bindAnim(&this->animationChr, unk2);
	this->animationChr.setUpdateRate(rate);
}

void daMegaGoomba_c::dieFall_Begin() {
	this->dEn_c::dieFall_Begin();
}
void daMegaGoomba_c::dieFall_Execute() {
	
	this->timer = this->timer + 1.0;
	
	this->dying = this->dying + 0.15;
	
	this->pos.x = this->pos.x + 0.15;
	this->pos.y = this->pos.y + ((-0.2 * (this->dying*this->dying)) + 5);
	
	this->dEn_c::dieFall_Execute();
}

void daMegaGoomba_c::setupBodyModel() {
	allocator.link(-1, GameHeaps[0], 0, 0x20);

	this->resFile.data = getResource("kuriboBoss", "g3d/kuriboBoss.brres");
	nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kuriboBig");
	bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
	SetupTextures_Enemy(&bodyModel, 0);

	bool ret;
	nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk");
	ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0);
	this->bindAnimChr_and_setUpdateRate("walk", 1, 0.0, 0.2);

	nw4r::g3d::ResAnmTexPat anmPat = this->resFile.GetResAnmTexPat("walk");
	this->resTexPat = anmPat;
	ret = this->animationPat.setup(mdl, anmPat, &this->allocator, 0, 1);
	this->animationPat.bindEntry(&this->bodyModel, &anmPat, 0, 0);
	this->bodyModel.bindAnim(&this->animationPat, 0.0);
	this->animationPat.setFrameForEntry(1.0, 0);
	this->animationPat.setUpdateRateForEntry(1.0, 0);
	this->animationPat.setEntryByte34(0, 0);

	allocator.unlink();
}

void daMegaGoomba_c::setupCollision() {
	//POINTLESS WITH GROWTH
	this->scale.x = this->scale.y = this->scale.z = 0.666;

	this->collMgr.Init(this, struct_1, 0, struct_3);

	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->aPhysics.info.xDistToCenter = 0.0;
	this->aPhysics.info.yDistToCenter = 12.0;
	this->aPhysics.info.xDistToEdge = 14.0;
	this->aPhysics.info.yDistToEdge = 12.0;

	//NOT NEEDED
	//this->doStateChange(&StateID_Walk);
}

int daMegaGoomba_c::onCreate() {
	/*80033230 daEnLkuribo_c::onCreate()*/
	this->setupBodyModel();
	this->max_speed.y = -4.0;
	this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos);
	this->rot.y = (this->direction) ? 0xE000 : 0x2000;
	this->_518 = 2;

	isBigBoss = this->settings & 0xF;
	this->animationChr.setCurrentFrame(69.0);

	ActivePhysics::Info hm;
	hm.xDistToCenter = 0.0;
	hm.yDistToCenter = 8.0;
	hm.xDistToEdge   = 12.0;
	hm.yDistToEdge   = 12.0;
	hm.category1 = 0x3;
	hm.category2 = 0x0;
	hm.bitfield1 = 0x4f;
	hm.bitfield2 = 0xffbafffe;
	hm.unkShort1C = 0;
	hm.callback = &dEn_c::collisionCallback;
	this->aPhysics.initWithStruct(this, &hm);
	this->aPhysics.addToList();

	this->_120 |= 0x200;

	this->_36D = 0;
	this->setupCollision();

	//HOMEMADE//
	speed.y = 0.0;
	dying = 0.0;
	rot.x = rot.z = 0;
	life = 3;
	already_hit = false;
	this->x_speed_inc = 0.1;
	this->pos.y -= 16.0;

	// 2.0 is good final speed
	this->XSpeed = 0.2;
	this->JumpHeight = 48.0;
	this->JumpDist = 64.0;
	this->JumpTime = 50.0;

	// doStateChange(&StateID_Grow);

	scale.x = 4.0;
	scale.y = 4.0;
	scale.z = 4.0;
	setNewActivePhysicsRect(this, &this->scale);
	doStateChange(&StateID_Walk);

	this->onExecute();
	return true;
}

int daMegaGoomba_c::onDelete() {
	return true;
}

int daMegaGoomba_c::onExecute() {
	//80033450
	acState.execute();
	//if(CheckSomethingEnemyRelated())		// checks class1EC bitfield
	//	sub_80033f10(this);					// spawn hit effect and play hit sound
	//else
	//	dStageActor_c__checkZoneBoundaries(this, 0);
	//// dont do updateModelMatrices ////

	updateModelMatrices();

	return true;
}

int daMegaGoomba_c::onDraw() {
	bodyModel.scheduleForDrawing();

	//DONT DO REST HERE//
#if 0
	bodyModel._vf1C();
	animationPat.process();
#endif
	return true;
}


void daMegaGoomba_c::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);
}

///////////////
// Grow State
///////////////
	// void daMegaGoomba_c::beginState_Grow() { 
	// 	this->timer = 0;

	// 	SetupKameck(this, Kameck);
	// }

	// void daMegaGoomba_c::executeState_Grow() { 
	// 	this->timer += 1;
		
	// 	bool ret;
	// 	// ret = GrowBoss(this, Kameck, 1.0, 16.0, 0, this->timer);
	// 	ret = GrowBoss(this, Kameck, 1.0, 5.0, 0, this->timer);

	// 	if (ret) { 	
	// 		setNewActivePhysicsRect(this, &this->scale);
	// 		PlaySound(this, SE_EMY_KURI_CHANGE_BIG);
	// 		doStateChange(&StateID_Walk); 
	// 	}
	// }
	// void daMegaGoomba_c::endState_Grow() { 
	// 	CleanupKameck(this, Kameck);
	// }

	// Grow State
		// void daMegaGoomba_c::beginState_Grow() { 
		// 	this->timer = 1.0;

		// 	float start, end, shift1, shift2;
		// 	start  = 59.0;
		// 	shift1 = 90.0;
		// 	shift2 = 120.0;
		// 	end    = 139.0;
		// 	/* keysX[i] = { frame, value, slope }; */
		// 	Xkey_count = 7;
		// 	keysX[0] = (HermiteKey){ start,             1.0, 1.0 };
		// 	keysX[1] = (HermiteKey){ (start+shift1)/2,  2.0, 1.0 };
		// 	keysX[2] = (HermiteKey){ shift1,            4.0, 1.0 };
		// 	keysX[3] = (HermiteKey){ (shift1+shift2)/2, 3.0, 1.0 };
		// 	keysX[3] = (HermiteKey){ shift2,            6.0, 1.0 };
		// 	keysX[3] = (HermiteKey){ (shift2+end)/2,    5.0, 1.0 };
		// 	keysX[6] = (HermiteKey){ end,               7.0, 1.0 };
		// }
		// void daMegaGoomba_c::executeState_Grow() { 
			
		// 	this->timer += 1.0;
			
		// 	if ((this->timer > 60.0) && (this->timer < 140.0)) {

		// 		float modifier = GetHermiteCurveValue(this->timer, this->keysX, Xkey_count);
		// 		this->scale = (Vec){modifier, modifier, modifier};
		// 		setNewActivePhysicsRect(this, &this->scale);

		// 	}
		// 	if(this->timer == 60.0)
		// 		PlaySound(this, SE_EMY_KURI_CHANGE_BIG);
			
		// 	if (this->timer > 170.0) { doStateChange(&StateID_Walk); }
			
		// }
		// void daMegaGoomba_c::endState_Grow() { }




// Shrink State
void daMegaGoomba_c::beginState_Shrink() {
	this->timer = 1.0;
	Xkey_count = 4;
	keysX[0] = (HermiteKey){  0.0, this->scale.y,        0.5 };
	keysX[1] = (HermiteKey){ 10.0, this->scale.y - 0.75, 0.5 };
	keysX[2] = (HermiteKey){ 20.0, this->scale.y - 0.35, 0.5 };
	keysX[3] = (HermiteKey){ 39.0, this->scale.y - 0.75, 0.5 };

	// disable being hit
	Vec tempVec = (Vec){0.0, 0.0, 0.0};
	setNewActivePhysicsRect(this,  &tempVec );
}
void daMegaGoomba_c::executeState_Shrink() { 
	this->timer += 1.0;
	
	float modifier = GetHermiteCurveValue(this->timer, this->keysX, Xkey_count);
	this->scale = (Vec){modifier, modifier, modifier};

	if(this->timer == 2.0)
		PlaySound(this, SE_EMY_KURIBO_L_DAMAGE_02);

	if (this->timer > 40.0) { doStateChange(&StateID_Walk); }
}
void daMegaGoomba_c::endState_Shrink() {
	// enable being hit
	setNewActivePhysicsRect(this, &this->scale);
	this->already_hit = false;
}



// Launch State - Launches some small goombas up in arcs
	// void daMegaGoomba_c::beginState_Launch() { 
	// 	this->timer = 0.0; 
	// 	rot.y = 0x0;
	// }
	// void daMegaGoomba_c::executeState_Launch() { 
			
	// 	if (this->timer < 120.0) {
	// 		// 3 shakes per second, exactly 24 shakes overall
	// 		this->rot.y = sin(this->timer * 3.14 / 5) * 4000;

	// 		dStageActor_c *spawner = NULL;
	// 		// 120ticks /  120numbers * 3cases  = 3avg kuribo
	// 		int randChoice = GenerateRandomNumber(120);
	// 		int randChoiceX = GenerateRandomNumber(10);
	// 		int randChoiceY = GenerateRandomNumber(7);
	// 		switch(randChoice) {
	// 			case 0:
	// 			case 1:
	// 				spawner = CreateActor(EN_KURIBO, 0, this->pos, 0, 0);
	// 				spawner->speed.x = randChoiceX - 5.0;
	// 				spawner->speed.y = randChoiceY + 6.0;
	// 				spawner->scale = (Vec){1.0, 1.0, 1.0};
	// 				break;
	// 			case 2:
	// 				spawner = CreateActor(EN_BEANS_KURIBO, 0, this->pos, 0, 0);
	// 				spawner->speed.x = randChoiceX - 5.0;
	// 				spawner->speed.y = randChoiceY + 6.0;
	// 				spawner->scale = (Vec){1.0, 1.0, 1.0};
	// 				break;
	// 			case 3:
	// 				spawner = CreateActor(EN_PATA_KURIBO, 0, this->pos, 0, 0);
	// 				spawner->speed.x = randChoiceX - 5.0;
	// 				spawner->speed.y = randChoiceY + 6.0;
	// 				spawner->scale = (Vec){1.0, 1.0, 1.0};
	// 				break;
	// 			default:
	// 				break;
	// 		};
	// 	}

	// 	if (this->timer > 150.0) { doStateChange(&StateID_Walk); }
	// 	this->timer = this->timer + 1.0;
	// }
	// void daMegaGoomba_c::endState_Launch() { 
	// 	//rot.y = (this->direction) ? 0xe000 : 0x2000;
	// }

// Jump State
	// void daMegaGoomba_c::beginState_Jump() {
	// 	this->timer = 1.0;

	// 	//Variables for choosing a curve
	// 	float jump_height = this->JumpHeight;
	// 	float delta = (this->direction) ? -JumpDist : JumpDist;
	// 	float fullTime = this->JumpTime;
	// 	//Key count
	// 	Xkey_count = 2;
	// 	Ykey_count = 3;

	// 	//Initial Position
	// 	keysX[0] = (HermiteKey){ 0.0, this->pos.x, 0.0 };
	// 	keysY[0] = (HermiteKey){ 0.0, this->pos.y, 0.8 };

	// 	//Middle Position
	// 	keysY[1] = (HermiteKey){ (fullTime/2.0), this->pos.y + jump_height, 0.0 };

	// 	//End Position
	// 	keysX[1] = (HermiteKey){ fullTime, this->pos.x + delta, 0.0 };
	// 	keysY[2] = (HermiteKey){ fullTime, this->pos.y, 0.8 };

	// 	// using this to stop walk animation
	// 	this->animationChr.setCurrentFrame(900.0);
	// }
	// void daMegaGoomba_c::executeState_Jump() { 

	// 	this->pos.x = GetHermiteCurveValue(this->timer, this->keysX, Xkey_count);
	// 	this->pos.y = GetHermiteCurveValue(this->timer, this->keysY, Ykey_count);

	// 	float TimerMax = JumpTime + 1.0;
	// 	if (this->timer > TimerMax) {
	// 		doStateChange(&StateID_Walk);
	// 	}

	// 	this->timer = this->timer + 1.0;

	// }
	// void daMegaGoomba_c::endState_Jump() { }


// Turn State
void daMegaGoomba_c::beginState_Turn() {
	this->direction ^= 1;
	this->speed.x = 0.0;
}
void daMegaGoomba_c::executeState_Turn() { 
	this->bodyModel._vf1C();
	this->animationPat.process();

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

	/*this->_vf2D0();	//nullsub();*/
	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) ? 0x2000 : 0xE000;
	int done = SmoothRotation(&this->rot.y, amt, 0x80);
	if(done) {
		this->doStateChange(&StateID_Walk);
	}

	int frame = (int)(this->animationChr.getCurrentFrame() * 5.0);
	if ((frame == 100) || (frame == 325) || (frame == 550) || (frame == 775)) {
		ShakeScreen(StageScreen, 0, 1, 0, 0);
		ShakePlayers(this);
		PlaySound(this, SE_BOSS_MORTON_GROUND_SHAKE);
	}

	if (isBigBoss) {
		if ((frame == 250) || (frame == 500) || (frame == 700) || (frame == 900))
			StopPlayerShake(this);
	}
	else {
		if ((frame == 200) || (frame == 425) || (frame == 650) || (frame == 875))
			StopPlayerShake(this);
	}
}
void daMegaGoomba_c::endState_Turn() {
	this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed;
}


// Walk State
void daMegaGoomba_c::beginState_Walk() {
	//inline this piece of code
	this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos);
	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 daMegaGoomba_c::executeState_Walk() { 
	/* 800345e0 - daEnLkuribo_c::executeState_Walk() */
	this->bodyModel._vf1C();
	this->animationPat.process();
	//HOMEMADE//
	this->HandleXSpeed();
	this->HandleYSpeed();
	this->doSpriteMovement();
	u16 amt = (this->direction == 0) ? 0x2000 : 0xE000;
	SmoothRotation(&this->rot.y, amt, 0x200);
	/*this->_vf2D0();	//nullsub();*/
	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_Turn);
		//this->acState.setField10ToOne();
	}
	u32 bitfield2 = this->collMgr.directional_bitfields[this->direction];
	if(bitfield2) {
		this->doStateChange(&StateID_Turn);
	}
	DoStuffAndMarkDead(this, this->pos, 1.0);


	int frame = (int)(this->animationChr.getCurrentFrame() * 5.0);
	if ((frame == 100) || (frame == 325) || (frame == 550) || (frame == 775)) {
		ShakeScreen(StageScreen, 0, 1, 0, 0);
		ShakePlayers(this);
		PlaySound(this, SE_BOSS_MORTON_GROUND_SHAKE);
	}

	if (isBigBoss) {
		if ((frame == 250) || (frame == 500) || (frame == 700) || (frame == 900))
			StopPlayerShake(this);
	}
	else {
		if ((frame == 200) || (frame == 425) || (frame == 650) || (frame == 875))
			StopPlayerShake(this);
	}

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

		int new_dir = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, pos);
		if(this->direction != new_dir)
			doStateChange(&StateID_Turn);
	}
}
void daMegaGoomba_c::endState_Walk() { }





///////////////
// Outro State
///////////////
	// void daMegaGoomba_c::beginState_Outro() { 

	// 	OutroSetup(this);
	// 	this->aPhysics.removeFromList();
	// }
	// void daMegaGoomba_c::executeState_Outro() {

	// 	if (this->dying == 1) { 

	// 		if (this->timer > 180) { ExitStage(WORLD_MAP, 0, BEAT_LEVEL, MARIO_WIPE); }
	// 		if (this->timer == 60) { PlayerVictoryCries(this); }	
			
	// 		this->timer += 1;
	// 		return; 
	// 	}	

	// 	bool ret;
	// 	ret = ShrinkBoss(this, &this->pos, 1.0, this->timer);

	// 	if (ret == true) 	{ 
	// 		BossExplode(this, &this->pos); 
	// 		this->dying = 1;
	// 		this->timer = 0;	
	// 	}
	// 	else 		{ PlaySound(this, SE_EMY_BIG_KURIBO_DOWN); }
	
	// 	this->timer += 1;
	// }
	// void daMegaGoomba_c::endState_Outro() { }