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 (dynamic_cast<CGameObject *>(treeItem) && (name.contains("Doorbot") || name.contains("BellBot"))) return true; } return false; }
bool CPetControl::isBotInView(const CString &name) const { CGameManager *gameManager = getGameManager(); if (!gameManager) return false; CViewItem *view = gameManager->getView(); if (!view) return false; // Iterate to find NPC for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) { CGameObject *gameObject = dynamic_cast<CGameObject *>(child); if (gameObject) { if (!gameObject->getName().compareToIgnoreCase(name)) return true; } } return false; }
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; }