From 486713613309d1faae440e0bcc39a324edafb005 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Thu, 9 Nov 2023 18:59:43 -0600 Subject: [PATCH] fix spawners and cleanup --- dGame/dUtilities/VanityUtilities.cpp | 43 ++++++++++++++-------------- dGame/dUtilities/VanityUtilities.h | 3 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index b5f376c7..e047eb83 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -37,10 +37,11 @@ void VanityUtilities::SpawnVanity() { if (npc.m_LOT == 176){ LOG("Removing spawner %llu", npc.m_ID); Game::zoneManager->RemoveSpawner(npc.m_ID); - } - auto* entity = Game::entityManager->GetEntity(npc.m_ID); - if (!entity) continue; - entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT); + } else{ + auto* entity = Game::entityManager->GetEntity(npc.m_ID); + if (!entity) continue; + entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT); + } } m_NPCs.clear(); } @@ -139,25 +140,26 @@ void VanityUtilities::SpawnVanity() { auto* spawner = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf); if (!spawner) continue; npc.m_ID = spawner->m_Info.spawnerID; - } - // Spawn the NPC - auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf, npc.m_ID); - if (!npcEntity) continue; - npc.m_ID = npcEntity->GetObjectID(); - if (!npc.m_Phrases.empty()){ - npcEntity->SetVar>(u"chats", npc.m_Phrases); + } else { + // Spawn the NPC + auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf); + if (!npcEntity) continue; + npc.m_ID = npcEntity->GetObjectID(); + if (!npc.m_Phrases.empty()){ + npcEntity->SetVar>(u"chats", npc.m_Phrases); - auto* scriptComponent = npcEntity->GetComponent(); + auto* scriptComponent = npcEntity->GetComponent(); - if (scriptComponent && !npc.m_Script.empty()) { - scriptComponent->SetScript(npc.m_Script); - scriptComponent->SetSerialized(false); + if (scriptComponent && !npc.m_Script.empty()) { + scriptComponent->SetScript(npc.m_Script); + scriptComponent->SetSerialized(false); - for (const auto& npc : npc.m_Flags) { - npcEntity->SetVar(GeneralUtils::ASCIIToUTF16(npc.first), npc.second); + for (const auto& npc : npc.m_Flags) { + npcEntity->SetVar(GeneralUtils::ASCIIToUTF16(npc.first), npc.second); + } } + SetupNPCTalk(npcEntity); } - SetupNPCTalk(npcEntity); } } @@ -251,13 +253,12 @@ Spawner* VanityUtilities::SpawnSpawner(LOT lot, const NiPoint3& position, const return spawner; } -Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector& inventory, const std::vector& ldf, const LWOOBJID ID) { +Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector& inventory, const std::vector& ldf) { EntityInfo info; info.lot = lot; info.pos = position; info.rot = rotation; - if (ID == LWOOBJID_EMPTY) info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID(); - else info.spawnerID = ID; + info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID(); info.settings = ldf; auto* entity = Game::entityManager->CreateEntity(info); diff --git a/dGame/dUtilities/VanityUtilities.h b/dGame/dUtilities/VanityUtilities.h index 5f639a93..97738c8d 100644 --- a/dGame/dUtilities/VanityUtilities.h +++ b/dGame/dUtilities/VanityUtilities.h @@ -42,8 +42,7 @@ public: const NiPoint3& position, const NiQuaternion& rotation, const std::vector& inventory, - const std::vector& ldf, - const LWOOBJID ID = LWOOBJID_EMPTY + const std::vector& ldf ); static Spawner* SpawnSpawner(