mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 14:37:25 +00:00
Ugc: Use persistent Id for rocekts and cars
This commit is contained in:
parent
2c9a98313a
commit
3ec31027cd
@ -5564,13 +5564,6 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
|
||||||
if (!inv) return;
|
if (!inv) return;
|
||||||
|
|
||||||
LOG("Build finished");
|
|
||||||
|
|
||||||
GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build
|
|
||||||
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
|
|
||||||
|
|
||||||
//inv->UnequipItem(inv->GetItemStackByLOT(6086, eInventoryType::ITEMS)); // take off the thinking cap
|
|
||||||
//Game::entityManager->SerializeEntity(entity);
|
|
||||||
|
|
||||||
uint8_t count; // 3 for rockets, 7 for cars
|
uint8_t count; // 3 for rockets, 7 for cars
|
||||||
|
|
||||||
@ -5605,50 +5598,56 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto moduleAssembly = new LDFData<std::u16string>(u"assemblyPartLOTs", modules);
|
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newId) {
|
||||||
|
LOG("Build finished");
|
||||||
|
GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build
|
||||||
|
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
|
||||||
|
|
||||||
std::vector<LDFBaseData*> config;
|
//inv->UnequipItem(inv->GetItemStackByLOT(6086, eInventoryType::ITEMS)); // take off the thinking cap
|
||||||
config.push_back(moduleAssembly);
|
//Game::entityManager->SerializeEntity(entity);
|
||||||
|
|
||||||
LWOOBJID newIdBig;
|
const auto moduleAssembly = new LDFData<std::u16string>(u"assemblyPartLOTs", modules);
|
||||||
// Make sure a subkey isnt already in use. Persistent Ids do not make sense here since this only needs to be unique for
|
|
||||||
// this character. Because of that, we just generate a random id and check for a collision.
|
std::vector<LDFBaseData*> config;
|
||||||
do {
|
config.push_back(moduleAssembly);
|
||||||
newIdBig = ObjectIDManager::Instance()->GenerateRandomObjectID();
|
|
||||||
|
LWOOBJID newIdBig = newId;
|
||||||
|
// Make sure a subkey isnt already in use. Persistent Ids do not make sense here since this only needs to be unique for
|
||||||
|
// this character. Because of that, we just generate a random id and check for a collision.
|
||||||
GeneralUtils::SetBit(newIdBig, eObjectBits::CHARACTER);
|
GeneralUtils::SetBit(newIdBig, eObjectBits::CHARACTER);
|
||||||
} while (inv->FindItemBySubKey(newIdBig));
|
|
||||||
|
|
||||||
if (count == 3) {
|
if (count == 3) {
|
||||||
inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
||||||
} else if (count == 7) {
|
} else if (count == 7) {
|
||||||
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config, LWOOBJID_EMPTY, true, false, newIdBig);
|
||||||
}
|
|
||||||
|
|
||||||
auto* missionComponent = character->GetComponent<MissionComponent>();
|
|
||||||
|
|
||||||
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
|
|
||||||
if (missionComponent != nullptr) {
|
|
||||||
missionComponent->Progress(eMissionTaskType::SCRIPT, entity->GetLOT(), entity->GetObjectID());
|
|
||||||
if (count >= 7 && everyPieceSwapped) missionComponent->Progress(eMissionTaskType::RACING, LWOOBJID_EMPTY, (LWOOBJID)eRacingTaskParam::MODULAR_BUILDING);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
auto* missionComponent = character->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
|
if (entity->GetLOT() != 9980 || Game::server->GetZoneID() != 1200) {
|
||||||
script->OnModularBuildExit(entity, character, count >= 3, modList);
|
if (missionComponent != nullptr) {
|
||||||
}
|
missionComponent->Progress(eMissionTaskType::SCRIPT, entity->GetLOT(), entity->GetObjectID());
|
||||||
|
if (count >= 7 && everyPieceSwapped) missionComponent->Progress(eMissionTaskType::RACING, LWOOBJID_EMPTY, (LWOOBJID)eRacingTaskParam::MODULAR_BUILDING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Move remaining temp models back to models
|
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
||||||
std::vector<Item*> items;
|
|
||||||
|
|
||||||
for (const auto& pair : temp->GetItems()) {
|
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
|
||||||
items.push_back(pair.second);
|
script->OnModularBuildExit(entity, character, count >= 3, modList);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* item : items) {
|
// Move remaining temp models back to models
|
||||||
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false);
|
std::vector<Item*> items;
|
||||||
|
|
||||||
|
for (const auto& pair : temp->GetItems()) {
|
||||||
|
items.push_back(pair.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto* item : items) {
|
||||||
|
inv->MoveItemToInventory(item, eInventoryType::MODELS, item->GetCount(), false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user