summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xinclude/game.h2
-rw-r--r--kamek_pal.x2
-rw-r--r--src/bossFuzzyBear.cpp391
-rwxr-xr-xsrc/mrsun.cpp167
4 files changed, 496 insertions, 66 deletions
diff --git a/include/game.h b/include/game.h
index f7728db..c57a93d 100755
--- a/include/game.h
+++ b/include/game.h
@@ -1549,7 +1549,7 @@ public:
virtual void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual bool collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
virtual void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
diff --git a/kamek_pal.x b/kamek_pal.x
index 801c7ed..8535c2c 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -29,7 +29,7 @@ SECTIONS {
HandleYSpeed = 0x8006CDE0;
UpdateObjectPosBasedOnSpeedValues_real = 0x8006CD40;
dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3 = 0x80096240;
-
+ CalculateDistanceFromActorsNextPosToFurthestPlayer = 0x80064740;
diff --git a/src/bossFuzzyBear.cpp b/src/bossFuzzyBear.cpp
index b206299..6b0fab0 100644
--- a/src/bossFuzzyBear.cpp
+++ b/src/bossFuzzyBear.cpp
@@ -12,30 +12,40 @@ class daFuzzyBear_c : public dEn_c {
m3d::mdl_c bodyModel;
int timer;
+ char BigBossFuzzyBear;
float Baseline;
float AreaWidthLeft;
float AreaWidthRight;
float LaunchSpeedShort;
float LaunchSpeedHigh;
float dying;
+ float storeSpeed;
Vec initialPos;
+ char RolyBounces;
+ Vec RolyPos;
+ char falldown;
+ char damage;
+ char fireballs;
void dieBigFall_Execute();
static daFuzzyBear_c *build();
void updateModelMatrices();
-// void playerCollision(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);
- void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ bool collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCat9_RollingObject(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);
+ DECLARE_STATE(Needles);
+ DECLARE_STATE(Spray);
+ DECLARE_STATE(RolyPoly);
};
daFuzzyBear_c *daFuzzyBear_c::build() {
@@ -48,29 +58,47 @@ 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" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daFuzzyBear_c *, Vec pos);
extern "C" dStageActor_c *GetSpecificPlayerActor(int number);
+int NearestPlayerF(daFuzzyBear_c *Sprite);
+float PlayertoSpriteDistanceF(Vec sprite, Vec player);
CREATE_STATE(daFuzzyBear_c, Grow);
CREATE_STATE(daFuzzyBear_c, Bounce);
+CREATE_STATE(daFuzzyBear_c, Needles);
+CREATE_STATE(daFuzzyBear_c, Spray);
+CREATE_STATE(daFuzzyBear_c, RolyPoly);
#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::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
+ this->_vf220(apOther->owner);
+ OSReport("I hit Mario.");
+}
+void daFuzzyBear_c::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) {
+ OSReport("Hit Fireball");
+ this->timer = 0;
+ this->fireballs = this->fireballs + 1;
+ if (this->fireballs > 4) { this->damage = this->damage + 1; }
+ if (this->damage > 2) { doStateChange(&StateID_DieBigFall); }
+}
+bool daFuzzyBear_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Iceball"); return false; }
void daFuzzyBear_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) {
OSReport("Hit Rolling Object");
this->timer = 0;
- doStateChange(&StateID_DieBigFall); }
+ this->damage = this->damage + 1;
+ if (this->damage > 2) { doStateChange(&StateID_DieBigFall); } }
void daFuzzyBear_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) {
OSReport("Hit Hammer");
this->timer = 0;
- doStateChange(&StateID_DieBigFall); }
+ this->damage = this->damage + 1;
+ if (this->damage > 2) { doStateChange(&StateID_DieBigFall); } }
void daFuzzyBear_c::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Yoshi Fire"); }
@@ -98,6 +126,9 @@ int daFuzzyBear_c::onCreate() {
allocator.unlink();
+ this->BigBossFuzzyBear = this->settings >> 28;
+
+
OSReport("Setting Fuzzy Bear's Size to 1.0");
this->scale = (Vec){1.0, 1.0, 1.0};
@@ -106,12 +137,20 @@ int daFuzzyBear_c::onCreate() {
ActivePhysics::Info HitMeBaby;
HitMeBaby.xDistToCenter = 0.0;
HitMeBaby.yDistToCenter = 0.0;
- HitMeBaby.xDistToEdge = 38.0;
- HitMeBaby.yDistToEdge = 38.0;
- HitMeBaby.category1 = 0x3;
+
+ if (BigBossFuzzyBear == 0) {
+ HitMeBaby.xDistToEdge = 38.0;
+ HitMeBaby.yDistToEdge = 38.0; }
+ else {
+ HitMeBaby.xDistToEdge = 50.0;
+ HitMeBaby.yDistToEdge = 50.0; }
+
+ HitMeBaby.category1 = 0x7;
HitMeBaby.category2 = 0x0;
- HitMeBaby.bitfield1 = 0x4F;
- HitMeBaby.bitfield2 = 0x828E;
+ HitMeBaby.bitfield1 = 0x0;
+ HitMeBaby.bitfield2 = 0x0;
+// HitMeBaby.bitfield1 = 0x4F;
+// HitMeBaby.bitfield2 = 0x828E;
HitMeBaby.unkShort1C = 0;
HitMeBaby.callback = &dEn_c::collisionCallback;
@@ -136,6 +175,10 @@ int daFuzzyBear_c::onCreate() {
this->AreaWidthLeft = (this->settings >> 8) && 0xFF;
this->initialPos = this->pos;
+ this->storeSpeed = 0;
+ this->falldown = 0;
+ this->fireballs = 0;
+ this->damage = 0;
OSReport("Setting Fuzzy Bear's State");
doStateChange(&StateID_Grow);
@@ -153,12 +196,67 @@ int daFuzzyBear_c::onExecute() {
// OSReport("Fuzzy Bear was Executed.");
acState.execute();
updateModelMatrices();
-
-// this->speed.y = this->speed.y - 0.2; // Gravity
+ if (this->aPhysics.result1 == 1) {
+ char PlayerID = NearestPlayerF(this);
+ dStageActor_c *Player = GetSpecificPlayerActor(PlayerID);
+
+ this->_vf220(Player);
+ }
+
return true;
}
+int NearestPlayerF(daFuzzyBear_c *Sprite) {
+ float pfloat[] = { 0.0, 0.0, 0.0, 0.0 };
+ float max = 1000000.0;
+ char maxPlayer = 5;
+ int i;
+ OSReport("FINDING NEAREST PLAYER");
+
+ for (i=0; i<4; i++) {
+ OSReport("K, let's check out Player %d", i);
+ dStageActor_c *Player = GetSpecificPlayerActor(i);
+ if (Player != 0) {
+ OSReport("Player %d exists", i);
+ pfloat[i] = PlayertoSpriteDistanceF(Sprite->pos, Player->pos);
+
+ OSReport("if %f > %f", pfloat[i], max);
+ if (pfloat[i] < max) {
+ max = pfloat[i];
+ maxPlayer = i;
+ OSReport("MaxPlayer now %d", i);
+ }
+ }
+ }
+
+ OSReport("MaxPlayer finalized at %d", maxPlayer);
+
+ return maxPlayer;
+}
+
+float PlayertoSpriteDistanceF(Vec sprite, Vec player) {
+ float x = sprite.x - player.x;
+ float y = sprite.y - player.y;
+
+ float x2 = x * x;
+ float y2 = y * y;
+
+ float returnval = x2+y2;
+
+ OSReport("X: (%f - %f)^2 = %f", sprite.x, player.x, x2);
+ OSReport("Y: (%f - %f)^2 = %f", sprite.y, player.y, y2);
+
+
+ if (returnval < 0) { returnval = -returnval; }
+
+ OSReport("Return: %f", returnval);
+
+ return returnval;
+}
+
+
+
int daFuzzyBear_c::onDraw() {
bodyModel.scheduleForDrawing();
return true;
@@ -187,13 +285,22 @@ void daFuzzyBear_c::executeState_Grow() {
this->timer = this->timer + 1;
+ float scaleSpeed, yPosScaling;
+
if ((this->timer > 60) && (this->timer < 140)) {
+ if (BigBossFuzzyBear == 0) {
+ scaleSpeed = 0.025;
+ yPosScaling = 25; }
+ else {
+ scaleSpeed = 0.0375;
+ yPosScaling = 33; }
float modifier;
- modifier = 1.0 + ((this->timer - 60) * 0.025);
+
+ modifier = 1.0 + ((this->timer - 60) * scaleSpeed);
this->scale = (Vec){modifier, modifier, modifier};
- this->pos.y = this->pos.y + (25/80);
+ this->pos.y = this->pos.y + (yPosScaling/80);
}
if (this->timer > 170) { doStateChange(&StateID_Bounce); }
@@ -212,25 +319,45 @@ void daFuzzyBear_c::endState_Grow() {
void daFuzzyBear_c::beginState_Bounce() {
+ OSReport("Begin Bouncing");
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;
+ if (this->storeSpeed != 0) { this->speed.x = this->storeSpeed; }
this->timer = 20;
}
void daFuzzyBear_c::executeState_Bounce() {
+
+ float wallDistance, scaleDown, scaleUp, scaleBase;
+
+ if (BigBossFuzzyBear == 0) {
+ wallDistance = 38.0;
+ scaleDown = 3.0;
+ scaleUp = 12.0;
+ scaleBase = 3.0;
+ }
+ else {
+ wallDistance = 50.0;
+ scaleDown = 4.0;
+ scaleUp = 16.0;
+ scaleBase = 4.0;
+ }
+
+
+ if (this->falldown == 1) { this->speed.x = 0; this->timer = 0; }
+
// Check for walls
- if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + 38.0)) { // Hit left wall, head right.
+ if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + wallDistance)) { // Hit left wall, head right.
this->speed.x = -this->speed.x;
- this->direction = 0;
+ this->direction = 1;
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.
+ if (this->pos.x >= this->initialPos.x + ((AreaWidthRight * 24.0) - wallDistance)) { // Hit right wall, head left.
this->speed.x = -this->speed.x;
- this->direction = 1;
+ this->direction = 0;
this->pos.x = this->pos.x - 1.0; }
@@ -238,32 +365,49 @@ void daFuzzyBear_c::executeState_Bounce() {
if (this->pos.y < this->Baseline) {
- OSReport("Prepare for Landing.");
+ this->falldown = 0;
this->timer = this->timer + 1;
+ if (this->speed.x != 0) {
+ this->storeSpeed = this->speed.x; }
this->speed.x = 0;
this->speed.y = 0;
if (this->timer < 10) {
float modifier;
- modifier = 3.0 - (this->timer * 0.05);
+ modifier = scaleBase - (this->timer * 0.1);
this->scale.y = modifier;
- this->pos.y = this->pos.y + (6/15);
+ this->pos.y = this->pos.y + (scaleDown/10.0);
if (this->pos.y > this->Baseline) { this->pos.y = this->Baseline - 1.0; }
}
else {
float modifier;
- modifier = 2.0 + ((this->timer - 20) * 0.05);
+ modifier = (scaleBase - 1.0) + ((this->timer - 10) * 0.1);
this->scale.y = modifier;
- this->pos.y = this->pos.y + (24/15);
+ this->pos.y = this->pos.y + (scaleUp/10.0);
if (this->pos.y > this->Baseline) { this->pos.y = this->Baseline - 1.0; }
}
if (this->timer >= 20) {
+
int randChoice;
+
+ if (BigBossFuzzyBear == 1) {
+ randChoice = GenerateRandomNumber(5);
+
+ if (randChoice == 0) { doStateChange(&StateID_Spray); }
+ else if (randChoice == 1) { doStateChange(&StateID_Needles); }
+ else if (randChoice == 2) { doStateChange(&StateID_RolyPoly); }
+
+ }
+ else {
+ randChoice = GenerateRandomNumber(2);
+ if (randChoice == 0) { doStateChange(&StateID_RolyPoly); }
+ }
+
randChoice = GenerateRandomNumber(5);
if (randChoice == 0) { this->speed.y = LaunchSpeedHigh; }
@@ -272,15 +416,91 @@ void daFuzzyBear_c::executeState_Bounce() {
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; }
+
+ this->speed.x = this->storeSpeed;
}
}
else { this->speed.y = this->speed.y - 0.1; } // Gravity
+ HandleXSpeed(this);
+ HandleYSpeed(this);
+
+ UpdateObjectPosBasedOnSpeedValues_real(this);
+
+}
+
+void daFuzzyBear_c::endState_Bounce() { OSReport("No more bouncing."); }
+
+
+
+
+
+// Needles State - shoots out some black icicles
+
+void daFuzzyBear_c::beginState_Needles() {
+ this->timer = 0;
+ this->speed.y = 0;
+ this->speed.x = 0;
+ OSReport("Fuzzy Needle State Begin");
+}
+void daFuzzyBear_c::executeState_Needles() {
+ float origScale;
+
+ this->speed.y = 0;
+ this->speed.x = 0;
+
+ if (BigBossFuzzyBear == 0) {
+ origScale = 3.0;
+ }
+ else {
+ origScale = 4.0;
+ }
+
+ this->timer = this->timer + 1;
+ OSReport("Needle Timer: %d", this->timer);
+
+ if (this->timer < 120) {
+ this->scale.y = (sin(this->timer * 3.14 / 5.0) / 2.0) + origScale; // 3 shakes per second, exactly 24 shakes overall
+ this->scale.x = (sin(this->timer * 3.14 / 5.0) / 2.0) + origScale; // 3 shakes per second, exactly 24 shakes overall
+
+ if (this->timer == 30) {
+ dStageActor_c *spawner = CreateActor(511, 0, this->pos, 0, 0);
+ spawner->speed.x = -6.0;
+ spawner->speed.y = 0.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ }
+
+ if (this->timer == 45) {
+ dStageActor_c *spawner = CreateActor(511, 0, this->pos, 0, 0);
+ spawner->speed.x = 6.0;
+ spawner->speed.y = 6.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ }
+
+ if (this->timer == 60) {
+ dStageActor_c *spawner = CreateActor(511, 0, this->pos, 0, 0);
+ spawner->speed.x = 0.0;
+ spawner->speed.y = 6.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ }
+
+ if (this->timer == 75) {
+ dStageActor_c *spawner = CreateActor(511, 0, this->pos, 0, 0);
+ spawner->speed.x = -6.0;
+ spawner->speed.y = 6.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ }
+
+ if (this->timer == 90) {
+ dStageActor_c *spawner = CreateActor(511, 0, this->pos, 0, 0);
+ spawner->speed.x = -6.0;
+ spawner->speed.y = 0.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ }
+ }
+ else { doStateChange(&StateID_Bounce); }
HandleXSpeed(this);
HandleYSpeed(this);
@@ -288,10 +508,121 @@ void daFuzzyBear_c::executeState_Bounce() {
UpdateObjectPosBasedOnSpeedValues_real(this);
}
+void daFuzzyBear_c::endState_Needles() { OSReport("Fuzzy Needle State End"); }
-void daFuzzyBear_c::endState_Bounce() {
+// Spray State - jumps in the air and shakes out some small fuzzies
+
+void daFuzzyBear_c::beginState_Spray() {
+ this->timer = 0;
+ this->speed.y = 7.0;
+ this->speed.x = 0.0;
+ OSReport("Fuzzy Spray State Begin");
}
+void daFuzzyBear_c::executeState_Spray() {
+
+ this->speed.x = 0.0;
+ OSReport("Fuzzy Spray State Execute");
+ if (this->speed.y < 1.0) {
+ this->speed.y = 0;
+
+ if (this->timer < 120) {
+
+ this->rot.y = sin(this->timer * 3.14 / 5) * 4000; // 3 shakes per second, exactly 24 shakes overall
+ int randChoice;
+ randChoice = GenerateRandomNumber(20); // 1.3 Fuzzies per second, 6 fuzzies overall
+
+ if (randChoice == 0) {
+ int randChoiceX, randChoiceY;
+ randChoiceX = GenerateRandomNumber(24);
+ randChoiceY = GenerateRandomNumber(16);
+
+ dStageActor_c *spawner = CreateActor(144, 0, this->pos, 0, 0);
+ spawner->speed.x = randChoiceX - 12.0;
+ spawner->speed.y = randChoiceY * 1.0;
+ spawner->scale = (Vec){1.0, 1.0, 1.0};
+ } }
+
+ else { doStateChange(&StateID_Bounce); }
+ this->timer = this->timer + 1;
+
+ }
+
+ else { this->speed.y = this->speed.y - 0.1; } // Gravity
+
+
+ HandleXSpeed(this);
+ HandleYSpeed(this);
+
+ UpdateObjectPosBasedOnSpeedValues_real(this);
+
+}
+void daFuzzyBear_c::endState_Spray() {
+ this->rot.y = 0;
+ this->timer = 20;
+ this->falldown = 1;
+ OSReport("Fuzzy Spray State End");
+}
+
+
+// Roly Poly State - Rolls from left to right, bounces off both walls, and returns to original position.
+
+void daFuzzyBear_c::beginState_RolyPoly() {
+ this->speed.x = this->storeSpeed;
+ this->speed.y = 0;
+ this->RolyBounces = 0;
+ this->RolyPos = this->pos;
+ OSReport("Fuzzy Roly State Begin");
+}
+void daFuzzyBear_c::executeState_RolyPoly() {
+ OSReport("Fuzzy Roly State Execute");
+ float wallDistance, scaleDown, scaleUp;
+
+ if (BigBossFuzzyBear == 0) {
+ wallDistance = 38.0;
+ }
+ else {
+ wallDistance = 50.0;
+ }
+
+ this->speed.y = 0;
+
+ if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + wallDistance)) { // Hit left wall, head right.
+ this->speed.x = -this->speed.x;
+ this->direction = 1;
+ this->pos.x = this->pos.x + 1.0;
+ this->RolyBounces = this->RolyBounces + 1;
+ }
+
+ if (this->pos.x >= this->initialPos.x + ((AreaWidthRight * 24.0) - wallDistance)) { // Hit right wall, head left.
+ this->speed.x = -this->speed.x;
+ this->direction = 0;
+ this->pos.x = this->pos.x - 1.0;
+ this->RolyBounces = this->RolyBounces + 1;
+ }
+
+
+ if (this->direction == 1) { this->rot.z = this->rot.z + 0x1000; }
+ else { this->rot.z = this->rot.z - 0x1000; }
+
+ if (this->RolyBounces == 2) {
+ if (this->direction == 1) {
+ if (this->pos.x > this->RolyPos.x) {
+ this->speed.x = 0;
+ if (this->rot.z == 0) { doStateChange(&StateID_Bounce); } } }
+ else {
+ if (this->pos.x < this->RolyPos.x) {
+ this->speed.x = 0;
+ if (this->rot.z == 0) { doStateChange(&StateID_Bounce); } } }
+ }
+
+ HandleXSpeed(this);
+ HandleYSpeed(this);
+
+ UpdateObjectPosBasedOnSpeedValues_real(this);
+
+ }
+void daFuzzyBear_c::endState_RolyPoly() { this->rot.z = 0; OSReport("Fuzzy Roly State End"); }
diff --git a/src/mrsun.cpp b/src/mrsun.cpp
index 19b5902..01ab485 100755
--- a/src/mrsun.cpp
+++ b/src/mrsun.cpp
@@ -34,18 +34,21 @@ class daMrSun_c : public dEn_c {
int dying;
char sunDying;
+ u64 eventFlag;
+
+
void dieFall_Execute();
static daMrSun_c *build();
void updateModelMatrices();
-// void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
-// void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
- void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ bool 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);
+ void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
+ void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
USING_STATES(daMrSun_c);
DECLARE_STATE(Follow);
@@ -71,6 +74,8 @@ extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char r
extern "C" dStageActor_c *GetSpecificPlayerActor(int number);
+int NearestPlayer(daMrSun_c *Sprite);
+float PlayertoSpriteDistance(Vec sprite, Vec player);
CREATE_STATE(daMrSun_c, Follow);
CREATE_STATE(daMrSun_c, Swoop);
@@ -83,16 +88,34 @@ CREATE_STATE(daMrSun_c, Wait);
#define DEACTIVATE 0
+struct EventTable_t {
+ u64 events;
+ // ...
+};
+
+extern EventTable_t *EventTable;
+
+
+
+void daMrSun_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
+ this->_vf220(apOther->owner);
+ OSReport("I hit Mario.");
+}
+
void daMrSun_c::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Fireball"); }
-void daMrSun_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) {
+bool daMrSun_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) {
OSReport("Hit Iceball");
- if (this->settings == 0) { // It's a sun
- if (this->sunDying == 5) {
- this->isDead = 1;
- doStateChange(&StateID_DieIceVanish); }
- else {
- this->sunDying = this->sunDying + 1; }
- } }
+
+ if (this->settings == 1) { // It's a moon
+ OSReport("What Kind is it?: %d", apOther->owner->name);
+ if (apOther->owner->name == 0x76) { // BROS_ICEBALL
+ OSReport("No hits 4 u.");
+ return true;
+ }
+ }
+ OSReport("K it hit.");
+ return false;
+}
void daMrSun_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) {
OSReport("Hit Rolling Object");
this->timer = 0;
@@ -101,13 +124,17 @@ void daMrSun_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOt
OSReport("Hit Hammer");
this->timer = 0;
doStateChange(&StateID_DieFall); }
-void daMrSun_c::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Yoshi Fire"); }
+void daMrSun_c::collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther) {
+ OSReport("Hit StarMario");
+ this->timer = 0;
+ doStateChange(&StateID_DieFall); }
+void daMrSun_c::collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Groundpound"); }
+
void daMrSun_c::dieFall_Execute() {
this->timer = this->timer + 1;
-
this->dying = this->dying + 0.15;
@@ -132,6 +159,7 @@ void daMrSun_c::dieFall_Execute() {
doStateChange(&StateID_Follow); }
this->pos.y = this->Baseline;
+ this->aPhysics.addToList();
doStateChange(&StateID_Follow);
}
}
@@ -141,7 +169,7 @@ int daMrSun_c::onCreate() {
OSReport("Creating the Mr.Sun Models");
allocator.link(-1, GameHeaps[0], 0, 0x20);
- if (this->settings == 0) { // It's a sun
+ if ((this->settings & 0xF) == 0) { // It's a sun
hasGlow = true;
nw4r::g3d::ResFile rf(getResource("bilikyu", "g3d/sun.brres"));
@@ -158,9 +186,6 @@ int daMrSun_c::onCreate() {
nw4r::g3d::ResFile rf(getResource("bilikyu", "g3d/moon.brres"));
bodyModel.setup(rf.GetResMdl("Moon"), &allocator, 0x224, 1, 0);
SetupTextures_Map(&bodyModel, 0);
-
-// glowModel.setup(rf.GetResMdl("MoonGlow"), &allocator, 0x224, 1, 0);
-// SetupTextures_Map(&glowModel, 0);
}
allocator.unlink();
@@ -173,17 +198,19 @@ int daMrSun_c::onCreate() {
ActivePhysics::Info HitMeBaby;
HitMeBaby.xDistToCenter = 0.0;
HitMeBaby.yDistToCenter = 0.0;
- HitMeBaby.xDistToEdge = 16.0;
- HitMeBaby.yDistToEdge = 16.0;
HitMeBaby.category1 = 0x3;
HitMeBaby.category2 = 0x0;
- HitMeBaby.bitfield1 = 0x4F;
+ HitMeBaby.bitfield1 = 0x6F;
- if (this->settings == 0) { // It's a sun
- HitMeBaby.bitfield2 = 0x3E020C; // Can be hit by iceballs of all kinds, shells and rollies, pipe cannons, and star power
+ if ((this->settings & 0xF) == 0) { // It's a sun
+ HitMeBaby.bitfield2 = 0xffbafffc;
+ HitMeBaby.xDistToEdge = 24.0;
+ HitMeBaby.yDistToEdge = 24.0;
}
else { // It's a moon
- HitMeBaby.bitfield2 = 0x3E0200; // Can be hit by fireballs of all kinds, shells and rollies, pipe cannons, and star power
+ HitMeBaby.bitfield2 = 0xffbafffe;
+ HitMeBaby.xDistToEdge = 12.0;
+ HitMeBaby.yDistToEdge = 12.0;
}
HitMeBaby.unkShort1C = 0;
@@ -207,6 +234,14 @@ int daMrSun_c::onCreate() {
this->sunDying = 0;
this->pos.z = 3300.00;
+
+
+ char eventNum = (this->settings >> 16) & 0xFF;
+ OSReport("Event to activate: %d", eventNum);
+
+ this->eventFlag = (u64)1 << (eventNum - 1);
+
+
OSReport("Setting Mr.Sun's State");
doStateChange(&StateID_Follow);
@@ -224,9 +259,69 @@ int daMrSun_c::onExecute() {
//OSReport("Oh Mr.Sun, Sun, Mr.Golden Sun");
acState.execute();
updateModelMatrices();
+ if (this->aPhysics.result1 == 1) {
+ char PlayerID = NearestPlayer(this);
+ dStageActor_c *Player = GetSpecificPlayerActor(PlayerID);
+
+ this->_vf220(Player);
+ }
+
+ if (EventTable->events & this->eventFlag) {
+ this->kill();
+ this->pos.y = this->pos.y + 800.0;
+ }
+
return true;
}
+int NearestPlayer(daMrSun_c *Sprite) {
+ float pfloat[] = { 0.0, 0.0, 0.0, 0.0 };
+ float max = 1000000.0;
+ char maxPlayer = 5;
+ int i;
+ OSReport("FINDING NEAREST PLAYER");
+
+ for (i=0; i<4; i++) {
+ OSReport("K, let's check out Player %d", i);
+ dStageActor_c *Player = GetSpecificPlayerActor(i);
+ if (Player != 0) {
+ OSReport("Player %d exists", i);
+ pfloat[i] = PlayertoSpriteDistance(Sprite->pos, Player->pos);
+
+ OSReport("if %f > %f", pfloat[i], max);
+ if (pfloat[i] < max) {
+ max = pfloat[i];
+ maxPlayer = i;
+ OSReport("MaxPlayer now %d", i);
+ }
+ }
+ }
+
+ OSReport("MaxPlayer finalized at %d", i);
+
+ return maxPlayer;
+}
+
+float PlayertoSpriteDistance(Vec sprite, Vec player) {
+ float x = sprite.x - player.x;
+ float y = sprite.y - player.y;
+
+ float x2 = x * x;
+ float y2 = y * y;
+
+ float returnval = x2+y2;
+
+ OSReport("X: (%f - %f)^2 = %f", sprite.x, player.x, x2);
+ OSReport("Y: (%f - %f)^2 = %f", sprite.y, player.y, y2);
+
+
+ if (returnval < 0) { returnval = -returnval; }
+
+ OSReport("Return: %f", returnval);
+
+ return returnval;
+}
+
int daMrSun_c::onDraw() {
bodyModel.scheduleForDrawing();
if (hasGlow)
@@ -282,10 +377,10 @@ void daMrSun_c::executeState_Follow() {
this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos);
float speedDelta;
- if (this->settings == 0) { speedDelta = 0.1; } // It's a sun
+ if ((this->settings & 0xF) == 0) { speedDelta = 0.1; } // It's a sun
else { speedDelta = 0.15; } // It's a moon
- OSReport("Speed: %f", this->speed.x);
+// OSReport("Speed: %f", this->speed.x);
if (this->direction == 0) {
this->speed.x = this->speed.x + speedDelta;
@@ -328,7 +423,7 @@ void daMrSun_c::beginState_Swoop() {
if (this->swoopTarget.y < (this->pos.y - 50)) { doStateChange(&StateID_Spit); }
if (((this->pos.x - 96) < this->swoopTarget.x) && (this->swoopTarget.x < (this->pos.x + 96))) { doStateChange(&StateID_Spit); }
- if (this->settings == 0) {
+ if ((this->settings & 0xF) == 0) {
this->swoopTarget.y = this->swoopTarget.y - 16;
} // It's a sun
@@ -392,7 +487,7 @@ void daMrSun_c::executeState_Spiral() {
Magnitude = 11.0;
// Use a period of 0.1 for the moon
- if (this->settings == 0) { Period = 0.1; } // It's a sun
+ if ((this->settings & 0xF) == 0) { Period = 0.1; } // It's a sun
else { Period = 0.125; } // It's a moon
this->pos.x = this->xSpiralOffset + Magnitude*((this->SpiralLoop * cos(this->SpiralLoop)));
@@ -424,7 +519,7 @@ void daMrSun_c::executeState_Spit() {
if (this->direction == 0) { neg = 1.0; }
- if (this->settings == 0) {
+ if ((this->settings & 0xF) == 0) {
dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0);
spawner->speed.x = 6.0 * neg;
spawner->speed.y = -2.5;
@@ -447,16 +542,19 @@ void daMrSun_c::executeState_Spit() {
spawner->speed.x = 6.0 * neg;
spawner->speed.y = -2.5;
spawner->pos.z = 3350.0;
+ *((u32 *) (((char *) spawner) + 0x3DC)) = this->id;
spawner = CreateActor(118, 0, this->pos, 0, 0);
spawner->speed.x = 0.0 * neg;
spawner->speed.y = -6.0;
spawner->pos.z = 3350.0;
+ *((u32 *) (((char *) spawner) + 0x3DC)) = this->id;
spawner = CreateActor(118, 0, this->pos, 0, 0);
spawner->speed.x = 3.5 * neg;
spawner->speed.y = -6.0;
spawner->pos.z = 3350.0;
+ *((u32 *) (((char *) spawner) + 0x3DC)) = this->id;
} // It's a moon
}
@@ -557,7 +655,7 @@ void daMrSun_c::executeState_Spin() {
ylaunch = -5.0; }
- if (this->settings == 0) {
+ if ((this->settings & 0xF) == 0) {
dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0);
spawner->speed.x = xlaunch;
spawner->speed.y = ylaunch;
@@ -569,6 +667,8 @@ void daMrSun_c::executeState_Spin() {
spawner->speed.x = xlaunch;
spawner->speed.y = ylaunch;
spawner->pos.z = 3350.0;
+
+ *((u32 *) (((char *) spawner) + 0x3DC)) = this->id;
} // It's a moon
}
@@ -608,15 +708,14 @@ void daMrSun_c::executeState_Wait() {
int Choice;
int TimerMax;
- if (this->settings == 0) { TimerMax = 20; } // It's a sun
+ if ((this->settings & 0xF) == 0) { TimerMax = 20; } // It's a sun
else { TimerMax = 15; } // It's a moon
if (this->timer > TimerMax) {
-// doStateChange(&StateID_Spit);
- Choice = GenerateRandomNumber(7);
+ Choice = GenerateRandomNumber(9);
- OSReport("Choice: %d", Choice);
+// OSReport("Choice: %d", Choice);
if (Choice == 0) { doStateChange(&StateID_Spit); }
else if (Choice == 1) { doStateChange(&StateID_Spit); }