void ConversationManager::startConversation(NPCObject* npc,PlayerObject* player) { //we can't converse whilst in combat /* commented out for preview as borked. client ctd ftl if(player->states.checkState(CreatureState_Combat)) { stopConversation(player,true); gMessageLib->sendSystemMessage(player,"You may not start a Conversation whilst in Combat!"); }*/ // make sure theres no conversation running yet if(getActiveConversation(player->getId()) != NULL) { stopConversation(player); } // initialize a new one Conversation* conv = getConversation(npc->getInternalAttribute<uint32>("base_conversation")); ActiveConversation* av = new(mActiveConversationPool.malloc()) ActiveConversation(conv,player,npc); // ConversationPage* currentPage = av->getCurrentPage(); mActiveConversations.insert(std::make_pair(player->getId(),av)); // In case of npc trainers, they may not always open a dialog, they just chat in spatial. (like traniers that you can not train from yet) // We need a way to abort the dialog. // Pre process npc conversation. if (av->preProcessConversation()) { ConversationPage* currentPage = av->getCurrentPage(); // Get the options dialog data. av->prepareFilteredOptions(); gMessageLib->sendStartNPCConversation(npc,player); if(currentPage->mAnimation) { if (gWorldConfig->isInstance()) { // We are running in an instance. gMessageLib->sendCreatureAnimation(npc,gWorldManager->getNpcConverseAnimation(currentPage->mAnimation), player); } else { gMessageLib->sendCreatureAnimation(npc,gWorldManager->getNpcConverseAnimation(currentPage->mAnimation)); } } gMessageLib->sendNPCDialogMessage(av,player); gMessageLib->sendNPCDialogOptions(av->getFilteredOptions(),player); } else { // We terminate (do not start) this conversation. stopConversation(player); } }
void IngameGUI::processEventQueue() { // The dialog takes preference if (_dialog) { if (_dialog->processEventQueue() != 0) stopConversation(); return; } for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p) (*p)->processEventQueue(); _compass->processEventQueue(); _quickchat->processEventQueue(); _quickbar->processEventQueue(); }
void ConversationManager::updateConversation(uint32 selectId,PlayerObject* player) { ActiveConversation* av = getActiveConversation(player->getId()); if(!av) { gLogger->logMsgF("ConversationManager::updateConversation: could not find conversation for %"PRIu64,MSG_NORMAL,player->getId()); return; } av->updateCurrentPage(selectId); ConversationPage* currentPage = av->getCurrentPage(); if(!currentPage) { stopConversation(player,true); return; } if(currentPage->mAnimation) { if (gWorldConfig->isInstance()) { // We are running in an instance. gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(currentPage->mAnimation), player); } else { gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(currentPage->mAnimation)); } // gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(currentPage->mAnimation)); } gMessageLib->sendNPCDialogMessage(av,player); gMessageLib->sendNPCDialogOptions(av->getFilteredOptions(),player); // Post process npc conversation. av->postProcessCurrentPage(); }
bool IngameGUI::startConversation(const Common::UString &conv, Creature &pc, Object &obj, bool playHello) { stopConversation(); if (conv.empty()) return true; try { _dialog = new Dialog(conv, pc, obj, *_module, playHello); _dialog->show(); } catch (Common::Exception &e) { delete _dialog; _dialog = 0; e.add("Failed starting conversation \"%s\"", conv.c_str()); Common::printException(e, "WARNING: "); return false; } return true; }