diff options
Diffstat (limited to 'src/thundercloud.cpp')
-rwxr-xr-x | src/thundercloud.cpp | 124 |
1 files changed, 86 insertions, 38 deletions
diff --git a/src/thundercloud.cpp b/src/thundercloud.cpp index 5ba1143..28778db 100755 --- a/src/thundercloud.cpp +++ b/src/thundercloud.cpp @@ -28,6 +28,8 @@ class dThunderCloud : public dEn_c { int dying; char killFlag; bool stationary; + float leader; + pointSensor_s below; u64 eventFlag; @@ -59,6 +61,8 @@ class dThunderCloud : public dEn_c { void _vf14C(); bool CreateIceActors(); + void lightningStrike(); + USING_STATES(dThunderCloud); DECLARE_STATE(Follow); DECLARE_STATE(Lightning); @@ -83,17 +87,20 @@ CREATE_STATE(dThunderCloud, Wait); extern "C" int CheckExistingPowerup(void * Player); void dThunderCloud::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { - if (apThis->info.category2 == 0x9) { - int p = CheckExistingPowerup(apOther->owner); - if (p != 0 && p != 3) { // Powerups - 0 = small; 1 = big; 2 = fire; 3 = mini; 4 = prop; 5 = peng; 6 = ice; 7 = hammer - dAcPy_c__ChangePowerupWithAnimation(apOther->owner, 3); + + if (this->counter_504[apOther->owner->which_player]) { + if (apThis->info.category2 == 0x9) { + int p = CheckExistingPowerup(apOther->owner); + if (p != 0 && p != 3) { // Powerups - 0 = small; 1 = big; 2 = fire; 3 = mini; 4 = prop; 5 = peng; 6 = ice; 7 = hammer + dAcPy_c__ChangePowerupWithAnimation(apOther->owner, 3); + } + else { dAcPy_vf3F4(apOther->owner, this, 9); } } + else { dAcPy_vf3F4(apOther->owner, this, 9); } } - else { dAcPy_vf3F4(apOther->owner, this, 9); } - - this->counter_504[apOther->owner->which_player] = 0x40; + this->counter_504[apOther->owner->which_player] = 0x20; } void dThunderCloud::yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther) { this->playerCollision(apThis, apOther); } @@ -194,7 +201,6 @@ void dThunderCloud::bindAnimChr_and_setUpdateRate(const char* name, int unk, flo this->anm.setUpdateRate(rate); } - int dThunderCloud::onCreate() { // Setup the model @@ -220,7 +226,7 @@ int dThunderCloud::onCreate() { Cloud.category2 = 0x0; Cloud.bitfield1 = 0x4F; - Cloud.bitfield2 = 0xffbafffe; + Cloud.bitfield2 = 0xffba7ffe; Cloud.xDistToEdge = 18.0; Cloud.yDistToEdge = 12.0; @@ -230,23 +236,9 @@ int dThunderCloud::onCreate() { this->aPhysics.initWithStruct(this, &Cloud); this->aPhysics.addToList(); - - ActivePhysics::Info Shock; - Shock.xDistToCenter = 0.0; - Shock.yDistToCenter = -104.0; - Shock.category1 = 0x3; - Shock.category2 = 0x9; - Shock.bitfield1 = 0x4F; - - Shock.bitfield2 = 0xffbafffe; - Shock.xDistToEdge = 12.0; - Shock.yDistToEdge = 90.0; - - Shock.unkShort1C = 0; - Shock.callback = &dEn_c::collisionCallback; - - this->Lightning.initWithStruct(this, &Shock); - + below.x = 0; + below.y = 0; + collMgr.init(this, &below, 0, 0); // Some Settings this->Baseline = this->pos.y; @@ -331,17 +323,17 @@ void dThunderCloud::executeState_Follow() { float speedDelta; speedDelta = 0.05; - if (this->direction == 0) { - this->speed.x = this->speed.x + speedDelta; + if (this->direction == 0) { // Going Left + this->speed.x = this->speed.x + speedDelta; // - if (this->speed.x < 0) { this->speed.x = this->speed.x + (speedDelta / 1.5); } - if (this->speed.x < 6.0) { this->speed.x = this->speed.x + (speedDelta); } + if (this->speed.x < 0) { this->speed.x += (speedDelta / 1.5); } + if (this->speed.x < -6.0) { this->speed.x += (speedDelta * 2.0); } } - else { + else { // Going Right this->speed.x = this->speed.x - speedDelta; - if (this->speed.x > 0) { this->speed.x = this->speed.x - (speedDelta / 1.5); } - if (this->speed.x > 6.0) { this->speed.x = this->speed.x - (speedDelta); } + if (this->speed.x > 0) { this->speed.x -= (speedDelta / 1.5); } + if (this->speed.x > 6.0) { this->speed.x -= (speedDelta * 2.0); } } this->HandleXSpeed(); @@ -394,9 +386,52 @@ void dThunderCloud::endState_Wait() { } // Lightning State +void dThunderCloud::lightningStrike() { + PlaySound(this, SE_OBJ_KAZAN_ERUPTION); + + float boltsize = (leader-14.0)/2; + float boltpos = -boltsize - 14.0; + + ActivePhysics::Info Shock; + Shock.xDistToCenter = 0.0; + Shock.yDistToCenter = boltpos; + Shock.category1 = 0x3; + Shock.category2 = 0x9; + Shock.bitfield1 = 0x4F; + + Shock.bitfield2 = 0xffba7ffe; + Shock.xDistToEdge = 12.0; + Shock.yDistToEdge = boltsize; + + Shock.unkShort1C = 0; + Shock.callback = &dEn_c::collisionCallback; + + this->Lightning.initWithStruct(this, &Shock); + this->Lightning.addToList(); +} + void dThunderCloud::beginState_Lightning() { this->timer = 0; this->speed.x = 0.0; + + float backupY = pos.y, backupYSpeed = speed.y; + + u32 result = 0; + while (result == 0) { + below.y -= 0x8000; + OSReport("Sending out leader to %d", below.y>>12); + + result = collMgr.calculateBelowCollisionWithSmokeEffect(); + OSReport("Result %d", result); + } + + OSReport("Lightning strikes at %d", below.y>>12); + + leader = -(below.y >> 12); + below.y = 0; + + pos.y = backupY; + speed.y = backupYSpeed; } void dThunderCloud::executeState_Lightning() { @@ -407,13 +442,14 @@ void dThunderCloud::executeState_Lightning() { case 1: charge.spawn("Wm_en_birikyu", 0, &(Vec){pos.x, pos.y, pos.z}, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}); break; - case 2: - this->Lightning.addToList(); + case 2: PlaySound(this, SE_BOSS_JR_ELEC_APP); PlaySound(this, SE_BOSS_JR_DAMAGE_ELEC); - PlaySound(this, SE_OBJ_KAZAN_ERUPTION); - bolt.spawn("Wm_jr_electricline", 0, &(Vec){pos.x, pos.y - 98.0, pos.z}, &(S16Vec){0,0,0}, &(Vec){1.0, 2.5, 1.0}); + float boltsize = (leader-14.0)/2; + float boltpos = -boltsize - 14.0; + + bolt.spawn("Wm_jr_electricline", 0, &(Vec){pos.x, pos.y + boltpos, pos.z}, &(S16Vec){0,0,0}, &(Vec){1.0, boltsize/36.0, 1.0}); break; case 3: this->Lightning.removeFromList(); @@ -433,7 +469,10 @@ void dThunderCloud::executeState_Lightning() { if(this->anm.isAnimationDone() && this->anm.getCurrentFrame() != 0.0) { this->timer += 1; - if (timer == 2) { this->bindAnimChr_and_setUpdateRate("thundershoot", 1, 0.0, 1.0); } + if (timer == 2) { + this->bindAnimChr_and_setUpdateRate("thundershoot", 1, 0.0, 1.0); + lightningStrike(); + } if (timer == 3) { this->bindAnimChr_and_setUpdateRate("cloud_wait", 1, 0.0, 1.0); } this->anm.setCurrentFrame(0.0); } @@ -443,3 +482,12 @@ void dThunderCloud::endState_Lightning() { } +// Thundercloud center = 0 +// Thundercloud bottom = -12 +// Thundercloud boltpos = -boltsize/2 - 14.0 +// Thundercloud boltsize = (leader-14.0)/2 +// Thundercloud effSize = 36.0 [*2] +// Thundercloud effScale = boltsize / effSize +// Thundercloud effPos = -boltsize/2 - 14.0 + + |