random sound selection for triggers

This commit is contained in:
2026-01-06 16:26:57 -05:00
parent b41b6df19e
commit 5124f77817
12 changed files with 104 additions and 59 deletions
+18 -2
View File
@@ -40,7 +40,17 @@ namespace anm2ed::anm2
else
{
element->QueryIntAttribute("EventId", &eventID);
element->QueryIntAttribute("SoundId", &soundID);
int soundID{};
// Backwards compatibility with old formats
if (element->QueryIntAttribute("SoundId", &soundID) == XML_SUCCESS) soundIDs.push_back(soundID);
for (auto child = element->FirstChildElement("Sound"); child; child = child->NextSiblingElement("Sound"))
{
child->QueryIntAttribute("Id", &soundID);
soundIDs.push_back(soundID);
}
element->QueryIntAttribute("AtFrame", &atFrame);
}
}
@@ -94,7 +104,13 @@ namespace anm2ed::anm2
break;
case TRIGGER:
element->SetAttribute("EventId", eventID);
element->SetAttribute("SoundId", soundID);
for (auto& id : soundIDs)
{
auto soundChild = element->InsertNewChildElement("Sound");
soundChild->SetAttribute("Id", id);
}
element->SetAttribute("AtFrame", atFrame);
break;
default: