GetCurrentTime, HasSoulGem

actorid
scrawl 12 years ago
parent 0db48b29c7
commit e68dc19256

@ -256,6 +256,33 @@ namespace MWScript
}
};
template <class R>
class OpHasSoulGem : public Interpreter::Opcode0
{
public:
virtual void execute(Interpreter::Runtime &runtime)
{
MWWorld::Ptr ptr = R()(runtime);
std::string creatureName = toLower (runtime.getStringLiteral (runtime[0].mInteger));
runtime.pop();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr);
for (MWWorld::ContainerStoreIterator it = invStore.begin(MWWorld::ContainerStore::Type_Miscellaneous);
it != invStore.end(); ++it)
{
if (toLower(it->getCellRef().mSoul) == toLower(creatureName))
{
runtime.push(1);
return;
}
}
runtime.push(0);
}
};
const int opcodeAddItem = 0x2000076;
const int opcodeAddItemExplicit = 0x2000077;
const int opcodeGetItemCount = 0x2000078;
@ -268,6 +295,8 @@ namespace MWScript
const int opcodeGetArmorTypeExplicit = 0x20001d2;
const int opcodeHasItemEquipped = 0x20001d5;
const int opcodeHasItemEquippedExplicit = 0x20001d6;
const int opcodeHasSoulGem = 0x20001de;
const int opcodeHasSoulGemExplicit = 0x20001df;
void registerExtensions (Compiler::Extensions& extensions)
{
@ -279,6 +308,7 @@ namespace MWScript
extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit);
extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit);
extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit);
extensions.registerFunction ("hassoulgem", 'l', "c", opcodeHasSoulGem, opcodeHasSoulGemExplicit);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -293,9 +323,10 @@ namespace MWScript
interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip<ExplicitRef>);
interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType<ImplicitRef>);
interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType<ExplicitRef>);
interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped<ExplicitRef>);
interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped<ImplicitRef>);
interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped<ExplicitRef>);
interpreter.installSegment5 (opcodeHasSoulGem, new OpHasSoulGem<ImplicitRef>);
interpreter.installSegment5 (opcodeHasSoulGemExplicit, new OpHasSoulGem<ExplicitRef>);
}
}
}

@ -270,5 +270,8 @@ op 0x20001d9: GetRace
op 0x20001da: GetRace, explicit
op 0x20001db: GetSpellEffects
op 0x20001dc: GetSpellEffects, explicit
opcodes 0x20001dd-0x3ffffff unused
op 0x20001dd: GetCurrentTime
op 0x20001de: HasSoulGem
op 0x20001df: HasSoulGem, explicit
opcodes 0x20001e0-0x3ffffff unused

@ -347,6 +347,16 @@ namespace MWScript
}
};
class OpGetCurrentTime : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
runtime.push(MWBase::Environment::get().getWorld()->getTimeStamp().getHour());
}
};
const int opcodeXBox = 0x200000c;
const int opcodeOnActivate = 0x200000d;
const int opcodeActivate = 0x2000075;
@ -376,6 +386,7 @@ namespace MWScript
const int opcodeGetWeaponDrawnExplicit = 0x20001d8;
const int opcodeGetSpellEffects = 0x20001db;
const int opcodeGetSpellEffectsExplicit = 0x20001dc;
const int opcodeGetCurrentTime = 0x20001dd;
void registerExtensions (Compiler::Extensions& extensions)
{
@ -407,6 +418,7 @@ namespace MWScript
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
extensions.registerFunction ("getcurrenttime", 'f', "", opcodeGetCurrentTime);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -440,6 +452,7 @@ namespace MWScript
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
interpreter.installSegment5 (opcodeGetSpellEffects, new OpGetSpellEffects<ImplicitRef>);
interpreter.installSegment5 (opcodeGetSpellEffectsExplicit, new OpGetSpellEffects<ExplicitRef>);
interpreter.installSegment5 (opcodeGetCurrentTime, new OpGetCurrentTime);
}
}
}

Loading…
Cancel
Save