aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-26 12:39:44 -0400
committerPaul Gilbert2016-07-15 19:25:09 -0400
commit6f063c4703e5705edbba7ad39ef9c0656b74bc75 (patch)
tree64cb04d4e3f3a327f6a080ffef8e7af6c0f12152
parent0146a3c6b6bdb16eef6f46e116b0d9fe9883858f (diff)
downloadscummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.gz
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.bz2
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.zip
TITANIC: Fleshing out CGameObject and CPetControl methods
-rw-r--r--engines/titanic/carry/arm.cpp10
-rw-r--r--engines/titanic/carry/brain.cpp4
-rw-r--r--engines/titanic/carry/bridge_piece.cpp4
-rw-r--r--engines/titanic/carry/carry.cpp22
-rw-r--r--engines/titanic/carry/carry.h10
-rw-r--r--engines/titanic/carry/carry_parrot.cpp4
-rw-r--r--engines/titanic/carry/chicken.cpp12
-rw-r--r--engines/titanic/carry/napkin.cpp4
-rw-r--r--engines/titanic/core/game_object.cpp182
-rw-r--r--engines/titanic/core/game_object.h159
-rw-r--r--engines/titanic/debugger.cpp2
-rw-r--r--engines/titanic/game/television.cpp4
-rw-r--r--engines/titanic/npcs/deskbot.cpp16
-rw-r--r--engines/titanic/npcs/true_talk_npc.cpp10
-rw-r--r--engines/titanic/npcs/true_talk_npc.h10
-rw-r--r--engines/titanic/pet_control/pet_control.cpp115
-rw-r--r--engines/titanic/pet_control/pet_control.h32
-rw-r--r--engines/titanic/pet_control/pet_conversations.cpp16
-rw-r--r--engines/titanic/pet_control/pet_conversations.h4
-rw-r--r--engines/titanic/pet_control/pet_drag_chev.cpp2
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp2
-rw-r--r--engines/titanic/pet_control/pet_inventory.h2
-rw-r--r--engines/titanic/pet_control/pet_real_life.h2
-rw-r--r--engines/titanic/room_flags.cpp30
-rw-r--r--engines/titanic/room_flags.h20
25 files changed, 450 insertions, 228 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp
index d662b43f76..ee58aea445 100644
--- a/engines/titanic/carry/arm.cpp
+++ b/engines/titanic/carry/arm.cpp
@@ -119,7 +119,7 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (hookedMsg._result) {
_string7 = "GondolierLeftLever";
} else {
- addToInventory();
+ petAddToInventory();
}
} else if (msg->_other->getName() == "GondolierRightLever") {
CIsHookedOnMsg hookedMsg(_hookedRect, 0, getName());
@@ -129,7 +129,7 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (hookedMsg._result) {
_string7 = "GondolierRightLever";
} else {
- addToInventory();
+ petAddToInventory();
}
}
@@ -166,13 +166,13 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) {
CGameObject *child = static_cast<CGameObject *>(getFirstChild());
if (child) {
child->setVisible(true);
- addToInventory();
+ petAddToInventory();
}
_visibleFrame = _field170;
loadFrame(_visibleFrame);
_string6 = "None";
- invChange();
+ petInvChange();
}
}
@@ -189,7 +189,7 @@ bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
_visibleFrame = _field170;
loadFrame(_visibleFrame);
child->setVisible(true);
- child->addToInventory();
+ child->petAddToInventory();
}
_string6 = "None";
diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp
index acc29b3f0e..a60e652bda 100644
--- a/engines/titanic/carry/brain.cpp
+++ b/engines/titanic/carry/brain.cpp
@@ -59,13 +59,13 @@ bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (slot) {
if (slot->getName() == "CentralCore") {
setVisible(false);
- moveToHiddenRoom();
+ petMoveToHiddenRoom();
CAddHeadPieceMsg headpieceMsg(getName());
headpieceMsg.execute("CentralCoreSlot");
}
else if (!slot->_value1 && slot->getName() == "CentralCoreSlot") {
setVisible(false);
- moveToHiddenRoom();
+ petMoveToHiddenRoom();
CAddHeadPieceMsg headpieceMsg(getName());
headpieceMsg.execute(msg->_other);
playSound("z#116.wav", 100, 0, 0);
diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp
index 4fafac26b5..1fe5e048ed 100644
--- a/engines/titanic/carry/bridge_piece.cpp
+++ b/engines/titanic/carry/bridge_piece.cpp
@@ -56,14 +56,14 @@ bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (!shipSetting) {
return CCarry::UseWithOtherMsg(msg);
} else if (shipSetting->_string4 == "NULL") {
- addToInventory();
+ petAddToInventory();
return true;
} else {
setVisible(false);
playSound("z#54.wav", 100, 0, 0);
setPosition(shipSetting->_pos1);
shipSetting->_string4 = getName();
- moveToHiddenRoom();
+ petMoveToHiddenRoom();
CAddHeadPieceMsg headpieceMsg(shipSetting->getName() == _string6 ?
"Enable" : "Disable");
diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index cb87b94c90..ca022a6c8f 100644
--- a/engines/titanic/carry/carry.cpp
+++ b/engines/titanic/carry/carry.cpp
@@ -123,7 +123,7 @@ bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) {
if (msg->_dropTarget) {
if (msg->_dropTarget->isPet()) {
- addToInventory();
+ petAddToInventory();
return true;
}
@@ -147,7 +147,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) {
CString viewName = getViewFullName();
if (viewName.empty() || msg->_mousePos.y >= 360) {
sleep(250);
- addToInventory();
+ petAddToInventory();
} else {
setPosition(_origPos);
loadFrame(_itemFrame);
@@ -165,7 +165,7 @@ bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) {
} else {
CShowTextMsg textMsg(_string4);
textMsg.execute("PET");
- addToInventory();
+ petAddToInventory();
}
return true;
@@ -182,7 +182,7 @@ bool CCarry::UseWithOtherMsg(CUseWithOtherMsg *msg) {
_fullViewName = getViewFullName();
if (_fullViewName.empty() || _bounds.top >= 360) {
sleep(250);
- addToInventory();
+ petAddToInventory();
} else {
setPosition(_origPos);
}
@@ -238,18 +238,4 @@ bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
return true;
}
-void CCarry::addToInventory() {
- CPetControl *pet = getPetControl();
- if (pet) {
- makeDirty();
- pet->addToInventory(this);
- }
-}
-
-void CCarry::invChange() {
- CPetControl *pet = getPetControl();
- if (pet)
- pet->invChange(this);
-}
-
} // End of namespace Titanic
diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h
index ba782fda7e..f4476721cc 100644
--- a/engines/titanic/carry/carry.h
+++ b/engines/titanic/carry/carry.h
@@ -61,11 +61,6 @@ protected:
int _enterFrame;
bool _enterFrameSet;
int _visibleFrame;
-protected:
- /**
- *
- */
- void invChange();
public:
CLASSDEF
CCarry();
@@ -79,11 +74,6 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
-
- /**
- * Add the item to the inventory
- */
- void addToInventory();
};
} // End of namespace Titanic
diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp
index e274679b82..b0916bb4c4 100644
--- a/engines/titanic/carry/carry_parrot.cpp
+++ b/engines/titanic/carry/carry_parrot.cpp
@@ -105,7 +105,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) {
stopMovie();
if (msg->_mousePos.y >= 360) {
- addToInventory();
+ petAddToInventory();
return true;
}
@@ -215,7 +215,7 @@ bool CCarryParrot::ActMsg(CActMsg *msg) {
CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers"));
if (feathers) {
feathers->setVisible(true);
- feathers->addToInventory();
+ feathers->petAddToInventory();
}
_field140 = true;
diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp
index 8483a3fb29..60627bdb7e 100644
--- a/engines/titanic/carry/chicken.cpp
+++ b/engines/titanic/carry/chicken.cpp
@@ -72,13 +72,13 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (_field12C || _string6 == "None") {
CActMsg actMsg("Clean");
actMsg.execute(this);
- addToInventory();
+ petAddToInventory();
} else {
CShowTextMsg textMsg("The chicken is already clean.");
textMsg.execute("PET");
}
- addToInventory();
+ petAddToInventory();
} else {
CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other);
if (!dispensor || _string6 == "None") {
@@ -101,7 +101,7 @@ bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) {
acceptMsg._item = this;
acceptMsg.execute(succubus);
} else {
- addToInventory();
+ petAddToInventory();
}
return true;
@@ -110,7 +110,7 @@ bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) {
bool CChicken::ActMsg(CActMsg *msg) {
if (msg->_action == "GoToPET") {
setVisible(true);
- addToInventory();
+ petAddToInventory();
} else if (msg->_action == "Tomato") {
_string6 = "Tomato";
loadFrame(4);
@@ -142,7 +142,7 @@ bool CChicken::ActMsg(CActMsg *msg) {
_v1 = 120;
} else if (msg->_action == "Eaten") {
setVisible(false);
- moveToHiddenRoom();
+ petMoveToHiddenRoom();
_field13C = 1;
}
@@ -171,7 +171,7 @@ bool CChicken::TimerMsg(CTimerMsg *msg) {
}
if (flag) {
- invChange();
+ petInvChange();
stopTimer(_timerId);
}
diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp
index a8ceaad5ba..cba2b4a560 100644
--- a/engines/titanic/carry/napkin.cpp
+++ b/engines/titanic/carry/napkin.cpp
@@ -49,11 +49,11 @@ bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) {
CActMsg actMsg("Clean");
actMsg.execute("Chicken");
} else {
- petDisplayMsg("The Chicken is already quite clean enough, thank you.");
+ petDisplayMessage("The Chicken is already quite clean enough, thank you.");
}
}
- addToInventory();
+ petAddToInventory();
return CCarry::UseWithOtherMsg(msg);
}
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 95024b9dae..a90318961c 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -501,12 +501,6 @@ bool CGameObject::checkStartDragging(CMouseDragStartMsg *msg) {
}
}
-void CGameObject::setPetArea(PetArea newArea) const {
- CPetControl *pet = getPetControl();
- if (pet)
- pet->setArea(newArea);
-}
-
bool CGameObject::hasActiveMovie() const {
if (_surface && _surface->_movie)
return _surface->_movie->isActive();
@@ -684,16 +678,6 @@ int CGameObject::compareRoomNameTo(const CString &name) {
return room->getName().compareToIgnoreCase(name);
}
-void CGameObject::petDisplayMsg(const CString &msg) const {
- CPetControl *pet = getPetControl();
- if (pet)
- pet->displayMessage(msg);
-}
-
-void CGameObject::displayMessage(const CString &msg) const {
- petDisplayMsg(msg);
-}
-
CGameObject *CGameObject::getMailManFirstObject() const {
CMailMan *mailMan = getMailMan();
return mailMan ? mailMan->getFirstObject() : nullptr;
@@ -764,14 +748,6 @@ Found CGameObject::find(const CString &name, CGameObject **item, int findAreas)
return FOUND_NONE;
}
-void CGameObject::moveToHiddenRoom() {
- CPetControl *pet = getPetControl();
- if (pet) {
- makeDirty();
- pet->moveToHiddenRoom(this);
- }
-}
-
void CGameObject::moveToView() {
CViewItem *view = getGameManager()->getView();
detach();
@@ -806,24 +782,6 @@ void CGameObject::unlockMouse() {
gameMan->unlockInputHandler();
}
-void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) {
- CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName));
- startTalking(npc, id, view);
-}
-
-void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
- CGameManager *gameManager = getGameManager();
- if (gameManager) {
- CTrueTalkManager *talkManager = gameManager->getTalkManager();
- if (talkManager)
- talkManager->start(npc, id, view);
- }
-}
-
-void CGameObject::endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
- warning("TODO: CGameObject::endTalking");
-}
-
void CGameObject::loadSurface() {
if (!_surface && !_resource.empty()) {
loadResource(_resource);
@@ -869,6 +827,10 @@ Point CGameObject::getControid() const {
_bounds.top + _bounds.height() / 2);
}
+void CGameObject::performAction(int actionNum, CViewItem *view) {
+ // TODO
+}
+
bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const {
return _clipList1.existsByStart(name, startFrame);
}
@@ -888,7 +850,7 @@ void CGameObject::checkPlayMovie(const CString &name, int flags) {
}
}
-void CGameObject::clearPet() const {
+void CGameObject::petClear() const {
CPetControl *petControl = getPetControl();
if (petControl)
petControl->resetActiveNPC();
@@ -1002,12 +964,20 @@ int CGameObject::getClipDuration(const CString &name, int frameRate) const {
return clip ? (clip->_endFrame - clip->_startFrame) * 1000 / frameRate : 0;
}
-void CGameObject::petLockInput() {
- getPetControl()->incInputLocks();
-}
+bool CGameObject::compareRoomFlags(int mode, uint flags1, uint flags2) {
+ switch (mode) {
+ case 1:
+ return CRoomFlags::compareLocation(flags1, flags2);
-void CGameObject::petUnlockInput() {
- getPetControl()->decInputLocks();
+ case 2:
+ return CRoomFlags::compareClassElevator(flags1, flags2);
+
+ case 3:
+ return CRoomFlags::isTitania(flags1, flags2);
+
+ default:
+ return false;
+ }
}
void CGameObject::setState1C(bool flag) {
@@ -1051,10 +1021,48 @@ void CGameObject::resetMail() {
mailMan->resetValue();
}
-void CGameObject::petSetRooms1D0(int val) {
- CPetControl *petControl = getPetControl();
- if (petControl)
- petControl->setRooms1D0(val);
+void CGameObject::petAddToCarryParcel(CGameObject *obj) {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ CGameObject *parcel = pet->getHiddenObject("CarryParcel");
+ if (parcel)
+ parcel->moveUnder(obj);
+ }
+}
+
+void CGameObject::petAddToInventory() {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ makeDirty();
+ pet->addToInventory(this);
+ }
+}
+
+CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) {
+ CPetControl *pet = getPetControl();
+ if (!obj || !pet)
+ return nullptr;
+ if (!obj->compareRoomNameTo("CarryParcel"))
+ return obj;
+
+ CGameObject *item = static_cast<CGameObject *>(pet->getLastChild());
+ if (item)
+ item->detach();
+
+ pet->moveToHiddenRoom(obj);
+ pet->removeFromInventory(item, false, false);
+
+ return item;
+}
+
+void CGameObject::petDisplayMessage(int unused, const CString &msg) {
+ petDisplayMessage(msg);
+}
+
+void CGameObject::petDisplayMessage(const CString &msg) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->displayMessage(msg);
}
int CGameObject::petGetRooms1D0() const {
@@ -1062,10 +1070,78 @@ int CGameObject::petGetRooms1D0() const {
return petControl ? petControl->getRooms1D0() : 0;
}
-void CGameObject::reassignRoom(int passClassNum) {
+void CGameObject::petInvChange() {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->invChange(this);
+}
+
+void CGameObject::petLockInput() {
+ getPetControl()->incInputLocks();
+}
+
+void CGameObject::petMoveToHiddenRoom() {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ makeDirty();
+ pet->moveToHiddenRoom(this);
+ }
+}
+
+void CGameObject::petReassignRoom(int passClassNum) {
CPetControl *petControl = getPetControl();
if (petControl)
petControl->reassignRoom(passClassNum);
}
+void CGameObject::petSetArea(PetArea newArea) const {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->setArea(newArea);
+}
+
+void CGameObject::petSetRooms1D0(int val) {
+ CPetControl *petControl = getPetControl();
+ if (petControl)
+ petControl->setRooms1D0(val);
+}
+
+void CGameObject::petOnSummonBot(const CString &name, int val) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->summonBot(name, val);
+}
+
+void CGameObject::petUnlockInput() {
+ getPetControl()->decInputLocks();
+}
+
+/*------------------------------------------------------------------------*/
+
+void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) {
+ CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName));
+ startTalking(npc, id, view);
+}
+
+void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
+ CGameManager *gameManager = getGameManager();
+ if (gameManager) {
+ CTrueTalkManager *talkManager = gameManager->getTalkManager();
+ if (talkManager)
+ talkManager->start(npc, id, view);
+ }
+}
+
+void CGameObject::endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->setActiveNPC(npc);
+
+ if (viewFlag)
+ npc->setView(view);
+
+ if (pet)
+ pet->refreshNPC();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 7a12abe76c..4ca8061d75 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -111,11 +111,6 @@ protected:
bool checkStartDragging(CMouseDragStartMsg *msg);
/**
- * Sets a new area in the PET
- */
- void setPetArea(PetArea newArea) const;
-
- /**
* Goto a new view
*/
void gotoView(const CString &viewName, const CString &clipName);
@@ -126,26 +121,6 @@ protected:
*/
CViewItem * parseView(const CString &viewString);
- /**
- * Highlights a glyph in the currently active PET section
- */
- void petHighlightGlyph(int id);
-
- /**
- * Hides the text cursor in the current section, if applicable
- */
- void petHideCursor();
-
- /**
- * Shows the text cursor in the current section, if applicable
- */
- void petShowCursor();
-
- /**
- * Set the remote target in the PET to this object
- */
- void petSetRemoteTarget();
-
void incState38();
void inc54();
void dec54();
@@ -221,11 +196,6 @@ protected:
int compareRoomNameTo(const CString &name);
/**
- * Display a message in the PET
- */
- void petDisplayMsg(const CString &msg) const;
-
- /**
* Display a message
*/
void displayMessage(const CString &msg) const;
@@ -256,21 +226,6 @@ protected:
void moveToView();
/**
- * Start a conversation with the NPC
- */
- void startTalking(const CString &name, uint id, CViewItem *view = nullptr);
-
- /**
- * Start a conversation with the NPC
- */
- void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
-
- /**
- * Stop a conversation with the NPC
- */
- void endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
-
- /**
* Change the view
*/
bool changeView(const CString &viewName, const CString &clipName);
@@ -317,7 +272,12 @@ protected:
/**
* Clear the PET display
*/
- void clearPet() const;
+ void petClear() const;
+
+ /**
+ * Perform an action
+ */
+ void performAction(int actionNum, CViewItem *view = nullptr);
/**
* Returns the MailMan
@@ -463,11 +423,6 @@ public:
* Returns true if the item is the PET control
*/
virtual bool isPet() const;
-
- /**
- * Returns the PET control
- */
- CPetControl *getPetControl() const;
/**
* Play the movie specified in _resource
@@ -475,11 +430,6 @@ public:
void playMovie(uint startFrame, uint endFrame, uint flags);
/**
- * Moves the item from it's original position to be under the hidden room
- */
- void moveToHiddenRoom();
-
- /**
* Checks the passed point is validly in the object,
* with extra checking of object flags status
*/
@@ -567,19 +517,108 @@ public:
*/
void createCredits();
- void petSetRooms1D0(int val);
+ /**
+ * Support function for drag moving
+ */
+ void dragMove(const Point &pt);
+
+ bool compareRoomFlags(int mode, uint flags1, uint flags2);
+
+ /*--- CPetControl Methods ---*/
+
+ /**
+ * Returns the PET control
+ */
+ CPetControl *getPetControl() const;
+
+ /**
+ * Moves a specified item to the carry parcel
+ */
+ void petAddToCarryParcel(CGameObject *obj);
+
+ /**
+ * Add the item to the inventory
+ */
+ void petAddToInventory();
+
+ CTreeItem *petContainerRemove(CGameObject *obj);
+
+ /**
+ * Display a message in the PET
+ */
+ void petDisplayMessage(int unused, const CString &msg);
+
+ /**
+ * Display a message in the PET
+ */
+ void petDisplayMessage(const CString &msg);
int petGetRooms1D0() const;
/**
+ * Hides the text cursor in the current section, if applicable
+ */
+ void petHideCursor();
+
+ /**
+ * Highlights a glyph in the currently active PET section
+ */
+ void petHighlightGlyph(int id);
+
+ /**
+ * Called when the status of an item in the inventory has changed
+ */
+ void petInvChange();
+
+ /**
+ * Moves the item from it's original position to be under the hidden room
+ */
+ void petMoveToHiddenRoom();
+
+ /**
* Gives the player a new assigned room in the specified passenger class
*/
- void reassignRoom(int passClassNum);
+ void petReassignRoom(int passClassNum);
/**
- * Support function for drag moving
+ * Sets a new area in the PET
*/
- void dragMove(const Point &pt);
+ void petSetArea(PetArea newArea) const;
+
+ /**
+ * Set the remote target in the PET to this object
+ */
+ void petSetRemoteTarget();
+
+ void petSetRooms1D0(int val);
+
+ /**
+ * Shows the text cursor in the current section, if applicable
+ */
+ void petShowCursor();
+
+ /**
+ * Summon a bot
+ */
+ void petOnSummonBot(const CString &name, int val);
+
+ /*--- CTrueTalkManager Methods ---*/
+
+ /**
+ * Stop a conversation with the NPC
+ */
+ void endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr);
+
+ /**
+ * Start a conversation with the NPC
+ */
+ void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
+
+ /**
+ * Start a conversation with the NPC
+ */
+ void startTalking(const CString &name, uint id, CViewItem *view = nullptr);
+
};
} // End of namespace Titanic
diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp
index e02f1c8f64..37fc546851 100644
--- a/engines/titanic/debugger.cpp
+++ b/engines/titanic/debugger.cpp
@@ -249,7 +249,7 @@ bool Debugger::cmdItem(int argc, const char **argv) {
// Ensure the PET is active and add the item to the inventory
gameState._petActive = true;
gameManager.initBounds();
- item->addToInventory();
+ item->petAddToInventory();
return false;
} else {
diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp
index 4d8e3f2042..57b2b7f453 100644
--- a/engines/titanic/game/television.cpp
+++ b/engines/titanic/game/television.cpp
@@ -101,7 +101,7 @@ void CTelevision::load(SimpleFile *file) {
}
bool CTelevision::LeaveViewMsg(CLeaveViewMsg *msg) {
- clearPet();
+ petClear();
if (_isOn) {
if (soundFn1(_soundHandle))
stopSound(_soundHandle, 0);
@@ -139,7 +139,7 @@ bool CTelevision::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
}
bool CTelevision::EnterViewMsg(CEnterViewMsg *msg) {
- setPetArea(PET_REMOTE);
+ petSetArea(PET_REMOTE);
petHighlightGlyph(GLYPH_TELEVISION_CONTROL);
petSetRemoteTarget();
setVisible(0);
diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp
index eb42a8e21d..3fe92367ce 100644
--- a/engines/titanic/npcs/deskbot.cpp
+++ b/engines/titanic/npcs/deskbot.cpp
@@ -80,7 +80,7 @@ bool CDeskbot::TurnOn(CTurnOn *msg) {
setVisible(true);
playClip("BellRinging", 4);
playSound("b#69.wav");
- setPetArea(PET_CONVERSATION);
+ petSetArea(PET_CONVERSATION);
_npcFlags |= NPCFLAG_20000;
_deskbotActive = true;
@@ -110,7 +110,7 @@ bool CDeskbot::MovieEndMsg(CMovieEndMsg *msg) {
bool flag = false;
if (_npcFlags & NPCFLAG_10000) {
if (_classNum) {
- setPetArea(PET_ROOMS);
+ petSetArea(PET_ROOMS);
dec54();
unlockMouse();
playSound("z#47.wav", 100, 0, 0);
@@ -169,25 +169,25 @@ bool CDeskbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) {
case 19:
inc54();
lockMouse();
- setPetArea(PET_CONVERSATION);
+ petSetArea(PET_CONVERSATION);
playClip("ReprogramPETInHand", 4);
_npcFlags |= NPCFLAG_10000;
_classNum = msg->_param1;
switch (_classNum) {
case 1:
- petDisplayMsg("You have been upgraded to 1st Class status. Enjoy hugely.");
+ petDisplayMessage("You have been upgraded to 1st Class status. Enjoy hugely.");
setPassengerClass(_classNum);
- reassignRoom(_classNum);
+ petReassignRoom(_classNum);
break;
case 2:
- petDisplayMsg("You have been upgraded to 2nd Class status. Enjoy.");
+ petDisplayMessage("You have been upgraded to 2nd Class status. Enjoy.");
setPassengerClass(_classNum);
- reassignRoom(_classNum);
+ petReassignRoom(_classNum);
break;
case 3:
setPassengerClass(3);
- reassignRoom(_classNum);
+ petReassignRoom(_classNum);
break;
default:
break;
diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp
index 32c6412fef..00b68c2913 100644
--- a/engines/titanic/npcs/true_talk_npc.cpp
+++ b/engines/titanic/npcs/true_talk_npc.cpp
@@ -197,10 +197,6 @@ void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) {
talkManager->processInput(this, msg, view);
}
-void CTrueTalkNPC::performAction(int actionNum, CViewItem *view) {
- // TODO
-}
-
int CTrueTalkNPC::startAnimTimer(const CString &action, uint firstDuration, uint duration) {
CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(),
duration > 0, firstDuration, duration, this, 0, action);
@@ -209,4 +205,10 @@ int CTrueTalkNPC::startAnimTimer(const CString &action, uint firstDuration, uint
return timer->_id;
}
+void CTrueTalkNPC::setView(CViewItem *view) {
+ CTrueTalkManager *talkManager = getGameManager()->getTalkManager();
+ if (talkManager)
+ talkManager->start3(this, view);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h
index a1303c3e5d..1a10a0aa9b 100644
--- a/engines/titanic/npcs/true_talk_npc.h
+++ b/engines/titanic/npcs/true_talk_npc.h
@@ -64,11 +64,6 @@ protected:
void processInput(CTextInputMsg *msg, CViewItem *view);
/**
- * Perform an action
- */
- void performAction(int actionNum, CViewItem *view = nullptr);
-
- /**
* Start an animation timer
*/
int startAnimTimer(const CString &action, uint firstDuration, uint duration);
@@ -85,6 +80,11 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ /**
+ * Set the view for the NPC
+ */
+ void setView(CViewItem *view);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 7e5cd20441..e526a03b58 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -183,6 +183,21 @@ void CPetControl::resetRemoteTarget() {
_remoteTargetName.clear();
}
+void CPetControl::setActiveNPC(CTrueTalkNPC *npc) {
+ if (_activeNPC == npc) {
+ if (_activeNPC) {
+ _activeNPCName = npc->getName();
+ _conversations.displayNPCName(npc);
+ } else {
+ _activeNPCName = "";
+ }
+ }
+}
+
+void CPetControl::refreshNPC() {
+ _conversations.setNPC(_activeNPCName);
+}
+
void CPetControl::resetActiveNPC() {
_activeNPC = nullptr;
_activeNPCName = "";
@@ -379,7 +394,7 @@ void CPetControl::addToInventory(CGameObject *item) {
if (child)
child->detach();
- item->moveToHiddenRoom();
+ item->petMoveToHiddenRoom();
if (!child)
return;
@@ -413,12 +428,12 @@ void CPetControl::removeFromInventory(CGameObject *item, CTreeItem *newParent,
}
}
-void CPetControl::removeFromInventory(CCarry *item, bool refreshUI, bool sendMsg) {
+void CPetControl::removeFromInventory(CGameObject *item, bool refreshUI, bool sendMsg) {
CViewItem *view = getGameManager()->getView();
removeFromInventory(item, view, refreshUI, sendMsg);
}
-void CPetControl::invChange(CCarry *item) {
+void CPetControl::invChange(CGameObject *item) {
_inventory.change(item);
}
@@ -430,6 +445,66 @@ void CPetControl::moveToHiddenRoom(CTreeItem *item) {
}
}
+bool CPetControl::checkNode(const CString &name) {
+ CGameManager *gameManager = getGameManager();
+ if (!gameManager)
+ return true;
+ if (name == "NULL")
+ return false;
+
+ CViewItem *view = gameManager->getView();
+ if (!view)
+ return true;
+
+ CNodeItem *node = view->findNode();
+ if (!node)
+ return true;
+
+ CString viewName = view->getName();
+ CString nodeName = node->getName();
+ CRoomItem *room = getGameManager()->getRoom();
+
+ if (room) {
+ CString roomName = room->getName();
+ CString newNode;
+
+ if (roomName == "1stClassRestaurant") {
+ } else if (nodeName == "Lobby Node") {
+ nodeName = "Node 1";
+ } else if (nodeName == "Entrance Node") {
+ nodeName = "Node 2";
+ } else if (nodeName == "MaitreD Node") {
+ nodeName = "Node 3";
+ } else if (nodeName == "Scraliontis Table Standing Node") {
+ nodeName = "Node 4";
+ } else if (nodeName == "Pellerator Node") {
+ nodeName = "Node 5";
+ } else if (nodeName == "SUB Node") {
+ nodeName = "Node 6";
+ } else if (nodeName == "Phonograph Node") {
+ nodeName = "Node 7";
+ } else if (nodeName == "Scraliontis Table Seated Node") {
+ nodeName = "Node 8";
+ }
+
+ if (roomName == "MusicRoom") {
+ if (nodeName == "Musical Instruments")
+ nodeName = "Node 1";
+ if (nodeName == "Phonograph Node")
+ nodeName = "Node 2";
+ }
+ }
+
+ CString str = CString::format("%s.%s", nodeName.c_str(), viewName.c_str());
+ str = str.right(5);
+ str.toLowercase();
+
+ CString nameLower = name;
+ nameLower.toLowercase();
+
+ return nameLower.contains(str);
+}
+
void CPetControl::playSound(int soundNum) {
CTreeItem *player = getHiddenObject("PETSoundPlayer");
if (player) {
@@ -443,9 +518,9 @@ CString CPetControl::getRoomName() const {
return room ? room->getName() : CString();
}
-int CPetControl::canSummonNPC(const CString &name) {
+int CPetControl::canSummonBot(const CString &name) {
// If player is the very same view as the NPC, then it's already present
- if (isNPCInView(name))
+ if (isBotInView(name))
return SUMMON_CAN;
// Get the room
@@ -461,7 +536,7 @@ int CPetControl::canSummonNPC(const CString &name) {
return queryMsg.execute(room) ? SUMMON_CAN : SUMMON_CANT;
}
-bool CPetControl::isNPCInView(const CString &name) const {
+bool CPetControl::isBotInView(const CString &name) const {
CGameManager *gameManager = getGameManager();
if (!gameManager)
return false;
@@ -481,7 +556,7 @@ bool CPetControl::isNPCInView(const CString &name) const {
return false;
}
-void CPetControl::summonNPC(const CString &name, int val) {
+void CPetControl::summonBot(const CString &name, int val) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
CRoomItem *room = gameManager->getRoom();
@@ -493,6 +568,20 @@ void CPetControl::summonNPC(const CString &name, int val) {
}
}
+void CPetControl::onSummonBot(const CString &name, int val) {
+ CGameObject *bot = findObject(name, getHiddenRoom());
+ if (!bot) {
+ bot = findObject(name, getRoot());
+ }
+
+ if (bot) {
+ removeFromInventory(bot, false, false);
+
+ COnSummonBotMsg summonMsg(val);
+ summonMsg.execute(bot);
+ }
+}
+
void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target) {
stopPetTimer(timerIndex);
_timers[timerIndex]._id = addTimer(timerIndex, firstDuration, duration);
@@ -511,6 +600,18 @@ void CPetControl::setTimer44(int id, int val) {
getGameManager()->setTimer44(id, val);
}
+CGameObject *CPetControl::findObject(const CString &name, CTreeItem *root) {
+ for (CTreeItem *item = root; item; item = item->scan(root)) {
+ if (!item->getName().compareToIgnoreCase(name)) {
+ CGameObject *obj = static_cast<CGameObject *>(item);
+ if (obj)
+ return obj;
+ }
+ }
+
+ return nullptr;
+}
+
CString CPetControl::getFullViewName() {
CGameManager *gameManager = getGameManager();
return gameManager ? gameManager->getFullViewName() : CString();
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index c3afb7862b..6b40c15a6d 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -96,9 +96,14 @@ private:
/**
* Checks whether a designated NPC in present in the current view
*/
- bool isNPCInView(const CString &name) const;
+ bool isBotInView(const CString &name) const;
void setTimer44(int id, int val);
+
+ /**
+ * Find an object under a given root
+ */
+ CGameObject *findObject(const CString &name, CTreeItem *root);
protected:
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
@@ -251,12 +256,12 @@ public:
/**
* Remove an item from the inventory
*/
- void removeFromInventory(CCarry *item, bool refreshUI = true, bool sendMsg = true);
+ void removeFromInventory(CGameObject *item, bool refreshUI = true, bool sendMsg = true);
/**
* Called when the status of an item in the inventory has changed
*/
- void invChange(CCarry *item);
+ void invChange(CGameObject *item);
/**
* Moves a tree item from it's original position to be under the hidden room
@@ -269,6 +274,8 @@ public:
*/
void setAreaChangeType(int changeType) { _areaChangeType = changeType; }
+ bool checkNode(const CString &name);
+
/**
* Play a sound
*/
@@ -282,12 +289,17 @@ public:
/**
* Check whether an NPC can be summoned
*/
- int canSummonNPC(const CString &name);
+ int canSummonBot(const CString &name);
/**
* Summon an NPC to the player
*/
- void summonNPC(const CString &name, int val);
+ void summonBot(const CString &name, int val);
+
+ /**
+ * Summon a bot to the player
+ */
+ void onSummonBot(const CString &name, int val);
/**
* Start a timer for a Pet Area
@@ -349,6 +361,16 @@ public:
}
/**
+ * Sets the actie NPC
+ */
+ void setActiveNPC(CTrueTalkNPC *npc);
+
+ /**
+ * Refresh the currently active NPC
+ */
+ void refreshNPC();
+
+ /**
* Resets the Active NPC
*/
void resetActiveNPC();
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp
index 3d239bb36b..f9c051a883 100644
--- a/engines/titanic/pet_control/pet_conversations.cpp
+++ b/engines/titanic/pet_control/pet_conversations.cpp
@@ -162,12 +162,12 @@ bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
return true;
if (_doorBot.MouseButtonUpMsg(msg->_mousePos)) {
- switch (canSummonNPC("DoorBot")) {
+ switch (canSummonBot("DoorBot")) {
case SUMMON_CANT:
_log.addLine("Sadly, it is not possible to summon the DoorBot from this location.", getColor(1));
break;
case SUMMON_CAN:
- summonNPC("DoorBot");
+ summonBot("DoorBot");
return true;
default:
break;
@@ -179,12 +179,12 @@ bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
}
if (_bellBot.MouseButtonUpMsg(msg->_mousePos)) {
- switch (canSummonNPC("BellBot")) {
+ switch (canSummonBot("BellBot")) {
case SUMMON_CANT:
_log.addLine("Sadly, it is not possible to summon the BellBot from this location.", getColor(1));
break;
case SUMMON_CAN:
- summonNPC("BellBot");
+ summonBot("BellBot");
return true;
default:
break;
@@ -412,16 +412,16 @@ void CPetConversations::scrollToBottom() {
_logChanged = true;
}
-int CPetConversations::canSummonNPC(const CString &name) {
- return _petControl ? _petControl->canSummonNPC(name) : SUMMON_CANT;
+int CPetConversations::canSummonBot(const CString &name) {
+ return _petControl ? _petControl->canSummonBot(name) : SUMMON_CANT;
}
-void CPetConversations::summonNPC(const CString &name) {
+void CPetConversations::summonBot(const CString &name) {
if (_petControl) {
if (_petControl->getPassengerClass() >= 4) {
_petControl->displayMessage("Sorry, you must be at least 3rd class before you can summon for help.");
} else {
- _petControl->summonNPC(name, 0);
+ _petControl->summonBot(name, 0);
}
}
}
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index 876f3d78a9..51487e1ff4 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -92,12 +92,12 @@ private:
/**
* Check whether an NPC can be summoned
*/
- int canSummonNPC(const CString &name);
+ int canSummonBot(const CString &name);
/**
* Summon an NPC
*/
- void summonNPC(const CString &name);
+ void summonBot(const CString &name);
/**
* Starts the NPC timer
diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp
index 3143cde0ea..e6c4749123 100644
--- a/engines/titanic/pet_control/pet_drag_chev.cpp
+++ b/engines/titanic/pet_control/pet_drag_chev.cpp
@@ -63,7 +63,7 @@ bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) {
if (petControl && petControl->contains(msg->_mousePos)
&& msg->_mousePos.x < 528) {
if (petControl->checkDragEnd(this))
- moveToHiddenRoom();
+ petMoveToHiddenRoom();
}
}
}
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index a207c6695d..62eee83667 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -158,7 +158,7 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
return true;
}
-void CPetInventory::change(CCarry *item) {
+void CPetInventory::change(CGameObject *item) {
if (item) {
CInventoryGlyphAction action(item, ACTION_CHANGE);
_items.doAction(&action);
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index e931abf5c6..8a6bcebd9f 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -144,7 +144,7 @@ public:
/**
*
*/
- void change(CCarry *item);
+ void change(CGameObject *item);
/**
* Called when an item has been removed from the PET
diff --git a/engines/titanic/pet_control/pet_real_life.h b/engines/titanic/pet_control/pet_real_life.h
index aa980fca0f..d049d47913 100644
--- a/engines/titanic/pet_control/pet_real_life.h
+++ b/engines/titanic/pet_control/pet_real_life.h
@@ -81,8 +81,6 @@ public:
virtual bool KeyCharMsg(CKeyCharMsg *msg);
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
- virtual int proc14() { return 0; }
-
/**
* Returns item a drag-drop operation has dropped on, if any
*/
diff --git a/engines/titanic/room_flags.cpp b/engines/titanic/room_flags.cpp
index ac378e20c1..4b3aeb424e 100644
--- a/engines/titanic/room_flags.cpp
+++ b/engines/titanic/room_flags.cpp
@@ -433,14 +433,17 @@ void CRoomFlags::changeLocation(int action) {
setRoomBits(roomNum);
}
-bool CRoomFlags::compareFlags(CRoomFlags flags1, CRoomFlags flags2) const {
- if (flags1.getFloorNum() != flags2.getFloorNum())
+bool CRoomFlags::compareClassElevator(uint flags1, uint flags2) {
+ CRoomFlags f1(flags1);
+ CRoomFlags f2(flags2);
+
+ if (f1.getFloorNum() != f2.getFloorNum())
return false;
- uint elev1 = flags1.getElevatorNum();
- uint elev2 = flags2.getElevatorNum();
- uint class1 = getPassengerClassNum();
- uint class2 = getPassengerClassNum();
+ uint elev1 = f1.getElevatorNum();
+ uint elev2 = f2.getElevatorNum();
+ uint class1 = f1.getPassengerClassNum();
+ uint class2 = f2.getPassengerClassNum();
if (class1 > 0 && class1 < 3) {
if (elev1 == 2)
@@ -458,12 +461,17 @@ bool CRoomFlags::compareFlags(CRoomFlags flags1, CRoomFlags flags2) const {
return elev1 == elev2;
}
-bool CRoomFlags::compareLocation(uint roomFlags) {
- CRoomFlags flags(roomFlags);
+bool CRoomFlags::compareLocation(uint flags1, uint flags2) {
+ CRoomFlags f1(flags1);
+ CRoomFlags f2(flags2);
+
+ return f1.getElevatorNum() == f2.getElevatorBits() &&
+ f1.getFloorNum() == f2.getFloorNum() &&
+ f1.getRoomNum() == f2.getRoomNum();
+}
- return getElevatorNum() == flags.getElevatorBits() &&
- getFloorNum() == flags.getFloorNum() &&
- getRoomNum() == flags.getRoomNum();
+bool CRoomFlags::isTitania(uint flags1, uint flags2) {
+ return flags2 == 0x8A397;
}
void CRoomFlags::setRandomLocation(int classNum, bool flag) {
diff --git a/engines/titanic/room_flags.h b/engines/titanic/room_flags.h
index dfb7c89d96..f0f90f80d1 100644
--- a/engines/titanic/room_flags.h
+++ b/engines/titanic/room_flags.h
@@ -58,25 +58,25 @@ private:
*/
uint decodeFloorBits(uint bits) const;
+ static bool is2To19(uint v) { return v >= 2 && v <= 19; }
+ static bool is20To27(uint v) { return v >= 20 && v <= 27; }
+ static bool is28To38(uint v) { return v >= 28 && v <= 38; }
+public:
/**
- * Compares two room flags together
+ * Compares the current flags against the specified flags
+ * for a matching elevator, floor, and room
*/
- bool compareFlags(CRoomFlags flags1, CRoomFlags flags2) const;
+ static bool compareLocation(uint flags1, uint flags2);
/**
- * Compares the current flags against the specified flags
- * for a matching elevator, floor, and room
+ * Compares two room flags together
*/
- bool compareLocation(uint roomFlags);
+ static bool compareClassElevator(uint flags1, uint flags2);
/**
* Returns true if the current flags is for Titania's room
*/
- bool isTitania() const { return _data == 0x8A397; }
-
- static bool is2To19(uint v) { return v >= 2 && v <= 19; }
- static bool is20To27(uint v) { return v >= 20 && v <= 27; }
- static bool is28To38(uint v) { return v >= 28 && v <= 38; }
+ static bool isTitania(uint flags1, uint flags2);
public:
CRoomFlags() : _data(0) {}
CRoomFlags(uint data) : _data(data) {}