From 49bd90a8c871994fb66c58aef841b4f8a0b8f732 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 15 Feb 2013 23:44:29 +0100 Subject: fixed various more samurshai bugs --- src/bossSamurshai.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/bossSamurshai.cpp b/src/bossSamurshai.cpp index 3a1ecc4..b608916 100644 --- a/src/bossSamurshai.cpp +++ b/src/bossSamurshai.cpp @@ -69,6 +69,8 @@ class daSamurshai : public daBoss { void addScoreWhenHit(void *other); int randomPlayer(); + bool isNearWall(); + USING_STATES(daSamurshai); DECLARE_STATE(Intro); @@ -420,7 +422,7 @@ void daSamurshai::updateModelMatrices() { WLClass::instance->_4 = 4; WLClass::instance->_8 = 0; - BossGoalForAllPlayers(); + MakeMarioEnterDemoMode(); // Make sure to use the correct position Vec KamekPos = (Vec){pos.x - 124.0, pos.y + 104.0, 3564.0}; @@ -535,8 +537,9 @@ void daSamurshai::updateModelMatrices() { amountCharged += abs(speed.x); // should we stop charging? - if (amountCharged > 480.0f) { - doStateChange(&StateID_ChargeSlash); + if (amountCharged > 480.0f && !isNearWall()) { + speed.x = (this->direction) ? -this->XSpeed : this->XSpeed; + doStateChange(&StateID_Uppercut); } } @@ -558,7 +561,8 @@ void daSamurshai::updateModelMatrices() { // if (xDistance < 32.0) { doStateChange(&StateID_SpinAttack); } // Condition for Uppercut - if ((xDistance > 48.0) && (xDistance < 64.0)) { doStateChange(&StateID_Uppercut); } + if ((xDistance > 48.0) && (xDistance < 64.0) && !isNearWall()) + doStateChange(&StateID_Uppercut); } bool ret = calculateTileCollisions(); @@ -918,6 +922,7 @@ void daSamurshai::updateModelMatrices() { } void daSamurshai::executeState_Outro() { + calculateTileCollisions(); if (this->dying == 1) { @@ -937,7 +942,7 @@ void daSamurshai::updateModelMatrices() { SpawnEffect("Wm_mr_wirehit_hit", 0, &(Vec){pos.x + 8.0, pos.y, pos.z + 500.0}, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}); MapSoundPlayer(SoundRelatedClass, STRM_BGM_SHIRO_BOSS_CLEAR, 1); - MakeMarioEnterDemoMode(); + BossGoalForAllPlayers(); this->dying = 1; this->timer = 0; @@ -947,3 +952,36 @@ void daSamurshai::updateModelMatrices() { } void daSamurshai::endState_Outro() { } +bool daSamurshai::isNearWall() { + // back up our current settings + VEC3 savePos = pos; + VEC3 saveSpeed = speed; + int saveDirection = direction; + + float checkLeft = (direction == 0) ? 8.0f : 104.0f; + float checkRight = (direction == 0) ? 104.0f : 8.0f; + + bool result = false; + + speed.x = -0.1f; + speed.y = 0.0f; + pos.x = savePos.x - checkLeft; + direction = 1; // left + if (collMgr.calculateAdjacentCollision()) + result = true; + + speed.x = 0.1f; + speed.y = 0.0f; + pos.x = savePos.x + checkRight; + direction = 0; // right + if (collMgr.calculateAdjacentCollision()) + result = true; + + // restore our settings + pos = savePos; + speed = saveSpeed; + direction = saveDirection; + + return result; +} + -- cgit v1.2.3