Skip to content

Commit

Permalink
feat(skymp5-server): enable reloot for scripted item removal (#1706)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Nov 3, 2023
1 parent db5ee49 commit f96fc6b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@ const bool& MpObjectReference::IsDisabled() const

std::chrono::system_clock::duration MpObjectReference::GetRelootTime() const
{
if (relootTimeOverride)
if (relootTimeOverride) {
return *relootTimeOverride;
}

if (auto time = GetParent()->GetRelootTime(baseType))
if (auto time = GetParent()->GetRelootTime(baseType)) {
return *time;
}

if (!std::strcmp(baseType.data(), "FLOR") ||
!std::strcmp(baseType.data(), "TREE")) {
Expand Down Expand Up @@ -462,10 +464,6 @@ void MpObjectReference::TakeItem(MpActor& ac, const Inventory::Entry& e)
throw std::runtime_error(err.str());
}
RemoveItems({ e }, &ac);

if (GetInventory().IsEmpty()) {
RequestReloot();
}
}

void MpObjectReference::SetRelootTime(
Expand Down Expand Up @@ -663,6 +661,14 @@ void MpObjectReference::RemoveItems(
target->AddItems(entries);

SendInventoryUpdate();

if (GetBaseType() == "CONT") {
if (GetInventory().IsEmpty()) {
spdlog::info("MpObjectReference::RemoveItems - {:x} requesting reloot",
this->GetFormId());
RequestReloot();
}
}
}

void MpObjectReference::RemoveAllItems(MpObjectReference* target)
Expand Down

0 comments on commit f96fc6b

Please sign in to comment.