summaryrefslogtreecommitdiff
path: root/src/bossFuzzyBear.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bossFuzzyBear.cpp297
1 files changed, 297 insertions, 0 deletions
diff --git a/src/bossFuzzyBear.cpp b/src/bossFuzzyBear.cpp
new file mode 100644
index 0000000..b206299
--- /dev/null
+++ b/src/bossFuzzyBear.cpp
@@ -0,0 +1,297 @@
+#include <common.h>
+#include <game.h>
+#include <g3dhax.h>
+
+class daFuzzyBear_c : public dEn_c {
+ int onCreate();
+ int onDelete();
+ int onExecute();
+ int onDraw();
+
+ mHeapAllocator_c allocator;
+ m3d::mdl_c bodyModel;
+
+ int timer;
+ float Baseline;
+ float AreaWidthLeft;
+ float AreaWidthRight;
+ float LaunchSpeedShort;
+ float LaunchSpeedHigh;
+ float dying;
+ Vec initialPos;
+
+ void dieBigFall_Execute();
+ static daFuzzyBear_c *build();
+
+ void updateModelMatrices();
+
+// void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+// void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
+
+ USING_STATES(daFuzzyBear_c);
+ DECLARE_STATE(Grow);
+ DECLARE_STATE(Bounce);
+};
+
+daFuzzyBear_c *daFuzzyBear_c::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(daFuzzyBear_c));
+ return new(buffer) daFuzzyBear_c;
+}
+
+
+extern "C" void *HandleXSpeed(daFuzzyBear_c *);
+extern "C" void *HandleYSpeed(daFuzzyBear_c *);
+extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daFuzzyBear_c *);
+extern "C" u32 GenerateRandomNumber(int max);
+extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daFuzzyBear_c *, Vec pos);
+extern "C" dStageActor_c *GetSpecificPlayerActor(int number);
+
+
+
+CREATE_STATE(daFuzzyBear_c, Grow);
+CREATE_STATE(daFuzzyBear_c, Bounce);
+
+
+#define ACTIVATE 1
+#define DEACTIVATE 0
+
+
+void daFuzzyBear_c::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Fireball"); }
+void daFuzzyBear_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Iceball"); }
+void daFuzzyBear_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) {
+ OSReport("Hit Rolling Object");
+ this->timer = 0;
+ doStateChange(&StateID_DieBigFall); }
+void daFuzzyBear_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) {
+ OSReport("Hit Hammer");
+ this->timer = 0;
+ doStateChange(&StateID_DieBigFall); }
+void daFuzzyBear_c::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Yoshi Fire"); }
+
+
+void daFuzzyBear_c::dieBigFall_Execute() {
+
+ this->timer = this->timer + 1;
+
+ 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::dieBigFall_Execute();
+}
+
+
+int daFuzzyBear_c::onCreate() {
+
+ OSReport("Creating the Fuzzy Bear Model");
+ allocator.link(-1, GameHeaps[0], 0, 0x20);
+
+ nw4r::g3d::ResFile rf(getResource("chorobon", "g3d/chorobon.brres"));
+ bodyModel.setup(rf.GetResMdl("chorobon"), &allocator, 0x224, 1, 0);
+ SetupTextures_Enemy(&bodyModel, 0);
+
+ allocator.unlink();
+
+ OSReport("Setting Fuzzy Bear's Size to 1.0");
+ this->scale = (Vec){1.0, 1.0, 1.0};
+
+ OSReport("Creating Fuzzy Bear's Physics Struct");
+
+ ActivePhysics::Info HitMeBaby;
+ HitMeBaby.xDistToCenter = 0.0;
+ HitMeBaby.yDistToCenter = 0.0;
+ HitMeBaby.xDistToEdge = 38.0;
+ HitMeBaby.yDistToEdge = 38.0;
+ HitMeBaby.category1 = 0x3;
+ HitMeBaby.category2 = 0x0;
+ HitMeBaby.bitfield1 = 0x4F;
+ HitMeBaby.bitfield2 = 0x828E;
+ HitMeBaby.unkShort1C = 0;
+ HitMeBaby.callback = &dEn_c::collisionCallback;
+
+
+ OSReport("Making the Physics Class and adding to the list");
+ this->aPhysics.initWithStruct(this, &HitMeBaby);
+ this->aPhysics.addToList();
+
+ OSReport("Setting up Fuzzy Bear's Box of Goodies");
+
+ this->pos.y = this->pos.y + 6;
+ this->rot.x = 0; // X is vertical axis
+ this->rot.y = 0; // Y is horizontal axis
+ this->rot.z = 0; // Z is ... an axis >.>
+ this->direction = 0; // Heading left.
+
+ this->speed.x = 0;
+ this->LaunchSpeedShort = ((this->settings >> 20) && 0xF) * 10.0;
+ this->LaunchSpeedHigh = ((this->settings >> 24) && 0xF) * 10.0;
+
+ this->AreaWidthRight = this->settings && 0xFF;
+ this->AreaWidthLeft = (this->settings >> 8) && 0xFF;
+
+ this->initialPos = this->pos;
+
+ OSReport("Setting Fuzzy Bear's State");
+ doStateChange(&StateID_Grow);
+
+ OSReport("Going to Execute Fuzzy Bear");
+ this->onExecute();
+ return true;
+}
+
+int daFuzzyBear_c::onDelete() {
+ return true;
+}
+
+int daFuzzyBear_c::onExecute() {
+ // OSReport("Fuzzy Bear was Executed.");
+ acState.execute();
+ updateModelMatrices();
+
+// this->speed.y = this->speed.y - 0.2; // Gravity
+
+ return true;
+}
+
+int daFuzzyBear_c::onDraw() {
+ bodyModel.scheduleForDrawing();
+ return true;
+}
+
+
+void daFuzzyBear_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 daFuzzyBear_c::beginState_Grow() {
+ OSReport("Growing when Kameck Tells me to.");
+ this->timer = 0;
+}
+
+void daFuzzyBear_c::executeState_Grow() {
+
+ this->timer = this->timer + 1;
+
+ if ((this->timer > 60) && (this->timer < 140)) {
+
+ float modifier;
+ modifier = 1.0 + ((this->timer - 60) * 0.025);
+
+ this->scale = (Vec){modifier, modifier, modifier};
+ this->pos.y = this->pos.y + (25/80);
+ }
+
+ if (this->timer > 170) { doStateChange(&StateID_Bounce); }
+
+}
+void daFuzzyBear_c::endState_Grow() {
+ this->Baseline = this->pos.y;
+ OSReport("OK. All grown up now.");
+}
+
+
+
+
+
+// Bounce State
+
+void daFuzzyBear_c::beginState_Bounce() {
+
+ if (this->direction = 0) { this->speed.x = ((this->settings >> 16) && 0xF) * 0.5; }
+ else { this->speed.x = ((this->settings >> 16) && 0xF) * -0.5; }
+
+ this->pos.y = this->Baseline - 1.0;
+
+ this->timer = 20;
+}
+void daFuzzyBear_c::executeState_Bounce() {
+
+ // Check for walls
+
+ if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + 38.0)) { // Hit left wall, head right.
+ this->speed.x = -this->speed.x;
+ this->direction = 0;
+ this->pos.x = this->pos.x + 1.0; }
+
+ if (this->pos.x >= this->initialPos.x + ((AreaWidthRight * 24.0) - 38.0)) { // Hit right wall, head left.
+ this->speed.x = -this->speed.x;
+ this->direction = 1;
+ this->pos.x = this->pos.x - 1.0; }
+
+
+ // Check if we're on the ground.
+
+ if (this->pos.y < this->Baseline) {
+
+ OSReport("Prepare for Landing.");
+
+ this->timer = this->timer + 1;
+ this->speed.x = 0;
+ this->speed.y = 0;
+
+
+ if (this->timer < 10) {
+ float modifier;
+ modifier = 3.0 - (this->timer * 0.05);
+
+ this->scale.y = modifier;
+ this->pos.y = this->pos.y + (6/15);
+ if (this->pos.y > this->Baseline) { this->pos.y = this->Baseline - 1.0; }
+ }
+ else {
+ float modifier;
+ modifier = 2.0 + ((this->timer - 20) * 0.05);
+
+ this->scale.y = modifier;
+ this->pos.y = this->pos.y + (24/15);
+ if (this->pos.y > this->Baseline) { this->pos.y = this->Baseline - 1.0; }
+ }
+
+ if (this->timer >= 20) {
+ int randChoice;
+ randChoice = GenerateRandomNumber(5);
+
+ if (randChoice == 0) { this->speed.y = LaunchSpeedHigh; }
+ else { this->speed.y = LaunchSpeedShort; }
+
+ this->timer = 0;
+ this->pos.y = this->Baseline + 1;
+ OSReport("Takeoff Initiated");
+
+ if (this->direction = 0) { this->speed.x = ((this->settings >> 16) && 0xF) * 0.5; }
+ else { this->speed.x = ((this->settings >> 16) && 0xF) * -0.5; }
+ }
+ }
+
+ else { this->speed.y = this->speed.y - 0.1; } // Gravity
+
+
+
+ HandleXSpeed(this);
+ HandleYSpeed(this);
+
+ UpdateObjectPosBasedOnSpeedValues_real(this);
+
+}
+
+void daFuzzyBear_c::endState_Bounce() {
+
+}
+
+
+