diff options
author | Paul Gilbert | 2016-08-17 22:15:05 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-17 22:15:05 -0400 |
commit | bf5835b0dcd8134a82221804be0eb6c415adeeb5 (patch) | |
tree | 5c20cb3f28fc1b4c68f1138aa3969028366bb34b /engines/titanic | |
parent | 41dab514e1f7dc4bbf9ff9bab21c5dc5cad7812f (diff) | |
download | scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.tar.gz scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.tar.bz2 scummvm-rg350-bf5835b0dcd8134a82221804be0eb6c415adeeb5.zip |
TITANIC: Implementing game logic classes
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/carry/central_core.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/carry/central_core.h | 4 | ||||
-rw-r--r-- | engines/titanic/game/cell_point_button.cpp | 34 | ||||
-rw-r--r-- | engines/titanic/game/cell_point_button.h | 7 | ||||
-rw-r--r-- | engines/titanic/game/chev_code.cpp | 135 | ||||
-rw-r--r-- | engines/titanic/game/chev_code.h | 15 | ||||
-rw-r--r-- | engines/titanic/game/sgt/chest_of_drawers.cpp | 43 | ||||
-rw-r--r-- | engines/titanic/game/sgt/chest_of_drawers.h | 4 | ||||
-rw-r--r-- | engines/titanic/gfx/changes_season_button.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/gfx/changes_season_button.h | 2 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 30 | ||||
-rw-r--r-- | engines/titanic/npcs/succubus.cpp | 2 |
12 files changed, 316 insertions, 27 deletions
diff --git a/engines/titanic/carry/central_core.cpp b/engines/titanic/carry/central_core.cpp index a50c95abbc..e210b34cbe 100644 --- a/engines/titanic/carry/central_core.cpp +++ b/engines/titanic/carry/central_core.cpp @@ -21,9 +21,16 @@ */ #include "titanic/carry/central_core.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CCentralCore, CBrain) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(DropZoneLostObjectMsg) + ON_MESSAGE(DropZoneGotObjectMsg) +END_MESSAGE_MAP() + void CCentralCore::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBrain::save(file, indent); @@ -34,4 +41,53 @@ void CCentralCore::load(SimpleFile *file) { CBrain::load(file); } +bool CCentralCore::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CString name = msg->_other->getName(); + if (name == "HammerDispensorButton") { + CPuzzleSolvedMsg solvedMsg; + solvedMsg.execute("BigHammer"); + } else if (name == "SpeechCentre") { + CShowTextMsg textMsg("This does not reach."); + textMsg.execute("PET"); + } + + return CBrain::UseWithOtherMsg(msg); +} + +bool CCentralCore::DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg) { + CString name = msg->_object->getName(); + if (name == "PerchCoreHolder") { + CParrot::_v2 = 1; + if (isEquals("CentralCore")) + CParrot::_v5 = 0; + + CActMsg actMsg("LosePerch"); + actMsg.execute("ParrotLobbyController"); + } else if (name == "PerchHolder") { + CActMsg actMsg("LoseStick"); + actMsg.execute("ParrotLobbyController"); + } + + return true; +} + +bool CCentralCore::DropZoneGotObjectMsg(CDropZoneGotObjectMsg *msg) { + CString name = msg->_object->getName(); + if (name == "PerchCoreHolder") { + if (isEquals("CentralCore")) { + CParrot::_v5 = 1; + CActMsg actMsg("CoreReplaced"); + actMsg.execute("ParrotCage"); + } + + CActMsg actMsg("GainPerch"); + actMsg.execute("ParrotLobbyController"); + } else if (name == "PerchHolder") { + CActMsg actMsg("GainStick"); + actMsg.execute("ParrotLobbyController"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/central_core.h b/engines/titanic/carry/central_core.h index 9d7bef2c13..cc5d9c2f95 100644 --- a/engines/titanic/carry/central_core.h +++ b/engines/titanic/carry/central_core.h @@ -28,6 +28,10 @@ namespace Titanic { class CCentralCore : public CBrain { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg); + bool DropZoneGotObjectMsg(CDropZoneGotObjectMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/cell_point_button.cpp b/engines/titanic/game/cell_point_button.cpp index 18ece09cb0..207dd73543 100644 --- a/engines/titanic/game/cell_point_button.cpp +++ b/engines/titanic/game/cell_point_button.cpp @@ -24,12 +24,17 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CCellPointButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CCellPointButton::CCellPointButton() : CBackground() { _fieldE0 = 0; _fieldE4 = 0; _fieldE8 = 0; _fieldEC = 0; - _fieldF0 = 0; + _regionNum = 0; _fieldF4 = 0; _fieldF8 = 0; _fieldFC = 0; @@ -44,7 +49,7 @@ void CCellPointButton::save(SimpleFile *file, int indent) { file->writeNumberLine(_fieldE4, indent); file->writeNumberLine(_fieldE8, indent); file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_regionNum, indent); file->writeNumberLine(_fieldF4, indent); file->writeNumberLine(_fieldF8, indent); file->writeNumberLine(_fieldFC, indent); @@ -52,7 +57,7 @@ void CCellPointButton::save(SimpleFile *file, int indent) { file->writeNumberLine(_field104, indent); file->writeNumberLine(_field108, indent); file->writeQuotedLine(_string3, indent); - file->writeNumberLine(_field118, indent); + file->writeNumberLine(_dialNum, indent); CBackground::save(file, indent); } @@ -63,7 +68,7 @@ void CCellPointButton::load(SimpleFile *file) { _fieldE4 = file->readNumber(); _fieldE8 = file->readNumber(); _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); + _regionNum = file->readNumber(); _fieldF4 = file->readNumber(); _fieldF8 = file->readNumber(); _fieldFC = file->readNumber(); @@ -71,9 +76,28 @@ void CCellPointButton::load(SimpleFile *file) { _field104 = file->readNumber(); _field108 = file->readNumber(); _string3 = file->readString(); - _field118 = file->readNumber(); + _dialNum = file->readNumber(); CBackground::load(file); } +bool CCellPointButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (getRandomNumber(2) == 0) { + CParrotSpeakMsg speakMsg("Cellpoints", _string3); + speakMsg.execute("PerchedParrot"); + } + + playMovie(0); + _regionNum = _regionNum ? 0 : 1; + playSound("z#425.wav"); + talkSetDialRegion(_string3, _dialNum, _regionNum); + + return true; +} + +bool CCellPointButton::EnterViewMsg(CEnterViewMsg *msg) { + _regionNum = talkGetDialRegion(_string3, _dialNum); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/cell_point_button.h b/engines/titanic/game/cell_point_button.h index 6f1fdc3809..33f58cbb83 100644 --- a/engines/titanic/game/cell_point_button.h +++ b/engines/titanic/game/cell_point_button.h @@ -28,12 +28,15 @@ namespace Titanic { class CCellPointButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: int _fieldE0; int _fieldE4; int _fieldE8; int _fieldEC; - int _fieldF0; + int _regionNum; int _fieldF4; int _fieldF8; int _fieldFC; @@ -41,7 +44,7 @@ public: int _field104; int _field108; CString _string3; - int _field118; + int _dialNum; public: CLASSDEF; CCellPointButton(); diff --git a/engines/titanic/game/chev_code.cpp b/engines/titanic/game/chev_code.cpp index ebc20578b7..4dd3ac3d4a 100644 --- a/engines/titanic/game/chev_code.cpp +++ b/engines/titanic/game/chev_code.cpp @@ -24,16 +24,147 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CChevCode, CGameObject) + ON_MESSAGE(SetChevLiftBits) + ON_MESSAGE(SetChevClassBits) + ON_MESSAGE(SetChevFloorBits) + ON_MESSAGE(SetChevRoomBits) + ON_MESSAGE(GetChevLiftNum) + ON_MESSAGE(GetChevClassNum) + ON_MESSAGE(GetChevFloorNum) + ON_MESSAGE(GetChevRoomNum) + ON_MESSAGE(CheckChevCode) + ON_MESSAGE(GetChevCodeFromRoomNameMsg) +END_MESSAGE_MAP() + void CChevCode::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_floorBits, indent); CGameObject::save(file, indent); } void CChevCode::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _floorBits = file->readNumber(); CGameObject::load(file); } +bool CChevCode::SetChevLiftBits(CSetChevLiftBits *msg) { + _floorBits &= ~0xC0000; + if (msg->_liftNum > 0 && msg->_liftNum < 5) + _floorBits = ((msg->_liftNum - 1) << 18) | _floorBits; + + return true; +} + +bool CChevCode::SetChevClassBits(CSetChevClassBits *msg) { + _floorBits &= ~0x30000; + if (msg->_classNum > 0 && msg->_classNum < 4) + _floorBits = (msg->_classNum << 16) | msg->_classNum; + + return true; +} + +bool CChevCode::SetChevFloorBits(CSetChevFloorBits *msg) { + int section = (msg->_floorNum + 4) / 10; + int index = (msg->_floorNum + 4) % 10; + _floorBits &= ~0xFF00; + + int val; + switch (section) { + case 0: + val = 144; + break; + case 1: + val = 208; + break; + case 2: + val = 224; + break; + case 3: + val = 240; + break; + default: + break; + } + + _floorBits |= ((index + val) << 8); + return true; +} + +bool CChevCode::SetChevRoomBits(CSetChevRoomBits *msg) { + _floorBits &= ~0xff; + if (msg->_roomNum > 0 && msg->_roomNum < 128) + _floorBits |= msg->_roomNum * 2; + + return true; +} + +bool CChevCode::GetChevLiftNum(CGetChevLiftNum *msg) { + msg->_liftNum = (_floorBits >> 18) & 3 + 1; + return true; +} + +bool CChevCode::GetChevClassNum(CGetChevClassNum *msg) { + msg->_classNum = (_floorBits >> 16) & 3; + return true; +} + +bool CChevCode::GetChevFloorNum(CGetChevFloorNum *msg) { + int val1 = (_floorBits >> 8) & 0xF; + int val2 = (_floorBits >> 12) & 0xF - 9; + + switch (val2) { + case 0: + val2 = 0; + break; + case 4: + val2 = 1; + break; + case 5: + val2 = 2; + break; + case 6: + val2 = 3; + break; + default: + val2 = 4; + break; + } + + msg->_floorNum = (val1 >= 10) ? 0 : val1 * 10; + return true; +} + +bool CChevCode::GetChevRoomNum(CGetChevRoomNum *msg) { + msg->_roomNum = (_floorBits >> 1) & 0x7F; + return true; +} + +bool CChevCode::CheckChevCode(CCheckChevCode *msg) { + // TODO + return true; +} + +bool CChevCode::GetChevCodeFromRoomNameMsg(CGetChevCodeFromRoomNameMsg *msg) { + static const char *const ROOM_NAMES[13] = { + "ParrotLobby", "sculptureChamber", "Bar", "EmbLobby", "MusicRoom", + "Titania", "BottomOfWell", "Arboretum", "PromenadeDeck", + "FCRestrnt", "CrtrsCham", "BilgeRoom", "Bridge" + }; + static const uint CHEV_CODES[13] = { + 0x1D0D9, 0x465FB, 0xB3D97, 0xCC971, 0xF34DB, 0x8A397, 0x59FAD, + 0x4D6AF, 0x79C45, 0x196D9, 0x2F86D, 0x3D94B, 0x39FCB + }; + + for (int idx = 0; idx < 13; ++idx) { + if (msg->_roomName == ROOM_NAMES[idx]) { + msg->_chevCode = CHEV_CODES[idx]; + break; + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/chev_code.h b/engines/titanic/game/chev_code.h index c4552d00a2..88b26cd6ec 100644 --- a/engines/titanic/game/chev_code.h +++ b/engines/titanic/game/chev_code.h @@ -28,11 +28,22 @@ namespace Titanic { class CChevCode : public CGameObject { + DECLARE_MESSAGE_MAP; + bool SetChevLiftBits(CSetChevLiftBits *msg); + bool SetChevClassBits(CSetChevClassBits *msg); + bool SetChevFloorBits(CSetChevFloorBits *msg); + bool SetChevRoomBits(CSetChevRoomBits *msg); + bool GetChevLiftNum(CGetChevLiftNum *msg); + bool GetChevClassNum(CGetChevClassNum *msg); + bool GetChevFloorNum(CGetChevFloorNum *msg); + bool GetChevRoomNum(CGetChevRoomNum *msg); + bool CheckChevCode(CCheckChevCode *msg); + bool GetChevCodeFromRoomNameMsg(CGetChevCodeFromRoomNameMsg *msg); public: - int _value; + int _floorBits; public: CLASSDEF; - CChevCode() : CGameObject(), _value(0) {} + CChevCode() : CGameObject(), _floorBits(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/chest_of_drawers.cpp b/engines/titanic/game/sgt/chest_of_drawers.cpp index be62e12c8e..d9c72d3021 100644 --- a/engines/titanic/game/sgt/chest_of_drawers.cpp +++ b/engines/titanic/game/sgt/chest_of_drawers.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CChestOfDrawers, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CChestOfDrawers::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,41 @@ void CChestOfDrawers::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CChestOfDrawers::TurnOn(CTurnOn *msg) { + if (_statics->_v6 == "Closed" && _statics->_v5 == "Open") { + _fieldE0 = false; + _statics->_v6 = "Open"; + _startFrame = 1; + _endFrame = 14; + playSound("b#11.wav"); + } + + return true; +} + +bool CChestOfDrawers::TurnOff(CTurnOff *msg) { + if (_statics->_v6 == "Open" && _statics->_v5 == "Closed") { + CVisibleMsg visibleMsg; + visibleMsg.execute("Drawer"); + _statics->_v6 = "Closed"; + _fieldE0 = true; + + _startFrame = 14; + _endFrame = 27; + playMovie(14, 27, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("b#11.wav"); + } + + return true; +} + +bool CChestOfDrawers::MovieEndMsg(CMovieEndMsg *msg) { + if (_statics->_v6 == "Open") { + CVisibleMsg visibleMsg; + visibleMsg.execute("Drawer"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/chest_of_drawers.h b/engines/titanic/game/sgt/chest_of_drawers.h index 16a1bf8fea..5bf852902b 100644 --- a/engines/titanic/game/sgt/chest_of_drawers.h +++ b/engines/titanic/game/sgt/chest_of_drawers.h @@ -28,6 +28,10 @@ namespace Titanic { class CChestOfDrawers : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/gfx/changes_season_button.cpp b/engines/titanic/gfx/changes_season_button.cpp index d5242ad890..584a9542f3 100644 --- a/engines/titanic/gfx/changes_season_button.cpp +++ b/engines/titanic/gfx/changes_season_button.cpp @@ -21,9 +21,14 @@ */ #include "titanic/gfx/changes_season_button.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CChangesSeasonButton, CSTButton) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CChangesSeasonButton::CChangesSeasonButton() : CSTButton() { } @@ -37,4 +42,10 @@ void CChangesSeasonButton::load(SimpleFile *file) { CSTButton::load(file); } +bool CChangesSeasonButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CChangeSeasonMsg changeMsg(_actionName); + changeMsg.execute(getRoot(), nullptr, MSGFLAG_SCAN); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/changes_season_button.h b/engines/titanic/gfx/changes_season_button.h index 2b58a3199b..4f588187eb 100644 --- a/engines/titanic/gfx/changes_season_button.h +++ b/engines/titanic/gfx/changes_season_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CChangesSeasonButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; CChangesSeasonButton(); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 9ee9ccb70d..816c5f5fd6 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -228,8 +228,8 @@ MESSAGE0(CDonNavHelmet); MESSAGE1(CDoorbotNeededInElevatorMsg, int, value, 0); MESSAGE0(CDoorbotNeededInHomeMsg); MESSAGE1(CDropObjectMsg, CCarry *, item, nullptr); -MESSAGE1(CDropZoneGotObjectMsg, int, value, 0); -MESSAGE1(CDropZoneLostObjectMsg, int, value, 0); +MESSAGE1(CDropZoneGotObjectMsg, CGameObject *, object, nullptr); +MESSAGE1(CDropZoneLostObjectMsg, CGameObject *, object, nullptr); MESSAGE1(CEjectCylinderMsg, int, value, 0); MESSAGE2(CPreEnterNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr); MESSAGE2(CPreEnterRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); @@ -240,15 +240,15 @@ MESSAGE2(CEnterViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nul MESSAGE0(CErasePhonographCylinderMsg); MESSAGE1(CFrameMsg, uint, ticks, 0); MESSAGE2(CFreshenCookieMsg, int, value1, 0, int, value2, 0); -MESSAGE1(CGetChevClassBits, int, value, 0); -MESSAGE1(CGetChevClassNum, int, value, 0); -MESSAGE2(CGetChevCodeFromRoomNameMsg, CString, strValue, "", int, numValue, 0); -MESSAGE1(CGetChevFloorBits, int, value, 0); -MESSAGE1(CGetChevFloorNum, int, value, 0); -MESSAGE1(CGetChevLiftBits, int, value, 0); -MESSAGE1(CGetChevLiftNum, int, value, 0); -MESSAGE1(CGetChevRoomBits, int, value, 0); -MESSAGE1(CGetChevRoomNum, int, value, 0); +MESSAGE1(CGetChevClassBits, int, classBits, 0); +MESSAGE1(CGetChevClassNum, int, classNum, 0); +MESSAGE2(CGetChevCodeFromRoomNameMsg, CString, roomName, "", uint, chevCode, 0); +MESSAGE1(CGetChevFloorBits, int, floorBits, 0); +MESSAGE1(CGetChevFloorNum, int, floorNum, 0); +MESSAGE1(CGetChevLiftBits, int, liftBits, 0); +MESSAGE1(CGetChevLiftNum, int, liftNum, 0); +MESSAGE1(CGetChevRoomBits, int, roomNum, 0); +MESSAGE1(CGetChevRoomNum, int, roomNum, 0); MESSAGE2(CHoseConnectedMsg, int, value, 1, CGameObject *, object, nullptr); MESSAGE0(CInitializeAnimMsg); MESSAGE1(CIsEarBowlPuzzleDone, int, value, 0); @@ -308,12 +308,12 @@ MESSAGE2(CServiceElevatorFloorChangeMsg, int, value1, 0, int, value2, 0); MESSAGE0(CServiceElevatorFloorRequestMsg); MESSAGE1(CServiceElevatorMsg, int, value, 4); MESSAGE2(CSetChevButtonImageMsg, int, value1, 0, int, value2, 0); -MESSAGE1(CSetChevClassBits, int, value, 0); -MESSAGE1(CSetChevFloorBits, int, value, 0); -MESSAGE1(CSetChevLiftBits, int, value, 0); +MESSAGE1(CSetChevClassBits, int, classNum, 0); +MESSAGE1(CSetChevFloorBits, int, floorNum, 0); +MESSAGE1(CSetChevLiftBits, int, liftNum, 0); MESSAGE2(CSetChevPanelBitMsg, int, value1, 0, int, value2, 0); MESSAGE1(CSetChevPanelButtonsMsg, int, value, 0); -MESSAGE1(CSetChevRoomBits, int, value, 0); +MESSAGE1(CSetChevRoomBits, int, roomNum, 0); MESSAGE1(CSetFrameMsg, int, frameNumber, 0); MESSAGE0(CSetMusicControlsMsg); MESSAGE2(CSetVarMsg, CString, varName, "", int, value, 0); diff --git a/engines/titanic/npcs/succubus.cpp b/engines/titanic/npcs/succubus.cpp index 9652e9c7ac..872b4f33ba 100644 --- a/engines/titanic/npcs/succubus.cpp +++ b/engines/titanic/npcs/succubus.cpp @@ -727,7 +727,7 @@ bool CSuccUBus::SUBTransition(CSUBTransition *msg) { bool CSuccUBus::SetChevRoomBits(CSetChevRoomBits *msg) { if (_enabled) { - _roomFlags = msg->_value; + _roomFlags = msg->_roomNum; playSound("z#98.wav", 100); } |