2021-12-05 17:54:36 +00:00
|
|
|
#include "PetDigBuild.h"
|
|
|
|
#include "EntityManager.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EntityInfo.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eMissionState.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void PetDigBuild::OnRebuildComplete(Entity* self, Entity* target) {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto flagNumber = self->GetVar<std::u16string>(u"flagNum");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
EntityInfo info{};
|
|
|
|
auto pos = self->GetPosition();
|
|
|
|
pos.SetY(pos.GetY() + 0.5f);
|
|
|
|
info.pos = pos;
|
|
|
|
info.rot = self->GetRotation();
|
|
|
|
info.spawnerID = self->GetSpawnerID();
|
|
|
|
info.settings = {
|
|
|
|
new LDFData<LWOOBJID>(u"builder", target->GetObjectID()),
|
|
|
|
new LDFData<LWOOBJID>(u"X", self->GetObjectID())
|
|
|
|
};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (!flagNumber.empty()) {
|
|
|
|
info.lot = 7410; // Normal GF treasure
|
|
|
|
info.settings.push_back(new LDFData<std::u16string>(u"groupID", u"Flag" + flagNumber));
|
|
|
|
} else {
|
|
|
|
auto* missionComponent = target->GetComponent<MissionComponent>();
|
2023-01-22 23:38:47 +00:00
|
|
|
if (missionComponent != nullptr && missionComponent->GetMissionState(746) == eMissionState::ACTIVE) {
|
2022-07-28 13:39:57 +00:00
|
|
|
info.lot = 9307; // Special Captain Jack treasure that drops a mission item
|
|
|
|
} else {
|
|
|
|
info.lot = 3495; // Normal AG treasure
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* treasure = EntityManager::Instance()->CreateEntity(info);
|
|
|
|
EntityManager::Instance()->ConstructEntity(treasure);
|
|
|
|
self->SetVar<LWOOBJID>(u"chestObj", treasure->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PetDigBuild::OnDie(Entity* self, Entity* killer) {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto treasureID = self->GetVar<LWOOBJID>(u"chestObj");
|
|
|
|
if (treasureID == LWOOBJID_EMPTY)
|
|
|
|
return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto treasure = EntityManager::Instance()->GetEntity(treasureID);
|
|
|
|
if (treasure == nullptr)
|
|
|
|
return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// If the quick build expired and the treasure was not collected, hide the treasure
|
|
|
|
if (!treasure->GetIsDead()) {
|
|
|
|
treasure->Smash(self->GetObjectID(), SILENT);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|