From 88298047d04aaea0c0201aaa30a8a6e5691b5ef3 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 24 Jun 2024 19:23:23 -0500 Subject: [PATCH] Yussy --- include/object/jizo_stone.hxx | 24 +++++++ include/object/key_chest.hxx | 4 +- include/object/pearl.hxx | 38 +++++++++++ include/settings.hxx | 73 -------------------- src/fludd/goop.cpp | 44 ------------ src/main.cpp | 4 ++ src/object/jizo_stone.cpp | 62 +++++++++++++++++ src/object/key_chest.cpp | 35 +++++----- src/object/pearl.cpp | 124 ++++++++++++++++++++++++++++++++++ src/p_settings.hxx | 1 - src/player/character.cpp | 25 +------ src/player/water_balloon.cpp | 1 - src/settings.cpp | 5 +- src/stage/behavior.cpp | 38 ++++++++++- src/stage/settings.cpp | 14 ++-- src/ui/e3_health.cpp | 23 ------- 16 files changed, 318 insertions(+), 197 deletions(-) create mode 100644 include/object/jizo_stone.hxx create mode 100644 include/object/pearl.hxx delete mode 100644 src/fludd/goop.cpp create mode 100644 src/object/jizo_stone.cpp create mode 100644 src/object/pearl.cpp delete mode 100644 src/ui/e3_health.cpp diff --git a/include/object/jizo_stone.hxx b/include/object/jizo_stone.hxx new file mode 100644 index 0000000..e37e15c --- /dev/null +++ b/include/object/jizo_stone.hxx @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +class TJizoStone : public TMapObjGeneral { +public: + BETTER_SMS_FOR_CALLBACK static JDrama::TNameRef *instantiate() { + return new TJizoStone("TJizoStone"); + } + + TJizoStone(const char *name); + ~TJizoStone() override = default; + + void touchWater(THitActor *actor) override; + void initMapCollisionData() override; + void initMapObj() override; + void setGroundCollision() override; + +protected: + void playBoingAnim(); +}; + +extern ObjData jizoStoneData; \ No newline at end of file diff --git a/include/object/key_chest.hxx b/include/object/key_chest.hxx index 9291fe4..73ee098 100644 --- a/include/object/key_chest.hxx +++ b/include/object/key_chest.hxx @@ -23,9 +23,9 @@ public: void playOpenAnim(); void spawnShine(); - private: +private: bool mOpening; - bool mHasFinishedSounds; + bool mHasFinishedSounds; }; extern ObjData keyChestData; diff --git a/include/object/pearl.hxx b/include/object/pearl.hxx new file mode 100644 index 0000000..ac0e51e --- /dev/null +++ b/include/object/pearl.hxx @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +class TPearlCracked : public TMapObjGeneral { +protected: + enum class State : u8 { + STATE_NORMAL, + STATE_BROKEN, + STATE_RESTING, + }; + +public: + BETTER_SMS_FOR_CALLBACK static JDrama::TNameRef *instantiate() { + return new TPearlCracked("TPearlCracked"); + } + + TPearlCracked(const char *name); + ~TPearlCracked() override = default; + + void control() override; + void initMapCollisionData() override; + void initMapObj() override; + void setGroundCollision() override; + +protected: + bool checkMarioRiding(TMario *player); + bool checkMarioPounding(TMario *player); + void swapToCracked(); + void playFractureAnim(); + void spawnShine(); + +private: + State mState; +}; + +extern ObjData pearlData; \ No newline at end of file diff --git a/include/settings.hxx b/include/settings.hxx index d206f31..1090f1a 100644 --- a/include/settings.hxx +++ b/include/settings.hxx @@ -14,77 +14,6 @@ using namespace BetterSMS; extern const u8 gSaveBnr[]; extern const u8 gSaveIcon[]; -class HUDSetting final : public Settings::IntSetting { -public: - enum HUD { SMS, E3, SPACEWORLD }; - - HUDSetting() : IntSetting("HUD Style", &mHUDValue) { - mValueRange = {0, 2, 1}; - mValueChangedCB = valueChanged; - } - ~HUDSetting() override {} - - void getValueName(char *dst) const override { - switch (mHUDValue) { - case SMS: - strncpy(dst, "DEFAULT", 8); - break; - case E3: - strncpy(dst, "E3 DEMO", 8); - break; - case SPACEWORLD: - strncpy(dst, "SPACEWORLD", 11); - break; - } - } - - void load(JSUMemoryInputStream &in) override { - IntSetting::load(in); - mValueChangedCB(&mHUDValue, &mHUDValue, - getKind()); // We manually update here to set instructions on load - } - - // clang-format off - static void valueChanged(void* old, void* cur, ValueKind kind) { - //if (*reinterpret_cast(cur) == LongJumpMappingSetting::BUTTON_Z) { - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249670, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249730, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249C34, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024BF30, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024C248, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024C36C, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80252124, 0, 0, 0)), 0x540004A5); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8834, 0, 0, 0)), 0x540006F7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8840, 0, 0, 0)), 0x540006F7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A884C, 0, 0, 0)), 0x41820010); // Allow L button meaning updates - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8860, 0, 0, 0)), 0x54000673); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A886C, 0, 0, 0)), 0x54000673); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A88C8, 0, 0, 0)), 0x54000673); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A88D4, 0, 0, 0)), 0x54000673); - //} - //else { - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249670, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249730, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80249C34, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024BF30, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024C248, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x8024C36C, 0, 0, 0)), 0x54000427); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x80252124, 0, 0, 0)), 0x540004E7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8834, 0, 0, 0)), 0x54000673); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8840, 0, 0, 0)), 0x54000673); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A884C, 0, 0, 0)), 0x60000000); // Allow L button meaning updates - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A8860, 0, 0, 0)), 0x540006F7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A886C, 0, 0, 0)), 0x540006F7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A88C8, 0, 0, 0)), 0x540006F7); - // PowerPC::writeU32(reinterpret_cast(SMS_PORT_REGION(0x802A88D4, 0, 0, 0)), 0x540006F7); - //} - } - // clang-format on - -private: - int mHUDValue; -}; - class BugsExploitsSetting final : public Settings::SwitchSetting { public: BugsExploitsSetting() : SwitchSetting("Bugs/Exploits", &mBugsExploitsValue) { @@ -187,5 +116,3 @@ public: private: bool mTutorialValue; }; - -HUDSetting::HUD getHUDKind(); \ No newline at end of file diff --git a/src/fludd/goop.cpp b/src/fludd/goop.cpp deleted file mode 100644 index c9ee2cb..0000000 --- a/src/fludd/goop.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include - -// static void sprayGoopMap(TPollutionManager *gpPollutionManager, f32 x, f32 y, -// f32 z, f32 r) { -// auto *playerData = -// Player::getData(gpMarioAddress); -// auto *prm = playerData->getParams(); -// -// if (!playerData->isMario()) -// clean__17TPollutionManagerFffff(gpPollutionManager, x, y, z, r); -// -// if (prm->mCleaningType.get() != -// Player::TPlayerParams::FluddCleanType::NONE) { -// if (prm->mCleaningType.get() == -// Player::TPlayerParams::FluddCleanType::CLEAN) -// clean__17TPollutionManagerFffff(gpPollutionManager, x, y, z, r); -// else if (prm->mCleaningType.get() == -// Player::TPlayerParams::FluddCleanType::GOOP) -// stamp__17TPollutionManagerFUsffff(gpPollutionManager, 1, x, y, z, r); -// } -// } -// SMS_PATCH_BL(SMS_PORT_REGION(0x800678C4, 0x80060F64, 0, 0), sprayGoopMap); -// SMS_PATCH_BL(SMS_PORT_REGION(0x801A3ED0, 0x8019C758, 0, 0), sprayGoopMap); -// SMS_PATCH_BL(SMS_PORT_REGION(0x801B42D8, 0x801AC190, 0, 0), sprayGoopMap); -// SMS_PATCH_BL(SMS_PORT_REGION(0x8024E710, 0x8024649C, 0, 0), sprayGoopMap); -// SMS_PATCH_BL(SMS_PORT_REGION(0x8027F7DC, 0x80277568, 0, 0), sprayGoopMap); -// SMS_PATCH_BL(SMS_PORT_REGION(0x8027F94C, 0x802776D8, 0, 0), sprayGoopMap); -// -// static bool canCleanSeals(TModelWaterManager *gpWaterManager) { -// return gpWaterManager->mWaterCardType != 0 || -// Player::getData(gpMarioAddress) -// ->getParams() -// ->mCanCleanSeals.get(); -// } -// SMS_PATCH_BL(SMS_PORT_REGION(0x800FED3C, 0x800F83DC, 0, 0), canCleanSeals); -// SMS_WRITE_32(SMS_PORT_REGION(0x800FED40, 0x800F83E0, 0, 0), 0x2C030000); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0692077..9c30fc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,8 +15,10 @@ #include "enemy/firey_petey.hxx" #include "object/darkness_effect.hxx" #include "object/follow_key.hxx" +#include "object/jizo_stone.hxx" #include "object/key_chest.hxx" #include "object/launch_star.hxx" +#include "object/pearl.hxx" #include "object/tornado_obj.hxx" #include "object/water_balloon.hxx" #include "p_settings.hxx" @@ -140,6 +142,8 @@ static void initModule() { Objects::registerObjectAsMapObj("LaunchStar", &launchStarData, TLaunchStarObj::instantiate); Objects::registerObjectAsMapObj("KeyFollow", &followKeyData, TFollowKey::instantiate); Objects::registerObjectAsMapObj("KeyChest", &keyChestData, TKeyChest::instantiate); + Objects::registerObjectAsMapObj("JizoStone", &jizoStoneData, TJizoStone::instantiate); + Objects::registerObjectAsMapObj("Pearl", &pearlData, TPearlCracked::instantiate); Objects::registerObjectAsMisc("FireyPetey", TFireyPetey::instantiate); Objects::registerObjectAsMisc("FireyPeteyManager", TFireyPeteyManager::instantiate); } diff --git a/src/object/jizo_stone.cpp b/src/object/jizo_stone.cpp new file mode 100644 index 0000000..b212350 --- /dev/null +++ b/src/object/jizo_stone.cpp @@ -0,0 +1,62 @@ +#include "object/jizo_stone.hxx" + +#include + +TJizoStone::TJizoStone(const char *name) : TMapObjGeneral(name) {} + +void TJizoStone::touchWater(THitActor *actor) { playBoingAnim(); } + +void TJizoStone::initMapCollisionData() { + mCollisionManager = new TMapCollisionManager(1, "mapObj", this); + mCollisionManager->init("jizo_stone", 1, nullptr); +} + +void TJizoStone::initMapObj() { + TMapObjGeneral::initMapObj(); + + if (mCollisionManager) { + mCollisionManager->changeCollision(0); + mCollisionManager->mCurrentMapCollision->setAllActor(this); + } +} + +void TJizoStone::setGroundCollision() { + auto *model = getModel(); + if (mCollisionManager) { + mCollisionManager->mCurrentMapCollision->_5C &= 0xFFFFFFFE; // Enable + mCollisionManager->mCurrentMapCollision->moveMtx(*model->mJointArray); + } +} + +void TJizoStone::playBoingAnim() { + if (!mActorData->isCurAnmAlreadyEnd(MActor::BCK)) { + return; + } + + if (gpMSound->gateCheck(MSD_SE_EN_SAMBOHEAD_W_HIT)) { + MSoundSE::startSoundActor(MSD_SE_EN_SAMBOHEAD_W_HIT, reinterpret_cast(&mTranslation), + 0, nullptr, 0, 4); + } + + mActorData->setBck("jizo_stone_boing"); + auto *ctrl = mActorData->getFrameCtrl(MActor::BCK); + ctrl->mAnimState = J3DFrameCtrl::ONCE; + ctrl->mFrameRate = 1.5f; + mModelLoadFlags &= ~0x100; +} + +ObjData jizoStoneData{.mMdlName = "jizo_stone", + .mObjectID = 0x40000F80 /*0x80000FFF*/, + .mLiveManagerName = gLiveManagerName, // const_cast("木マネージャー") + .mObjKey = gUnkManagerName, // const_cast("waterballoon"), + .mAnimInfo = nullptr, + .mObjCollisionData = nullptr, + .mMapCollisionInfo = nullptr, + .mSoundInfo = nullptr, + .mPhysicalInfo = nullptr, + .mSinkData = nullptr, + ._28 = nullptr, + .mBckMoveData = nullptr, + ._30 = 50.0f, + .mUnkFlags = 0x4 /*0x02130100*/, + .mKeyCode = cexp_calcKeyCode("JizoStone")}; \ No newline at end of file diff --git a/src/object/key_chest.cpp b/src/object/key_chest.cpp index 4dbc148..ebc99c3 100644 --- a/src/object/key_chest.cpp +++ b/src/object/key_chest.cpp @@ -19,24 +19,25 @@ #include "object/follow_key.hxx" #include "object/key_chest.hxx" -TKeyChest::TKeyChest(const char *name) : TMapObjGeneral(name), mOpening(false), mHasFinishedSounds(false) {} +TKeyChest::TKeyChest(const char *name) + : TMapObjGeneral(name), mOpening(false), mHasFinishedSounds(false) {} void TKeyChest::control() { - TMapObjGeneral::control(); - - if (mOpening) { - // Play chest next open sound when first sound has ended - bool isNextSoundReady = gpMSound->gateCheck(0x1967) && gpMSound->gateCheck(0x1966); - if (!mHasFinishedSounds && isNextSoundReady) { - MSoundSE::startSoundActor(0x1966, mTranslation, 0, nullptr, 0, 4); - mHasFinishedSounds = true; - } - - if (mActorData->isCurAnmAlreadyEnd(MActor::BCK)) { - mOpening = false; - spawnShine(); - } - } + TMapObjGeneral::control(); + + if (mOpening) { + // Play chest next open sound when first sound has ended + bool isNextSoundReady = gpMSound->gateCheck(0x1967) && gpMSound->gateCheck(0x1966); + if (!mHasFinishedSounds && isNextSoundReady) { + MSoundSE::startSoundActor(0x1966, mTranslation, 0, nullptr, 0, 4); + mHasFinishedSounds = true; + } + + if (mActorData->isCurAnmAlreadyEnd(MActor::BCK)) { + mOpening = false; + spawnShine(); + } + } } void TKeyChest::playIdleAnim() {} @@ -82,7 +83,7 @@ void TKeyChest::spawnShine() { void TKeyChest::touchPlayer(THitActor *actor) { if (actor->mObjectID == OBJECT_ID_MARIO) { TMario *player = reinterpret_cast(actor); - auto *data = SME::Player::getEclipseData(player); + auto *data = SME::Player::getEclipseData(player); if (data->mIsHoldingKey) { auto *nameRef = TMarNameRefGen::getInstance()->getRootNameRef(); u16 keyCode = JDrama::TNameRef::calcKeyCode("TreasureKey"); diff --git a/src/object/pearl.cpp b/src/object/pearl.cpp new file mode 100644 index 0000000..9aa7eae --- /dev/null +++ b/src/object/pearl.cpp @@ -0,0 +1,124 @@ +#include "object/pearl.hxx" + +#include +#include + +TPearlCracked::TPearlCracked(const char *name) + : TMapObjGeneral(name), mState(State::STATE_NORMAL) {} + +void TPearlCracked::control() { + TMapObjGeneral::control(); + + switch (mState) { + case State::STATE_NORMAL: + if (checkMarioPounding(gpMarioAddress)) { + swapToCracked(); + } + break; + case State::STATE_BROKEN: + if (mActorData->isCurAnmAlreadyEnd(MActor::BCK)) { + spawnShine(); + mState = State::STATE_RESTING; + } + break; + default: + break; + } +} + +void TPearlCracked::initMapCollisionData() { + mCollisionManager = new TMapCollisionManager(1, "mapObj", this); + mCollisionManager->init("pearl", 1, nullptr); +} + +void TPearlCracked::initMapObj() { + TMapObjGeneral::initMapObj(); + + if (mCollisionManager) { + mCollisionManager->changeCollision(0); + mCollisionManager->mCurrentMapCollision->setAllActor(this); + } +} + +void TPearlCracked::setGroundCollision() { + auto *model = getModel(); + if (mCollisionManager) { + mCollisionManager->mCurrentMapCollision->_5C &= 0xFFFFFFFE; // Enable + mCollisionManager->mCurrentMapCollision->moveMtx(*model->mJointArray); + } +} + +bool TPearlCracked::checkMarioRiding(TMario *player) { + if (gpMarioAddress->mFloorTriangle->mOwner != this) + return false; + + return SMS_IsMarioTouchGround4cm__Fv(); +} + +bool TPearlCracked::checkMarioPounding(TMario *player) { + if (!checkMarioRiding(player)) { + return false; + } + + if (player->mState == TMario::STATE_G_POUND || player->mState == 0x24DF) { + return true; + } + + if (player->mPrevState == TMario::STATE_G_POUND || player->mPrevState == 0x24DF) { + return true; + } + + return false; +} + +void TPearlCracked::swapToCracked() { + if (mCollisionManager) { + mCollisionManager->mCurrentMapCollision->_5C |= 1; // Disable + } + playFractureAnim(); + mState = State::STATE_BROKEN; +} + +void TPearlCracked::playFractureAnim() { + if (!mActorData->isCurAnmAlreadyEnd(MActor::BCK)) { + return; + } + + if (gpMSound->gateCheck(MSD_SE_OBJ_GLASS_BREAK)) { + MSoundSE::startSoundActor(MSD_SE_OBJ_GLASS_BREAK, reinterpret_cast(&mTranslation), 0, + nullptr, 0, 4); + } + + mActorData->setBck("pearl_fracture"); + auto *ctrl = mActorData->getFrameCtrl(MActor::BCK); + ctrl->mAnimState = J3DFrameCtrl::ONCE; + ctrl->mFrameRate = 1.0f; + mModelLoadFlags &= ~0x100; +} + +void TPearlCracked::spawnShine() { + auto *nameRef = TMarNameRefGen::getInstance()->getRootNameRef(); + u16 keyCode = JDrama::TNameRef::calcKeyCode("PearlShine"); + if (TNameRef *p = nameRef->searchF(keyCode, "PearlShine")) { + TShine *shine = reinterpret_cast(p); + shine->mTranslation = mTranslation; + shine->mTranslation.y += 100.0f; + shine->appearWithDemo("PearlCamera"); + } +} + +ObjData pearlData{.mMdlName = "pearl", + .mObjectID = 0x40000F81 /*0x80000FFF*/, + .mLiveManagerName = gLiveManagerName, // const_cast("木マネージャー") + .mObjKey = gUnkManagerName, // const_cast("waterballoon"), + .mAnimInfo = nullptr, + .mObjCollisionData = nullptr, + .mMapCollisionInfo = nullptr, + .mSoundInfo = nullptr, + .mPhysicalInfo = nullptr, + .mSinkData = nullptr, + ._28 = nullptr, + .mBckMoveData = nullptr, + ._30 = 50.0f, + .mUnkFlags = 0x4 /*0x02130100*/, + .mKeyCode = cexp_calcKeyCode("Pearl")}; \ No newline at end of file diff --git a/src/p_settings.hxx b/src/p_settings.hxx index 9fafc34..4c19210 100644 --- a/src/p_settings.hxx +++ b/src/p_settings.hxx @@ -1,6 +1,5 @@ #include "settings.hxx" -extern HUDSetting gHUDSetting; extern BugsExploitsSetting gBugsSetting; extern Settings::SettingsGroup gSettingsGroup; extern TutorialSetting gTutorialSetting; \ No newline at end of file diff --git a/src/player/character.cpp b/src/player/character.cpp index d7fbc59..868bda2 100644 --- a/src/player/character.cpp +++ b/src/player/character.cpp @@ -38,7 +38,7 @@ BETTER_SMS_FOR_CALLBACK void initCharacterArchives(TMarDirector *director) { sCharacterArcs.clear(); - for (int i = 0; i < 2; ++i) { + for (int i = 0; i < 1; ++i) { char buffer[32]; snprintf(buffer, 32, "%s", sCharacterPaths[(int)SME::TGlobals::sCharacterIDList[i]]); @@ -230,29 +230,6 @@ static void *getGlobalPlayerSplashTex(const char *local_path) { } SMS_PATCH_BL(SMS_PORT_REGION(0x8026707C, 0, 0, 0), getGlobalPlayerSplashTex); -// --- - -static TMActorKeeper *sKeeper = nullptr; -static MActor *sActor = nullptr; - -static void applyShadowEffects(u32 *tremble_efx) { - TMario *mario; - SMS_FROM_GPR(31, mario); - - ((u32 **)mario)[0x53C / 4] = tremble_efx; - if (SME::TGlobals::getCharacterIDFromPlayer(mario) == SME::CharacterID::SHADOW_MARIO) { - sKeeper = new TMActorKeeper(nullptr, 1); - sKeeper->mModelFlags = 0x11300000; - sActor = sKeeper->createMActorFromDefaultBmd("/common/kagemario", 0); - mario->mModelData->mModel = sActor->mModel; - mario->mBodyModelData = sActor->mModel->mModelData; - - /*for (int i = 0; i < sActor->mModel->mModelData->mJointNum; ++i) { - SMS_InitPacket_Fog__FP8J3DModelUs(sActor->mModel, i); - }*/ - sActor->setBtk("kagemario_scroll"); - } -} #else #endif // SMS_PATCH_BL(SMS_PORT_REGION(0x802474C0, 0, 0, 0), applyShadowEffects); diff --git a/src/player/water_balloon.cpp b/src/player/water_balloon.cpp index 7aed2da..7a6eef5 100644 --- a/src/player/water_balloon.cpp +++ b/src/player/water_balloon.cpp @@ -34,7 +34,6 @@ BETTER_SMS_FOR_CALLBACK void initializeWaterBalloons(TMario *player) { TWaterBalloon::sEmitInfo->load(in); auto *water_balloons = new BalloonBuf(4, false); - Player::deregisterData(player, "sme_balloon_info"); Player::registerData(player, "sme_balloon_info", water_balloons); for (int i = 0; i < water_balloons->capacity(); ++i) { diff --git a/src/settings.cpp b/src/settings.cpp index a8d4cbd..f891bbd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,7 +1,6 @@ #include "settings.hxx" #include -HUDSetting gHUDSetting; BugsExploitsSetting gBugsSetting; MirrorModeFlag gMirrorModeSetting; TutorialSetting gTutorialSetting; @@ -352,14 +351,12 @@ const u8 gSaveIcon[] = { 0x76, 0x44, 0x7c, 0x86, 0x7d, 0x85, 0xad, 0x10, 0x63, 0x03, 0x64, 0x03, 0x65, 0x15, 0x65, 0x26, 0x65, 0x36, 0x66, 0x36, 0x66, 0x15, 0x65, 0x04}; -HUDSetting::HUD getHUDKind() { return static_cast(gHUDSetting.getInt()); } - BETTER_SMS_FOR_CALLBACK void checkForCompletionAwards(TApplication *app) { if (!TFlagManager::smInstance) return; const size_t shineCount = TFlagManager::smInstance->getFlag(0x40000); - if (shineCount >= 300 && !BetterSMS::getBugFixesSetting()->isUnlocked()) { + if (shineCount >= MaxShineCount && !BetterSMS::getBugFixesSetting()->isUnlocked()) { BetterSMS::getBugFixesSetting()->unlock(); } } \ No newline at end of file diff --git a/src/stage/behavior.cpp b/src/stage/behavior.cpp index 9562875..d5adb5f 100644 --- a/src/stage/behavior.cpp +++ b/src/stage/behavior.cpp @@ -22,7 +22,8 @@ static void checkIceStageSweat() { SMS_PATCH_BL(SMS_PORT_REGION(0x8024FC58, 0, 0, 0), checkIceStageSweat); static void loadIceStageWalkSandA(JPAResourceManager *manager, const char *old_res, u16 id) { - if (gpMarDirector->mAreaID == 70 || gpMarDirector->mAreaID == 80 || gpMarDirector->mAreaID == 86) + if (gpMarDirector->mAreaID == 70 || gpMarDirector->mAreaID == 80 || + gpMarDirector->mAreaID == 86) manager->load("ms_m_walksnow_a.jpa", id); else manager->load(old_res, id); @@ -58,6 +59,41 @@ SMS_PATCH_BL(0x802B4470, loadIceStageWalkSandA); #pragma endregion +#pragma region OutsideDelfinoExBehavior + +// This allows the redcoinswitch to be immediately pressed in extended stages +// and for the player to have Fludd, while still being an ex stage. +static u8 disableExBehaviorForCruiserWorlds() { + if (gpApplication.mCurrentScene.mAreaID > 0x54) { + return 0xFF; + } + return SMS_getShineIDofExStage__FUc(gpApplication.mCurrentScene.mAreaID); +} +SMS_PATCH_BL(0x801C08EC, disableExBehaviorForCruiserWorlds); +SMS_PATCH_BL(0x80298B64, disableExBehaviorForCruiserWorlds); +SMS_PATCH_BL(0x802A681C, disableExBehaviorForCruiserWorlds); + +#pragma endregion + +// Called when a fire is extinguished +static MSound *checkForFireIncrement() { + TFlagManager::smInstance->incFlag(0x60020, 1); + return gpMSound; +} +SMS_PATCH_BL(0x80037F04, checkForFireIncrement); + +static void checkForSamboFlowerIncrement(MActor *actor, const char *hit_anm_name) { + actor->setBck(hit_anm_name); + TFlagManager::smInstance->incFlag(0x60021, 1); +} +SMS_PATCH_BL(0x800E4174, checkForSamboFlowerIncrement); + +static void checkForSamboFlowerDecrement(MActor *actor, const char *hit_anm_name) { + actor->checkCurAnm(hit_anm_name, MActor::BCK); + TFlagManager::smInstance->incFlag(0x60021, -1); +} +SMS_PATCH_BL(0x800E3F9C, checkForSamboFlowerDecrement); + // Disable guide menu SMS_WRITE_32(SMS_PORT_REGION(0x80297A64, 0, 0, 0), 0x4800000C); diff --git a/src/stage/settings.cpp b/src/stage/settings.cpp index 83ae0be..63097f9 100644 --- a/src/stage/settings.cpp +++ b/src/stage/settings.cpp @@ -168,15 +168,15 @@ void initDemoCredits(Settings::SettingsGroup &group) { group.addSetting(&sSpecialThanksCreditSetting); } -bool isDemoComplete() { return gBugsSetting.isUnlocked(); } +bool isGameCompletedPrior() { return gBugsSetting.isUnlocked(); } void lockModuleSettings(TApplication *app) { optional engine_module = BetterSMS::getModuleInfo("Better Sunshine Engine"); optional movement_module = BetterSMS::getModuleInfo("Better Sunshine Moveset"); - SMS_ASSERT(movement_module, + /*SMS_ASSERT(movement_module, "Super Mario Eclipse requires the Better Sunshine Movement module to be present and " - "loaded. Please restore \"BetterSunshineMovement.kxe\" to \"./Kuribo!/Mods/\"!"); + "loaded. Please restore \"BetterSunshineMovement.kxe\" to \"./Kuribo!/Mods/\"!");*/ Settings::SettingsGroup *engine_settings = engine_module->mSettings; { @@ -200,13 +200,13 @@ void lockModuleSettings(TApplication *app) { } } - if (!isDemoComplete()) { + if (!isGameCompletedPrior()) { { auto *setting = engine_settings->getSetting("Exploit Fixes"); setting->setBool(true); } - { + if (movement_module) { auto *movement_settings = movement_module->mSettings; { @@ -281,7 +281,7 @@ void unlockSettings(TMarDirector *director) { if (shine_count >= MaxShineCount && !gBugsSetting.isUnlocked()) { gBugsSetting.unlock(); - optional movement_module = BetterSMS::getModuleInfo("Better Sunshine Moveset"); + if (optional movement_module = BetterSMS::getModuleInfo("Better Sunshine Moveset")) { Settings::SettingsGroup *movement_settings = movement_module->mSettings; @@ -329,7 +329,7 @@ void unlockSettings(TMarDirector *director) { update_save = true; } - if (shine_count >= 30 && !gMirrorModeSetting.getBool()) { + if (shine_count >= MaxShineCount && !gMirrorModeSetting.getBool()) { gMirrorModeSetting.setBool(true); gMirrorModeSetting.updateSetting(); update_save = true; diff --git a/src/ui/e3_health.cpp b/src/ui/e3_health.cpp deleted file mode 100644 index 6da448c..0000000 --- a/src/ui/e3_health.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include "settings.hxx" - -using namespace BetterSMS; - -void manageE3HealthMeter(TMarDirector *director, J2DGrafContext *context) { - switch (getHUDKind()) { - case HUDSetting::E3: { - TGCConsole2 *console = gpMarDirector->mGCConsole; - const s16 health = gpMarioAddress->mHealth; - - for (int i = 0; i < 9; ++i) { - console->mHealthPoints[i].mActivePicture->mIsVisible = i == health; - console->mHealthPoints[i].mInactivePicture->mIsVisible = i == health; - } - break; - } - default: - break; - } -} \ No newline at end of file