diff options
-rw-r--r-- | engines/titanic/carry/liftbot_head.cpp | 67 | ||||
-rw-r--r-- | engines/titanic/carry/liftbot_head.h | 6 | ||||
-rw-r--r-- | engines/titanic/carry/long_stick.cpp | 32 | ||||
-rw-r--r-- | engines/titanic/carry/long_stick.h | 4 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 20 | ||||
-rw-r--r-- | engines/titanic/game/light.cpp | 89 | ||||
-rw-r--r-- | engines/titanic/game/light.h | 8 | ||||
-rw-r--r-- | engines/titanic/game/light_switch.cpp | 102 | ||||
-rw-r--r-- | engines/titanic/game/light_switch.h | 11 | ||||
-rw-r--r-- | engines/titanic/game/little_lift_button.cpp | 25 | ||||
-rw-r--r-- | engines/titanic/game/little_lift_button.h | 3 | ||||
-rw-r--r-- | engines/titanic/game/television.cpp | 13 | ||||
-rw-r--r-- | engines/titanic/game/transport/lift.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/game/transport/lift.h | 4 | ||||
-rw-r--r-- | engines/titanic/game/transport/lift_indicator.cpp | 196 | ||||
-rw-r--r-- | engines/titanic/game/transport/lift_indicator.h | 15 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 17 |
17 files changed, 562 insertions, 54 deletions
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/core/game_object.h b/engines/titanic/core/game_object.h index cb6a8529fb..cafd96e38e 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -466,11 +466,6 @@ protected: CGameObject *findMail(int id) const; /** - * Remove an object from the mail list - */ - void removeMail(int id, int v); - - /** * Resets the Mail Man value */ void resetMail(); @@ -704,11 +699,6 @@ public: int getPriorClass() const; /** - * Adds an object to the mail list - */ - void addMail(int mailId); - - /** * Sets the mail identifier for an object */ void setMailId(int mailId); @@ -774,6 +764,16 @@ public: CString getRoomNodeName() const; /** + * Adds an object to the mail list + */ + void addMail(int mailId); + + /** + * Remove an object from the mail list + */ + void removeMail(int id, int v); + + /** * Return the full Id of the current view in a * room.node.view tuplet form */ diff --git a/engines/titanic/game/light.cpp b/engines/titanic/game/light.cpp index fd3c446875..65e357047e 100644 --- a/engines/titanic/game/light.cpp +++ b/engines/titanic/game/light.cpp @@ -21,9 +21,22 @@ */ #include "titanic/game/light.h" +#include "titanic/game/television.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CLight, CBackground) + ON_MESSAGE(TurnOff) + ON_MESSAGE(LightsMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(TurnOn) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + CLight::CLight() : CBackground(), _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0), _fieldF0(0), _fieldF4(0), _fieldF8(0), _fieldFC(0) { @@ -57,8 +70,82 @@ void CLight::load(SimpleFile *file) { CBackground::load(file); } +bool CLight::TurnOff(CTurnOff *msg) { + setVisible(false); + return true; +} + +bool CLight::LightsMsg(CLightsMsg *msg) { + if ((msg->_flag2 && _fieldE8) || (msg->_flag3 && _fieldEC) + || (msg->_flag1 && _fieldE4) || (msg->_flag4 && _fieldF0)) { + setVisible(true); + } else { + setVisible(false); + } + + return true; +} + +bool CLight::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + // WORKAROUND: Original code doesn't seem to do anything + return true; +} + +bool CLight::TurnOn(CTurnOn *msg) { + setVisible(true); + return true; +} + +bool CLight::StatusChangeMsg(CStatusChangeMsg *msg) { + CPetControl *pet = getPetControl(); + bool flag = pet ? pet->isRoom59706() : false; + + if (_fieldFC == 1 && flag) { + petDisplayMessage(1, "That light appears to be loose."); + playSound("z#144.wav", 70); + } else { + petDisplayMessage(1, "Lumi-Glow(tm) Lights. They glow in the dark!"); + playSound("z#62.wav", 70); + } + + return true; +} + +bool CLight::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CPetControl *pet = getPetControl(); + bool flag = pet ? pet->isRoom59706() : false; + + if (_fieldFC == 1 && flag) { + petDisplayMessage(1, "That light appears to be loose."); + playSound("z#144.wav", 70); + } else { + petDisplayMessage(1, "Lumi-Glow(tm) Lights. They glow in the dark!"); + playSound("z#62.wav", 70); + } + + return true; +} + +bool CLight::ActMsg(CActMsg *msg) { + if (msg->_action == "Eye Removed") + _fieldFC = 0; + + return true; +} + bool CLight::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CLight::handleEvent"); + CPetControl *pet = getPetControl(); + setVisible(true); + + if (isEquals("6WTL")) { + CLightsMsg lightsMsg(1, 1, 1, 1); + lightsMsg.execute("1stClassState", CLight::_type, MSGFLAG_SCAN); + + bool flag = pet ? pet->isRoom59706() : false; + if (flag) + CTelevision::_turnOn = true; + } + return true; } diff --git a/engines/titanic/game/light.h b/engines/titanic/game/light.h index 79e4bc400e..68223275e5 100644 --- a/engines/titanic/game/light.h +++ b/engines/titanic/game/light.h @@ -29,6 +29,14 @@ namespace Titanic { class CLight : public CBackground { + DECLARE_MESSAGE_MAP; + bool TurnOff(CTurnOff *msg); + bool LightsMsg(CLightsMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool TurnOn(CTurnOn *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool ActMsg(CActMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); private: int _fieldE0; diff --git a/engines/titanic/game/light_switch.cpp b/engines/titanic/game/light_switch.cpp index 3f5c8d2084..188691033a 100644 --- a/engines/titanic/game/light_switch.cpp +++ b/engines/titanic/game/light_switch.cpp @@ -21,10 +21,24 @@ */ #include "titanic/game/light_switch.h" +#include "titanic/game/light.h" +#include "titanic/game/television.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { -int CLightSwitch::_v1; +BEGIN_MESSAGE_MAP(CLightSwitch, CBackground) + ON_MESSAGE(PETUpMsg) + ON_MESSAGE(PETDownMsg) + ON_MESSAGE(PETLeftMsg) + ON_MESSAGE(PETRightMsg) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +bool CLightSwitch::_flag; CLightSwitch::CLightSwitch() : CBackground(), _fieldE0(0), _fieldE4(0), _fieldE8(0) { @@ -34,7 +48,7 @@ void CLightSwitch::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_v1, indent); + file->writeNumberLine(_flag, indent); file->writeNumberLine(_fieldE8, indent); CBackground::save(file, indent); @@ -44,14 +58,94 @@ void CLightSwitch::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); _fieldE4 = file->readNumber(); - _v1 = file->readNumber(); + _flag = file->readNumber(); _fieldE8 = file->readNumber(); CBackground::load(file); } +bool CLightSwitch::PETUpMsg(CPETUpMsg *msg) { + if (msg->_name == "Light") { + CLightsMsg lightsMsg(true, true, false, false); + lightsMsg.execute("1stClassState", CLight::_type, MSGFLAG_SCAN); + + if (_fieldE8) + CTelevision::_turnOn = true; + } + + return true; +} + +bool CLightSwitch::PETDownMsg(CPETDownMsg *msg) { + if (msg->_name == "Light") { + CLightsMsg lightsMsg(false, false, true, true); + lightsMsg.execute("1stClassState", CLight::_type, MSGFLAG_SCAN); + + if (_fieldE8) + CTelevision::_turnOn = true; + } + + return true; +} + +bool CLightSwitch::PETLeftMsg(CPETLeftMsg *msg) { + if (msg->_name == "Light") { + CLightsMsg lightsMsg(false, true, true, false); + lightsMsg.execute("1stClassState", CLight::_type, MSGFLAG_SCAN); + + if (_fieldE8) + CTelevision::_turnOn = true; + } + + return true; +} + +bool CLightSwitch::PETRightMsg(CPETRightMsg *msg) { + if (msg->_name == "Light") { + CLightsMsg lightsMsg(true, false, false, true); + lightsMsg.execute("1stClassState", CLight::_type, MSGFLAG_SCAN); + + if (_fieldE8) + CTelevision::_turnOn = true; + } + + return true; +} + +bool CLightSwitch::PETActivateMsg(CPETActivateMsg *msg) { + if (msg->_name == "Light") { + if (_flag) { + CTurnOff offMsg; + offMsg.execute("1stClassState", CLight::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + + } else { + CTurnOn onMsg; + onMsg.execute("1stClassState", CLight::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + _flag = false; + if (_fieldE8) + CTelevision::_turnOn = false; + } + } + + return true; +} + +bool CLightSwitch::EnterViewMsg(CEnterViewMsg *msg) { + petSetRemoteTarget(); + return true; +} + +bool CLightSwitch::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + return true; +} + bool CLightSwitch::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CLightSwitch::handleEvent"); + _flag = true; + CPetControl *pet = getPetControl(); + if (pet) + _fieldE8 = pet->isRoom59706(); + return true; } diff --git a/engines/titanic/game/light_switch.h b/engines/titanic/game/light_switch.h index ce62d7d68c..f8c01dc8b0 100644 --- a/engines/titanic/game/light_switch.h +++ b/engines/titanic/game/light_switch.h @@ -25,13 +25,22 @@ #include "titanic/core/background.h" #include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CLightSwitch : public CBackground { + DECLARE_MESSAGE_MAP; + bool PETUpMsg(CPETUpMsg *msg); + bool PETDownMsg(CPETDownMsg *msg); + bool PETLeftMsg(CPETLeftMsg *msg); + bool PETRightMsg(CPETRightMsg *msg); + bool PETActivateMsg(CPETActivateMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); public: - static int _v1; + static bool _flag; private: int _fieldE0; int _fieldE4; diff --git a/engines/titanic/game/little_lift_button.cpp b/engines/titanic/game/little_lift_button.cpp index 5005cb1757..afda4cac1d 100644 --- a/engines/titanic/game/little_lift_button.cpp +++ b/engines/titanic/game/little_lift_button.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/little_lift_button.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CLittleLiftButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CLittleLiftButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +42,23 @@ void CLittleLiftButton::load(SimpleFile *file) { CBackground::load(file); } +bool CLittleLiftButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + playMovie(MOVIE_NOTIFY_OBJECT); + playSound("z#60.wav"); + return true; +} + +bool CLittleLiftButton::MovieEndMsg(CMovieEndMsg *msg) { + changeView("SecClassLittleLift.Node 1.N"); + + CRoomItem *room = getRoom(); + if (room) { + CStatusChangeMsg statusMsg; + statusMsg._newStatus = _value; + statusMsg.execute(room, nullptr, MSGFLAG_SCAN); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/little_lift_button.h b/engines/titanic/game/little_lift_button.h index b14651f4b8..2cbf3b97ff 100644 --- a/engines/titanic/game/little_lift_button.h +++ b/engines/titanic/game/little_lift_button.h @@ -28,6 +28,9 @@ namespace Titanic { class CLittleLiftButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: int _value; public: diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp index 8ba372eb7a..ba30fbe281 100644 --- a/engines/titanic/game/television.cpp +++ b/engines/titanic/game/television.cpp @@ -23,7 +23,9 @@ #include "titanic/game/television.h" #include "titanic/game/get_lift_eye2.h" #include "titanic/core/project_item.h" +#include "titanic/carry/magazine.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/titanic.h" namespace Titanic { @@ -237,10 +239,15 @@ bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) { if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) { playSound("z#47.wav", 100, 0, 0); _soundHandle = playSound("b#20.wav", 100, 0, 0); - CTreeItem *magazine = getRoot()->findByName("Magazine"); + CMagazine *magazine = dynamic_cast<CMagazine *>(getRoot()->findByName("Magazine")); if (magazine) { - warning("TODO: CTelevision::MovieEndMsg"); + CPetControl *pet = getPetControl(); + uint roomFlags = pet->getRoomFlags(); + + debugC(kDebugScripts, "Assigned room - %d", roomFlags); + magazine->addMail(roomFlags); + magazine->removeMail(roomFlags, roomFlags); } loadFrame(561); @@ -282,7 +289,7 @@ bool CTelevision::LightsMsg(CLightsMsg *msg) { if (pet) flag = pet->isRoom59706(); - if (msg->_field8 || !flag) + if (msg->_flag2 || !flag) _turnOn = true; return true; diff --git a/engines/titanic/game/transport/lift.cpp b/engines/titanic/game/transport/lift.cpp index ef8d9028d9..114e840007 100644 --- a/engines/titanic/game/transport/lift.cpp +++ b/engines/titanic/game/transport/lift.cpp @@ -49,7 +49,7 @@ void CLift::save(SimpleFile *file, int indent) { file->writeNumberLine(_elevator2Floor, indent); file->writeNumberLine(_elevator3Floor, indent); file->writeNumberLine(_elevator4Floor, indent); - file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_liftNum, indent); file->writeNumberLine(_v6, indent); CTransport::save(file, indent); @@ -62,7 +62,7 @@ void CLift::load(SimpleFile *file) { _elevator2Floor = file->readNumber(); _elevator3Floor = file->readNumber(); _elevator4Floor = file->readNumber(); - _fieldF8 = file->readNumber(); + _liftNum = file->readNumber(); _v6 = file->readNumber(); CTransport::load(file); diff --git a/engines/titanic/game/transport/lift.h b/engines/titanic/game/transport/lift.h index 38af00a1ce..c45d2b64d0 100644 --- a/engines/titanic/game/transport/lift.h +++ b/engines/titanic/game/transport/lift.h @@ -44,10 +44,10 @@ public: static int _elevator4Floor; static int _v6; - int _fieldF8; + int _liftNum; public: CLASSDEF; - CLift() : CTransport(), _fieldF8(1) {} + CLift() : CTransport(), _liftNum(1) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/transport/lift_indicator.cpp b/engines/titanic/game/transport/lift_indicator.cpp index 582de8ad3b..1336daf7aa 100644 --- a/engines/titanic/game/transport/lift_indicator.cpp +++ b/engines/titanic/game/transport/lift_indicator.cpp @@ -21,23 +21,32 @@ */ #include "titanic/game/transport/lift_indicator.h" +#include "titanic/game/transport/lift.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/titanic.h" namespace Titanic { BEGIN_MESSAGE_MAP(CLiftindicator, CLift) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(MovieEndMsg) ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(TimerMsg) END_MESSAGE_MAP() CLiftindicator::CLiftindicator() : CLift(), - _fieldFC(0), _field108(0), _field10C(0) { + _fieldFC(0), _start(0), _end(0) { } void CLiftindicator::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldFC, indent); - file->writePoint(_pos2, indent); - file->writeNumberLine(_field108, indent); - file->writeNumberLine(_field10C, indent); + file->writePoint(_indicatorPos, indent); + file->writeNumberLine(_start, indent); + file->writeNumberLine(_end, indent); CLift::save(file, indent); } @@ -45,11 +54,184 @@ void CLiftindicator::save(SimpleFile *file, int indent) { void CLiftindicator::load(SimpleFile *file) { file->readNumber(); _fieldFC = file->readNumber(); - _pos2 = file->readPoint(); - _field108 = file->readNumber(); - _field10C = file->readNumber(); + _indicatorPos = file->readPoint(); + _start = file->readNumber(); + _end = file->readNumber(); CLift::load(file); } +bool CLiftindicator::EnterViewMsg(CEnterViewMsg *msg) { + double multiplier = _fieldFC * 0.037037037; + CPetControl *pet = getPetControl(); + int floorNum = pet->getRoomsFloorNum(); + debugC(kDebugScripts, "Lifts = %d,%d,%d,%d, %d", + CLift::_elevator1Floor, CLift::_elevator2Floor, + CLift::_elevator3Floor, CLift::_elevator4Floor, + floorNum); + + if ((pet->petGetRoomsWellEntry() & 1) == (_fieldFC & 1)) { + petSetRemoteTarget(); + petSetArea(PET_REMOTE); + + CString str = CString::format("You are standing outside Elevator %d", + petGetRoomsWellEntry()); + petDisplayMessage(-1, str); + + debugC(kDebugScripts, "Claiming PET - %d, Multiplier = %f", + _liftNum, multiplier); + } + + switch (_liftNum) { + case 0: + loadFrame(pet->getRoomsFloorNum()); + break; + + case 1: + case 3: + switch (petGetRoomsWellEntry()) { + case 1: + case 2: + setPosition(Point(_bounds.left, _indicatorPos.y + + multiplier * CLift::_elevator1Floor)); + _startFrame = CLift::_elevator1Floor; + break; + + case 3: + case 4: + setPosition(Point(_bounds.left, _indicatorPos.y + + multiplier * CLift::_elevator3Floor)); + _startFrame = CLift::_elevator3Floor; + break; + + default: + break; + } + break; + + case 2: + case 4: + switch (petGetRoomsWellEntry()) { + case 1: + case 2: + setPosition(Point(_bounds.left, _indicatorPos.y + + multiplier * CLift::_elevator2Floor)); + _startFrame = CLift::_elevator2Floor; + break; + + case 3: + case 4: + setPosition(Point(_bounds.left, _indicatorPos.y + + multiplier * CLift::_elevator4Floor)); + _startFrame = CLift::_elevator4Floor; + break; + + default: + break; + } + break; + + default: + break; + } + + return true; +} + +bool CLiftindicator::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + return true; +} + +bool CLiftindicator::PETActivateMsg(CPETActivateMsg *msg) { + double multiplier = _fieldFC * 0.037037037; + CPetControl *pet = getPetControl(); + + if (msg->_name == "Lift") { + if (petDoorOrBellbotPresent()) { + petDisplayMessage(1, "I'm sorry, you cannot enter this elevator at present " + "as a bot is in the way."); + } else { + _endFrame = pet->getRoomsFloorNum(); + + if (petGetRoomsWellEntry() == 4 && !CLift::_v6 + && pet->getRoomsFloorNum() != CLift::_elevator4Floor) { + petDisplayMessage(1, "This elevator is currently in an advanced state of non-functionality."); + } else { + _start = _indicatorPos.y + _startFrame * multiplier; + _end = _indicatorPos.y + _endFrame * multiplier; + lockMouse(); + addTimer(100); + + if (petGetRoomsWellEntry() == 2) { + CLift::_elevator4Floor = CLift::_elevator2Floor; + CShipSettingMsg settingMsg; + settingMsg._value = CLift::_elevator4Floor; + settingMsg.execute("SGTStateroomTV"); + } + + switch (petGetRoomsWellEntry()) { + case 1: + CLift::_elevator1Floor = pet->getRoomsFloorNum(); + break; + case 2: + CLift::_elevator2Floor = pet->getRoomsFloorNum(); + break; + case 3: + CLift::_elevator3Floor = pet->getRoomsFloorNum(); + break; + case 4: + CLift::_elevator4Floor = pet->getRoomsFloorNum(); + break; + default: + break; + } + + debugC(kDebugScripts, "Lifts = %d,%d,%d,%d %d", + CLift::_elevator1Floor, CLift::_elevator2Floor, + CLift::_elevator3Floor, CLift::_elevator4Floor, + petGetRoomsWellEntry()); + } + } + } + + return true; +} + +bool CLiftindicator::MovieEndMsg(CMovieEndMsg *msg) { + playSound("357 gp button 1.wav"); + sleep(100); + changeView("Lift.Node 1.N"); + + unlockMouse(); + return true; +} + +bool CLiftindicator::EnterRoomMsg(CEnterRoomMsg *msg) { + return true; +} + +bool CLiftindicator::LeaveRoomMsg(CLeaveRoomMsg *msg) { + return true; +} + +bool CLiftindicator::TimerMsg(CTimerMsg *msg) { + debugC(kDebugScripts, "Start %d, End %d", _start, _end); + + if (_start > _end) { + setPosition(Point(_bounds.left, _bounds.top - 1)); + --_start; + addTimer(20); + } else if (_start < _end) { + setPosition(Point(_bounds.left, _bounds.top + 1)); + ++_start; + addTimer(20); + } else { + CMovieEndMsg endMsg(0, 0); + endMsg.execute(this); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/transport/lift_indicator.h b/engines/titanic/game/transport/lift_indicator.h index 945f627417..5d0bc45d7b 100644 --- a/engines/titanic/game/transport/lift_indicator.h +++ b/engines/titanic/game/transport/lift_indicator.h @@ -25,17 +25,24 @@ #include "titanic/game/transport/lift.h" #include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CLiftindicator : public CLift { DECLARE_MESSAGE_MAP; - bool EnterRoomMsg(CEnterRoomMsg *msg) { return true; } + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool PETActivateMsg(CPETActivateMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool TimerMsg(CTimerMsg *msg); private: int _fieldFC; - Point _pos2; - int _field108; - int _field10C; + Point _indicatorPos; + int _start; + int _end; public: CLASSDEF; CLiftindicator(); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 6a3961962b..fa05416fdc 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -164,22 +164,6 @@ public: } }; -class CLightsMsg : public CMessage { -public: - int _field4; - int _field8; - int _fieldC; - int _field10; -public: - CLASSDEF; - CLightsMsg() : CMessage(), _field4(0), _field8(0), - _fieldC(0), _field10(0) {} - - static bool isSupportedBy(const CTreeItem *item) { - return supports(item, _type); - } -}; - MESSAGE1(CTimeMsg, uint, _ticks, 0); class CTimerMsg : public CTimeMsg { @@ -256,6 +240,7 @@ MESSAGE2(CLeaveNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nul MESSAGE2(CLeaveRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); MESSAGE2(CLeaveViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr); MESSAGE1(CLemonFallsFromTreeMsg, Point, pt, Point()); +MESSAGE4(CLightsMsg, bool, flag1, false, bool, flag2, false, bool, flag3, false, bool, flag4, false); MESSAGE1(CLoadSuccessMsg, int, ticks, 0); MESSAGE1(CLockPhonographMsg, int, value, 0); MESSAGE0(CMaitreDDefeatedMsg); |