mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +00:00
Preserve inventories when resurrecting actors while looting them
This commit is contained in:
parent
893d569529
commit
58b888a38e
1 changed files with 12 additions and 7 deletions
|
@ -1194,20 +1194,25 @@ namespace MWScript
|
|||
{
|
||||
bool wasEnabled = ptr.getRefData().isEnabled();
|
||||
MWBase::Environment::get().getWorld()->undeleteObject(ptr);
|
||||
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
|
||||
auto windowManager = MWBase::Environment::get().getWindowManager();
|
||||
bool wasOpen = windowManager->containsMode(MWGui::GM_Container);
|
||||
windowManager->onDeleteCustomData(ptr);
|
||||
|
||||
// HACK: disable/enable object to re-add it to the scene properly (need a new Animation).
|
||||
MWBase::Environment::get().getWorld()->disable(ptr);
|
||||
// resets runtime state such as inventory, stats and AI. does not reset position in the world
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
|
||||
{
|
||||
// Reopen the loot GUI if it was closed because we resurrected the actor we were looting
|
||||
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
|
||||
windowManager->forceLootMode(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
|
||||
// resets runtime state such as inventory, stats and AI. does not reset position in the world
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
}
|
||||
if (wasEnabled)
|
||||
MWBase::Environment::get().getWorld()->enable(ptr);
|
||||
// Reopen the loot GUI if it was closed because we resurrected the actor we were looting
|
||||
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
|
||||
windowManager->forceLootMode(ptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue