Implement explodeSpell instruction (like Cast, with caster = target)

actorid
scrawl 11 years ago
parent 93e1a2df73
commit 366801f3d5

@ -434,7 +434,8 @@ namespace MWMechanics
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
if (!fail && roll >= successChance)
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
if (mCaster.getRefData().getHandle() == "player")
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
fail = true;
}

@ -360,4 +360,6 @@ op 0x2000225: ToggleAIExplicit
op 0x2000226: COE
op 0x2000227: Cast
op 0x2000228: Cast, explicit
opcodes 0x2000229-0x3ffffff unused
op 0x2000229: ExplodeSpell
op 0x200022a: ExplodeSpell, explicit
opcodes 0x200022b-0x3ffffff unused

@ -722,6 +722,22 @@ namespace MWScript
}
};
template <class R>
class OpExplodeSpell : 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();
MWMechanics::CastSpell cast(ptr, ptr);
cast.cast(spell);
}
};
void installOpcodes (Interpreter::Interpreter& interpreter)
{
interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox);
@ -784,6 +800,8 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Misc::opcodeEnableLevitation, new OpEnableLevitation<true>);
interpreter.installSegment5 (Compiler::Misc::opcodeCast, new OpCast<ImplicitRef>);
interpreter.installSegment5 (Compiler::Misc::opcodeCastExplicit, new OpCast<ExplicitRef>);
interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpell, new OpExplodeSpell<ImplicitRef>);
interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpellExplicit, new OpExplodeSpell<ExplicitRef>);
}
}
}

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

@ -230,6 +230,8 @@ namespace Compiler
const int opcodeEnableLevitation = 0x2000221;
const int opcodeCast = 0x2000227;
const int opcodeCastExplicit = 0x2000228;
const int opcodeExplodeSpell = 0x2000229;
const int opcodeExplodeSpellExplicit = 0x200022a;
}
namespace Sky

Loading…
Cancel
Save