void DialogManager::endDialog() { m_ProcessInfos = false; m_Interaction.currentInfo.invalidate(); m_Interaction.player.invalidate(); m_Interaction.target.invalidate(); m_World.getEngine()->getHud().getDialogBox().setHidden(true); m_World.getEngine()->getHud().setGameplayHudVisible(true); m_DialogActive = false; // Clear the dialog partners EMs // FIXME: I dont think the original game does this (start the routine), but NPCs won't change their state after talking // sometimes (baar parvez for example) VobTypes::NpcVobInformation playerVob = VobTypes::getVobFromScriptHandle(m_World, m_Interaction.player); VobTypes::NpcVobInformation targetVob = VobTypes::getVobFromScriptHandle(m_World, m_Interaction.target); // Start routine EventMessages::StateMessage msg; msg.subType = EventMessages::StateMessage::EV_StartState; msg.functionSymbol = 0; if (playerVob.isValid()) playerVob.playerController->getEM().onMessage(msg, playerVob.entity); if (targetVob.isValid()) targetVob.playerController->getEM().onMessage(msg, playerVob.entity); m_World.getCameraController()->restoreCameraMode(); m_World.getEngine()->getSession().enableActionBindings(true); }
void Ladder::onBeginStateChange(Handle::EntityHandle npc, int from, int to) { MobCore::onBeginStateChange(npc, from, to); VobTypes::NpcVobInformation n = VobTypes::asNpcVob(m_World, npc); if(n.isValid()) { // NPC shouldn't be put on ground while using the ladder n.playerController->setPhysicsEnabled(false); } }
void DialogManager::queueDialogEndEvent(NpcHandle target) { // Push the actual conversation-message EventMessages::ConversationMessage endDialogMessage; endDialogMessage.subType = EventMessages::ConversationMessage::ST_StopProcessInfos; // select on which EventManager the exit-DialogManager-event will be scheduled bool playerGetsEndEvent = false; auto handleForQueuing = playerGetsEndEvent ? m_Interaction.player : target; VobTypes::NpcVobInformation queueVob = VobTypes::getVobFromScriptHandle(m_World, handleForQueuing); if (queueVob.isValid()) queueVob.playerController->getEM().onMessage(endDialogMessage); }
void DialogManager::onAIOutput(NpcHandle self, NpcHandle target, const ZenLoad::oCMsgConversationData& msg) { LogInfo() << getGameState().getNpc(self).name[0] << ": " << msg.text; // Make a new message for the talking NPC VobTypes::NpcVobInformation selfnpc = VobTypes::getVobFromScriptHandle(m_World, self); if (!selfnpc.playerController) { LogWarn() << "AI_Output: Self not found/invalid!"; return; } bool isDialogMessage = isDialogActive() && ((m_Interaction.target == self && m_Interaction.player == target) || (m_Interaction.target == target && m_Interaction.player == self)); if (target.isValid()) LogInfo() << "AIOutput: From " << getGameState().getNpc(self).name[0] << " to " << getGameState().getNpc(target).name[0]; else { LogInfo() << "AIOutput: From " << getGameState().getNpc(self).name[0] << " (no target)"; if (isDialogMessage) { LogError() << "Error: conversation target is invalid"; assert(false); return; } } EventMessages::ConversationMessage conv; conv.subType = isDialogMessage ? EventMessages::ConversationMessage::ST_Output : EventMessages::ConversationMessage::ST_OutputMonolog; conv.name = msg.name; conv.text = msg.text; // Push the actual conversation-message auto sharedConvMessage = selfnpc.playerController->getEM().onMessage(conv); if (isDialogMessage) { // Make both wait for this ai_output to complete. selfnpc.playerController->getEM().waitForMessage(sharedConvMessage); if (target.isValid()) { VobTypes::NpcVobInformation targetnpc = VobTypes::getVobFromScriptHandle(m_World, target); if (targetnpc.isValid()) { sharedConvMessage->target = targetnpc.entity; targetnpc.playerController->getEM().waitForMessage(sharedConvMessage); } } } }
void Ladder::onEndStateChange(Handle::EntityHandle npc, int from, int to) { MobCore::onEndStateChange(npc, from, to); VobTypes::NpcVobInformation n = VobTypes::asNpcVob(m_World, npc); if(n.isValid() && to <= 0) { // If the animation is done, we can put the npc on ground again n.playerController->setPhysicsEnabled(true); } if(to >= 1) m_StateNum = 0; // Put the NPC back to "grabbed the ladder" }