From 952786c166796e3a1e58c990c09e752793115290 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 3 Aug 2023 21:37:09 -0500 Subject: [PATCH] chore: cleanup some vanity npc logic (#1174) * Dont setup talk for vanity npc's if they are no phrases no ghosting ldfkey for canity npc's * void, oops * formatting --- dGame/Entity.h | 1 + dGame/dUtilities/VanityUtilities.cpp | 29 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dGame/Entity.h b/dGame/Entity.h index 90f2a34f..ca007912 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -85,6 +85,7 @@ public: bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; } bool GetIsGhostingCandidate() const; + void SetIsGhostingCandidate(bool value) { m_IsGhostingCandidate = value; }; int8_t GetObservers() const; diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 86fa9503..eb182e04 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -80,10 +80,10 @@ void VanityUtilities::SpawnVanity() { // Spawn the NPC auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf); - - npcEntity->SetVar>(u"chats", m_PartyPhrases); - - SetupNPCTalk(npcEntity); + if (!npc.m_Phrases.empty()) { + npcEntity->SetVar>(u"chats", m_PartyPhrases); + SetupNPCTalk(npcEntity); + } } return; @@ -114,21 +114,21 @@ void VanityUtilities::SpawnVanity() { // Spawn the NPC auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf); + if (!npc.m_Phrases.empty()){ + npcEntity->SetVar>(u"chats", npc.m_Phrases); - 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); } if (zoneID == 1200) { @@ -160,6 +160,7 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin auto* entity = Game::entityManager->CreateEntity(info); entity->SetVar(u"npcName", name); + if (entity->GetVar(u"noGhosting")) entity->SetIsGhostingCandidate(false); auto* inventoryComponent = entity->GetComponent();