diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 10 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.cpp | 46 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.h | 18 |
4 files changed, 77 insertions, 7 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index a90318961c..154d2aeefc 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -1055,6 +1055,16 @@ CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) { return item; } +bool CGameObject::petDismissBot(const CString &name) { + CPetControl *pet = getPetControl(); + return pet ? pet->dismissBot(name) : false; +} + +bool CGameObject::petDoorOrBellbotPresent() const { + CPetControl *pet = getPetControl(); + return pet ? pet->isDoorOrBellbotPresent() : false; +} + void CGameObject::petDisplayMessage(int unused, const CString &msg) { petDisplayMessage(msg); } diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 4ca8061d75..c43d73f73d 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -544,6 +544,16 @@ public: CTreeItem *petContainerRemove(CGameObject *obj); /** + * Dismiss a bot + */ + bool petDismissBot(const CString &name); + + /** + * Is Doorbot or Bellbot present in the current view + */ + bool petDoorOrBellbotPresent() const; + + /** * Display a message in the PET */ void petDisplayMessage(int unused, const CString &msg); diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index e526a03b58..7d35eb31f2 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -569,9 +569,9 @@ void CPetControl::summonBot(const CString &name, int val) { } void CPetControl::onSummonBot(const CString &name, int val) { - CGameObject *bot = findObject(name, getHiddenRoom()); + CGameObject *bot = findBot(name, getHiddenRoom()); if (!bot) { - bot = findObject(name, getRoot()); + bot = findBot(name, getRoot()); } if (bot) { @@ -582,6 +582,46 @@ void CPetControl::onSummonBot(const CString &name, int val) { } } +bool CPetControl::dismissBot(const CString &name) { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return false; + CViewItem *view = gameManager->getView(); + if (!view) + return false; + + bool result = false; + CDismissBotMsg dismissMsg; + for (CTreeItem *treeItem = view->getFirstChild(); treeItem; + treeItem = treeItem->scan(view)) { + if (!treeItem->getName().compareToIgnoreCase(name)) + dismissMsg.execute(treeItem); + else + result = true; + } + + return result; +} + +bool CPetControl::isDoorOrBellbotPresent() const { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return false; + CViewItem *view = gameManager->getView(); + if (!view) + return false; + + for (CTreeItem *treeItem = view->getFirstChild(); treeItem; + treeItem = treeItem->scan(view)) { + CString name = treeItem->getName(); + if (static_cast<CGameObject *>(treeItem) && + (name.contains("Doorbot") || name.contains("BellBot"))) + return true; + } + + return false; +} + void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target) { stopPetTimer(timerIndex); _timers[timerIndex]._id = addTimer(timerIndex, firstDuration, duration); @@ -600,7 +640,7 @@ void CPetControl::setTimer44(int id, int val) { getGameManager()->setTimer44(id, val); } -CGameObject *CPetControl::findObject(const CString &name, CTreeItem *root) { +CGameObject *CPetControl::findBot(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); diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index 6b40c15a6d..07a4ffa680 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -98,12 +98,12 @@ private: */ bool isBotInView(const CString &name) const; - void setTimer44(int id, int val); - /** - * Find an object under a given root + * Find a bot under a given root */ - CGameObject *findObject(const CString &name, CTreeItem *root); + CGameObject *findBot(const CString &name, CTreeItem *root); + + void setTimer44(int id, int val); protected: bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); bool MouseDragStartMsg(CMouseDragStartMsg *msg); @@ -302,6 +302,16 @@ public: void onSummonBot(const CString &name, int val); /** + * Dismiss an NPC + */ + bool dismissBot(const CString &name); + + /** + * Returns true if Doorbot or Bellbot present + */ + bool isDoorOrBellbotPresent() const; + + /** * Start a timer for a Pet Area */ void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target); |