Implement Cast script instruction (shrines work now)

actorid
scrawl 11 years ago
parent b42240be6d
commit 93e1a2df73

@ -358,5 +358,6 @@ op 0x2000223: GetLineOfSightExplicit
op 0x2000224: ToggleAI op 0x2000224: ToggleAI
op 0x2000225: ToggleAIExplicit op 0x2000225: ToggleAIExplicit
op 0x2000226: COE op 0x2000226: COE
op 0x2000227: Cast
opcodes 0x2000227-0x3ffffff unused op 0x2000228: Cast, explicit
opcodes 0x2000229-0x3ffffff unused

@ -23,6 +23,7 @@
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/spellcasting.hpp"
#include "interpretercontext.hpp" #include "interpretercontext.hpp"
#include "ref.hpp" #include "ref.hpp"
@ -700,6 +701,26 @@ namespace MWScript
} }
}; };
template <class R>
class OpCast : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
std::string spell = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
std::string targetId = ::Misc::StringUtils::lowerCase(runtime.getStringLiteral (runtime[0].mInteger));
runtime.pop();
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr (targetId, false);
MWMechanics::CastSpell cast(ptr, target);
cast.cast(spell);
}
};
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
{ {
@ -761,6 +782,8 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Misc::opcodeToggleGodMode, new OpToggleGodMode); interpreter.installSegment5 (Compiler::Misc::opcodeToggleGodMode, new OpToggleGodMode);
interpreter.installSegment5 (Compiler::Misc::opcodeDisableLevitation, new OpEnableLevitation<false>); interpreter.installSegment5 (Compiler::Misc::opcodeDisableLevitation, new OpEnableLevitation<false>);
interpreter.installSegment5 (Compiler::Misc::opcodeEnableLevitation, new OpEnableLevitation<true>); interpreter.installSegment5 (Compiler::Misc::opcodeEnableLevitation, new OpEnableLevitation<true>);
interpreter.installSegment5 (Compiler::Misc::opcodeCast, new OpCast<ImplicitRef>);
interpreter.installSegment5 (Compiler::Misc::opcodeCastExplicit, new OpCast<ExplicitRef>);
} }
} }
} }

@ -222,6 +222,7 @@ namespace Compiler
extensions.registerInstruction ("activate", "", opcodeActivate); extensions.registerInstruction ("activate", "", opcodeActivate);
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit); extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit); extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
extensions.registerInstruction ("cast", "SS", opcodeCast, opcodeCastExplicit);
extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionBoxes); extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionBoxes);
extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug); extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug);
extensions.registerInstruction ("tcb", "", opcodeToggleCollisionBoxes); extensions.registerInstruction ("tcb", "", opcodeToggleCollisionBoxes);

@ -228,6 +228,8 @@ namespace Compiler
const int opcodeToggleGodMode = 0x200021f; const int opcodeToggleGodMode = 0x200021f;
const int opcodeDisableLevitation = 0x2000220; const int opcodeDisableLevitation = 0x2000220;
const int opcodeEnableLevitation = 0x2000221; const int opcodeEnableLevitation = 0x2000221;
const int opcodeCast = 0x2000227;
const int opcodeCastExplicit = 0x2000228;
} }
namespace Sky namespace Sky

Loading…
Cancel
Save