diff options
Diffstat (limited to 'engines/titanic/carry')
56 files changed, 1024 insertions, 78 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp index 880c93d309..a67937ebdf 100644 --- a/engines/titanic/carry/arm.cpp +++ b/engines/titanic/carry/arm.cpp @@ -163,7 +163,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { if (!_field158) playSound("z#47.wav", 100, 0, 0); if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CGameObject *child = static_cast<CGameObject *>(getFirstChild()); + CGameObject *child = dynamic_cast<CGameObject *>(getFirstChild()); if (child) { child->setVisible(true); petAddToInventory(); @@ -184,7 +184,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { if (_field158) { if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CCarry *child = static_cast<CCarry *>(getFirstChild()); + CCarry *child = dynamic_cast<CCarry *>(getFirstChild()); if (child) { _visibleFrame = _field170; loadFrame(_visibleFrame); diff --git a/engines/titanic/carry/auditory_centre.cpp b/engines/titanic/carry/auditory_centre.cpp index d88989a801..0bda975a36 100644 --- a/engines/titanic/carry/auditory_centre.cpp +++ b/engines/titanic/carry/auditory_centre.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CAuditoryCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) +END_MESSAGE_MAP() + void CAuditoryCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBrain::save(file, indent); @@ -34,4 +38,10 @@ void CAuditoryCentre::load(SimpleFile *file) { CBrain::load(file); } +bool CAuditoryCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = 1; + setVisible(true); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/auditory_centre.h b/engines/titanic/carry/auditory_centre.h index 743f8f2498..6f24e86208 100644 --- a/engines/titanic/carry/auditory_centre.h +++ b/engines/titanic/carry/auditory_centre.h @@ -28,6 +28,8 @@ namespace Titanic { class CAuditoryCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/carry/bowl_ear.cpp b/engines/titanic/carry/bowl_ear.cpp index bb5172e580..852a77899a 100644 --- a/engines/titanic/carry/bowl_ear.cpp +++ b/engines/titanic/carry/bowl_ear.cpp @@ -24,6 +24,13 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CBowlEar, CEar) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(NutPuzzleMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CBowlEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CEar::save(file, indent); @@ -34,4 +41,28 @@ void CBowlEar::load(SimpleFile *file) { CEar::load(file); } +bool CBowlEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + CBowlStateChangeMsg changeMsg(3); + changeMsg.execute("ParrotNutBowlActor"); + + return CEar::PETGainedObjectMsg(msg); +} + +bool CBowlEar::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(false); + return true; +} + +bool CBowlEar::NutPuzzleMsg(CNutPuzzleMsg *msg) { + if (msg->_value == "BowlUnlocked") + _fieldE0 = 1; + + return true; +} + +bool CBowlEar::MouseDragStartMsg(CMouseDragStartMsg *msg) { + setVisible(true); + return CEar::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/bowl_ear.h b/engines/titanic/carry/bowl_ear.h index 4f2fbea478..d78092f6d7 100644 --- a/engines/titanic/carry/bowl_ear.h +++ b/engines/titanic/carry/bowl_ear.h @@ -28,6 +28,11 @@ namespace Titanic { class CBowlEar : public CEar { + DECLARE_MESSAGE_MAP; + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool NutPuzzleMsg(CNutPuzzleMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp index 8df0de9961..102d8d9049 100644 --- a/engines/titanic/carry/brain.cpp +++ b/engines/titanic/carry/brain.cpp @@ -55,7 +55,7 @@ void CBrain::load(SimpleFile *file) { } bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CBrainSlot *slot = static_cast<CBrainSlot *>(msg->_other); + CBrainSlot *slot = dynamic_cast<CBrainSlot *>(msg->_other); if (slot) { if (slot->getName() == "CentralCore") { setVisible(false); diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp index fc845feff0..a2cb23add6 100644 --- a/engines/titanic/carry/bridge_piece.cpp +++ b/engines/titanic/carry/bridge_piece.cpp @@ -52,17 +52,17 @@ void CBridgePiece::load(SimpleFile *file) { } bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CShipSetting *shipSetting = static_cast<CShipSetting *>(msg->_other); + CShipSetting *shipSetting = dynamic_cast<CShipSetting *>(msg->_other); if (!shipSetting) { return CCarry::UseWithOtherMsg(msg); - } else if (shipSetting->_string4 == "NULL") { + } else if (shipSetting->_itemName != "NULL") { petAddToInventory(); return true; } else { setVisible(false); playSound("z#54.wav", 100, 0, 0); setPosition(shipSetting->_pos1); - shipSetting->_string4 = getName(); + shipSetting->_itemName = getName(); petMoveToHiddenRoom(); CAddHeadPieceMsg headpieceMsg(shipSetting->getName() == _string6 ? diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index 75b3b6f35b..03798e8713 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -127,7 +127,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { return true; } - CCharacter *npc = static_cast<CCharacter *>(msg->_dropTarget); + CCharacter *npc = dynamic_cast<CCharacter *>(msg->_dropTarget); if (npc) { CUseWithCharMsg charMsg(npc); charMsg.execute(this, nullptr, 0); @@ -157,7 +157,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { } bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) { CSubAcceptCCarryMsg carryMsg; carryMsg._item = this; diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h index 72f4024904..06e446a1b5 100644 --- a/engines/titanic/carry/carry.h +++ b/engines/titanic/carry/carry.h @@ -44,11 +44,7 @@ class CCarry : public CGameObject { bool EnterViewMsg(CEnterViewMsg *msg); bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); protected: - CString _string1; - Point _origPos; - CString _fullViewName; int _fieldDC; - int _fieldE0; CString _string3; CString _string4; Point _tempPos; @@ -62,6 +58,11 @@ protected: bool _enterFrameSet; int _visibleFrame; public: + CString _string1; + int _fieldE0; + Point _origPos; + CString _fullViewName; +public: CLASSDEF; CCarry(); diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp index cf96204122..b0461ded26 100644 --- a/engines/titanic/carry/carry_parrot.cpp +++ b/engines/titanic/carry/carry_parrot.cpp @@ -111,7 +111,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { if (compareViewNameTo("ParrotLobby.Node 1.N")) { if (msg->_mousePos.x >= 75 && msg->_mousePos.x <= 565 && - !CParrot::_v2 && !CCage::_v2) { + !CParrot::_v2 && !CCage::_open) { setVisible(false); _fieldE0 = 0; CTreeItem *perchedParrot = findUnder(getRoot(), "PerchedParrot"); @@ -133,7 +133,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { actMsg.execute("ParrotCage"); } } else { - CCharacter *character = static_cast<CCharacter *>(msg->_dropTarget); + CCharacter *character = dynamic_cast<CCharacter *>(msg->_dropTarget); if (character) { CUseWithCharMsg charMsg(character); charMsg.execute(this, nullptr, 0); @@ -167,7 +167,7 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { return CCarry::PassOnDragStartMsg(msg); } - CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); @@ -181,7 +181,7 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { loadSurface(); - CCarryParrot *parrot = static_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot")); + CCarryParrot *parrot = dynamic_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot")); if (parrot) parrot->_fieldE0 = 0; @@ -189,7 +189,7 @@ bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { } bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) CParrot::_v4 = 3; @@ -198,7 +198,7 @@ bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { bool CCarryParrot::ActMsg(CActMsg *msg) { if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) { - CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); @@ -212,7 +212,7 @@ bool CCarryParrot::ActMsg(CActMsg *msg) { playSound("z#475.wav", 100, 0, 0); if (!_field140) { - CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers")); + CCarry *feathers = dynamic_cast<CCarry *>(getRoot()->findByName("Feathers")); if (feathers) { feathers->setVisible(true); feathers->petAddToInventory(); 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/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp index 65404dc65d..0e8f6b3653 100644 --- a/engines/titanic/carry/chicken.cpp +++ b/engines/titanic/carry/chicken.cpp @@ -80,7 +80,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { petAddToInventory(); } else { - CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other); + CSauceDispensor *dispensor = dynamic_cast<CSauceDispensor *>(msg->_other); if (!dispensor || _string6 == "None") { return CCarry::UseWithOtherMsg(msg); } else { @@ -94,7 +94,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { } bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) { setPosition(Point(330, 300)); CSubAcceptCCarryMsg acceptMsg; diff --git a/engines/titanic/carry/chicken.h b/engines/titanic/carry/chicken.h index 65fe30fd81..e64ae458a4 100644 --- a/engines/titanic/carry/chicken.h +++ b/engines/titanic/carry/chicken.h @@ -41,7 +41,7 @@ class CChicken : public CCarry { bool MouseDragEndMsg(CMouseDragEndMsg *msg); bool PETObjectStateMsg(CPETObjectStateMsg *msg); bool PETLostObjectMsg(CPETLostObjectMsg *msg); -private: +public: static int _v1; public: int _field12C; diff --git a/engines/titanic/carry/crushed_tv.cpp b/engines/titanic/carry/crushed_tv.cpp index a265b611a9..486537d28e 100644 --- a/engines/titanic/carry/crushed_tv.cpp +++ b/engines/titanic/carry/crushed_tv.cpp @@ -76,5 +76,4 @@ bool CCrushedTV::MouseDragStartMsg(CMouseDragStartMsg *msg) { return CCarry::MouseDragStartMsg(msg); } - } // End of namespace Titanic diff --git a/engines/titanic/carry/ear.cpp b/engines/titanic/carry/ear.cpp index 8d85e247f7..a2234bc6dc 100644 --- a/engines/titanic/carry/ear.cpp +++ b/engines/titanic/carry/ear.cpp @@ -21,9 +21,15 @@ */ #include "titanic/carry/ear.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CEar, CHeadPiece) + ON_MESSAGE(ActMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + CEar::CEar() : CHeadPiece() { } @@ -37,4 +43,25 @@ void CEar::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CEar::ActMsg(CActMsg *msg) { + if (msg->_action == "MusicSolved") + _fieldE0 = true; + return true; +} + +bool CEar::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (slot) { + setVisible(false); + petMoveToHiddenRoom(); + setPosition(Point(0, 0)); + + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute(addMsg._value == "Ear1" ? "Ear1Slot" : "Ear2Slot"); + } + + return CCarry::UseWithOtherMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/ear.h b/engines/titanic/carry/ear.h index edef873d35..a357f46bbf 100644 --- a/engines/titanic/carry/ear.h +++ b/engines/titanic/carry/ear.h @@ -28,6 +28,9 @@ namespace Titanic { class CEar : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; CEar(); diff --git a/engines/titanic/carry/eye.cpp b/engines/titanic/carry/eye.cpp index 5de1789e54..400df2fdc8 100644 --- a/engines/titanic/carry/eye.cpp +++ b/engines/titanic/carry/eye.cpp @@ -21,22 +21,119 @@ */ #include "titanic/carry/eye.h" +#include "titanic/game/head_slot.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/game/transport/lift.h" +#include "titanic/game/television.h" namespace Titanic { -CEye::CEye() : CHeadPiece(), _eyeNum(0) { +BEGIN_MESSAGE_MAP(CEye, CHeadPiece) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(PassOnDragStartMsg) +END_MESSAGE_MAP() + +CEye::CEye() : CHeadPiece(), _eyeFlag(false) { } void CEye::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_eyeNum, indent); + file->writeNumberLine(_eyeFlag, indent); CHeadPiece::save(file, indent); } void CEye::load(SimpleFile *file) { file->readNumber(); - _eyeNum = file->readNumber(); + _eyeFlag = file->readNumber(); CHeadPiece::load(file); } + +bool CEye::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (slot) { + petMoveToHiddenRoom(); + _flag = true; + CAddHeadPieceMsg headMsg(getName()); + + if (headMsg._value != "NULL") + headMsg.execute(isEquals("Eye1") ? "Eye1Slot" : "Eye2Slot"); + } else if (msg->_other->isEquals("LiftbotWithoutHead")) { + CPetControl *pet = getPetControl(); + if (!CLift::_v1 && pet->getRoomsElevatorNum() == 4) { + _eyeFlag = true; + setPosition(_origPos); + setVisible(false); + CActMsg actMsg1(getName()); + actMsg1.execute("GetLiftEye"); + + CActMsg actMsg2("AddWrongHead"); + actMsg2.execute("FaultyLiftbot"); + } + } else { + return CCarry::UseWithOtherMsg(msg); + } + + return true; +} + +bool CEye::UseWithCharMsg(CUseWithCharMsg *msg) { + CLift *lift = dynamic_cast<CLift *>(msg->_character); + if (lift && lift->getName() == "Well") { + CPetControl *pet = getPetControl(); + if (!CLift::_v1 && pet->getRoomsElevatorNum() == 4) { + _eyeFlag = true; + setPosition(_origPos); + setVisible(false); + + CActMsg actMsg1(getName()); + actMsg1.execute("GetLiftEye"); + CActMsg actMsg2("AddWrongHead"); + actMsg2.execute(msg->_character); + } + + return true; + } else { + return CHeadPiece::UseWithCharMsg(msg); + } +} + +bool CEye::ActMsg(CActMsg *msg) { + if (msg->_action == "BellbotGetLight") { + setVisible(true); + petAddToInventory(); + playSound("z#47.wav"); + + CActMsg actMsg("Eye Removed"); + actMsg.execute("1stClassState"); + } else { + _eyeFlag = false; + + CActMsg actMsg("LoseHead"); + actMsg.execute("FaultyLiftbot"); + } + + return true; +} + +bool CEye::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (isEquals("Eye1")) + CTelevision::_v5 = 0; + + return CHeadPiece::PETGainedObjectMsg(msg); +} + +bool CEye::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + setVisible(true); + if (_eyeFlag) + CTelevision::_v6 = 0; + else if (isEquals("Eye1")) + CTelevision::_v5 = 0; + + return CHeadPiece::PassOnDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/eye.h b/engines/titanic/carry/eye.h index 066a85609b..886bd39b84 100644 --- a/engines/titanic/carry/eye.h +++ b/engines/titanic/carry/eye.h @@ -28,8 +28,14 @@ namespace Titanic { class CEye : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool ActMsg(CActMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); private: - int _eyeNum; + bool _eyeFlag; public: CLASSDEF; CEye(); diff --git a/engines/titanic/carry/fruit.cpp b/engines/titanic/carry/fruit.cpp index 832dccf45a..68f3af7229 100644 --- a/engines/titanic/carry/fruit.cpp +++ b/engines/titanic/carry/fruit.cpp @@ -21,9 +21,17 @@ */ #include "titanic/carry/fruit.h" +#include "titanic/npcs/character.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CFruit, CCarry) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(LemonFallsFromTreeMsg) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + CFruit::CFruit() : CCarry(), _field12C(0), _field130(0), _field134(0), _field138(0) { } @@ -48,4 +56,43 @@ void CFruit::load(SimpleFile *file) { CCarry::load(file); } +bool CFruit::UseWithCharMsg(CUseWithCharMsg *msg) { + if (msg->_character->isEquals("Barbot") && msg->_character->_visible) { + CActMsg actMsg("Fruit"); + actMsg.execute(msg->_character); + _fieldE0 = 0; + setVisible(false); + return true; + } else { + return CCarry::UseWithCharMsg(msg); + } +} + +bool CFruit::LemonFallsFromTreeMsg(CLemonFallsFromTreeMsg *msg) { + setVisible(true); + dragMove(msg->_pt); + _field130 = 1; + return true; +} + +bool CFruit::UseWithOtherMsg(CUseWithOtherMsg *msg) { + petAddToInventory(); + return true; +} + +bool CFruit::FrameMsg(CFrameMsg *msg) { + if (_field130) { + if (_bounds.top > 240) { + _field130 = 0; + _field134 = 1; + } + + makeDirty(); + _bounds.top += 3; + makeDirty(); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/fruit.h b/engines/titanic/carry/fruit.h index 93fe920740..bcbd314de8 100644 --- a/engines/titanic/carry/fruit.h +++ b/engines/titanic/carry/fruit.h @@ -28,6 +28,11 @@ namespace Titanic { class CFruit : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool LemonFallsFromTreeMsg(CLemonFallsFromTreeMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool FrameMsg(CFrameMsg *msg); private: int _field12C; int _field130; diff --git a/engines/titanic/carry/glass.cpp b/engines/titanic/carry/glass.cpp index 051457af03..03050dc60d 100644 --- a/engines/titanic/carry/glass.cpp +++ b/engines/titanic/carry/glass.cpp @@ -21,9 +21,21 @@ */ #include "titanic/carry/glass.h" +#include "titanic/carry/chicken.h" +#include "titanic/game/sauce_dispensor.h" +#include "titanic/npcs/character.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CGlass, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + CGlass::CGlass() : CCarry(), _string6("None") { } @@ -39,4 +51,108 @@ void CGlass::load(SimpleFile *file) { CCarry::load(file); } +bool CGlass::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CSauceDispensor *dispensor = dynamic_cast<CSauceDispensor *>(msg->_other); + CChicken *chicken = dynamic_cast<CChicken *>(msg->_other); + + if (dispensor && _string6 != "None") { + CUse useMsg(this); + useMsg.execute(dispensor); + } else if (msg->_other->isEquals("Chicken") && _string6 != "None") { + if (chicken->_string6 != "None") { + if (!chicken->_field12C) { + CActMsg actMsg(_string6); + actMsg.execute("Chicken"); + } + + _string6 = "None"; + loadFrame(0); + _visibleFrame = 0; + } + + petAddToInventory(); + } else if (msg->_other->isEquals("Napkin") && _string6 != "None") { + petAddToInventory(); + _string6 = "None"; + loadFrame(0); + _visibleFrame = 0; + } else { + petAddToInventory(); + } + + return true; +} + +bool CGlass::UseWithCharMsg(CUseWithCharMsg *msg) { + if (msg->_character->isEquals("Barbot") && msg->_character->_visible) { + CActMsg actMsg(_string6); + setVisible(false); + + if (_string6 != "Bird") + setPosition(_origPos); + + actMsg.execute(msg->_character); + } else { + petAddToInventory(); + } + + return true; +} + +bool CGlass::ActMsg(CActMsg *msg) { + if (msg->_action == "GoToPET") { + setVisible(true); + petAddToInventory(); + } else if (msg->_action == "Mustard") { + _string6 = "Mustard"; + loadFrame(1); + _visibleFrame = 1; + } else if (msg->_action == "Tomato") { + _string6 = "Tomato"; + loadFrame(2); + _visibleFrame = 2; + } else if (msg->_action == "Bird") { + _string6 = "Bird"; + loadFrame(3); + _visibleFrame = 3; + } else if (msg->_action == "InTitilator") { + _string6 = "None"; + loadFrame(0); + _visibleFrame = 0; + } + + return true; +} + +bool CGlass::MouseDragEndMsg(CMouseDragEndMsg *msg) { + showMouse(); + if (msg->_dropTarget) { + error("TODO: See what drop target is"); + CCharacter *npc = dynamic_cast<CCharacter *>(msg->_dropTarget); + if (npc) { + CUseWithCharMsg useMsg(npc); + useMsg.execute(this); + } else { + CUseWithOtherMsg otherMsg(npc); + otherMsg.execute(this); + } + } else if (compareViewNameTo(_fullViewName) && msg->_mousePos.y < 360) { + setPosition(_origPos); + } else { + petAddToInventory(); + } + + return true; +} + +bool CGlass::TurnOn(CTurnOn *msg) { + setVisible(true); + return true; +} + +bool CGlass::TurnOff(CTurnOff *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/glass.h b/engines/titanic/carry/glass.h index 9f4056b1be..608d45cb66 100644 --- a/engines/titanic/carry/glass.h +++ b/engines/titanic/carry/glass.h @@ -28,7 +28,14 @@ namespace Titanic { class CGlass : public CCarry { -private: + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool ActMsg(CActMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); +public: CString _string6; public: CLASSDEF; diff --git a/engines/titanic/carry/hammer.cpp b/engines/titanic/carry/hammer.cpp index d3b912184c..88c766d564 100644 --- a/engines/titanic/carry/hammer.cpp +++ b/engines/titanic/carry/hammer.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CHammer, CCarry) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + CHammer::CHammer() : CCarry() { } @@ -37,4 +42,22 @@ void CHammer::load(SimpleFile *file) { CCarry::load(file); } +bool CHammer::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = 1; + return true; +} + +bool CHammer::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CString name = msg->_other->getName(); + if (name == "LongStickDispenser") { + CPuzzleSolvedMsg solvedMsg; + solvedMsg.execute("LongStickDispenser"); + } else if (name == "Bomb") { + CActMsg actMsg("Hit"); + actMsg.execute("Bomb"); + } + + return CCarry::UseWithOtherMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/hammer.h b/engines/titanic/carry/hammer.h index a455d71434..8cc86f3db1 100644 --- a/engines/titanic/carry/hammer.h +++ b/engines/titanic/carry/hammer.h @@ -28,6 +28,9 @@ namespace Titanic { class CHammer : public CCarry { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; CHammer(); diff --git a/engines/titanic/carry/head_piece.cpp b/engines/titanic/carry/head_piece.cpp index ae709644a0..34850488a7 100644 --- a/engines/titanic/carry/head_piece.cpp +++ b/engines/titanic/carry/head_piece.cpp @@ -24,13 +24,19 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CHeadPiece, CCarry) + ON_MESSAGE(SenseWorkingMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CHeadPiece::CHeadPiece() : CCarry(), _string6("Not Working"), - _field12C(0), _field13C(0) { + _flag(0), _field13C(false) { } void CHeadPiece::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_flag, indent); file->writeQuotedLine(_string6, indent); file->writeNumberLine(_field13C, indent); @@ -39,11 +45,49 @@ void CHeadPiece::save(SimpleFile *file, int indent) { void CHeadPiece::load(SimpleFile *file) { file->readNumber(); - _field12C = file->readNumber(); + _flag = file->readNumber(); _string6 = file->readString(); _field13C = file->readNumber(); CCarry::load(file); } +bool CHeadPiece::SenseWorkingMsg(CSenseWorkingMsg *msg) { + _string6 = msg->_value; + return true; +} + +bool CHeadPiece::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + _visibleFrame = 1; + if (!_field13C) { + stateInc38(); + _field13C = true; + } + + return true; +} + +bool CHeadPiece::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkPoint(msg->_mousePos, false, true)) { + return false; + } else if (!_fieldE0) { + return true; + } + + if (_flag) { + setVisible(true); + moveToView(); + setPosition(Point(msg->_mousePos.x - _bounds.width() / 2, + msg->_mousePos.y - _bounds.height() / 2)); + + CTakeHeadPieceMsg takeMsg(getName()); + if (takeMsg._value != "NULL") + takeMsg.execute("TitaniaControl"); + + _flag = false; + } + + return CCarry::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/head_piece.h b/engines/titanic/carry/head_piece.h index 05ac772853..367f781f0e 100644 --- a/engines/titanic/carry/head_piece.h +++ b/engines/titanic/carry/head_piece.h @@ -24,14 +24,19 @@ #define TITANIC_HEAD_PIECE_H #include "titanic/carry/carry.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CHeadPiece : public CCarry { -private: - int _field12C; + DECLARE_MESSAGE_MAP; + bool SenseWorkingMsg(CSenseWorkingMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); +protected: + bool _flag; CString _string6; - int _field13C; + bool _field13C; public: CLASSDEF; CHeadPiece(); diff --git a/engines/titanic/carry/hose.cpp b/engines/titanic/carry/hose.cpp index 747d58c339..e90119138a 100644 --- a/engines/titanic/carry/hose.cpp +++ b/engines/titanic/carry/hose.cpp @@ -21,9 +21,18 @@ */ #include "titanic/carry/hose.h" +#include "titanic/npcs/succubus.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CHose, CCarry) + ON_MESSAGE(DropZoneGotObjectMsg) + ON_MESSAGE(PumpingMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(HoseConnectedMsg) + ON_MESSAGE(DropZoneLostObjectMsg) +END_MESSAGE_MAP() + CHoseStatics *CHose::_statics; void CHose::init() { @@ -40,18 +49,72 @@ CHose::CHose() : CCarry(), void CHose::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_statics->_v1, indent); - file->writeQuotedLine(_statics->_v2, indent); + file->writeNumberLine(_statics->_actionVal, indent); + file->writeQuotedLine(_statics->_actionTarget, indent); file->writeQuotedLine(_string6, indent); CCarry::save(file, indent); } void CHose::load(SimpleFile *file) { file->readNumber(); - _statics->_v1 = file->readNumber(); - _statics->_v2 = file->readString(); + _statics->_actionVal = file->readNumber(); + _statics->_actionTarget = file->readString(); _string6 = file->readString(); CCarry::load(file); } +bool CHose::DropZoneGotObjectMsg(CDropZoneGotObjectMsg *msg) { + _statics->_actionTarget = msg->_object->getName(); + CPumpingMsg pumpingMsg; + pumpingMsg._value = _statics->_actionVal; + pumpingMsg.execute(_statics->_actionTarget); + CHoseConnectedMsg connectedMsg; + connectedMsg._value = 1; + connectedMsg.execute(this); + + return true; +} + +bool CHose::PumpingMsg(CPumpingMsg *msg) { + _statics->_actionVal = msg->_value; + if (!_statics->_actionTarget.empty()) { + CPumpingMsg pumpingMsg; + pumpingMsg._value = _statics->_actionVal; + pumpingMsg.execute(_statics->_actionTarget); + } + + return true; +} + +bool CHose::UseWithCharMsg(CUseWithCharMsg *msg) { + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); + if (!_statics->_actionVal && succubus) { + CHoseConnectedMsg connectedMsg(1, this); + if (connectedMsg.execute(succubus)) + return true; + } + + return CCarry::UseWithCharMsg(msg); +} + +bool CHose::HoseConnectedMsg(CHoseConnectedMsg *msg) { + if (msg->_value) { + CHose *hose = dynamic_cast<CHose *>(findChildInstanceOf(CHose::_type)); + if (hose) { + setVisible(true); + petAddToInventory(); + } + } + + return true; +} + +bool CHose::DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg) { + CPumpingMsg pumpingMsg; + pumpingMsg._value = 0; + pumpingMsg.execute(msg->_object); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/hose.h b/engines/titanic/carry/hose.h index ebd45860e8..3c8c1549c1 100644 --- a/engines/titanic/carry/hose.h +++ b/engines/titanic/carry/hose.h @@ -28,16 +28,23 @@ namespace Titanic { struct CHoseStatics { - int _v1; - CString _v2; + int _actionVal; + CString _actionTarget; + CHoseStatics() : _actionVal(0) {} }; class CHose : public CCarry { + DECLARE_MESSAGE_MAP; + bool DropZoneGotObjectMsg(CDropZoneGotObjectMsg *msg); + bool PumpingMsg(CPumpingMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool HoseConnectedMsg(CHoseConnectedMsg *msg); + bool DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg); protected: - static CHoseStatics *_statics; - CString _string6; public: + static CHoseStatics *_statics; +public: CLASSDEF; CHose(); static void init(); diff --git a/engines/titanic/carry/key.cpp b/engines/titanic/carry/key.cpp index 6e947464f1..187ff1b6c3 100644 --- a/engines/titanic/carry/key.cpp +++ b/engines/titanic/carry/key.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CKey, CCarry) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + CKey::CKey() : CCarry() { } @@ -37,4 +42,19 @@ void CKey::load(SimpleFile *file) { CCarry::load(file); } +bool CKey::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = 1; + setVisible(true); + return true; +} + +bool CKey::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->getName() == "1stClassPhono") { + CActMsg actMsg("Unlock"); + actMsg.execute(msg->_other); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/key.h b/engines/titanic/carry/key.h index 8f1600f2b3..9d3957937c 100644 --- a/engines/titanic/carry/key.h +++ b/engines/titanic/carry/key.h @@ -28,6 +28,9 @@ namespace Titanic { class CKey : public CCarry { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; CKey(); diff --git a/engines/titanic/carry/liftbot_head.cpp b/engines/titanic/carry/liftbot_head.cpp index bcab8e8574..5f516fcf8c 100644 --- a/engines/titanic/carry/liftbot_head.cpp +++ b/engines/titanic/carry/liftbot_head.cpp @@ -21,22 +21,83 @@ */ #include "titanic/carry/liftbot_head.h" +#include "titanic/game/transport/lift.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { -CLiftbotHead::CLiftbotHead() : CCarry(), _field12C(0) { +BEGIN_MESSAGE_MAP(CLiftbotHead, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + +CLiftbotHead::CLiftbotHead() : CCarry(), _flag(false) { } void CLiftbotHead::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_flag, indent); CCarry::save(file, indent); } void CLiftbotHead::load(SimpleFile *file) { file->readNumber(); - _field12C = file->readNumber(); + _flag = file->readNumber(); CCarry::load(file); } +bool CLiftbotHead::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->getName() == "LiftbotWithoutHead") { + CPetControl *pet = getPetControl(); + if (CLift::_v1 == 1 && pet->getRoomsElevatorNum() == 4) { + _flag = true; + CActMsg actMsg("AddRightHead"); + actMsg.execute("FaultyLiftbot"); + setVisible(false); + } + + return true; + } else { + return CCarry::UseWithOtherMsg(msg); + } +} + +bool CLiftbotHead::UseWithCharMsg(CUseWithCharMsg *msg) { + CLift *lift = dynamic_cast<CLift *>(msg->_character); + if (lift) { + CPetControl *pet = getPetControl(); + if (lift->isEquals("Well") && !CLift::_v1 && pet->getRoomsElevatorNum() == 4) { + _flag = true; + CActMsg actMsg("AddRightHead"); + actMsg.execute(lift); + setVisible(false); + + return true; + } + } + + return CCarry::UseWithCharMsg(msg); +} + +bool CLiftbotHead::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) { + return false; + } else if (compareViewNameTo("BottomOfWell.Node 8.N")) { + changeView("BottomOfWell.Node 13.N"); + moveToView(); + + CActMsg actMsg("LiftbotHeadTaken"); + actMsg.execute("BOWLiftbotHeadMonitor"); + + return CCarry::MouseDragStartMsg(msg); + } else if (_flag) { + _flag = false; + CActMsg actMsg("LoseHead"); + actMsg.execute("FaultyLiftbot"); + } + + return CCarry::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/liftbot_head.h b/engines/titanic/carry/liftbot_head.h index 2fcd6a71f9..44cc51c993 100644 --- a/engines/titanic/carry/liftbot_head.h +++ b/engines/titanic/carry/liftbot_head.h @@ -28,8 +28,12 @@ namespace Titanic { class CLiftbotHead : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: - int _field12C; + bool _flag; public: CLASSDEF; CLiftbotHead(); diff --git a/engines/titanic/carry/long_stick.cpp b/engines/titanic/carry/long_stick.cpp index ab1e42b81f..557b75ab87 100644 --- a/engines/titanic/carry/long_stick.cpp +++ b/engines/titanic/carry/long_stick.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CLongStick, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + CLongStick::CLongStick() : CCarry() { } @@ -37,4 +43,30 @@ void CLongStick::load(SimpleFile *file) { CCarry::load(file); } +bool CLongStick::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->isEquals("SpeechCentre")) { + CPuzzleSolvedMsg puzzleMsg; + puzzleMsg.execute(msg->_other); + } else if (msg->_other->isEquals("LongStickDispensor")) { + petDisplayMessage(1, "You already have one."); + } else if (msg->_other->isEquals("Bomb")) { + CActMsg actMsg("Hit"); + actMsg.execute("Bomb"); + } else { + return CCarry::UseWithOtherMsg(msg); + } + + return true; +} + +bool CLongStick::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = 1; + return true; +} + +bool CLongStick::LeaveViewMsg(CLeaveViewMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/long_stick.h b/engines/titanic/carry/long_stick.h index 2ff5b7228e..329ca838f9 100644 --- a/engines/titanic/carry/long_stick.h +++ b/engines/titanic/carry/long_stick.h @@ -28,6 +28,10 @@ namespace Titanic { class CLongStick : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: CLASSDEF; CLongStick(); diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp index cdf92fc707..e68c63f8f9 100644 --- a/engines/titanic/carry/magazine.cpp +++ b/engines/titanic/carry/magazine.cpp @@ -52,7 +52,7 @@ void CMagazine::load(SimpleFile *file) { } bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { - CDeskbot *deskbot = static_cast<CDeskbot *>(msg->_character); + CDeskbot *deskbot = dynamic_cast<CDeskbot *>(msg->_character); if (deskbot) { if (deskbot->_deskbotActive) { setVisible(false); diff --git a/engines/titanic/carry/maitred_left_arm.cpp b/engines/titanic/carry/maitred_left_arm.cpp index b31c2a6f6d..0962f232bd 100644 --- a/engines/titanic/carry/maitred_left_arm.cpp +++ b/engines/titanic/carry/maitred_left_arm.cpp @@ -21,19 +21,48 @@ */ #include "titanic/carry/maitred_left_arm.h" +#include "titanic/npcs/true_talk_npc.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMaitreDLeftArm, CArm) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CMaitreDLeftArm::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field174, indent); + file->writeNumberLine(_flag, indent); CArm::save(file, indent); } void CMaitreDLeftArm::load(SimpleFile *file) { file->readNumber(); - _field174 = file->readNumber(); + _flag = file->readNumber(); CArm::load(file); } +bool CMaitreDLeftArm::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_flag) { + CTrueTalkNPC *maitreD = dynamic_cast<CTrueTalkNPC *>(findRoomObject("MaitreD")); + startTalking(maitreD, 126); + startTalking(maitreD, 127); + } + + return true; +} + +bool CMaitreDLeftArm::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (checkPoint(msg->_mousePos) && !_flag) { + CVisibleMsg visibleMsg; + visibleMsg.execute("MD left arm background image"); + _flag = true; + + CArmPickedUpFromTableMsg takenMsg; + takenMsg.execute("Restaurant Table Pan Handler", nullptr, MSGFLAG_SCAN); + } + + return CArm::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/maitred_left_arm.h b/engines/titanic/carry/maitred_left_arm.h index 8f5090b073..0e1732df46 100644 --- a/engines/titanic/carry/maitred_left_arm.h +++ b/engines/titanic/carry/maitred_left_arm.h @@ -28,11 +28,14 @@ namespace Titanic { class CMaitreDLeftArm : public CArm { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: - int _field174; + bool _flag; public: CLASSDEF; - CMaitreDLeftArm() : CArm(), _field174(0) {} + CMaitreDLeftArm() : CArm(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/carry/maitred_right_arm.cpp b/engines/titanic/carry/maitred_right_arm.cpp index 7030e83c9d..5cec6be9bd 100644 --- a/engines/titanic/carry/maitred_right_arm.cpp +++ b/engines/titanic/carry/maitred_right_arm.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMaitreDRightArm, CArm) + ON_MESSAGE(DropZoneLostObjectMsg) +END_MESSAGE_MAP() + void CMaitreDRightArm::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CArm::save(file, indent); @@ -34,4 +38,12 @@ void CMaitreDRightArm::load(SimpleFile *file) { CArm::load(file); } +bool CMaitreDRightArm::DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg) { + CActMsg actMsg("LoseArm"); + actMsg.execute("MaitreDBody"); + actMsg.execute("MaitreD Arm Holder"); + _fieldE0 = 1; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/maitred_right_arm.h b/engines/titanic/carry/maitred_right_arm.h index ce07ed7af4..4a53d45f69 100644 --- a/engines/titanic/carry/maitred_right_arm.h +++ b/engines/titanic/carry/maitred_right_arm.h @@ -28,6 +28,8 @@ namespace Titanic { class CMaitreDRightArm : public CArm { + DECLARE_MESSAGE_MAP; + bool DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/carry/mouth.cpp b/engines/titanic/carry/mouth.cpp index 8c3791fa9c..e48929a391 100644 --- a/engines/titanic/carry/mouth.cpp +++ b/engines/titanic/carry/mouth.cpp @@ -21,9 +21,16 @@ */ #include "titanic/carry/mouth.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMouth, CHeadPiece) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(PETGainedObjectMsg) +END_MESSAGE_MAP() + CMouth::CMouth() : CHeadPiece() { } @@ -37,4 +44,37 @@ void CMouth::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CMouth::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (!slot) + return CHeadPiece::UseWithOtherMsg(msg); + + _flag = true; + setVisible(false); + setPosition(Point(0, 0)); + petMoveToHiddenRoom(); + + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute("MouthSlot"); + + return true; +} + +bool CMouth::MovieEndMsg(CMovieEndMsg *msg) { + return true; +} + +bool CMouth::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + _visibleFrame = 2; + loadFrame(2); + setVisible(true); + if (!_field13C) { + stateInc38(); + _field13C = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/mouth.h b/engines/titanic/carry/mouth.h index e394330494..f5f0f53b45 100644 --- a/engines/titanic/carry/mouth.h +++ b/engines/titanic/carry/mouth.h @@ -28,6 +28,10 @@ namespace Titanic { class CMouth : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); public: CLASSDEF; CMouth(); diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp index ace5a389a0..d0ee9acc1a 100644 --- a/engines/titanic/carry/napkin.cpp +++ b/engines/titanic/carry/napkin.cpp @@ -43,7 +43,7 @@ void CNapkin::load(SimpleFile *file) { } bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CChicken *chicken = static_cast<CChicken *>(msg->_other); + CChicken *chicken = dynamic_cast<CChicken *>(msg->_other); if (chicken) { if (chicken->_string6 == "None" || chicken->_field12C) { CActMsg actMsg("Clean"); @@ -57,5 +57,4 @@ bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { return CCarry::UseWithOtherMsg(msg); } - } // End of namespace Titanic diff --git a/engines/titanic/carry/nose.cpp b/engines/titanic/carry/nose.cpp index 4f3afe24ac..a08d02a88c 100644 --- a/engines/titanic/carry/nose.cpp +++ b/engines/titanic/carry/nose.cpp @@ -21,9 +21,15 @@ */ #include "titanic/carry/nose.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CNose, CHeadPiece) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + CNose::CNose() : CHeadPiece() { } @@ -37,4 +43,23 @@ void CNose::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CNose::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + // WORKAROUND: Redundant code in original skipped + return true; +} + +bool CNose::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (!slot) + return CCarry::UseWithOtherMsg(msg); + + petMoveToHiddenRoom(); + _flag = false; + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute("NoseSlot"); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/nose.h b/engines/titanic/carry/nose.h index b688da231a..6e5be30df2 100644 --- a/engines/titanic/carry/nose.h +++ b/engines/titanic/carry/nose.h @@ -28,6 +28,9 @@ namespace Titanic { class CNose : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; CNose(); diff --git a/engines/titanic/carry/perch.cpp b/engines/titanic/carry/perch.cpp index 281b3fce53..4f0e76bdb0 100644 --- a/engines/titanic/carry/perch.cpp +++ b/engines/titanic/carry/perch.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPerch, CCentralCore) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + void CPerch::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CCentralCore::save(file, indent); @@ -34,4 +38,13 @@ void CPerch::load(SimpleFile *file) { CCentralCore::load(file); } +bool CPerch::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->isEquals("SpeechCentre")) { + CShowTextMsg textMsg("This does not reach."); + textMsg.execute("PET"); + } + + return CCentralCore::UseWithOtherMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/perch.h b/engines/titanic/carry/perch.h index d23868d909..8941c8ea4d 100644 --- a/engines/titanic/carry/perch.h +++ b/engines/titanic/carry/perch.h @@ -28,6 +28,8 @@ namespace Titanic { class CPerch : public CCentralCore { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp index 0684c56611..3dedbc4ac9 100644 --- a/engines/titanic/carry/phonograph_cylinder.cpp +++ b/engines/titanic/carry/phonograph_cylinder.cpp @@ -22,6 +22,7 @@ #include "titanic/carry/phonograph_cylinder.h" #include "titanic/game/phonograph.h" +#include "titanic/sound/music_room.h" namespace Titanic { @@ -101,7 +102,7 @@ void CPhonographCylinder::load(SimpleFile *file) { } bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CPhonograph *phonograph = static_cast<CPhonograph *>(msg->_other); + CPhonograph *phonograph = dynamic_cast<CPhonograph *>(msg->_other); if (phonograph) { CSetVarMsg varMsg("m_RecordStatus", 1); return true; @@ -162,10 +163,33 @@ bool CPhonographCylinder::RecordOntoCylinderMsg(CRecordOntoCylinderMsg *msg) { } bool CPhonographCylinder::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { - if (_itemName.left(7) == "STMusic") { - //todo - warning("TODO"); - } + if (!_itemName.hasPrefix("STMusic")) + return true; + + CMusicRoom *musicRoom = getMusicRoom(); + musicRoom->setMuteControl(BELLS, _bellsMuteControl); + musicRoom->setPitchControl(BELLS, _bellsPitchControl); + musicRoom->setSpeedControl(BELLS, _bellsSpeedControl); + musicRoom->setInversionControl(BELLS, _bellsInversionControl); + musicRoom->setDirectionControl(BELLS, _bellsDirectionControl); + + musicRoom->setMuteControl(SNAKE, _snakeMuteControl); + musicRoom->setPitchControl(SNAKE, _snakePitchControl); + musicRoom->setSpeedControl(SNAKE, _snakeSpeedControl); + musicRoom->setInversionControl(SNAKE, _snakeInversionControl); + musicRoom->setDirectionControl(SNAKE, _snakeDirectionControl); + + musicRoom->setMuteControl(PIANO, _pianoMuteControl); + musicRoom->setPitchControl(PIANO, _pianoPitchControl); + musicRoom->setSpeedControl(PIANO, _pianoSpeedControl); + musicRoom->setInversionControl(PIANO, _pianoInversionControl); + musicRoom->setDirectionControl(PIANO, _pianoDirectionControl); + + musicRoom->setMuteControl(BASS, _bassMuteControl); + musicRoom->setPitchControl(BASS, _bassPitchControl); + musicRoom->setSpeedControl(BASS, _bassSpeedControl); + musicRoom->setInversionControl(BASS, _bassInversionControl); + musicRoom->setDirectionControl(BASS, _bassDirectionControl); return true; } diff --git a/engines/titanic/carry/phonograph_ear.cpp b/engines/titanic/carry/phonograph_ear.cpp index ceb71babd2..95297a77a1 100644 --- a/engines/titanic/carry/phonograph_ear.cpp +++ b/engines/titanic/carry/phonograph_ear.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPhonographEar, CEar) + ON_MESSAGE(CorrectMusicPlayedMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(TimerMsg) +END_MESSAGE_MAP() + void CPhonographEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field140, indent); @@ -36,4 +42,24 @@ void CPhonographEar::load(SimpleFile *file) { CEar::load(file); } +bool CPhonographEar::CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg) { + _fieldE0 = true; + return true; +} + +bool CPhonographEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (_field140) { + _field140 = false; + addTimer(1000); + } + + return CEar::PETGainedObjectMsg(msg); +} + +bool CPhonographEar::TimerMsg(CTimerMsg *msg) { + CVisibleMsg visibleMsg; + visibleMsg.execute("Replacement Phonograph Ear"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/phonograph_ear.h b/engines/titanic/carry/phonograph_ear.h index 582db9f7ef..b5db015f90 100644 --- a/engines/titanic/carry/phonograph_ear.h +++ b/engines/titanic/carry/phonograph_ear.h @@ -28,11 +28,15 @@ namespace Titanic { class CPhonographEar : public CEar { + DECLARE_MESSAGE_MAP; + bool CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool TimerMsg(CTimerMsg *msg); private: - int _field140; + bool _field140; public: CLASSDEF; - CPhonographEar() : CEar(), _field140(1) {} + CPhonographEar() : CEar(), _field140(true) {} /** * Save the data for the class to file diff --git a/engines/titanic/carry/photograph.cpp b/engines/titanic/carry/photograph.cpp index 7f32a0623d..039efd0252 100644 --- a/engines/titanic/carry/photograph.cpp +++ b/engines/titanic/carry/photograph.cpp @@ -21,6 +21,7 @@ */ #include "titanic/carry/photograph.h" +#include "titanic/core/dont_save_file_item.h" #include "titanic/core/room_item.h" namespace Titanic { @@ -59,8 +60,12 @@ bool CPhotograph::MouseDragEndMsg(CMouseDragEndMsg *msg) { _v1 = 0; CGameObject *target = msg->_dropTarget; - if (target && target->getName() != "NavigationComputer") { - warning("TODO: CPhotograph::MouseDragEndMsg"); + if (target && target->isEquals("NavigationComputer")) { + moveUnder(getDontSave()); + makeDirty(); + playSound("a#46.wav"); + starFn1(14); + showMouse(); return true; } else { return CCarry::MouseDragEndMsg(msg); @@ -78,7 +83,7 @@ bool CPhotograph::MouseDragStartMsg(CMouseDragStartMsg *msg) { } bool CPhotograph::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { - if (getRoom()->getName() == "Home") { + if (getRoom()->isEquals("Home")) { CActMsg actMsg("PlayerPutsPhotoInPET"); actMsg.execute("Doorbot"); } diff --git a/engines/titanic/carry/plug_in.cpp b/engines/titanic/carry/plug_in.cpp index c82a4cc422..883458c9b1 100644 --- a/engines/titanic/carry/plug_in.cpp +++ b/engines/titanic/carry/plug_in.cpp @@ -47,19 +47,13 @@ bool CPlugIn::UseWithOtherMsg(CUseWithOtherMsg *msg) { if (otherName == "PET") { return CCarry::UseWithOtherMsg(msg); - } else if (otherName == "DatasideTransporter") { - CString name = getName(); - if (name == "DatasideTransporter") { - // TODO - if (name != "SendYourself") { - // TODO - } - } else { - // TODO - } - } else { + } else if (isEquals("DatasideTransporter")) { CShowTextMsg textMsg("This item is incorrectly calibrated."); textMsg.execute("PET"); + } else if (isEquals("DatasideTransporter")) { + error("TODO: Set msg->_other->fieldC4 = 2"); + } else if (isEquals("SendYourself")) { + error("TODO: Set msg->_other->fieldC8 = 1"); } return true; diff --git a/engines/titanic/carry/speech_centre.cpp b/engines/titanic/carry/speech_centre.cpp index b8076aee76..29ced484a5 100644 --- a/engines/titanic/carry/speech_centre.cpp +++ b/engines/titanic/carry/speech_centre.cpp @@ -24,10 +24,17 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSpeechCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(SpeechFallsFromTreeMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + void CSpeechCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field13C, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_season, indent); file->writeNumberLine(_field14C, indent); CBrain::save(file, indent); @@ -36,10 +43,41 @@ void CSpeechCentre::save(SimpleFile *file, int indent) { void CSpeechCentre::load(SimpleFile *file) { file->readNumber(); _field13C = file->readNumber(); - _string1 = file->readString(); + _season = file->readString(); _field14C = file->readNumber(); CBrain::load(file); } +bool CSpeechCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + if (_field13C == 1 && _season == "Autumn") + _fieldE0 = true; + return true; +} + +bool CSpeechCentre::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _season = msg->_season; + return true; +} + +bool CSpeechCentre::SpeechFallsFromTreeMsg(CSpeechFallsFromTreeMsg *msg) { + setVisible(true); + dragMove(msg->_pos); + _field14C = true; + return true; +} + +bool CSpeechCentre::FrameMsg(CFrameMsg *msg) { + if (_field14C) { + if (_bounds.top > 200) + _field14C = false; + + makeDirty(); + _bounds.top += 3; + makeDirty(); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/speech_centre.h b/engines/titanic/carry/speech_centre.h index 50f47e9c8a..806e22247b 100644 --- a/engines/titanic/carry/speech_centre.h +++ b/engines/titanic/carry/speech_centre.h @@ -28,13 +28,18 @@ namespace Titanic { class CSpeechCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool SpeechFallsFromTreeMsg(CSpeechFallsFromTreeMsg *msg); + bool FrameMsg(CFrameMsg *msg); private: int _field13C; - CString _string1; + CString _season; int _field14C; public: CLASSDEF; - CSpeechCentre() : CBrain(), _string1("Summer"), + CSpeechCentre() : CBrain(), _season("Summer"), _field13C(1), _field14C(0) {} /** diff --git a/engines/titanic/carry/vision_centre.cpp b/engines/titanic/carry/vision_centre.cpp index 8c8bab15f8..fd30089fc5 100644 --- a/engines/titanic/carry/vision_centre.cpp +++ b/engines/titanic/carry/vision_centre.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CVisionCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CVisionCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBrain::save(file, indent); @@ -34,4 +40,27 @@ void CVisionCentre::load(SimpleFile *file) { CBrain::load(file); } +bool CVisionCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = true; + return true; +} + +bool CVisionCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + return CBrain::MouseButtonDownMsg(msg); + } else { + petDisplayMessage(1, "It would be nice if you could take that but you can't."); + return true; + } +} + +bool CVisionCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_fieldE0) { + return CBrain::MouseDragStartMsg(msg); + } else { + petDisplayMessage(1, "It would be nice if you could take that but you can't."); + return true; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/vision_centre.h b/engines/titanic/carry/vision_centre.h index 6cf8e2c653..14055a5f5f 100644 --- a/engines/titanic/carry/vision_centre.h +++ b/engines/titanic/carry/vision_centre.h @@ -28,6 +28,10 @@ namespace Titanic { class CVisionCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; |
