diff options
Diffstat (limited to 'src/bossWrenchThrow.cpp')
-rw-r--r-- | src/bossWrenchThrow.cpp | 290 |
1 files changed, 138 insertions, 152 deletions
diff --git a/src/bossWrenchThrow.cpp b/src/bossWrenchThrow.cpp index 6ce36f6..1abc226 100644 --- a/src/bossWrenchThrow.cpp +++ b/src/bossWrenchThrow.cpp @@ -16,11 +16,12 @@ class daWrench : public dEn_c { m3d::mdl_c bodyModel; int timer; - char homing; + char Kaboom; char direction; char front; float ymod; int lifespan; + u32 cmgr_returnValue; static daWrench *build(); @@ -32,34 +33,34 @@ class daWrench : public dEn_c { void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther); void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther); void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther); + void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther); USING_STATES(daWrench); - DECLARE_STATE(HandThrow); - DECLARE_STATE(Homing); DECLARE_STATE(Straight); + DECLARE_STATE(Kaboom); }; -CREATE_STATE(daWrench, HandThrow); -CREATE_STATE(daWrench, Homing); CREATE_STATE(daWrench, Straight); - +CREATE_STATE(daWrench, Kaboom); extern "C" void *PlaySound(dEn_c *, int soundID); +extern "C" void *PlaySoundAsync(dEn_c *, int soundID); +extern "C" void *PlayWrenchSound(dEn_c *); extern "C" dStageActor_c *GetSpecificPlayerActor(int number); +extern "C" u32 GenerateRandomNumber(int max); void daWrench::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { + this->dEn_c::playerCollision(apThis, apOther); this->_vf220(apOther->owner); - + this->isDead = 0; this->flags_4FC |= (1<<(31-7)); - if(apOther->owner->which_player > 3) { - OSReport("!!!ATTENTION!!!\napOther->owner->which_player > 3\n"); - }else{ + if(apOther->owner->which_player < 4) { this->counter_504[apOther->owner->which_player] = 0; } } @@ -72,13 +73,18 @@ void daWrench::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics void daWrench::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) { CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.5, 0.5, 0.5}, 48); - PlaySound(this, SE_BOSS_JR_FLOOR_BREAK); - - //FIXME changed to dStageActor_c::Delete(u8) from fBase_c(void) - this->Delete(this->_390); + PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); + this->Delete(1); } void daWrench::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) {} +void daWrench::collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther) { + this->_vf220(apOther->owner); + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.5, 0.5, 0.5}, 48); + + PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); + this->Delete(1); +} @@ -100,32 +106,31 @@ int daWrench::onCreate() { this->direction = this->settings & 0xF; - this->homing = (this->settings >> 4) & 0xF; + this->Kaboom = (this->settings >> 4) & 0xF; this->front = (this->settings >> 8) & 0xF; - ActivePhysics::Info HitMeBaby; - if (this->homing == 0) { + if (this->Kaboom == 0) { HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 0.0; - HitMeBaby.xDistToEdge = 6.0; - HitMeBaby.yDistToEdge = 6.0; + HitMeBaby.xDistToEdge = 5.0; + HitMeBaby.yDistToEdge = 5.0; - this->scale.x = 1.5; - this->scale.y = 1.5; - this->scale.z = 1.5; + this->scale.x = 1.25; + this->scale.y = 1.25; + this->scale.z = 1.25; } else { HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 0.0; - HitMeBaby.xDistToEdge = 12.0; - HitMeBaby.yDistToEdge = 12.0; + HitMeBaby.xDistToEdge = 8.0; + HitMeBaby.yDistToEdge = 8.0; - this->scale.x = 3.0; - this->scale.y = 3.0; - this->scale.z = 3.0; + this->scale.x = 2.0; + this->scale.y = 2.0; + this->scale.z = 2.0; } HitMeBaby.category1 = 0x3; @@ -139,9 +144,40 @@ int daWrench::onCreate() { this->aPhysics.addToList(); - this->pos.z = 3300.0; + spriteSomeRectX = 5.0f; + spriteSomeRectY = 5.0f; + _320 = 0.0f; + _324 = 5.0f; + + // These structs tell stupid collider what to collide with - these are from koopa troopa + static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; + static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; + static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + + collMgr.Init(this, one, two, three); + collMgr.execute(); + + cmgr_returnValue = collMgr.CollidedWithTile(); + + + if (this->direction == 0) { // Ground Facing Left + this->pos.x -= 0.0; // -32 to +32 + this->pos.y += 36.0; + this->rot.z = 0x2000; + } + else if (this->direction == 1) { // Ground Facing Right + this->pos.x += 0.0; // +32 to -32 + this->pos.y += 36.0; + this->rot.z = 0xE000; + } + if (this->front == 1) { this->pos.z = -1804.0; } + else { this->pos.z = 3300.0; } + - doStateChange(&StateID_HandThrow); + if (this->Kaboom) { + doStateChange(&StateID_Kaboom); } + else { + doStateChange(&StateID_Straight); } this->onExecute(); return true; @@ -176,160 +212,110 @@ int daWrench::onExecute() { } +void daWrench::beginState_Kaboom() { + float rand = (float)GenerateRandomNumber(10) * 0.4; -void daWrench::beginState_HandThrow() { - - if (this->direction == 0) { // Ground Facing Left - this->pos.x += 32.0; - this->pos.y += 48.0; - this->rot.z = 0x4000; + if (this->direction == 0) { // directions 1 spins clockwise, fly rightwards + speed.x = 1.0 + rand; } - else if (this->direction == 1) { // Ground Facing Right - this->pos.x -= 32.0; - this->pos.y += 48.0; - this->rot.z = 0xC000; + else { // directions 0 spins anti-clockwise, fly leftwards + speed.x = -1.0 - rand; } - else if (this->direction == 2) { // Upside Down Facing Left - this->pos.x += 32.0; - this->pos.y -= 48.0; - this->rot.z = 0x4000; - } - else if (this->direction == 3) { // Upside Down Facing Right - this->pos.x -= 32.0; - this->pos.y -= 48.0; - this->rot.z = 0xC000; - } - - if (this->front == 1) { this->pos.z = -1804.0; } - - this->lifespan = 0; -} -void daWrench::executeState_HandThrow() { - - if (this->lifespan > 30) { - - if (this->homing == 0) { - doStateChange(&StateID_Straight); } - else { - doStateChange(&StateID_Homing); } - } - - this->lifespan += 1; - + speed.y = 6.0; } -void daWrench::endState_HandThrow() { } - - - -void daWrench::beginState_Homing() { - this->lifespan = 360; +void daWrench::executeState_Kaboom() { - Vec tempPos = this->pos; + speed.y = speed.y - 0.01875; - char PlayerID = NearestPlayer(this); - dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); + HandleXSpeed(); + HandleYSpeed(); + doSpriteMovement(); - if ((Player->pos.y >= tempPos.y - 16.0) && (Player->pos.y <= tempPos.y + 16.0)) { - this->ymod = 0.0; } + cmgr_returnValue = collMgr.CollidedWithTile(); + collMgr.execute(); - else if ((Player->pos.y >= tempPos.y - 106.0) && (Player->pos.y < tempPos.y - 16.0)) { - this->ymod = -0.6; } + if (collMgr.CollidedWithTile()) { + // hit the ground + PlaySoundAsync(this, SE_BOSS_JR_BOMB_BURST); - else if ((Player->pos.y <= tempPos.y + 106.0) && (Player->pos.y > tempPos.y + 16.0)) { - this->ymod = 0.6; } - - else if (Player->pos.y < tempPos.y - 106.0) { - this->ymod = -1.2; } - - else if (Player->pos.y > tempPos.y + 106.0) { - this->ymod = 1.2; } - - else { - this->ymod = 0.0; } - - if (this->direction & 1) { this->speed.x = -1.5; } - else { this->speed.x = 1.5; } - - this->speed.y = 0; - -} -void daWrench::executeState_Homing() { - - if (this->direction && 1) { // directions 1 and 3 spin clockwise, fly rightwards - this->rot.z -= 0x1000; } - else { // directions 0 and 2 spin anti-clockwise, fly leftwards - this->rot.z += 0x1000; } - - this->pos.y += this->ymod * this->lifespan / 360; - - this->UpdateObjectPosBasedOnSpeedValuesReal(); - - if (this->lifespan < 1) { - - PlaySound(this, SE_OBJ_HAMMER_HIT_BOTH); + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}, 9); + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){1.25, 1.25, 1.25}, 167); + this->Delete(1); + } + if (collMgr.bitfield_for_checks & (0x15 << direction)) { + // hit the wall + PlaySoundAsync(this, SE_BOSS_JR_BOMB_BURST); + + if (this->direction == 0) { // directions 1 spins clockwise, fly rightwards + CreateEffect(&this->pos, &(S16Vec){0,0x4000,0}, &(Vec){0.75, 0.75, 0.75}, 9); + CreateEffect(&this->pos, &(S16Vec){0,0x4000,0}, &(Vec){1.25, 1.25, 1.25}, 167); + } + else { // directions 0 spins anti-clockwise, fly leftwards + CreateEffect(&this->pos, &(S16Vec){0,0xE000,0}, &(Vec){0.75, 0.75, 0.75}, 9); + CreateEffect(&this->pos, &(S16Vec){0,0xE000,0}, &(Vec){1.25, 1.25, 1.25}, 167); + } - CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}, 242); - //FIXME changed to dStageActor_c::Delete(u8) from fBase_c(void) - this->Delete(this->_390); + this->Delete(1); } - PlaySound(this, SE_EMY_CHOROPU_M_SPANNER); + if (this->direction == 1) { // directions 1 spins clockwise, fly rightwards + this->rot.z -= 0x1000; } + else { // directions 0 spins anti-clockwise, fly leftwards + this->rot.z += 0x1000; } - this->lifespan -= 1; + PlayWrenchSound(this); } -void daWrench::endState_Homing() { } +void daWrench::endState_Kaboom() { } void daWrench::beginState_Straight() { - - char PlayerID = NearestPlayer(this); - dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); - - - float slope = ( (this->pos.y - Player->pos.y) / (this->pos.x - Player->pos.x) ); + float rand = (float)GenerateRandomNumber(10) * 0.4; + if (this->direction == 0) { // directions 1 spins clockwise, fly rightwards + speed.x = 1.0 + rand; + } + else { // directions 0 spins anti-clockwise, fly leftwards + speed.x = -1.0 - rand; + } - Vec tempPos = this->pos; - if (this->direction & 1) { - this->speed.x = -2.0; - this->speed.y = 2.0 * slope; - } - - else { - this->speed.x = 2.0; - this->speed.y = 2.0 * slope; - } + speed.y = 6.0; } - void daWrench::executeState_Straight() { - this->lifespan = 360; - - if (this->direction && 1) { // directions 1 and 3 spin clockwise, fly rightwards - this->rot.z -= 0x1000; } - else { // directions 0 and 2 spin anti-clockwise, fly leftwards - this->rot.z += 0x1000; } - + speed.y = speed.y - 0.01875; - this->UpdateObjectPosBasedOnSpeedValuesReal(); - - PlaySound(this, SE_EMY_CHOROPU_M_SPANNER); + HandleXSpeed(); + HandleYSpeed(); + doSpriteMovement(); - if (this->lifespan == (360-45)) { this->pos.z = 3300.0; } + cmgr_returnValue = collMgr.CollidedWithTile(); + collMgr.execute(); - if (this->lifespan < 1) { - - PlaySound(this, SE_OBJ_HAMMER_HIT_BOTH); + if (collMgr.CollidedWithTile()) { + // hit the ground + PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); + + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}, 9); + this->Delete(1); + } + if (collMgr.bitfield_for_checks & (0x15 << direction)) { + // hit the wall + PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); - CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}, 242); - //FIXME changed to dStageActor_c::Delete(u8) from fBase_c(void) - this->Delete(this->_390); + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}, 9); + this->Delete(1); } - this->lifespan -= 1; + if (this->direction == 1) { // directions 1 spins clockwise, fly rightwards + this->rot.z -= 0x1000; } + else { // directions 0 spins anti-clockwise, fly leftwards + this->rot.z += 0x1000; } + + PlayWrenchSound(this); + } void daWrench::endState_Straight() { } |