mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-05 15:55:45 +00:00
Implement ResetActors script instruction (Fixes #1859)
This commit is contained in:
parent
58945c557a
commit
267cf4e140
@ -536,6 +536,9 @@ namespace MWBase
|
||||
|
||||
/// @see MWWorld::WeatherManager::getStormDirection
|
||||
virtual Ogre::Vector3 getStormDirection() const = 0;
|
||||
|
||||
/// Resets all actors in the current active cells to their original location within that cell.
|
||||
virtual void resetActors() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -431,5 +431,6 @@ op 0x2000294-0x20002ab: SetMagicEffect
|
||||
op 0x20002ac-0x20002c3: SetMagicEffect, explicit
|
||||
op 0x20002c4-0x20002db: ModMagicEffect
|
||||
op 0x20002dc-0x20002f3: ModMagicEffect, explicit
|
||||
op 0x20002f4: ResetActors
|
||||
|
||||
opcodes 0x20002f4-0x3ffffff unused
|
||||
opcodes 0x20002f5-0x3ffffff unused
|
||||
|
@ -719,6 +719,15 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
class OpResetActors : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->resetActors();
|
||||
}
|
||||
};
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
@ -759,6 +768,7 @@ namespace MWScript
|
||||
interpreter.installSegment5(Compiler::Transformation::opcodeMoveWorldExplicit,new OpMoveWorld<ExplicitRef>);
|
||||
interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngle, new OpGetStartingAngle<ImplicitRef>);
|
||||
interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngleExplicit, new OpGetStartingAngle<ExplicitRef>);
|
||||
interpreter.installSegment5(Compiler::Transformation::opcodeResetActors, new OpResetActors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2989,4 +2989,31 @@ namespace MWWorld
|
||||
if (!interpreterContext.hasActivationBeenHandled())
|
||||
interpreterContext.executeActivation(object, actor);
|
||||
}
|
||||
|
||||
struct ResetActorsFunctor
|
||||
{
|
||||
bool operator() (Ptr ptr)
|
||||
{
|
||||
// Can't reset actors that were moved to a different cell, because we don't know what cell they came from.
|
||||
// This could be fixed once we properly track actor cell changes, but may not be desirable behaviour anyhow.
|
||||
if (ptr.getClass().isActor() && ptr.getCellRef().getRefNum().mContentFile != -1)
|
||||
{
|
||||
const ESM::Position& origPos = ptr.getCellRef().getPosition();
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, origPos.pos[0], origPos.pos[1], origPos.pos[2]);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, origPos.rot[0], origPos.rot[1], origPos.rot[2]);
|
||||
ptr.getClass().adjustPosition(ptr, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
void World::resetActors()
|
||||
{
|
||||
for (Scene::CellStoreCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
iter!=mWorldScene->getActiveCells().end(); ++iter)
|
||||
{
|
||||
CellStore* cellstore = *iter;
|
||||
ResetActorsFunctor functor;
|
||||
cellstore->forEach(functor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -611,6 +611,9 @@ namespace MWWorld
|
||||
|
||||
/// @see MWWorld::WeatherManager::getStormDirection
|
||||
virtual Ogre::Vector3 getStormDirection() const;
|
||||
|
||||
/// Resets all actors in the current active cells to their original location within that cell.
|
||||
virtual void resetActors();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -527,6 +527,8 @@ namespace Compiler
|
||||
extensions.registerInstruction("move","cf",opcodeMove,opcodeMoveExplicit);
|
||||
extensions.registerInstruction("moveworld","cf",opcodeMoveWorld,opcodeMoveWorldExplicit);
|
||||
extensions.registerFunction("getstartingangle",'f',"c",opcodeGetStartingAngle,opcodeGetStartingAngleExplicit);
|
||||
extensions.registerInstruction("resetactors","",opcodeResetActors);
|
||||
extensions.registerInstruction("ra","",opcodeResetActors);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,6 +484,7 @@ namespace Compiler
|
||||
const int opcodeMoveExplicit = 0x2000207;
|
||||
const int opcodeMoveWorld = 0x2000208;
|
||||
const int opcodeMoveWorldExplicit = 0x2000209;
|
||||
const int opcodeResetActors = 0x20002f4;
|
||||
}
|
||||
|
||||
namespace User
|
||||
|
Loading…
Reference in New Issue
Block a user