mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 05:09:43 +00:00
Use moveToCell and init mwscript
This commit is contained in:
parent
641f34a3c9
commit
33b57d9134
3 changed files with 11 additions and 7 deletions
|
@ -205,8 +205,7 @@ namespace MWClass
|
|||
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
newPtr.getRefData().setCount(count);
|
||||
}
|
||||
if (ptr.getCell() != &MWBase::Environment::get().getWorldModel()->getDraftCell())
|
||||
newPtr.getCellRef().unsetRefNum();
|
||||
newPtr.getCellRef().unsetRefNum();
|
||||
newPtr.getRefData().setLuaScripts(nullptr);
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
|
||||
return newPtr;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/localscripts.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/scene.hpp"
|
||||
#include "../mwworld/worldmodel.hpp"
|
||||
|
@ -112,17 +113,22 @@ namespace MWLua
|
|||
const MWWorld::Class& cls = ptr.getClass();
|
||||
if (cls.isActor())
|
||||
{
|
||||
auto& stats = ptr.getClass().getCreatureStats(ptr);
|
||||
auto& stats = cls.getCreatureStats(ptr);
|
||||
stats.land(false);
|
||||
stats.setTeleported(true);
|
||||
}
|
||||
const MWWorld::CellStore* srcCell = ptr.getCell();
|
||||
MWWorld::Ptr newPtr;
|
||||
if (ptr.getCell() == &wm->getDraftCell())
|
||||
if (srcCell == &wm->getDraftCell())
|
||||
{
|
||||
newPtr = world->placeObject(ptr, destCell, toPos(pos, rot));
|
||||
newPtr = cls.moveToCell(ptr, *destCell, toPos(pos, rot));
|
||||
ptr.getCellRef().unsetRefNum();
|
||||
ptr.getRefData().setLuaScripts(nullptr);
|
||||
ptr.getRefData().setCount(0);
|
||||
ESM::RefId script = cls.getScript(newPtr);
|
||||
if (!script.empty())
|
||||
world->getLocalScripts().add(script, newPtr);
|
||||
world->addContainerScripts(newPtr, newPtr.getCell());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -372,8 +372,7 @@ namespace MWWorld
|
|||
MWWorld::Ptr Class::copyToCell(const ConstPtr& ptr, CellStore& cell, int count) const
|
||||
{
|
||||
Ptr newPtr = copyToCellImpl(ptr, cell);
|
||||
if (ptr.getCell() != &MWBase::Environment::get().getWorldModel()->getDraftCell())
|
||||
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
|
||||
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
|
||||
newPtr.getRefData().setCount(count);
|
||||
newPtr.getRefData().setLuaScripts(nullptr);
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(newPtr);
|
||||
|
|
Loading…
Reference in a new issue