diff options
-rwxr-xr-x | src/mrsun.cpp | 257 |
1 files changed, 145 insertions, 112 deletions
diff --git a/src/mrsun.cpp b/src/mrsun.cpp index 32ab1c4..7e45902 100755 --- a/src/mrsun.cpp +++ b/src/mrsun.cpp @@ -19,6 +19,8 @@ class daMrSun_c : public dEn_c { Vec swoopTarget; float slope; u32 timer; + float xSpiralOffset; + float ySpiralOffset; static daMrSun_c *build(); @@ -54,6 +56,7 @@ CREATE_STATE(daMrSun_c, Swoop); CREATE_STATE(daMrSun_c, Spiral); CREATE_STATE(daMrSun_c, Spit); CREATE_STATE(daMrSun_c, Spin); +CREATE_STATE(daMrSun_c, Wait); #define ACTIVATE 1 #define DEACTIVATE 0 @@ -94,13 +97,15 @@ int daMrSun_c::onCreate() { this->Baseline = this->pos.y; this->SwoopSlope = 0.0; this->SpiralLoop = 0; - this->yThreshold = 10.0; + this->yThreshold = 100.0; this->yAccel = 0.2; this->timer = 0; - + this->xSpiralOffset = 0.0; + this->ySpiralOffset = 0.0; + OSReport("Setting Mr.Sun's State"); - doStateChange(&StateID_Swoop); + doStateChange(&StateID_Follow); OSReport("Going to Execute Mr.Sun"); this->onExecute(); @@ -140,47 +145,42 @@ void daMrSun_c::updateModelMatrix() { void daMrSun_c::beginState_Follow() { OSReport("Mr.Sun is following youuuuu."); this->timer = 0; + this->rot.x = 0; + this->rot.y = 0; } void daMrSun_c::executeState_Follow() { - if (this->timer > 1000) - this->doStateChange(&StateID_Wait); + if (this->timer > 200) { this->doStateChange(&StateID_Wait); } this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); if (this->direction == 0) { - if (this->speed.x > 10.0) - this->speed.x = this->speed.x + 0.1; + this->speed.x = this->speed.x + 0.1; } else { - if (this->speed.x < -10.0) - this->speed.x = this->speed.x - 0.1; + this->speed.x = this->speed.x - 0.1; } HandleXSpeed(this); - if (this->pos.y > this->Baseline) { - if (this->speed.y > -this->yThreshold) - this->speed.y = this->speed.y - this->yAccel; - } + float yDiff; + yDiff = (this->Baseline - this->pos.y) / 4; + this->speed.y = yDiff; - else if (this->pos.y < this->Baseline) { - if (this->speed.y > -this->yThreshold) - this->speed.y = this->speed.y + this->yAccel; - } - else { - this->pos.y = this->Baseline; - this->speed.y = 0; - } + OSReport("YSpeed = %f", this->speed.y); HandleYSpeed(this); UpdateObjectPosBasedOnSpeedValues_real(this); + this->timer = this->timer + 1; } -void daMrSun_c::endState_Follow() { OSReport("Mr.Sun is coming for you."); } +void daMrSun_c::endState_Follow() { + OSReport("Mr.Sun is coming for you."); + this->speed.y = 0; +} // Swoop State @@ -189,15 +189,10 @@ void daMrSun_c::beginState_Swoop() { OSReport("Swooping down from above, Mr.Sun falls down."); dStageActor_c *Player = GetSpecificPlayerActor(0); - if (Player == 0) - Player = GetSpecificPlayerActor(1); - if (Player == 0) - Player = GetSpecificPlayerActor(2); - if (Player == 0) - Player = GetSpecificPlayerActor(3); - if (Player == 0) - doStateChange(&StateID_Follow); - + if (Player == 0) { Player = GetSpecificPlayerActor(1); } + if (Player == 0) { Player = GetSpecificPlayerActor(2); } + if (Player == 0) { Player = GetSpecificPlayerActor(3); } + if (Player == 0) { doStateChange(&StateID_Follow); } this->swoopTarget = Player->pos; @@ -208,40 +203,54 @@ void daMrSun_c::beginState_Swoop() { } void daMrSun_c::executeState_Swoop() { - if (this->pos.y > this->swoopTarget.y) - doStateChange(&StateID_Follow); - - if (this->slope < 0.0) - this->speed.x = this->speed.x + 0.2; - - if (this->slope > 0.0) - this->speed.x = this->speed.x - 0.2; + if (this->slope < 0.0) { + this->speed.x = this->speed.x + 0.3; + this->speed.y = this->speed.y + (0.2 * -slope); + } + else if (this->slope > 0.0) { + this->speed.x = this->speed.x - 0.3; + this->speed.y = this->speed.y + (0.2 * slope); + } + HandleXSpeed(this); HandleYSpeed(this); UpdateObjectPosBasedOnSpeedValues_real(this); + + if (this->pos.y > this->swoopTarget.y) { doStateChange(&StateID_Follow); } } void daMrSun_c::endState_Swoop() { OSReport("Returning to the sky, Mr.Sun flies into the sunset."); - - this->swoopTarget = (Vec){0.0, 0.0, 0.0}; } // Spiral State -void daMrSun_c::beginState_Spiral() { OSReport("Super Spiral Sunspot!"); } +void daMrSun_c::beginState_Spiral() { + OSReport("Super Spiral Sunspot!"); + + this->xSpiralOffset = this->pos.x; + this->ySpiralOffset = this->pos.y; +} void daMrSun_c::executeState_Spiral() { - if (this->SpiralLoop > (6.28 * 5)) - doStateChange(&StateID_Follow); + float Loops; + float Period; + float Magnitude; + + Loops = 1.0; + Period = 0.1; + Magnitude = 1.0; + + this->pos.x = Magnitude*(this->xSpiralOffset + (this->SpiralLoop * cos(this->SpiralLoop))); + this->pos.y = Magnitude*(this->ySpiralOffset + (this->SpiralLoop * sin(this->SpiralLoop))); - this->pos.x = this->SpiralLoop * cos(this->SpiralLoop); - this->pos.y = this->SpiralLoop * sin(this->SpiralLoop); + this->SpiralLoop = this->SpiralLoop + Period; + + if (this->SpiralLoop > (3.14 * Loops)) { doStateChange(&StateID_Follow); } - this->SpiralLoop = this->SpiralLoop + 0.1; } void daMrSun_c::endState_Spiral() { OSReport("Nightmare Spiral Attack Ends!"); } @@ -249,26 +258,37 @@ void daMrSun_c::endState_Spiral() { OSReport("Nightmare Spiral Attack Ends!"); } // Spit State -void daMrSun_c::beginState_Spit() { OSReport("Goodness Gracious Great Balls of Fire!"); } -void daMrSun_c::executeState_Spit() { +void daMrSun_c::beginState_Spit() { + + OSReport("Goodness Gracious Great Balls of Fire!"); + this->timer = 0; - if (this->timer > 1000) - doStateChange(&StateID_Follow); +} +void daMrSun_c::executeState_Spit() { - dStageActor_c *spawner = CreateActor(107, 0, this->pos, 0, 0); - spawner->speed.x = 10.0; - spawner->speed.y = 10.0; + if (this->timer == 10) { + this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); + + float neg = -1.0; + if (this->direction == 0) { neg = 1.0; } + + dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); + spawner->speed.x = 6.0 * neg; + spawner->speed.y = -2.5; + + spawner = CreateActor(106, 0, this->pos, 0, 0); + spawner->speed.x = 0.0 * neg; + spawner->speed.y = -6.0; - spawner = CreateActor(107, 0, this->pos, 0, 0); - spawner->speed.x = 8.0; - spawner->speed.y = 5.0; - - spawner = CreateActor(107, 0, this->pos, 0, 0); - spawner->speed.x = 4.0; - spawner->speed.y = 0.0; + spawner = CreateActor(106, 0, this->pos, 0, 0); + spawner->speed.x = 3.5 * neg; + spawner->speed.y = -6.0; + } this->timer = this->timer + 1; + if (this->timer > 30) { doStateChange(&StateID_Follow); } + } void daMrSun_c::endState_Spit() { OSReport("Armageddon complete."); } @@ -279,67 +299,80 @@ void daMrSun_c::endState_Spit() { OSReport("Armageddon complete."); } void daMrSun_c::beginState_Spin() { OSReport("Hoola hoola hoola hoop."); } void daMrSun_c::executeState_Spin() { - if (this->timer > 1000) - this->doStateChange(&StateID_Follow); - this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); if (this->direction == 0) { - if (this->speed.x > 10.0) - this->speed.x = this->speed.x + 0.1; + this->speed.x = this->speed.x + 0.2; } else { - if (this->speed.x < -10.0) - this->speed.x = this->speed.x - 0.1; + this->speed.x = this->speed.x - 0.2; } HandleXSpeed(this); UpdateObjectPosBasedOnSpeedValues_real(this); this->timer = this->timer + 1; + + int rotBonus; + if (this->timer < 60) { rotBonus = this->timer; } + else { rotBonus = 120 - this->timer; } - int direction; - direction = GenerateRandomNumber(8); - - float xlaunch; - float ylaunch; - - switch (direction) { - case 1: // E + this->rot.x = this->rot.x + (50 * rotBonus); + this->rot.y = this->rot.y + (50 * rotBonus); + + int randomBall; + randomBall = GenerateRandomNumber(5); + if (randomBall == 1) { + int direction; + direction = GenerateRandomNumber(8); + + float xlaunch; + float ylaunch; + + if (direction == 0) { xlaunch = 10.0; - ylaunch = 0.0; - case 2: // SE + ylaunch = 0.0; } + else if (direction == 1) { // SE xlaunch = 10.0; - ylaunch = 10.0; - case 3: // S + ylaunch = 10.0; } + else if (direction == 2) { // S xlaunch = 0.0; - ylaunch = 10.0; - case 4: // SW + ylaunch = 10.0; } + else if (direction == 3) { // SW xlaunch = -10.0; - ylaunch = 10.0; - case 5: // W + ylaunch = 10.0; } + else if (direction == 4) { // W xlaunch = -10.0; - ylaunch = 0.0; - case 6: // NW + ylaunch = 0.0; } + else if (direction == 5) { // NW xlaunch = -10.0; - ylaunch = -10.0; - case 7: // N + ylaunch = -10.0; } + else if (direction == 6) { // N xlaunch = 0.0; - ylaunch = -10.0; - case 8: // NE - xlaunch = 10.0; - ylaunch = -10.0; - default: + ylaunch = -10.0; } + else if (direction == 7) { // NE xlaunch = 10.0; - ylaunch = -10.0; + ylaunch = -10.0; } + + + dStageActor_c *spawner = CreateActor(106, 0, this->pos, 0, 0); + spawner->speed.x = xlaunch; + spawner->speed.y = ylaunch; } + + if (this->timer > 120) { + this->rot.x = this->rot.x / 2; + this->rot.y = this->rot.y / 2; + this->doStateChange(&StateID_Follow); } - dStageActor_c *spawner = CreateActor(107, 0, this->pos, 0, 0); - spawner->speed.x = xlaunch; - spawner->speed.y = ylaunch; +} +void daMrSun_c::endState_Spin() { + + OSReport("K, I is dizzy now."); + this->rot.x = 0; + this->rot.y = 0; } -void daMrSun_c::endState_Spin() { OSReport("K, I is dizzy now."); } @@ -351,26 +384,24 @@ void daMrSun_c::beginState_Wait() { this->timer = 0; this->speed.x = 0.0; + this->rot.x = 0; + this->rot.y = 0; } void daMrSun_c::executeState_Wait() { int Choice; - if (this->timer > 1000) { + if (this->timer > 20) { + +// doStateChange(&StateID_Spit); + Choice = GenerateRandomNumber(1); + + OSReport("Choice: %d", Choice); - Choice = GenerateRandomNumber(4); + if (Choice == 0) { doStateChange(&StateID_Spin); } +// else if (Choice == 1) { doStateChange(&StateID_Spin); } +// else if (Choice == 2) { doStateChange(&StateID_Swoop); } +// else if (Choice == 3) { doStateChange(&StateID_Spiral); } - switch (Choice) { - case 1: - doStateChange(&StateID_Swoop); - case 2: - doStateChange(&StateID_Spiral); - case 3: - doStateChange(&StateID_Spit); - case 4: - doStateChange(&StateID_Follow); - default: - doStateChange(&StateID_Follow); - } } this->timer = this->timer + 1; @@ -378,6 +409,8 @@ void daMrSun_c::executeState_Wait() { void daMrSun_c::endState_Wait() { OSReport("Mr.Sun Cometh!"); this->timer = 0; + this->rot.x = 0; + this->rot.y = 0; } |