mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
merged opcode classes that came in explicit and implicit variants
This commit is contained in:
parent
67a745cdf6
commit
2ffe1206a6
7 changed files with 237 additions and 909 deletions
|
@ -103,6 +103,7 @@ set(GAMESCRIPT_HEADER
|
|||
mwscript/controlextensions.hpp
|
||||
mwscript/extensions.hpp
|
||||
mwscript/globalscripts.hpp
|
||||
mwscript/ref.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -15,46 +16,14 @@ namespace MWScript
|
|||
{
|
||||
namespace Ai
|
||||
{
|
||||
template<class R>
|
||||
class OpAiTravel : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
// discard additional arguments (reset), because we have no idea what they mean.
|
||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpAiTravelExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
@ -72,56 +41,14 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpAiEscort : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float duration = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
// discard additional arguments (reset), because we have no idea what they mean.
|
||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpAiEscortExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
@ -146,16 +73,14 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetAiPackageDone : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = 0;
|
||||
|
||||
|
@ -163,25 +88,6 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpGetAiPackageDoneExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
Interpreter::Type_Integer value = 0;
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const int opcodeAiTravel = 0x20000;
|
||||
|
@ -204,12 +110,13 @@ namespace MWScript
|
|||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel);
|
||||
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravelExplicit);
|
||||
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort);
|
||||
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscortExplicit);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDoneExplicit);
|
||||
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel<ExplicitRef>);
|
||||
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit,
|
||||
new OpGetAiPackageDone<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,17 +14,21 @@
|
|||
#include "../mwworld/containerutil.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Container
|
||||
{
|
||||
template<class R>
|
||||
class OpAddItem : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
@ -37,40 +41,6 @@ namespace MWScript
|
|||
if (count<0)
|
||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||
|
||||
ref.getPtr().getRefData().setCount (count);
|
||||
|
||||
MWWorld::Class::get (ref.getPtr()).insertIntoContainer (ref.getPtr(),
|
||||
MWWorld::Class::get (ptr).getContainerStore (ptr));
|
||||
}
|
||||
};
|
||||
|
||||
class OpAddItemExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (count<0)
|
||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||
|
||||
ref.getPtr().getRefData().setCount (count);
|
||||
|
@ -80,55 +50,21 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetItemCount : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
std::vector<MWWorld::Ptr> list;
|
||||
|
||||
MWWorld::listItemsInContainer (item,
|
||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
||||
context.getWorld().getStore(), list);
|
||||
|
||||
Interpreter::Type_Integer sum = 0;
|
||||
|
||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin()); iter!=list.end();
|
||||
++iter)
|
||||
{
|
||||
sum += iter->getRefData().getCount();
|
||||
}
|
||||
|
||||
runtime.push (sum);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetItemCountExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
std::vector<MWWorld::Ptr> list;
|
||||
|
||||
MWWorld::listItemsInContainer (item,
|
||||
|
@ -147,12 +83,15 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpRemoveItem : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
@ -165,58 +104,6 @@ namespace MWScript
|
|||
if (count<0)
|
||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
std::vector<MWWorld::Ptr> list;
|
||||
|
||||
MWWorld::listItemsInContainer (item,
|
||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
||||
context.getWorld().getStore(), list);
|
||||
|
||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin());
|
||||
iter!=list.end() && count;
|
||||
++iter)
|
||||
{
|
||||
if (iter->getRefData().getCount()<=count)
|
||||
{
|
||||
count -= iter->getRefData().getCount();
|
||||
iter->getRefData().setCount (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter->getRefData().setCount (iter->getRefData().getCount()-count);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// To be fully compatible with original Morrowind, we would need to check if
|
||||
// count is >= 0 here and throw an exception. But let's be tollerant instead.
|
||||
}
|
||||
};
|
||||
|
||||
class OpRemoveItemExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
if (count<0)
|
||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
std::vector<MWWorld::Ptr> list;
|
||||
|
||||
MWWorld::listItemsInContainer (item,
|
||||
|
@ -262,12 +149,12 @@ namespace MWScript
|
|||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeAddItem, new OpAddItem);
|
||||
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItemExplicit);
|
||||
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount);
|
||||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCountExplicit);
|
||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem);
|
||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItemExplicit);
|
||||
interpreter.installSegment5 (opcodeAddItem, new OpAddItem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItem<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Misc
|
||||
|
@ -55,42 +56,14 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpLock : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer lockLevel = 100;
|
||||
|
||||
if (arg0==1)
|
||||
{
|
||||
lockLevel = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
}
|
||||
|
||||
MWWorld::Class::get (ptr).lock (ptr, lockLevel);
|
||||
}
|
||||
};
|
||||
|
||||
class OpLockExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer lockLevel = 100;
|
||||
|
||||
|
@ -104,34 +77,14 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpUnlock : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).unlock (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
class OpUnlockExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWWorld::Class::get (ptr).unlock (ptr);
|
||||
}
|
||||
|
@ -160,10 +113,10 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
||||
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
||||
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
||||
interpreter.installSegment3 (opcodeLock, new OpLock);
|
||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLockExplicit);
|
||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock);
|
||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlockExplicit);
|
||||
interpreter.installSegment3 (opcodeLock, new OpLock<ImplicitRef>);
|
||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLock<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
41
apps/openmw/mwscript/ref.hpp
Normal file
41
apps/openmw/mwscript/ref.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef GAME_MWSCRIPT_REF_H
|
||||
#define GAME_MWSCRIPT_REF_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <components/interpreter/runtime.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
struct ExplicitRef
|
||||
{
|
||||
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
return context.getWorld().getPtr (id, false);
|
||||
}
|
||||
};
|
||||
|
||||
struct ImplicitRef
|
||||
{
|
||||
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
return context.getReference();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -7,22 +7,26 @@
|
|||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Sound
|
||||
{
|
||||
template<class R>
|
||||
class OpSay : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
@ -32,21 +36,24 @@ namespace MWScript
|
|||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().say (context.getReference(), file);
|
||||
context.getSoundManager().say (ptr, file);
|
||||
context.messageBox (text);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSayDone : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
runtime.push (context.getSoundManager().sayDone (context.getReference()));
|
||||
runtime.push (context.getSoundManager().sayDone (ptr));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -104,6 +111,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpPlaySound3D : public Interpreter::Opcode0
|
||||
{
|
||||
bool mLoop;
|
||||
|
@ -114,17 +122,19 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().playSound3D (context.getReference(), sound,
|
||||
1.0, 1.0, mLoop);
|
||||
context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpPlaySoundVP3D : public Interpreter::Opcode0
|
||||
{
|
||||
bool mLoop;
|
||||
|
@ -135,6 +145,8 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
@ -147,34 +159,39 @@ namespace MWScript
|
|||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().playSound3D (context.getReference(), sound, volume,
|
||||
pitch, mLoop);
|
||||
context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpStopSound : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().stopSound3D (context.getReference(), sound);
|
||||
context.getSoundManager().stopSound3D (ptr, sound);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetSoundPlaying : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
@ -182,143 +199,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||
context.getReference(), runtime.getStringLiteral (index)));
|
||||
}
|
||||
};
|
||||
|
||||
class OpSayExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
||||
file);
|
||||
}
|
||||
};
|
||||
|
||||
class OpSayDoneExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
runtime.push (context.getSoundManager().sayDone (
|
||||
context.getWorld().getPtr (id, true)));
|
||||
}
|
||||
};
|
||||
|
||||
class OpPlaySound3DExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
bool mLoop;
|
||||
|
||||
public:
|
||||
|
||||
OpPlaySound3DExplicit (bool loop) : mLoop (loop) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().playSound3D (
|
||||
context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop);
|
||||
}
|
||||
};
|
||||
|
||||
class OpPlaySoundVP3DExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
bool mLoop;
|
||||
|
||||
public:
|
||||
|
||||
OpPlaySoundVP3DExplicit (bool loop) : mLoop (loop) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float volume = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().playSound3D (
|
||||
context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class OpStopSoundExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().stopSound3D (
|
||||
context.getWorld().getPtr (id, true), sound);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetSoundPlayingExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
int index = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||
context.getWorld().getPtr (id, true),
|
||||
runtime.getStringLiteral (index)));
|
||||
ptr, runtime.getStringLiteral (index)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -366,32 +247,32 @@ namespace MWScript
|
|||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeSay, new OpSay);
|
||||
interpreter.installSegment5 (opcodeSayDone, new OpSayDone);
|
||||
interpreter.installSegment5 (opcodeSay, new OpSay<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSayDone, new OpSayDone<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic);
|
||||
interpreter.installSegment5 (opcodePlaySound, new OpPlaySound);
|
||||
interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP);
|
||||
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false));
|
||||
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true));
|
||||
interpreter.installSegment5 (opcodeStopSound, new OpStopSound);
|
||||
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying);
|
||||
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D<ImplicitRef> (false));
|
||||
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D<ImplicitRef> (false));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D<ImplicitRef> (true));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3DVP,
|
||||
new OpPlaySoundVP3D<ImplicitRef> (true));
|
||||
interpreter.installSegment5 (opcodeStopSound, new OpStopSound<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying<ImplicitRef>);
|
||||
|
||||
interpreter.installSegment5 (opcodeSayExplicit, new OpSayExplicit);
|
||||
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDoneExplicit);
|
||||
interpreter.installSegment5 (opcodeSayExplicit, new OpSay<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDone<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodePlaySound3DExplicit,
|
||||
new OpPlaySound3DExplicit (false));
|
||||
new OpPlaySound3D<ExplicitRef> (false));
|
||||
interpreter.installSegment5 (opcodePlaySound3DVPExplicit,
|
||||
new OpPlaySoundVP3DExplicit (false));
|
||||
new OpPlaySoundVP3D<ExplicitRef> (false));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3DExplicit,
|
||||
new OpPlaySound3DExplicit (true));
|
||||
new OpPlaySound3D<ExplicitRef> (true));
|
||||
interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit,
|
||||
new OpPlaySoundVP3DExplicit (true));
|
||||
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSoundExplicit);
|
||||
new OpPlaySoundVP3D<ExplicitRef> (true));
|
||||
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSound<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSoundPlayingExplicit,
|
||||
new OpGetSoundPlayingExplicit);
|
||||
new OpGetSoundPlaying<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
#include "ref.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Stats
|
||||
{
|
||||
template<class R>
|
||||
class OpGetAttribute : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -27,36 +29,7 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetAttributeExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpGetAttributeExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
|
@ -66,6 +39,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetAttribute : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -76,45 +50,17 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
class OpSetAttributeExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpSetAttributeExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpModAttribute : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -125,14 +71,11 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
|
@ -141,36 +84,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpModAttributeExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpModAttributeExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
value +=
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
getModified();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||
setModified (value, 0, 100);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetDynamic : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -181,46 +95,7 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||
{
|
||||
// health is a special case
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
||||
runtime.push (value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
getCurrent();
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetDynamicExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpGetDynamicExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||
{
|
||||
|
@ -240,6 +115,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetDynamic : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -250,45 +126,17 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
class OpSetDynamicExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpSetDynamicExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpModDynamic : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -299,14 +147,11 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
@ -318,40 +163,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpModDynamicExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpModDynamicExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
stats.mDynamic[mIndex].setModified (
|
||||
diff + stats.mDynamic[mIndex].getModified(), 0);
|
||||
|
||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class R>
|
||||
class OpModCurrentDynamic : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -362,14 +174,11 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
@ -378,36 +187,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpModCurrentDynamicExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpModCurrentDynamicExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||
|
||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetDynamicGetRatio : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -418,10 +198,7 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
|
@ -436,38 +213,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpGetDynamicGetRatioExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpGetDynamicGetRatioExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWMechanics::CreatureStats& stats =
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||
|
||||
Interpreter::Type_Float value = 0;
|
||||
|
||||
Interpreter::Type_Float max = stats.mDynamic[mIndex].getModified();
|
||||
|
||||
if (max>0)
|
||||
value = stats.mDynamic[mIndex].getCurrent() / max;
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetSkill : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -478,36 +224,7 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
getModified();
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetSkillExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpGetSkillExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value =
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
|
@ -517,6 +234,7 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpSetSkill : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -527,45 +245,17 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
class OpSetSkillExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpSetSkillExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
setModified (value, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpModSkill : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
@ -576,14 +266,11 @@ namespace MWScript
|
|||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
getModified();
|
||||
|
||||
|
@ -592,36 +279,6 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpModSkillExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
int mIndex;
|
||||
|
||||
public:
|
||||
|
||||
OpModSkillExplicit (int index) : mIndex (index) {}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
value +=
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
getModified();
|
||||
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||
setModified (value, 0, 100);
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfAttributes = 8;
|
||||
|
||||
const int opcodeGetAttribute = 0x2000027;
|
||||
|
@ -729,53 +386,54 @@ namespace MWScript
|
|||
{
|
||||
for (int i=0; i<numberOfAttributes; ++i)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute (i));
|
||||
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeGetAttributeExplicit+i,
|
||||
new OpGetAttributeExplicit (i));
|
||||
new OpGetAttribute<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i));
|
||||
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeSetAttributeExplicit+i,
|
||||
new OpSetAttributeExplicit (i));
|
||||
new OpSetAttribute<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i));
|
||||
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeModAttributeExplicit+i,
|
||||
new OpModAttributeExplicit (i));
|
||||
new OpModAttribute<ExplicitRef> (i));
|
||||
}
|
||||
|
||||
for (int i=0; i<numberOfDynamics; ++i)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic (i));
|
||||
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeGetDynamicExplicit+i,
|
||||
new OpGetDynamicExplicit (i));
|
||||
new OpGetDynamic<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i));
|
||||
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeSetDynamicExplicit+i,
|
||||
new OpSetDynamicExplicit (i));
|
||||
new OpSetDynamic<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i));
|
||||
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
|
||||
new OpModDynamicExplicit (i));
|
||||
new OpModDynamic<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i));
|
||||
interpreter.installSegment5 (opcodeModCurrentDynamic+i,
|
||||
new OpModCurrentDynamic<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
|
||||
new OpModCurrentDynamicExplicit (i));
|
||||
new OpModCurrentDynamic<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeGetDynamicGetRatio+i,
|
||||
new OpGetDynamicGetRatio (i));
|
||||
new OpGetDynamicGetRatio<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i,
|
||||
new OpGetDynamicGetRatioExplicit (i));
|
||||
new OpGetDynamicGetRatio<ExplicitRef> (i));
|
||||
}
|
||||
|
||||
for (int i=0; i<numberOfSkills; ++i)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill (i));
|
||||
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkillExplicit (i));
|
||||
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkill<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i));
|
||||
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkillExplicit (i));
|
||||
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkill<ExplicitRef> (i));
|
||||
|
||||
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i));
|
||||
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkillExplicit (i));
|
||||
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
|
||||
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue