mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
fix spawners and cleanup
This commit is contained in:
parent
6e07798023
commit
4867136133
@ -37,10 +37,11 @@ void VanityUtilities::SpawnVanity() {
|
|||||||
if (npc.m_LOT == 176){
|
if (npc.m_LOT == 176){
|
||||||
LOG("Removing spawner %llu", npc.m_ID);
|
LOG("Removing spawner %llu", npc.m_ID);
|
||||||
Game::zoneManager->RemoveSpawner(npc.m_ID);
|
Game::zoneManager->RemoveSpawner(npc.m_ID);
|
||||||
}
|
} else{
|
||||||
auto* entity = Game::entityManager->GetEntity(npc.m_ID);
|
auto* entity = Game::entityManager->GetEntity(npc.m_ID);
|
||||||
if (!entity) continue;
|
if (!entity) continue;
|
||||||
entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT);
|
entity->Smash(LWOOBJID_EMPTY, eKillType::VIOLENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_NPCs.clear();
|
m_NPCs.clear();
|
||||||
}
|
}
|
||||||
@ -139,25 +140,26 @@ void VanityUtilities::SpawnVanity() {
|
|||||||
auto* spawner = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf);
|
auto* spawner = SpawnSpawner(npc.m_LOT, location.m_Position, location.m_Rotation, npc.ldf);
|
||||||
if (!spawner) continue;
|
if (!spawner) continue;
|
||||||
npc.m_ID = spawner->m_Info.spawnerID;
|
npc.m_ID = spawner->m_Info.spawnerID;
|
||||||
}
|
} else {
|
||||||
// Spawn the NPC
|
// 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);
|
auto* npcEntity = SpawnNPC(npc.m_LOT, npc.m_Name, location.m_Position, location.m_Rotation, npc.m_Equipment, npc.ldf);
|
||||||
if (!npcEntity) continue;
|
if (!npcEntity) continue;
|
||||||
npc.m_ID = npcEntity->GetObjectID();
|
npc.m_ID = npcEntity->GetObjectID();
|
||||||
if (!npc.m_Phrases.empty()){
|
if (!npc.m_Phrases.empty()){
|
||||||
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
|
npcEntity->SetVar<std::vector<std::string>>(u"chats", npc.m_Phrases);
|
||||||
|
|
||||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||||
|
|
||||||
if (scriptComponent && !npc.m_Script.empty()) {
|
if (scriptComponent && !npc.m_Script.empty()) {
|
||||||
scriptComponent->SetScript(npc.m_Script);
|
scriptComponent->SetScript(npc.m_Script);
|
||||||
scriptComponent->SetSerialized(false);
|
scriptComponent->SetSerialized(false);
|
||||||
|
|
||||||
for (const auto& npc : npc.m_Flags) {
|
for (const auto& npc : npc.m_Flags) {
|
||||||
npcEntity->SetVar<bool>(GeneralUtils::ASCIIToUTF16(npc.first), npc.second);
|
npcEntity->SetVar<bool>(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;
|
return spawner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector<LOT>& inventory, const std::vector<LDFBaseData*>& ldf, const LWOOBJID ID) {
|
Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoint3& position, const NiQuaternion& rotation, const std::vector<LOT>& inventory, const std::vector<LDFBaseData*>& ldf) {
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
info.lot = lot;
|
info.lot = lot;
|
||||||
info.pos = position;
|
info.pos = position;
|
||||||
info.rot = rotation;
|
info.rot = rotation;
|
||||||
if (ID == LWOOBJID_EMPTY) info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
||||||
else info.spawnerID = ID;
|
|
||||||
info.settings = ldf;
|
info.settings = ldf;
|
||||||
|
|
||||||
auto* entity = Game::entityManager->CreateEntity(info);
|
auto* entity = Game::entityManager->CreateEntity(info);
|
||||||
|
@ -42,8 +42,7 @@ public:
|
|||||||
const NiPoint3& position,
|
const NiPoint3& position,
|
||||||
const NiQuaternion& rotation,
|
const NiQuaternion& rotation,
|
||||||
const std::vector<LOT>& inventory,
|
const std::vector<LOT>& inventory,
|
||||||
const std::vector<LDFBaseData*>& ldf,
|
const std::vector<LDFBaseData*>& ldf
|
||||||
const LWOOBJID ID = LWOOBJID_EMPTY
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static Spawner* SpawnSpawner(
|
static Spawner* SpawnSpawner(
|
||||||
|
Loading…
Reference in New Issue
Block a user