zCCSCutsceneContext* CreateCutsceneContext(oCNpc* npc, const zSTRING& name)
{
if (auto* svmMan = ogame->GetSVMManager())
if (auto* csMan = ogame->GetCutsceneManager())
if (int id = svmMan->GetOU(name, npc->voice); id >= 0)
if (csMan->LibValidateOU(id))
if (!csMan->LibIsSvmModuleRunning(id))
return ogame->GetWorld()->csPlayer->CreateNewOutputUnit(id, npc);
return nullptr;
}
void AI_OutputSVM_NoCS(oCNpc* npc, const zSTRING& name)
{
auto* context = CreateCutsceneContext(npc, name);
if (!context)
return;
auto blockPosition = context->GetFirstBlockPosition();
for (auto* message = context->GetNextMessage(blockPosition); message; message = context->GetNextMessage(blockPosition))
if (auto* conversation = message->CastTo<oCMsgConversation>())
if (conversation->subType == oCMsgConversation::EV_PLAYANISOUND)
{
npc->GetEM()->OnMessage(new oCMsgConversation{ oCMsgConversation::EV_PLAYSOUND, conversation->name, conversation->text }, npc);
break;
}
context->Release();
}
ZEXTERNAL(AI_OutputSVM_NoCS);