diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 5dba79d3f..530051b09 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -283,6 +283,27 @@ namespace MWScript } }; + template + class OpGetWeaponType : public Interpreter::Opcode0 + { + public: + + virtual void execute(Interpreter::Runtime &runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); + MWWorld::ContainerStoreIterator it = invStore.getSlot (MWWorld::InventoryStore::Slot_CarriedRight); + if (it == invStore.end()) + { + runtime.push(-1); + return; + } + + runtime.push(it->get()->mBase->mData.mType); + } + }; + const int opcodeAddItem = 0x2000076; const int opcodeAddItemExplicit = 0x2000077; const int opcodeGetItemCount = 0x2000078; @@ -297,6 +318,8 @@ namespace MWScript const int opcodeHasItemEquippedExplicit = 0x20001d6; const int opcodeHasSoulGem = 0x20001de; const int opcodeHasSoulGemExplicit = 0x20001df; + const int opcodeGetWeaponType = 0x20001e0; + const int opcodeGetWeaponTypeExplicit = 0x20001e1; void registerExtensions (Compiler::Extensions& extensions) { @@ -309,6 +332,7 @@ namespace MWScript extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit); extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit); extensions.registerFunction ("hassoulgem", 'l', "c", opcodeHasSoulGem, opcodeHasSoulGemExplicit); + extensions.registerFunction ("getweapontype", 'l', "", opcodeGetWeaponType, opcodeGetWeaponTypeExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -327,6 +351,8 @@ namespace MWScript interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped); interpreter.installSegment5 (opcodeHasSoulGem, new OpHasSoulGem); interpreter.installSegment5 (opcodeHasSoulGemExplicit, new OpHasSoulGem); + interpreter.installSegment5 (opcodeGetWeaponType, new OpGetWeaponType); + interpreter.installSegment5 (opcodeGetWeaponTypeExplicit, new OpGetWeaponType); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 3e8542335..26c87eeee 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -273,5 +273,9 @@ op 0x20001dc: GetSpellEffects, explicit op 0x20001dd: GetCurrentTime op 0x20001de: HasSoulGem op 0x20001df: HasSoulGem, explicit -opcodes 0x20001e0-0x3ffffff unused +op 0x20001e0: GetWeaponType +op 0x20001e1: GetWeaponType, explicit +opcodes 0x20001e2-0x3ffffff unused + + diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index eab6d6b8d..1c1ef76cf 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -66,7 +66,6 @@ namespace MWWorld void setUpDown(int value); void toggleRunning(); - void getRunning(); }; } #endif