diff --git a/CHANGELOG.md b/CHANGELOG.md index da0aaa762..aa4f03420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,7 @@ Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels Bug #5105: NPCs start combat with werewolves from any distance Bug #5110: ModRegion with a redundant numerical argument breaks script execution + Bug #5123: Script won't run on respawn Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 4c50634e0..fd89ef4a3 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -27,6 +27,7 @@ #include "../mwworld/containerstore.hpp" #include "../mwphysics/physicssystem.hpp" #include "../mwworld/cellstore.hpp" +#include "../mwworld/localscripts.hpp" #include "../mwrender/renderinginterface.hpp" #include "../mwrender/objects.hpp" @@ -844,7 +845,12 @@ namespace MWClass if (ptr.getCellRef().hasContentFile()) { if (ptr.getRefData().getCount() == 0) + { ptr.getRefData().setCount(1); + const std::string& script = getScript(ptr); + if(!script.empty()) + MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr); + } MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); ptr.getRefData().setCustomData(nullptr); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index aa326412f..87397efa2 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1,4 +1,4 @@ -#include "npc.hpp" +#include "npc.hpp" #include @@ -37,6 +37,7 @@ #include "../mwworld/customdata.hpp" #include "../mwphysics/physicssystem.hpp" #include "../mwworld/cellstore.hpp" +#include "../mwworld/localscripts.hpp" #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" @@ -1376,7 +1377,12 @@ namespace MWClass if (ptr.getCellRef().hasContentFile()) { if (ptr.getRefData().getCount() == 0) + { ptr.getRefData().setCount(1); + const std::string& script = getScript(ptr); + if (!script.empty()) + MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr); + } MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); ptr.getRefData().setCustomData(nullptr);