From 1a6feebe5b97c01c5acaf526d19641c6ba6d302d Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Thu, 5 Sep 2024 01:11:29 +0200 Subject: [PATCH] MapObj: Implement `ChurchDoor` --- data/odyssey_functions.csv | 50 +++++----- lib/al/Library/Bgm/BgmLineFunction.h | 3 + src/MapObj/ChurchDoor.cpp | 143 +++++++++++++++++++++++++++ src/MapObj/ChurchDoor.h | 39 ++++++++ src/Scene/ProjectActorFactory.cpp | 3 +- src/System/GameDataHolderAccessor.h | 6 ++ src/Util/StageSensorMsgFunction.h | 17 ++++ 7 files changed, 235 insertions(+), 26 deletions(-) create mode 100644 src/MapObj/ChurchDoor.cpp create mode 100644 src/MapObj/ChurchDoor.h create mode 100644 src/Util/StageSensorMsgFunction.h diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 580da8c9..b93d8005 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -14518,30 +14518,30 @@ Address,Quality,Size,Name 0x000000710024b30c,U,000004,_ZN21CheckpointFlagWatcherD0Ev 0x000000710024b310,U,000008,_ZNK21CheckpointFlagWatcher17getCameraDirectorEv 0x000000710024b318,U,000008,_ZThn8_NK21CheckpointFlagWatcher17getCameraDirectorEv -0x000000710024b320,U,000124,_ZN10ChurchDoorC2EPKc -0x000000710024b39c,U,000136,_ZN10ChurchDoorC1EPKc -0x000000710024b424,U,000200,_ZN10ChurchDoor4initERKN2al13ActorInitInfoE -0x000000710024b4ec,U,000324,_ZN10ChurchDoor10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_ -0x000000710024b630,U,000016,_ZNK10ChurchDoor10isOpenWaitEv -0x000000710024b640,U,000012,_ZNK10ChurchDoor17isDemoEnterChurchEv -0x000000710024b64c,U,000012,_ZN10ChurchDoor20startDemoEnterChurchEv -0x000000710024b658,U,000016,_ZN10ChurchDoor18endDemoEnterChurchEv -0x000000710024b668,U,000060,_ZN10ChurchDoor13exeCloseWait1Ev -0x000000710024b6a4,U,000068,_ZN10ChurchDoor8exeOpen1Ev -0x000000710024b6e8,U,000060,_ZN10ChurchDoor13exeCloseWait2Ev -0x000000710024b724,U,000068,_ZN10ChurchDoor8exeOpen2Ev -0x000000710024b768,U,000060,_ZN10ChurchDoor13exeCloseWait3Ev -0x000000710024b7a4,U,000076,_ZN10ChurchDoor8exeOpen3Ev -0x000000710024b7f0,U,000108,_ZN10ChurchDoor11exeOpenWaitEv -0x000000710024b85c,U,000004,_ZN10ChurchDoor18exeDemoEnterChurchEv -0x000000710024b860,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait17executeEPN2al11NerveKeeperE -0x000000710024b8a0,U,000112,_ZNK12_GLOBAL__N_121ChurchDoorNrvOpenWait7executeEPN2al11NerveKeeperE -0x000000710024b910,U,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen17executeEPN2al11NerveKeeperE -0x000000710024b958,U,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen27executeEPN2al11NerveKeeperE -0x000000710024b9a0,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait27executeEPN2al11NerveKeeperE -0x000000710024b9e0,U,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait37executeEPN2al11NerveKeeperE -0x000000710024ba20,U,000080,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen37executeEPN2al11NerveKeeperE -0x000000710024ba70,U,000008,_ZNK12_GLOBAL__N_128ChurchDoorNrvDemoEnterChurch7executeEPN2al11NerveKeeperE +0x000000710024b320,O,000124,_ZN10ChurchDoorC2EPKc +0x000000710024b39c,O,000136,_ZN10ChurchDoorC1EPKc +0x000000710024b424,O,000200,_ZN10ChurchDoor4initERKN2al13ActorInitInfoE +0x000000710024b4ec,O,000324,_ZN10ChurchDoor10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_ +0x000000710024b630,O,000016,_ZNK10ChurchDoor10isOpenWaitEv +0x000000710024b640,O,000012,_ZNK10ChurchDoor17isDemoEnterChurchEv +0x000000710024b64c,O,000012,_ZN10ChurchDoor20startDemoEnterChurchEv +0x000000710024b658,O,000016,_ZN10ChurchDoor18endDemoEnterChurchEv +0x000000710024b668,O,000060,_ZN10ChurchDoor13exeCloseWait1Ev +0x000000710024b6a4,O,000068,_ZN10ChurchDoor8exeOpen1Ev +0x000000710024b6e8,O,000060,_ZN10ChurchDoor13exeCloseWait2Ev +0x000000710024b724,O,000068,_ZN10ChurchDoor8exeOpen2Ev +0x000000710024b768,O,000060,_ZN10ChurchDoor13exeCloseWait3Ev +0x000000710024b7a4,O,000076,_ZN10ChurchDoor8exeOpen3Ev +0x000000710024b7f0,O,000108,_ZN10ChurchDoor11exeOpenWaitEv +0x000000710024b85c,O,000004,_ZN10ChurchDoor18exeDemoEnterChurchEv +0x000000710024b860,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait17executeEPN2al11NerveKeeperE +0x000000710024b8a0,O,000112,_ZNK12_GLOBAL__N_121ChurchDoorNrvOpenWait7executeEPN2al11NerveKeeperE +0x000000710024b910,O,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen17executeEPN2al11NerveKeeperE +0x000000710024b958,O,000072,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen27executeEPN2al11NerveKeeperE +0x000000710024b9a0,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait27executeEPN2al11NerveKeeperE +0x000000710024b9e0,O,000064,_ZNK12_GLOBAL__N_123ChurchDoorNrvCloseWait37executeEPN2al11NerveKeeperE +0x000000710024ba20,O,000080,_ZNK12_GLOBAL__N_118ChurchDoorNrvOpen37executeEPN2al11NerveKeeperE +0x000000710024ba70,O,000008,_ZNK12_GLOBAL__N_128ChurchDoorNrvDemoEnterChurch7executeEPN2al11NerveKeeperE 0x000000710024ba78,U,000124,_ZN12CityBuildingC2EPKc 0x000000710024baf4,U,000136,_ZN12CityBuildingC1EPKc 0x000000710024bb7c,U,000412,_ZN12CityBuilding4initERKN2al13ActorInitInfoE @@ -30075,7 +30075,7 @@ Address,Quality,Size,Name 0x00000071004b71bc,U,000052,_ZN2al19createActorFunctionI5ChairEEPNS_9LiveActorEPKc 0x00000071004b71f0,U,000052,_ZN2al19createActorFunctionI14CheckpointFlagEEPNS_9LiveActorEPKc 0x00000071004b7224,U,000052,_ZN2al19createActorFunctionI14ChorobonHolderEEPNS_9LiveActorEPKc -0x00000071004b7258,U,000052,_ZN2al19createActorFunctionI10ChurchDoorEEPNS_9LiveActorEPKc +0x00000071004b7258,O,000052,_ZN2al19createActorFunctionI10ChurchDoorEEPNS_9LiveActorEPKc 0x00000071004b728c,U,000052,_ZN2al19createActorFunctionI12CityBuildingEEPNS_9LiveActorEPKc 0x00000071004b72c0,U,000052,_ZN2al19createActorFunctionI15CityStreetlightEEPNS_9LiveActorEPKc 0x00000071004b72f4,U,000052,_ZN2al19createActorFunctionI13CityWorldSignEEPNS_9LiveActorEPKc diff --git a/lib/al/Library/Bgm/BgmLineFunction.h b/lib/al/Library/Bgm/BgmLineFunction.h index 185bbd4b..70ad841a 100644 --- a/lib/al/Library/Bgm/BgmLineFunction.h +++ b/lib/al/Library/Bgm/BgmLineFunction.h @@ -2,6 +2,7 @@ namespace al { class Resource; +class IUseAudioKeeper; class BgmDataBase { public: @@ -9,4 +10,6 @@ class BgmDataBase { BgmDataBase(const Resource*, const Resource*); }; + +void startBgmSituation(const IUseAudioKeeper*, const char*, bool, bool); } // namespace al diff --git a/src/MapObj/ChurchDoor.cpp b/src/MapObj/ChurchDoor.cpp new file mode 100644 index 00000000..12cf5ff9 --- /dev/null +++ b/src/MapObj/ChurchDoor.cpp @@ -0,0 +1,143 @@ +#include "MapObj/ChurchDoor.h" + +#include "Library/Bgm/BgmLineFunction.h" +#include "Library/LiveActor/ActorActionFunction.h" +#include "Library/LiveActor/ActorCollisionFunction.h" +#include "Library/LiveActor/ActorInitInfo.h" +#include "Library/LiveActor/ActorSensorFunction.h" +#include "Library/LiveActor/ActorSensorMsgFunction.h" +#include "Library/Nerve/NerveSetupUtil.h" +#include "Library/Nerve/NerveUtil.h" + +#include "Util/Sensor.h" +#include "Util/StageSensorMsgFunction.h" + +namespace { +NERVE_IMPL(ChurchDoor, DemoEnterChurch); +NERVE_IMPL(ChurchDoor, CloseWait1); +NERVE_IMPL(ChurchDoor, OpenWait); +NERVE_IMPL(ChurchDoor, Open1); +NERVE_IMPL(ChurchDoor, Open2); +NERVE_IMPL(ChurchDoor, CloseWait2); +NERVE_IMPL(ChurchDoor, CloseWait3); +NERVE_IMPL(ChurchDoor, Open3); + +NERVES_MAKE_NOSTRUCT(ChurchDoor, DemoEnterChurch, CloseWait1, OpenWait, Open1, Open2, CloseWait2, + CloseWait3, Open3); +} // namespace + +ChurchDoor::ChurchDoor(const char* name) : al::LiveActor(name) {} + +void ChurchDoor::init(const al::ActorInitInfo& info) { + al::initActor(this, info); + al::initNerve(this, &CloseWait1, 0); + + if (isCurrentStageMoonWeddingRoom(this)) { + mSaveObjInfo = rs::createSaveObjInfoWriteSaveData(info); + if (rs::isOnSaveObjInfo(mSaveObjInfo)) { + al::invalidateCollisionParts(this); + al::setNerve(this, &OpenWait); + makeActorAlive(); + return; + } + } + + al::startBgmSituation(this, "CloseChurchDoor", true, true); + makeActorAlive(); +} + +bool ChurchDoor::receiveMsg(const al::SensorMsg* msg, al::HitSensor* source, + al::HitSensor* target) { + if (rs::isMsgPlayerDisregardTargetMarker(msg)) + return true; + + if (rs::isMsgCapTouchWall(msg)) { + if ((al::isNerve(this, &Open1) || al::isNerve(this, &Open2)) && + al::isLessEqualStep(this, 10)) + return true; + + rs::requestHitReactionToAttacker(msg, source, al::getSensorPos(source)); + + if (al::isNerve(this, &CloseWait1)) { + al::startHitReaction(this, "ヒット1回目"); + al::setNerve(this, &Open1); + } else if (al::isNerve(this, &CloseWait2) || al::isNerve(this, &Open1)) { + al::startHitReaction(this, "ヒット2回目"); + al::setNerve(this, &Open2); + } else if (al::isNerve(this, &CloseWait3) || al::isNerve(this, &Open2)) { + al::startHitReaction(this, "ヒット3回目"); + al::setNerve(this, &Open3); + } + return true; + } + + return false; +} + +bool ChurchDoor::isOpenWait() const { + return al::isNerve(this, &OpenWait); +} + +bool ChurchDoor::isDemoEnterChurch() const { + return al::isNerve(this, &DemoEnterChurch); +} + +void ChurchDoor::startDemoEnterChurch() { + al::setNerve(this, &DemoEnterChurch); +} + +void ChurchDoor::endDemoEnterChurch() { + al::setNerve(this, &OpenWait); +} + +void ChurchDoor::exeCloseWait1() { + if (al::isFirstStep(this)) + al::startAction(this, "CloseWait1"); +} + +void ChurchDoor::exeOpen1() { + if (al::isFirstStep(this)) + al::startAction(this, "Open1"); + + al::setNerveAtActionEnd(this, &CloseWait2); +} + +void ChurchDoor::exeCloseWait2() { + if (al::isFirstStep(this)) + al::startAction(this, "CloseWait2"); +} + +void ChurchDoor::exeOpen2() { + if (al::isFirstStep(this)) + al::startAction(this, "Open2"); + + al::setNerveAtActionEnd(this, &CloseWait3); +} + +void ChurchDoor::exeCloseWait3() { + if (al::isFirstStep(this)) + al::startAction(this, "CloseWait3"); +} + +void ChurchDoor::exeOpen3() { + if (al::isFirstStep(this)) { + al::startAction(this, "Open3"); + al::invalidateCollisionParts(this); + } + + al::setNerveAtActionEnd(this, &OpenWait); +} + +void ChurchDoor::exeOpenWait() { + if (al::isFirstStep(this)) { + al::startAction(this, "OpenWait"); + + if (isCurrentStageMoonWeddingRoom(this)) + rs::onSaveObjInfo(mSaveObjInfo); + } +} + +void ChurchDoor::exeDemoEnterChurch() { + if (al::isFirstStep(this)) { + } +} diff --git a/src/MapObj/ChurchDoor.h b/src/MapObj/ChurchDoor.h new file mode 100644 index 00000000..b815ec13 --- /dev/null +++ b/src/MapObj/ChurchDoor.h @@ -0,0 +1,39 @@ +#pragma once + +#include "Library/Base/StringUtil.h" +#include "Library/LiveActor/LiveActor.h" + +#include "System/GameDataFunction.h" + +class SaveObjInfo; + +class ChurchDoor : public al::LiveActor { +public: + ChurchDoor(const char* name); + + void init(const al::ActorInitInfo& info) override; + bool receiveMsg(const al::SensorMsg* msg, al::HitSensor* source, + al::HitSensor* target) override; + + bool isOpenWait() const; + bool isDemoEnterChurch() const; + void startDemoEnterChurch(); + void endDemoEnterChurch(); + + void exeCloseWait1(); + void exeOpen1(); + void exeCloseWait2(); + void exeOpen2(); + void exeCloseWait3(); + void exeOpen3(); + void exeOpenWait(); + void exeDemoEnterChurch(); + +private: + SaveObjInfo* mSaveObjInfo = nullptr; +}; + +inline bool isCurrentStageMoonWeddingRoom(const al::LiveActor* actor) { + return al::isEqualString("MoonWorldWeddingRoomStage", + GameDataFunction::getCurrentStageName(actor)); +} diff --git a/src/Scene/ProjectActorFactory.cpp b/src/Scene/ProjectActorFactory.cpp index 0b002f0a..0b93e13d 100644 --- a/src/Scene/ProjectActorFactory.cpp +++ b/src/Scene/ProjectActorFactory.cpp @@ -9,6 +9,7 @@ #include "Library/Obj/AllDeadWatcher.h" #include "MapObj/AnagramAlphabet.h" +#include "MapObj/ChurchDoor.h" #include "MapObj/CitySignal.h" #include "MapObj/FireDrum2D.h" #include "MapObj/WorldMapEarth.h" @@ -114,7 +115,7 @@ static al::NameToCreator sProjectActorFactoryEntries[] {"Chair", nullptr}, {"CheckpointFlag", nullptr}, {"ChorobonHolder", nullptr}, - {"ChurchDoor", nullptr}, + {"ChurchDoor", al::createActorFunction}, {"CityBuilding", nullptr}, {"CityStreetlight", nullptr}, {"CityWorldSign", nullptr}, diff --git a/src/System/GameDataHolderAccessor.h b/src/System/GameDataHolderAccessor.h index f91ca8de..1c53157f 100644 --- a/src/System/GameDataHolderAccessor.h +++ b/src/System/GameDataHolderAccessor.h @@ -7,7 +7,9 @@ class IUseSceneObjHolder; class SceneObjHolder; class ISceneObj; class LiveActor; +class ActorInitInfo; } // namespace al +class SaveObjInfo; class GameDataHolderAccessor : public GameDataHolderWriter { // maybe extends GameDataHolderWriter? public: @@ -18,4 +20,8 @@ class GameDataHolderAccessor : public GameDataHolderWriter { // maybe extends G namespace rs { bool isInvalidChangeStage(const al::LiveActor* actor); bool isKidsMode(const al::LiveActor* actor); + +SaveObjInfo* createSaveObjInfoWriteSaveData(const al::ActorInitInfo&); +void onSaveObjInfo(SaveObjInfo*); +bool isOnSaveObjInfo(const SaveObjInfo*); } // namespace rs diff --git a/src/Util/StageSensorMsgFunction.h b/src/Util/StageSensorMsgFunction.h new file mode 100644 index 00000000..283679e4 --- /dev/null +++ b/src/Util/StageSensorMsgFunction.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace al { +class HitSensor; +class SensorMsg; +} // namespace al + +namespace rs { + +bool isMsgPlayerDisregardTargetMarker(const al::SensorMsg* msg); + +void requestHitReactionToAttacker(const al::SensorMsg*, const al::HitSensor*, + const sead::Vector3f&); + +} // namespace rs