aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-26 12:39:44 -0400
committerPaul Gilbert2016-07-15 19:25:09 -0400
commit6f063c4703e5705edbba7ad39ef9c0656b74bc75 (patch)
tree64cb04d4e3f3a327f6a080ffef8e7af6c0f12152 /engines/titanic/pet_control
parent0146a3c6b6bdb16eef6f46e116b0d9fe9883858f (diff)
downloadscummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.gz
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.bz2
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.zip
TITANIC: Fleshing out CGameObject and CPetControl methods
Diffstat (limited to 'engines/titanic/pet_control')
-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
8 files changed, 148 insertions, 27 deletions
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
*/