|
|
|
@ -12,6 +12,8 @@
|
|
|
|
|
#include <components/interpreter/runtime.hpp>
|
|
|
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/esm/loadmgef.hpp>
|
|
|
|
|
#include <components/esm/loadcrea.hpp>
|
|
|
|
|
|
|
|
|
@ -78,6 +80,33 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
namespace Misc
|
|
|
|
|
{
|
|
|
|
|
class OpMenuMode : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
|
{
|
|
|
|
|
runtime.push (MWBase::Environment::get().getWindowManager()->isGuiMode());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class OpRandom : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
|
{
|
|
|
|
|
Interpreter::Type_Integer limit = runtime[0].mInteger;
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
if (limit<0)
|
|
|
|
|
throw std::runtime_error (
|
|
|
|
|
"random: argument out of range (Don't be so negative!)");
|
|
|
|
|
|
|
|
|
|
runtime.push (static_cast<Interpreter::Type_Float>(::Misc::Rng::rollDice(limit))); // [o, limit)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpStartScript : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
@ -116,6 +145,16 @@ namespace MWScript
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class OpGetSecondsPassed : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
|
{
|
|
|
|
|
runtime.push (MWBase::Environment::get().getFrameDuration());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpEnable : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
@ -1530,10 +1569,13 @@ namespace MWScript
|
|
|
|
|
|
|
|
|
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
|
|
|
|
{
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeMenuMode, new OpMenuMode);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeRandom, new OpRandom);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeScriptRunning, new OpScriptRunning);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeStartScript, new OpStartScript<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeStartScriptExplicit, new OpStartScript<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeStopScript, new OpStopScript);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeGetSecondsPassed, new OpGetSecondsPassed);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeEnable, new OpEnable<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeEnableExplicit, new OpEnable<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (Compiler::Misc::opcodeDisable, new OpDisable<ImplicitRef>);
|
|
|
|
|