diff options
Diffstat (limited to '')
-rw-r--r-- | src/bossFuzzyBear.cpp | 259 | ||||
-rw-r--r-- | src/bossThwompaDomp.S | 40 | ||||
-rw-r--r-- | src/bossThwompaDomp.cpp | 45 | ||||
-rwxr-xr-x | src/firelaser.cpp | 27 | ||||
-rwxr-xr-x | src/mrsun.cpp | 64 | ||||
-rw-r--r-- | src/soundPlayer.S | 85 |
6 files changed, 408 insertions, 112 deletions
diff --git a/src/bossFuzzyBear.cpp b/src/bossFuzzyBear.cpp index 6b0fab0..65e6ab6 100644 --- a/src/bossFuzzyBear.cpp +++ b/src/bossFuzzyBear.cpp @@ -1,6 +1,7 @@ #include <common.h> #include <game.h> #include <g3dhax.h> +#include <sfx.h> class daFuzzyBear_c : public dEn_c { int onCreate(); @@ -25,7 +26,8 @@ class daFuzzyBear_c : public dEn_c { Vec RolyPos; char falldown; char damage; - char fireballs; + char roly; + char isInvulnerable; void dieBigFall_Execute(); static daFuzzyBear_c *build(); @@ -46,6 +48,7 @@ class daFuzzyBear_c : public dEn_c { DECLARE_STATE(Needles); DECLARE_STATE(Spray); DECLARE_STATE(RolyPoly); + DECLARE_STATE(Wait); }; daFuzzyBear_c *daFuzzyBear_c::build() { @@ -57,6 +60,9 @@ daFuzzyBear_c *daFuzzyBear_c::build() { extern "C" void *HandleXSpeed(daFuzzyBear_c *); extern "C" void *HandleYSpeed(daFuzzyBear_c *); extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daFuzzyBear_c *); +extern "C" void *doSpriteMovement(dEn_c *); +extern "C" void *PlaySound(daFuzzyBear_c *, int soundID); + 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); @@ -71,6 +77,7 @@ CREATE_STATE(daFuzzyBear_c, Bounce); CREATE_STATE(daFuzzyBear_c, Needles); CREATE_STATE(daFuzzyBear_c, Spray); CREATE_STATE(daFuzzyBear_c, RolyPoly); +CREATE_STATE(daFuzzyBear_c, Wait); #define ACTIVATE 1 @@ -78,27 +85,65 @@ CREATE_STATE(daFuzzyBear_c, RolyPoly); 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) { + + if (this->isInvulnerable == 1) { return; } + 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); } + PlaySound(this, SE_BOSS_KOOPA_FIRE_DISAPP); + this->damage++; + if (this->damage > 14) { 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"); + + if (this->isInvulnerable == 1) { return; } + + this->timer = 0; - this->damage = this->damage + 1; - if (this->damage > 2) { doStateChange(&StateID_DieBigFall); } } + this->damage = this->damage + 5; + + dActor_c *block = apOther->owner; + dEn_c *blah = (dEn_c*)block; + + this->pos.x += blah->speed.x; + + blah->speed.x = -blah->speed.x; + blah->pos.x += blah->speed.x; + + if (blah->direction == 0) { blah->direction = 1; this->roly = 0; } + else { blah->direction = 0; this->roly = 1; } + + if (blah->speed.y < 0) { + blah->speed.y = -blah->speed.y; } + + doSpriteMovement(blah); + doSpriteMovement(blah); + + PlaySound(this, SE_EMY_BLOW_PAKKUN_DOWN); + + + if (this->damage > 14) { doStateChange(&StateID_DieBigFall); } + else { doStateChange(&StateID_RolyPoly); } +} void daFuzzyBear_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) { + + if (this->isInvulnerable == 1) { return; } + + PlaySound(this, SE_EMY_BIG_PAKKUN_DAMAGE_1); OSReport("Hit Hammer"); this->timer = 0; - this->damage = this->damage + 1; - if (this->damage > 2) { doStateChange(&StateID_DieBigFall); } } + this->damage += 3; + + if (this->damage > 14) { doStateChange(&StateID_DieBigFall); } + else { doStateChange(&StateID_RolyPoly); } +} void daFuzzyBear_c::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Yoshi Fire"); } @@ -139,18 +184,16 @@ int daFuzzyBear_c::onCreate() { HitMeBaby.yDistToCenter = 0.0; if (BigBossFuzzyBear == 0) { + HitMeBaby.xDistToEdge = 32.0; + HitMeBaby.yDistToEdge = 32.0; } + else { HitMeBaby.xDistToEdge = 38.0; HitMeBaby.yDistToEdge = 38.0; } - else { - HitMeBaby.xDistToEdge = 50.0; - HitMeBaby.yDistToEdge = 50.0; } - HitMeBaby.category1 = 0x7; + HitMeBaby.category1 = 0x3; HitMeBaby.category2 = 0x0; - HitMeBaby.bitfield1 = 0x0; - HitMeBaby.bitfield2 = 0x0; -// HitMeBaby.bitfield1 = 0x4F; -// HitMeBaby.bitfield2 = 0x828E; + HitMeBaby.bitfield1 = 0x4F; + HitMeBaby.bitfield2 = 0x8828E; HitMeBaby.unkShort1C = 0; HitMeBaby.callback = &dEn_c::collisionCallback; @@ -177,8 +220,9 @@ int daFuzzyBear_c::onCreate() { this->initialPos = this->pos; this->storeSpeed = 0; this->falldown = 0; - this->fireballs = 0; + this->roly = 0; this->damage = 0; + this->isInvulnerable = 0; OSReport("Setting Fuzzy Bear's State"); doStateChange(&StateID_Grow); @@ -279,6 +323,7 @@ void daFuzzyBear_c::updateModelMatrices() { void daFuzzyBear_c::beginState_Grow() { OSReport("Growing when Kameck Tells me to."); this->timer = 0; +// PlaySound(this, SE_BOSS_ROY_MAGIC_MAKE_FAST); } void daFuzzyBear_c::executeState_Grow() { @@ -288,12 +333,12 @@ void daFuzzyBear_c::executeState_Grow() { float scaleSpeed, yPosScaling; if ((this->timer > 60) && (this->timer < 140)) { - if (BigBossFuzzyBear == 0) { + if (BigBossFuzzyBear == 1) { scaleSpeed = 0.025; yPosScaling = 25; } else { - scaleSpeed = 0.0375; - yPosScaling = 33; } + scaleSpeed = 0.01875; + yPosScaling = 18; } float modifier; @@ -301,6 +346,7 @@ void daFuzzyBear_c::executeState_Grow() { this->scale = (Vec){modifier, modifier, modifier}; this->pos.y = this->pos.y + (yPosScaling/80); + } if (this->timer > 170) { doStateChange(&StateID_Bounce); } @@ -320,8 +366,8 @@ 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; } + if (this->direction = 0) { this->speed.x = 1.5; } + else { this->speed.x = -1.5 ; } if (this->storeSpeed != 0) { this->speed.x = this->storeSpeed; } @@ -332,17 +378,17 @@ void daFuzzyBear_c::executeState_Bounce() { float wallDistance, scaleDown, scaleUp, scaleBase; if (BigBossFuzzyBear == 0) { + wallDistance = 32.0; + scaleDown = 12.0; + scaleUp = 10.0; + scaleBase = 2.5; + } + else { wallDistance = 38.0; - scaleDown = 3.0; + scaleDown = 16.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; } @@ -350,12 +396,12 @@ void daFuzzyBear_c::executeState_Bounce() { // Check for walls - if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + wallDistance)) { // Hit left wall, head right. + if (this->pos.x <= this->initialPos.x - ((15 * 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; } - if (this->pos.x >= this->initialPos.x + ((AreaWidthRight * 24.0) - wallDistance)) { // Hit right wall, head left. + if (this->pos.x >= this->initialPos.x + ((5 * 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; } @@ -389,29 +435,19 @@ void daFuzzyBear_c::executeState_Bounce() { this->scale.y = modifier; this->pos.y = this->pos.y + (scaleUp/10.0); if (this->pos.y > this->Baseline) { this->pos.y = this->Baseline - 1.0; } + PlaySound(this, SE_PLY_JUMPDAI); } 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; } - else { this->speed.y = LaunchSpeedShort; } + if (randChoice == 0) { doStateChange(&StateID_Wait); } + + randChoice = GenerateRandomNumber(4); + if (randChoice == 0) { this->speed.y = 8.0; } + else { this->speed.y = 6.0; } this->timer = 0; this->pos.y = this->Baseline + 1; @@ -452,49 +488,49 @@ void daFuzzyBear_c::executeState_Needles() { this->speed.x = 0; if (BigBossFuzzyBear == 0) { - origScale = 3.0; + origScale = 2.5; } else { - origScale = 4.0; + origScale = 3.0; } this->timer = this->timer + 1; OSReport("Needle Timer: %d", this->timer); - if (this->timer < 120) { + 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); + dStageActor_c *spawner = CreateActor(339, 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); + dStageActor_c *spawner = CreateActor(339, 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); + dStageActor_c *spawner = CreateActor(339, 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); + dStageActor_c *spawner = CreateActor(339, 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); + dStageActor_c *spawner = CreateActor(339, 0, this->pos, 0, 0); spawner->speed.x = -6.0; spawner->speed.y = 0.0; spawner->scale = (Vec){1.0, 1.0, 1.0}; @@ -532,18 +568,20 @@ void daFuzzyBear_c::executeState_Spray() { 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 + randChoice = GenerateRandomNumber(18); // 1.3 Fuzzies per second, 6 fuzzies overall if (randChoice == 0) { int randChoiceX, randChoiceY; - randChoiceX = GenerateRandomNumber(24); - randChoiceY = GenerateRandomNumber(16); + randChoiceX = GenerateRandomNumber(92); + randChoiceY = GenerateRandomNumber(48); + + float xa, ya; + xa = randChoiceX - 48.0; + ya = randChoiceY - 24.0; - 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}; - } } + CreateActor(144, 0, (Vec){this->pos.x + xa, this->pos.y + ya, this->pos.z}, 0, 0); + } + } else { doStateChange(&StateID_Bounce); } @@ -571,16 +609,39 @@ void daFuzzyBear_c::endState_Spray() { // 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->isInvulnerable = 1; + + if (this->roly == 0) { this->speed.x = 12.0; } + else { this->speed.x = -12.0; } + this->speed.y = 0; this->RolyBounces = 0; this->RolyPos = this->pos; OSReport("Fuzzy Roly State Begin"); + + if (BigBossFuzzyBear == 0) { + this->scale = (Vec){2.5, 2.5, 2.5}; + } + else { + this->scale = (Vec){3.0, 3.0, 3.0}; + } + } void daFuzzyBear_c::executeState_RolyPoly() { OSReport("Fuzzy Roly State Execute"); float wallDistance, scaleDown, scaleUp; + PlaySound(this, SE_OBJ_TEKKYU_G_ROLL); + + if (this->pos.y > this->Baseline) { this->pos.y -= 2.0; } + else { this->pos.y = this->Baseline - 1.0; } + + if (this->direction == 0) { // is even + this->pos.x = this->pos.x - 4.0; } + else { // is odd + this->pos.x = this->pos.x + 4.0; } + if (BigBossFuzzyBear == 0) { wallDistance = 38.0; } @@ -588,16 +649,16 @@ void daFuzzyBear_c::executeState_RolyPoly() { wallDistance = 50.0; } - this->speed.y = 0; + - if (this->pos.x <= this->initialPos.x - ((AreaWidthLeft * 24.0) + wallDistance)) { // Hit left wall, head right. + if (this->pos.x <= this->initialPos.x - ((15 * 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. + if (this->pos.x >= this->initialPos.x + ((5 * 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; @@ -605,24 +666,60 @@ void daFuzzyBear_c::executeState_RolyPoly() { } - if (this->direction == 1) { this->rot.z = this->rot.z + 0x1000; } - else { this->rot.z = this->rot.z - 0x1000; } + if (this->direction == 1) { this->rot.z = this->rot.z - 0x400; } + else { this->rot.z = this->rot.z + 0x400; } 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); } } } + if ((this->pos.x > this->RolyPos.x -20.0) && (this->pos.x < this->RolyPos.x + 20.0)) { + this->speed.x = 0; + if (this->rot.z == 0) { doStateChange(&StateID_Bounce); } } } - HandleXSpeed(this); - HandleYSpeed(this); - UpdateObjectPosBasedOnSpeedValues_real(this); + +// HandleXSpeed(this); +// HandleYSpeed(this); + +// doSpriteMovement(this); +// UpdateObjectPosBasedOnSpeedValues_real(this); } -void daFuzzyBear_c::endState_RolyPoly() { this->rot.z = 0; OSReport("Fuzzy Roly State End"); } +void daFuzzyBear_c::endState_RolyPoly() { + this->rot.z = 0; + OSReport("Fuzzy Roly State End"); + this->isInvulnerable = 0; +} + + + + + + + +void daFuzzyBear_c::beginState_Wait() { this->timer = 0;} +void daFuzzyBear_c::executeState_Wait() { + + this->timer = this->timer + 1; + + if (this->timer > 60) { + int randChoice; + + if (BigBossFuzzyBear == 1) { + + randChoice = GenerateRandomNumber(3); + + if (randChoice == 0) { doStateChange(&StateID_Spray); } +// else if (randChoice == 1) { doStateChange(&StateID_Needles); } + else { doStateChange(&StateID_RolyPoly); } + + } + else { + doStateChange(&StateID_Bounce); + } + } +} +void daFuzzyBear_c::endState_Wait() { } + + + + diff --git a/src/bossThwompaDomp.S b/src/bossThwompaDomp.S new file mode 100644 index 0000000..66aef2e --- /dev/null +++ b/src/bossThwompaDomp.S @@ -0,0 +1,40 @@ +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f1,1; .set f2,2 +.set f3,3; .set f4,4; .set f5,5; .set f6,6; .set f8,8 +.set f31,31; .set f30,30 +#endif + + +.text + +.extern OSReport +.extern ThwompaDompMoveC__FP5dEn_c + +.align 4 + + + +.global ThwompaDompMove +ThwompaDompMove: + + # Registers I can't clobber - r0, r3, r30, r31 + # r3 is self + + subi r0, r4, 1 + + + # Load settings and make sure it's thwompy + lwz r4, 4(r3) + slwi r4, r4, 28 + + cmpwi r4, 1 + b ThwompaDompMoveC__FP5dEn_c + + blr + diff --git a/src/bossThwompaDomp.cpp b/src/bossThwompaDomp.cpp new file mode 100644 index 0000000..70a3d17 --- /dev/null +++ b/src/bossThwompaDomp.cpp @@ -0,0 +1,45 @@ +#include <common.h> +#include <game.h> +#include <g3dhax.h> + + +extern "C" bool CollidedWithTile(u8 *); +extern "C" void *SomeStrangeModification(dEn_c *); + +void ThwompaDompMoveC(dEn_c *Sprite) { + + + + bool FirstCheck; + bool SecondCheck; + + // Check for collisions with walls? + FirstCheck = CollidedWithTile(Sprite->classAt1EC); + SomeStrangeModification(Sprite); + SecondCheck = CollidedWithTile(Sprite->classAt1EC); + + OSReport("XPos = %f, FirstCheck = %d, SecondCheck = %d", Sprite->pos.x, FirstCheck, SecondCheck); + + if ((FirstCheck != 0) && (SecondCheck != 0)) { + OSReport("Actually doing something, I swear"); + + Sprite->pos.y = Sprite->pos.y + 16.0; + Sprite->pos.x = Sprite->pos.x - 180.0; + + if (Sprite->direction == 0) { + Sprite->direction = 1; + Sprite->pos.x = Sprite->pos.x - 80.0; } + else { + Sprite->direction = 0; + Sprite->pos.x = Sprite->pos.x + 80.0; } + } + else { + if (Sprite->direction == 0) { + Sprite->pos.x = Sprite->pos.x + 1.0; } + else { + Sprite->pos.x = Sprite->pos.x - 1.0; } + } + + + return; +}
\ No newline at end of file diff --git a/src/firelaser.cpp b/src/firelaser.cpp index 244d659..db615ec 100755 --- a/src/firelaser.cpp +++ b/src/firelaser.cpp @@ -45,6 +45,7 @@ int daFireLaser_c::onCreate() { this->timer = 0; this->direction = this->settings & 0xF; + this->spitspeed = 8.0; char eventNum = (this->settings >> 16) & 0xFF; this->eventFlag = (u64)1 << (eventNum - 1); @@ -89,29 +90,29 @@ void daFireLaser_c::executeState_pewpewpew() { float ylaunch; if (this->direction == 0) { - xlaunch = spitspeed; + xlaunch = this->spitspeed; ylaunch = 0.0; } else if (this->direction == 1) { // SE - xlaunch = spitspeed; - ylaunch = spitspeed; } + xlaunch = this->spitspeed; + ylaunch = this->spitspeed; } else if (this->direction == 2) { // S xlaunch = 0.0; - ylaunch = spitspeed; } + ylaunch = this->spitspeed; } else if (this->direction == 3) { // SW - xlaunch = -spitspeed; - ylaunch = spitspeed; } + xlaunch = -this->spitspeed; + ylaunch = this->spitspeed; } else if (this->direction == 4) { // W - xlaunch = -spitspeed; + xlaunch = -this->spitspeed; ylaunch = 0.0; } else if (this->direction == 5) { // NW - xlaunch = -spitspeed; - ylaunch = -spitspeed; } + xlaunch = -this->spitspeed; + ylaunch = -this->spitspeed; } else if (this->direction == 6) { // N xlaunch = 0.0; - ylaunch = -spitspeed; } + ylaunch = -this->spitspeed; } else if (this->direction == 7) { // NE - xlaunch = spitspeed; - ylaunch = -spitspeed; } + xlaunch = this->spitspeed; + ylaunch = -this->spitspeed; } dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); @@ -125,6 +126,8 @@ void daFireLaser_c::executeState_pewpewpew() { } + else { this->timer = 0; } + } void daFireLaser_c::endState_pewpewpew() { diff --git a/src/mrsun.cpp b/src/mrsun.cpp index 3036a6b..df4d1ac 100755 --- a/src/mrsun.cpp +++ b/src/mrsun.cpp @@ -73,6 +73,7 @@ extern "C" u32 GenerateRandomNumber(int max); extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daMrSun_c *, Vec pos); extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); extern "C" dStageActor_c *GetSpecificPlayerActor(int number); +extern "C" void *PlaySound(daMrSun_c *, int soundID); int NearestPlayer(daMrSun_c *Sprite); @@ -135,6 +136,8 @@ void daMrSun_c::collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics * void daMrSun_c::dieFall_Execute() { + if (this->killFlag == 1) { return; } + this->timer = this->timer + 1; this->dying = this->dying + 0.15; @@ -143,26 +146,35 @@ void daMrSun_c::dieFall_Execute() { this->pos.y = this->pos.y - ((-0.2 * (this->dying*this->dying)) + 5); this->dEn_c::dieFall_Execute(); - - + if (this->timer > 450) { + + if ((this->settings >> 28) > 0) { + this->kill(); + this->pos.y = this->pos.y + 800.0; + this->killFlag = 1; + return; + } + dStageActor_c *Player = GetSpecificPlayerActor(0); if (Player == 0) { Player = GetSpecificPlayerActor(1); } if (Player == 0) { Player = GetSpecificPlayerActor(2); } if (Player == 0) { Player = GetSpecificPlayerActor(3); } - Player->pos; - this->pos.x = Player->pos.x - 300; - if (Player == 0) { this->pos.x = 0; doStateChange(&StateID_Follow); } + else { + Player->pos; + this->pos.x = Player->pos.x - 300; + } + this->pos.y = this->Baseline; this->aPhysics.addToList(); doStateChange(&StateID_Follow); - } + } } @@ -235,7 +247,7 @@ int daMrSun_c::onCreate() { this->sunDying = 0; this->killFlag = 0; - this->pos.z = 3300.00; + this->pos.z = 5500.00; char eventNum = (this->settings >> 16) & 0xFF; @@ -272,7 +284,9 @@ int daMrSun_c::onExecute() { if (this->killFlag == 0) { this->kill(); this->pos.y = this->pos.y + 800.0; - this->killFlag = 1; } + this->killFlag = 1; + doStateChange(&StateID_DieFall); + } } return true; @@ -453,6 +467,9 @@ void daMrSun_c::beginState_Swoop() { this->swoopSpeed = x3 * 2 / 75; + + PlaySound(this, 284); + } void daMrSun_c::executeState_Swoop() { @@ -480,6 +497,8 @@ void daMrSun_c::beginState_Spiral() { this->SpiralLoop = 0; this->xSpiralOffset = this->pos.x; this->ySpiralOffset = this->pos.y; + + PlaySound(this, 284); } void daMrSun_c::executeState_Spiral() { @@ -513,10 +532,14 @@ void daMrSun_c::beginState_Spit() { OSReport("Goodness Gracious Great Balls of Fire!"); this->timer = 0; this->spinStateOn = 1; + } void daMrSun_c::executeState_Spit() { if (this->timer == 10) { + + PlaySound(this, 431); + this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); float neg = -1.0; @@ -527,17 +550,17 @@ void daMrSun_c::executeState_Spit() { dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); spawner->speed.x = 6.0 * neg; spawner->speed.y = -2.5; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.0; spawner = CreateActor(106, 0, this->pos, 0, 0); spawner->speed.x = 0.0 * neg; spawner->speed.y = -6.0; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.0; spawner = CreateActor(106, 0, this->pos, 0, 0); spawner->speed.x = 3.5 * neg; spawner->speed.y = -6.0; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.0; } // It's a sun @@ -545,19 +568,19 @@ void daMrSun_c::executeState_Spit() { dStageActor_c *spawner = CreateActor(118, 0, this->pos, 0, 0); spawner->speed.x = 6.0 * neg; spawner->speed.y = -2.5; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.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; + spawner->pos.z = 5550.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; + spawner->pos.z = 5550.0; *((u32 *) (((char *) spawner) + 0x3DC)) = this->id; } // It's a moon @@ -584,6 +607,8 @@ void daMrSun_c::beginState_Spin() { } void daMrSun_c::executeState_Spin() { + PlaySound(this, 282); + this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); if (this->direction == 0) { @@ -626,10 +651,10 @@ void daMrSun_c::executeState_Spin() { float spitspeed; if ((this->settings & 0xF) == 0) { spitspeed = 3.0; } // It's a sun - else { spitspeed = 5.0; } // It's a moon + else { spitspeed = 4.0; } // It's a moon int randomBall; - randomBall = GenerateRandomNumber(6); + randomBall = GenerateRandomNumber(8); if (randomBall == 1) { int direction; direction = GenerateRandomNumber(8); @@ -662,19 +687,20 @@ void daMrSun_c::executeState_Spin() { xlaunch = spitspeed; ylaunch = -spitspeed; } - + PlaySound(this, 431); + if ((this->settings & 0xF) == 0) { dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); spawner->speed.x = xlaunch; spawner->speed.y = ylaunch; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.0; } // It's a sun else { dStageActor_c *spawner = CreateActor(118, 0, this->pos, 0, 0); spawner->speed.x = xlaunch; spawner->speed.y = ylaunch; - spawner->pos.z = 3350.0; + spawner->pos.z = 5550.0; *((u32 *) (((char *) spawner) + 0x3DC)) = this->id; } // It's a moon diff --git a/src/soundPlayer.S b/src/soundPlayer.S new file mode 100644 index 0000000..0fa028a --- /dev/null +++ b/src/soundPlayer.S @@ -0,0 +1,85 @@ +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f1,1; .set f2,2 +.set f3,3; .set f4,4; .set f5,5; .set f6,6; .set f8,8 +.set f31,31; .set f30,30 +#endif + + +.text + +.extern OSReport +.extern Actor_GetVec3WithValuesAdded +.extern ConvertStagePositionIntoScreenPosition__Maybe +.extern AnotherSoundRelatedFunction +.extern YetAnotherSoundPlayer +.extern CheckIfPlayingSound +.extern StopSound + +.align 4 + + + +# PlaySound(dActor_c *, int soundID) +# There's somehardcoding in here, might need to fix that for NTSC versions. + + +.global PlaySound +PlaySound: + stwu r1, -0x30(r1) + mflr r0 + mr r20, r4 + + # Gets Player Position + mr r4, r3 # object + stw r0, 0x34(r1) + addi r3, r1, 0x10 # dest + stw r31, 0x2C(r1) + bl Actor_GetVec3WithValuesAdded + + # Gives an accurate position for the sound + lwz r31, -0x5944(r13) + addi r3, r1, 8 + addi r4, r1, 0x10 + bl ConvertStagePositionIntoScreenPosition__Maybe + + # Checks if the passed sound is already playing + lis r4, 0x8043 + lwz r3, 0xA768(r4) + mr r4, r20 + bl CheckIfPlayingSound + + # Go away if it is + cmpwi r3, 0 + bne GoAwaySoundGuy + + # If we're good to go, play the sound! + mr r3, r31 + addi r5, r1, 8 + mr r4, r20 + li r6, 0 + bl YetAnotherSoundPlayer + + b GoAwaySoundGuy + + + +GoAwaySoundGuy: + lwz r0, 0x34(r1) + lwz r31, 0x2C(r1) + mtlr r0 + addi r1, r1, 0x30 + blr + + +.global StopSound +StopSound: + + lwz r3, 0xA768(r13) + b StopSound +
\ No newline at end of file |