Merge pull request #2477 from Assumeru/script-respawn

Add script for respawned creatures and NPCs with refcount 0 fixes #5123
pull/541/head
Alexei Dobrohotov 5 years ago committed by GitHub
commit b156be0209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -120,6 +120,7 @@
Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels
Bug #5105: NPCs start combat with werewolves from any distance Bug #5105: NPCs start combat with werewolves from any distance
Bug #5110: ModRegion with a redundant numerical argument breaks script execution Bug #5110: ModRegion with a redundant numerical argument breaks script execution
Bug #5123: Script won't run on respawn
Feature #1774: Handle AvoidNode Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls Feature #3025: Analogue gamepad movement controls

@ -27,6 +27,7 @@
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
@ -844,7 +845,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile()) if (ptr.getCellRef().hasContentFile())
{ {
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1); 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); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);

@ -1,4 +1,4 @@
#include "npc.hpp" #include "npc.hpp"
#include <memory> #include <memory>
@ -37,6 +37,7 @@
#include "../mwworld/customdata.hpp" #include "../mwworld/customdata.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
@ -1376,7 +1377,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile()) if (ptr.getCellRef().hasContentFile())
{ {
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1); 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); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);

Loading…
Cancel
Save