added ModCurrentHealth, ModCurrentMagicka, ModCurrentFatigue

pull/7/head
Marc Zinnschlag 15 years ago
parent 3b6b343c9b
commit a542ca22fd

@ -72,4 +72,6 @@ op 0x200005d-0x200005f: SetDynamic (health, magicka, fatigue)
op 0x2000060-0x2000062: SetDynamic (health, magicka, fatigue), explicit reference
op 0x2000063-0x2000065: ModDynamic (health, magicka, fatigue)
op 0x2000066-0x2000068: ModDynamic (health, magicka, fatigue), explicit reference
opcodes 0x2000069-0x3ffffff unused
op 0x2000069-0x200006b: ModDynamic (health, magicka, fatigue)
op 0x200006c-0x200006e: ModDynamic (health, magicka, fatigue), explicit reference
opcodes 0x200006f-0x3ffffff unused

@ -310,6 +310,59 @@ namespace MWScript
}
};
class OpModCurrentDynamic : public Interpreter::Opcode0
{
int mIndex;
public:
OpModCurrentDynamic (int index) : mIndex (index) {}
virtual void execute (Interpreter::Runtime& runtime)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
Interpreter::Type_Integer diff = runtime[0].mInteger;
runtime.pop();
MWMechanics::CreatureStats& stats = context.getReference().getCreatureStats();
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
stats.mDynamic[mIndex].setCurrent (diff + current);
}
};
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();
MWMechanics::CreatureStats& stats =
context.getWorld().getPtr (id, false).getCreatureStats();
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
stats.mDynamic[mIndex].setCurrent (diff + current);
}
};
const int numberOfAttributes = 8;
const int opcodeGetAttribute = 0x2000027;
@ -327,6 +380,8 @@ namespace MWScript
const int opcodeSetDynamicExplicit = 0x2000060;
const int opcodeModDynamic = 0x2000063;
const int opcodeModDynamicExplicit = 0x2000066;
const int opcodeModCurrentDynamic = 0x2000069;
const int opcodeModCurrentDynamicExplicit = 0x200006c;
void registerExtensions (Compiler::Extensions& extensions)
{
@ -344,6 +399,7 @@ namespace MWScript
std::string get ("get");
std::string set ("set");
std::string mod ("mod");
std::string modCurrent ("modcurrent");
for (int i=0; i<numberOfAttributes; ++i)
{
@ -367,6 +423,9 @@ namespace MWScript
extensions.registerInstruction (mod + dynamics[i], "l",
opcodeModDynamic+i, opcodeModDynamicExplicit+i);
extensions.registerInstruction (modCurrent + dynamics[i], "l",
opcodeModCurrentDynamic+i, opcodeModCurrentDynamicExplicit+i);
}
}
@ -400,6 +459,10 @@ namespace MWScript
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i));
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
new OpModDynamicExplicit (i));
interpreter.installSegment5 (opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i));
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
new OpModCurrentDynamicExplicit (i));
}
}
}

Loading…
Cancel
Save