From fb219fea17533812d416e9617bdda2c66b4fbf4d Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 7 Feb 2016 19:43:38 +0100 Subject: [PATCH] Fix respawning of NPCs/creatures when they were moved to a different cell --- apps/openmw/mwclass/creature.cpp | 10 +++++----- apps/openmw/mwclass/npc.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 6e9cfccb96..0f021b5a2e 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -772,18 +772,18 @@ namespace MWClass { if (isFlagBitSet(ptr, ESM::Creature::Respawn)) { - // Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell. - // This also means we cannot respawn dynamically placed references with no content file connection. if (ptr.getCellRef().hasContentFile()) { if (ptr.getRefData().getCount() == 0) ptr.getRefData().setCount(1); - // Reset to original position - ptr.getRefData().setPosition(ptr.getCellRef().getPosition()); - MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); ptr.getRefData().setCustomData(NULL); + + // Reset to original position + MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0], + ptr.getCellRef().getPosition().pos[1], + ptr.getCellRef().getPosition().pos[2]); } } } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 3519f9d83e..474985f7bb 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1305,18 +1305,18 @@ namespace MWClass { if (ptr.get()->mBase->mFlags & ESM::NPC::Respawn) { - // Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell. - // This also means we cannot respawn dynamically placed references with no content file connection. if (ptr.getCellRef().hasContentFile()) { if (ptr.getRefData().getCount() == 0) ptr.getRefData().setCount(1); - // Reset to original position - ptr.getRefData().setPosition(ptr.getCellRef().getPosition()); - MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); ptr.getRefData().setCustomData(NULL); + + // Reset to original position + MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0], + ptr.getCellRef().getPosition().pos[1], + ptr.getCellRef().getPosition().pos[2]); } } }