From 795cdb6365bcf01a92950e6fee8632a3a749d165 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 27 Aug 2016 07:50:19 -0400 Subject: TITANIC: Implemented PET game classes --- engines/titanic/game/pet/pet.cpp | 12 ++++++++++ engines/titanic/game/pet/pet.h | 2 ++ engines/titanic/game/pet/pet_lift.cpp | 37 +++++++++++++++++++++++++++++ engines/titanic/game/pet/pet_lift.h | 2 ++ engines/titanic/game/pet/pet_monitor.cpp | 20 +++++++++++++++- engines/titanic/game/pet/pet_pellerator.cpp | 24 +++++++++++++++++++ engines/titanic/game/pet/pet_pellerator.h | 3 +++ engines/titanic/game/pet/pet_sentinal.cpp | 29 ++++++++++++++++++++++ engines/titanic/game/pet/pet_sentinal.h | 7 ++++++ engines/titanic/game/pet/pet_sounds.cpp | 28 ++++++++++++++++++++-- engines/titanic/game/pet/pet_sounds.h | 8 +++++-- engines/titanic/game/pet/pet_transition.cpp | 23 ++++++++++++++++++ engines/titanic/game/pet/pet_transition.h | 2 ++ engines/titanic/game/pet/pet_transport.cpp | 2 +- engines/titanic/game/pet_disabler.cpp | 15 ++++++++++++ engines/titanic/game/pet_disabler.h | 3 +++ engines/titanic/messages/pet_messages.h | 2 +- 17 files changed, 212 insertions(+), 7 deletions(-) diff --git a/engines/titanic/game/pet/pet.cpp b/engines/titanic/game/pet/pet.cpp index cd4e16d38c..99c9e01eb3 100644 --- a/engines/titanic/game/pet/pet.cpp +++ b/engines/titanic/game/pet/pet.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/pet/pet.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPET, CGameObject) + ON_MESSAGE(ShowTextMsg) +END_MESSAGE_MAP() + CPET::CPET() : CGameObject(), _fieldBC(0), _fieldC0(3), _fieldC4(0), _fieldC8(0), _fieldD8(0), _fieldDC(0) { } @@ -54,4 +59,11 @@ void CPET::load(SimpleFile *file) { CGameObject::load(file); } +bool CPET::ShowTextMsg(CShowTextMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) + pet->petDisplayMessage(1, msg->_value); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet.h b/engines/titanic/game/pet/pet.h index cdad649401..de31a423d0 100644 --- a/engines/titanic/game/pet/pet.h +++ b/engines/titanic/game/pet/pet.h @@ -28,6 +28,8 @@ namespace Titanic { class CPET : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ShowTextMsg(CShowTextMsg *msg); public: int _fieldBC; int _fieldC0; diff --git a/engines/titanic/game/pet/pet_lift.cpp b/engines/titanic/game/pet/pet_lift.cpp index 39b0d01540..afa9dd04cd 100644 --- a/engines/titanic/game/pet/pet_lift.cpp +++ b/engines/titanic/game/pet/pet_lift.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/pet/pet_lift.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETLift, CPETTransport) + ON_MESSAGE(TransportMsg) +END_MESSAGE_MAP() + void CPETLift::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPETTransport::save(file, indent); @@ -34,4 +39,36 @@ void CPETLift::load(SimpleFile *file) { CPETTransport::load(file); } +bool CPETLift::TransportMsg(CTransportMsg *msg) { + CPetControl *pet = getPetControl(); + if (msg->_value1 != 1) + return false; + + int floorNum = -1; + if (msg->_roomName == "TopOfWell") { + floorNum = 1; + } else if (msg->_roomName == "BottomOfWell") { + floorNum = 39; + } else if (msg->_roomName == "PlayersRoom" && pet) { + int assignedFloor = pet->getAssignedFloorNum(); + if (assignedFloor < 1 || assignedFloor > 39) { + pet->petDisplayMessage("You have not assigned a room to go to."); + floorNum = -1; + } + } + + if (floorNum != -1) { + int elevatorNum = pet ? pet->getRoomsElevatorNum() : 0; + + if ((elevatorNum == 2 || elevatorNum == 4) && floorNum > 27) { + petDisplayMessage("Sorry, this elevator does not go below floor 27."); + } else { + CTrueTalkTriggerActionMsg triggerMsg(2, floorNum, 0); + triggerMsg.execute("Liftbot"); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_lift.h b/engines/titanic/game/pet/pet_lift.h index 88b4e1c029..ce3aace1a6 100644 --- a/engines/titanic/game/pet/pet_lift.h +++ b/engines/titanic/game/pet/pet_lift.h @@ -28,6 +28,8 @@ namespace Titanic { class CPETLift : public CPETTransport { + DECLARE_MESSAGE_MAP; + bool TransportMsg(CTransportMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_monitor.cpp b/engines/titanic/game/pet/pet_monitor.cpp index 6a0d207a55..2716a81fa8 100644 --- a/engines/titanic/game/pet/pet_monitor.cpp +++ b/engines/titanic/game/pet/pet_monitor.cpp @@ -21,6 +21,8 @@ */ #include "titanic/game/pet/pet_monitor.h" +#include "titanic/core/room_item.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { @@ -39,7 +41,23 @@ void CPETMonitor::load(SimpleFile *file) { } bool CPETMonitor::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPETMonitor::handleEvent"); + bool flag = true; + if (msg->_newRoom && msg->_oldRoom) { + CString oldRoomName = msg->_oldRoom->getName(); + CString newRoomName = msg->_newRoom->getName(); + + if (newRoomName == "SgtLobby" && oldRoomName == "SGTState") + flag = false; + } + + if (flag) { + CPetControl *pet = getPetControl(); + if (pet) { + pet->setRoomsRoomNum(0); + pet->resetRoomsHighlight(); + } + } + return true; } diff --git a/engines/titanic/game/pet/pet_pellerator.cpp b/engines/titanic/game/pet/pet_pellerator.cpp index a29942ca59..59516ebcde 100644 --- a/engines/titanic/game/pet/pet_pellerator.cpp +++ b/engines/titanic/game/pet/pet_pellerator.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPETPellerator, CPETTransport) + ON_MESSAGE(PETActivateMsg) +END_MESSAGE_MAP() + void CPETPellerator::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPETTransport::save(file, indent); @@ -34,4 +38,24 @@ void CPETPellerator::load(SimpleFile *file) { CPETTransport::load(file); } +bool CPETPellerator::PETActivateMsg(CPETActivateMsg *msg) { + CStatusChangeMsg statusMsg; + + if (msg->_name == "PromenadeDeck") + statusMsg._newStatus = 0; + else if (msg->_name == "MusicRoom") + statusMsg._newStatus = 1; + else if (msg->_name == "Bar") + statusMsg._newStatus = 2; + else if (msg->_name == "TopOfWell") + statusMsg._newStatus = 4; + else if (msg->_name == "1stClassRestaurant") + statusMsg._newStatus = 5; + else if (msg->_name == "Arboretum") + statusMsg._newStatus = 6; + + statusMsg.execute("PelleratorObject"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_pellerator.h b/engines/titanic/game/pet/pet_pellerator.h index 9b90c9af28..51af6f1bcd 100644 --- a/engines/titanic/game/pet/pet_pellerator.h +++ b/engines/titanic/game/pet/pet_pellerator.h @@ -24,10 +24,13 @@ #define TITANIC_PET_PELLERATOR_H #include "titanic/game/pet/pet_transport.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CPETPellerator : public CPETTransport { + DECLARE_MESSAGE_MAP; + bool PETActivateMsg(CPETActivateMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_sentinal.cpp b/engines/titanic/game/pet/pet_sentinal.cpp index 1b647d7c62..ac4cbc8418 100644 --- a/engines/titanic/game/pet/pet_sentinal.cpp +++ b/engines/titanic/game/pet/pet_sentinal.cpp @@ -21,17 +21,46 @@ */ #include "titanic/game/pet/pet_sentinal.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETSentinal, CGameObject) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CPETSentinal::CPETSentinal() : CGameObject(), _elevatorNum(0), + _wellEntry(0), _resetHighlight(0) { +} + void CPETSentinal::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); + file->writeNumberLine(_elevatorNum, indent); + file->writeNumberLine(_wellEntry, indent); + file->writeNumberLine(_resetHighlight, indent); CGameObject::save(file, indent); } void CPETSentinal::load(SimpleFile *file) { file->readNumber(); + _elevatorNum = file->readNumber(); + _wellEntry = file->readNumber(); + _resetHighlight = file->readNumber(); CGameObject::load(file); } +bool CPETSentinal::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + if (_elevatorNum != -1) + pet->setRoomsElevatorNum(_elevatorNum); + if (_wellEntry) + pet->setRoomsWellEntry(_wellEntry); + if (_resetHighlight) + pet->resetRoomsHighlight(); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sentinal.h b/engines/titanic/game/pet/pet_sentinal.h index f7f9fef0ba..150fe4a87e 100644 --- a/engines/titanic/game/pet/pet_sentinal.h +++ b/engines/titanic/game/pet/pet_sentinal.h @@ -28,8 +28,15 @@ namespace Titanic { class CPETSentinal : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); +private: + int _elevatorNum; + int _wellEntry; + bool _resetHighlight; public: CLASSDEF; + CPETSentinal(); /** * Save the data for the class to file diff --git a/engines/titanic/game/pet/pet_sounds.cpp b/engines/titanic/game/pet/pet_sounds.cpp index d612c745bb..c7f3cd3bf8 100644 --- a/engines/titanic/game/pet/pet_sounds.cpp +++ b/engines/titanic/game/pet/pet_sounds.cpp @@ -24,16 +24,40 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPETSounds, CGameObject) + ON_MESSAGE(PETPlaySoundMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + void CPETSounds::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_ticks, indent); CGameObject::save(file, indent); } void CPETSounds::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _ticks = file->readNumber(); CGameObject::load(file); } +bool CPETSounds::PETPlaySoundMsg(CPETPlaySoundMsg *msg) { + if (msg->_soundNum == 1) { + playSound("z#65.wav"); + } else if (msg->_soundNum == 2 && stateGet24()) { + uint ticks = getTicksCount(); + if (!_ticks || ticks > (_ticks + 12000)) { + playSound("z#36.wav"); + _ticks = ticks; + } + } + + return true; +} + +bool CPETSounds::LoadSuccessMsg(CLoadSuccessMsg *msg) { + _ticks = 0; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sounds.h b/engines/titanic/game/pet/pet_sounds.h index 1d3acdb5f3..2262fde916 100644 --- a/engines/titanic/game/pet/pet_sounds.h +++ b/engines/titanic/game/pet/pet_sounds.h @@ -24,15 +24,19 @@ #define TITANIC_PET_SOUNDS_H #include "titanic/core/game_object.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CPETSounds : public CGameObject { + DECLARE_MESSAGE_MAP; + bool PETPlaySoundMsg(CPETPlaySoundMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); public: - int _value; + uint _ticks; public: CLASSDEF; - CPETSounds() : CGameObject(), _value(0) {} + CPETSounds() : CGameObject(), _ticks(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/pet/pet_transition.cpp b/engines/titanic/game/pet/pet_transition.cpp index 33cc36ca11..ec10569236 100644 --- a/engines/titanic/game/pet/pet_transition.cpp +++ b/engines/titanic/game/pet/pet_transition.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/pet/pet_transition.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/core/view_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETTransition, CGameObject) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CPETTransition::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +40,21 @@ void CPETTransition::load(SimpleFile *file) { CGameObject::load(file); } +bool CPETTransition::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + + if (compareRoomNameTo("1stClassLobby") && pet) { + int elevatorNum = pet->getRoomsElevatorNum(); + CString nodeView = msg->_newView->getNodeViewName(); + + if (nodeView == "Node 1.E") { + pet->setRoomsElevatorNum((elevatorNum == 1 || elevatorNum == 2) ? 1 : 3); + } else if (nodeView == "Node 1.W") { + pet->setRoomsElevatorNum((elevatorNum == 1 || elevatorNum == 2) ? 2 : 4); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_transition.h b/engines/titanic/game/pet/pet_transition.h index 4abf16d509..d0fa20ccc5 100644 --- a/engines/titanic/game/pet/pet_transition.h +++ b/engines/titanic/game/pet/pet_transition.h @@ -28,6 +28,8 @@ namespace Titanic { class CPETTransition : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_transport.cpp b/engines/titanic/game/pet/pet_transport.cpp index 9661cace2c..a48e70ed01 100644 --- a/engines/titanic/game/pet/pet_transport.cpp +++ b/engines/titanic/game/pet/pet_transport.cpp @@ -39,7 +39,7 @@ void CPETTransport::load(SimpleFile *file) { } bool CPETTransport::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPETTransport::handleEvent"); + petClear(); return true; } diff --git a/engines/titanic/game/pet_disabler.cpp b/engines/titanic/game/pet_disabler.cpp index 2275156503..c4946fe39f 100644 --- a/engines/titanic/game/pet_disabler.cpp +++ b/engines/titanic/game/pet_disabler.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPetDisabler, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CPetDisabler::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeQuotedLine(_value, indent); @@ -36,4 +41,14 @@ void CPetDisabler::load(SimpleFile *file) { CGameObject::load(file); } +bool CPetDisabler::EnterViewMsg(CEnterViewMsg *msg) { + petLockInput(); + return true; +} + +bool CPetDisabler::LeaveViewMsg(CLeaveViewMsg *msg) { + petUnlockInput(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet_disabler.h b/engines/titanic/game/pet_disabler.h index 92b4dff0a8..06e99be49e 100644 --- a/engines/titanic/game/pet_disabler.h +++ b/engines/titanic/game/pet_disabler.h @@ -28,6 +28,9 @@ namespace Titanic { class CPetDisabler : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: CString _value; public: diff --git a/engines/titanic/messages/pet_messages.h b/engines/titanic/messages/pet_messages.h index 48e5bab64c..60981726ed 100644 --- a/engines/titanic/messages/pet_messages.h +++ b/engines/titanic/messages/pet_messages.h @@ -35,7 +35,7 @@ MESSAGE0(CPETLostObjectMsg); MESSAGE0(CPETObjectSelectedMsg); MESSAGE1(CPETObjectStateMsg, int, value, 0); MESSAGE0(CPETPhotoOnOffMsg); -MESSAGE1(CPETPlaySoundMsg, int, value, 0); +MESSAGE1(CPETPlaySoundMsg, int, soundNum, 0); MESSAGE0(CPETReceiveMsg); MESSAGE0(CPETSetStarDestinationMsg); MESSAGE1(CPETStarFieldLockMsg, int, value, 0); -- cgit v1.2.3