From 0af869c8164ebe65a3f32a1407461f5a29d708ce Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 20:22:51 +0100 Subject: [PATCH 01/13] GetReputation --- apps/openmw/mwscript/dialogueextensions.cpp | 18 ++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 2 ++ 2 files changed, 20 insertions(+) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 72ae257241..ec5d49b1fd 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -159,6 +159,18 @@ namespace MWScript } }; + template + class OpGetReputation : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).getReputation ()); + } + }; const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; @@ -172,6 +184,8 @@ namespace MWScript const int opcodeModReputation = 0x20001ae; const int opcodeSetReputationExplicit = 0x20001af; const int opcodeModReputationExplicit = 0x20001b0; + const int opcodeGetReputation = 0x20001b1; + const int opcodeGetReputationExplicit = 0x20001b2; void registerExtensions (Compiler::Extensions& extensions) { @@ -188,6 +202,8 @@ namespace MWScript opcodeSetReputationExplicit); extensions.registerInstruction("modreputation", "l", opcodeModReputation, opcodeModReputationExplicit); + extensions.registerFunction("getreputation", 'l', "", opcodeGetReputation, + opcodeGetReputationExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -200,10 +216,12 @@ namespace MWScript interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting); interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting); interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye); + interpreter.installSegment5 (opcodeGetReputation, new OpGetReputation); interpreter.installSegment5 (opcodeSetReputation, new OpSetReputation); interpreter.installSegment5 (opcodeModReputation, new OpModReputation); interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation); interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation); + interpreter.installSegment5 (opcodeGetReputationExplicit, new OpGetReputation); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index b130aa9547..fcfb33d215 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -226,5 +226,7 @@ op 0x20001ad: SetReputation op 0x20001ae: ModReputation op 0x20001af: SetReputation, explicit op 0x20001b0: ModReputation, explicit +op 0x20001b1: GetReputation +op 0x20001b2: GetReputation, explicit opcodes 0x20001b1-0x3ffffff unused From 064cb80c0ac64a229df53c39ba09d4873b98234e Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 20:48:53 +0100 Subject: [PATCH 02/13] fix wait dialog fading --- apps/openmw/mwrender/renderingmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5f1f1ad433..8cb8e9fa8b 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -332,6 +332,8 @@ void RenderingManager::update (float duration, bool paused) } mOcclusionQuery->update(duration); + mRendering.update(duration); + if(paused) { Ogre::ControllerManager::getSingleton().setTimeFactor(0.f); @@ -350,8 +352,6 @@ void RenderingManager::update (float duration, bool paused) mSkyManager->setGlare(mOcclusionQuery->getSunVisibility()); - mRendering.update(duration); - MWWorld::RefData &data = MWBase::Environment::get() .getWorld() From d54ed557bfe6bfa9be8b7397192658c615f09a2b Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 20:48:59 +0100 Subject: [PATCH 03/13] Equip --- apps/openmw/mwscript/containerextensions.cpp | 34 ++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 4 ++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 5e9746b2f1..dd4c62a696 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -14,6 +14,8 @@ #include "../mwworld/manualref.hpp" #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" +#include "../mwworld/actionequip.hpp" +#include "../mwworld/inventorystore.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -128,12 +130,41 @@ namespace MWScript } }; + template + class OpEquip : public Interpreter::Opcode0 + { + public: + + virtual void execute(Interpreter::Runtime &runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + std::string item = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); + MWWorld::ContainerStoreIterator it = invStore.begin(); + for (; it != invStore.end(); ++it) + { + if (toLower(it->getCellRef().mRefID) == toLower(item)) + break; + } + if (it == invStore.end()) + throw std::runtime_error("Item to equip not found"); + + MWWorld::ActionEquip action (*it); + action.execute(ptr); + } + }; + const int opcodeAddItem = 0x2000076; const int opcodeAddItemExplicit = 0x2000077; const int opcodeGetItemCount = 0x2000078; const int opcodeGetItemCountExplicit = 0x2000079; const int opcodeRemoveItem = 0x200007a; const int opcodeRemoveItemExplicit = 0x200007b; + const int opcodeEquip = 0x20001b3; + const int opcodeEquipExplicit = 0x20001b4; void registerExtensions (Compiler::Extensions& extensions) { @@ -142,6 +173,7 @@ namespace MWScript opcodeGetItemCountExplicit); extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem, opcodeRemoveItemExplicit); + extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -152,6 +184,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount); interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem); interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem); + interpreter.installSegment5 (opcodeEquip, new OpEquip); + interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index fcfb33d215..eda08cae0c 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -228,5 +228,7 @@ op 0x20001af: SetReputation, explicit op 0x20001b0: ModReputation, explicit op 0x20001b1: GetReputation op 0x20001b2: GetReputation, explicit -opcodes 0x20001b1-0x3ffffff unused +op 0x20001b3: Equip +op 0x20001b4: Equip, explicit +opcodes 0x20001b5-0x3ffffff unused From 9c170af30cd3b15051705af405d5490d268f250a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 20:57:08 +0100 Subject: [PATCH 04/13] SameFaction --- apps/openmw/mwscript/dialogueextensions.cpp | 22 +++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index ec5d49b1fd..f636232751 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -12,6 +12,7 @@ #include "../mwbase/journal.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/player.hpp" #include "../mwmechanics/npcstats.hpp" #include "interpretercontext.hpp" @@ -172,6 +173,21 @@ namespace MWScript } }; + template + class OpSameFaction : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); + + runtime.push (MWWorld::Class::get(ptr).getNpcStats (ptr).isSameFaction (MWWorld::Class::get(player).getNpcStats (player))); + } + }; + const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; @@ -186,6 +202,8 @@ namespace MWScript const int opcodeModReputationExplicit = 0x20001b0; const int opcodeGetReputation = 0x20001b1; const int opcodeGetReputationExplicit = 0x20001b2; + const int opcodeSameFaction = 0x20001b5; + const int opcodeSameFactionExplicit = 0x20001b6; void registerExtensions (Compiler::Extensions& extensions) { @@ -204,6 +222,8 @@ namespace MWScript opcodeModReputationExplicit); extensions.registerFunction("getreputation", 'l', "", opcodeGetReputation, opcodeGetReputationExplicit); + extensions.registerFunction("samefaction", 'l', "", opcodeSameFaction, + opcodeSameFactionExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -222,6 +242,8 @@ namespace MWScript interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation); interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation); interpreter.installSegment5 (opcodeGetReputationExplicit, new OpGetReputation); + interpreter.installSegment5 (opcodeSameFaction, new OpSameFaction); + interpreter.installSegment5 (opcodeSameFactionExplicit, new OpSameFaction); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index eda08cae0c..f45b75bb13 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -230,5 +230,7 @@ op 0x20001b1: GetReputation op 0x20001b2: GetReputation, explicit op 0x20001b3: Equip op 0x20001b4: Equip, explicit -opcodes 0x20001b5-0x3ffffff unused +op 0x20001b5: SameFaction +op 0x20001b6: SameFaction, explicit +opcodes 0x20001b7-0x3ffffff unused From d418e2137190d049ff90cdb5503bbe092a9ede81 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 21:14:32 +0100 Subject: [PATCH 05/13] --- apps/openmw/mwscript/aiextensions.cpp | 103 ++++++++++++++++--------- apps/openmw/mwscript/docs/vmformat.txt | 18 ++++- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 787962ad1e..aa1d2d0309 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -114,71 +114,56 @@ namespace MWScript // discard additional arguments (reset), because we have no idea what they mean. for (unsigned int i=0; i - class OpSetHello : public Interpreter::Opcode0 + class OpGetAiSetting : public Interpreter::Opcode0 { + int mIndex; public: + OpGetAiSetting(int index) : mIndex(index) {} virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (0, value); + runtime.push(MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex)); } }; - template - class OpSetFight : public Interpreter::Opcode0 + class OpModAiSetting : public Interpreter::Opcode0 { + int mIndex; public: + OpModAiSetting(int index) : mIndex(index) {} virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (1, value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex, + MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSetting (mIndex) + value); } }; - template - class OpSetFlee : public Interpreter::Opcode0 + class OpSetAiSetting : public Interpreter::Opcode0 { + int mIndex; public: + OpSetAiSetting(int index) : mIndex(index) {} virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (2, value); - } - }; - - template - class OpSetAlarm : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = R()(runtime); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (3, value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (mIndex, + value); } }; @@ -199,6 +184,22 @@ namespace MWScript const int opcodeSetFleeExplicit = 0x2000161; const int opcodeSetAlarm = 0x2000162; const int opcodeSetAlarmExplicit = 0x2000163; + const int opcodeModHello = 0x20001b7; + const int opcodeModHelloExplicit = 0x20001b8; + const int opcodeModFight = 0x20001b9; + const int opcodeModFightExplicit = 0x20001ba; + const int opcodeModFlee = 0x20001bb; + const int opcodeModFleeExplicit = 0x20001bc; + const int opcodeModAlarm = 0x20001bd; + const int opcodeModAlarmExplicit = 0x20001be; + const int opcodeGetHello = 0x20001bf; + const int opcodeGetHelloExplicit = 0x20001c0; + const int opcodeGetFight = 0x20001c1; + const int opcodeGetFightExplicit = 0x20001c2; + const int opcodeGetFlee = 0x20001c3; + const int opcodeGetFleeExplicit = 0x20001c4; + const int opcodeGetAlarm = 0x20001c5; + const int opcodeGetAlarmExplicit = 0x20001c6; void registerExtensions (Compiler::Extensions& extensions) { @@ -216,6 +217,14 @@ namespace MWScript extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit); extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit); extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit); + extensions.registerInstruction ("modhello", "l", opcodeModHello, opcodeModHelloExplicit); + extensions.registerInstruction ("modfight", "l", opcodeModFight, opcodeModFightExplicit); + extensions.registerInstruction ("modflee", "l", opcodeModFlee, opcodeModFleeExplicit); + extensions.registerInstruction ("modalarm", "l", opcodeModAlarm, opcodeModAlarmExplicit); + extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit); + extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit); + extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit); + extensions.registerFunction ("getalarm", 'l', "", opcodeGetAlarm, opcodeGetAlarmExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -229,14 +238,32 @@ namespace MWScript interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone); interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDone); - interpreter.installSegment5 (opcodeSetHello, new OpSetHello); - interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetHello); - interpreter.installSegment5 (opcodeSetFight, new OpSetFight); - interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetFight); - interpreter.installSegment5 (opcodeSetFlee, new OpSetFlee); - interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetFlee); - interpreter.installSegment5 (opcodeSetAlarm, new OpSetAlarm); - interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAlarm); + interpreter.installSegment5 (opcodeSetHello, new OpSetAiSetting(0)); + interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetAiSetting(0)); + interpreter.installSegment5 (opcodeSetFight, new OpSetAiSetting(1)); + interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetAiSetting(1)); + interpreter.installSegment5 (opcodeSetFlee, new OpSetAiSetting(2)); + interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetAiSetting(2)); + interpreter.installSegment5 (opcodeSetAlarm, new OpSetAiSetting(3)); + interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAiSetting(3)); + + interpreter.installSegment5 (opcodeModHello, new OpModAiSetting(0)); + interpreter.installSegment5 (opcodeModHelloExplicit, new OpModAiSetting(0)); + interpreter.installSegment5 (opcodeModFight, new OpModAiSetting(1)); + interpreter.installSegment5 (opcodeModFightExplicit, new OpModAiSetting(1)); + interpreter.installSegment5 (opcodeModFlee, new OpModAiSetting(2)); + interpreter.installSegment5 (opcodeModFleeExplicit, new OpModAiSetting(2)); + interpreter.installSegment5 (opcodeModAlarm, new OpModAiSetting(3)); + interpreter.installSegment5 (opcodeModAlarmExplicit, new OpModAiSetting(3)); + + interpreter.installSegment5 (opcodeGetHello, new OpGetAiSetting(0)); + interpreter.installSegment5 (opcodeGetHelloExplicit, new OpGetAiSetting(0)); + interpreter.installSegment5 (opcodeGetFight, new OpGetAiSetting(1)); + interpreter.installSegment5 (opcodeGetFightExplicit, new OpGetAiSetting(1)); + interpreter.installSegment5 (opcodeGetFlee, new OpGetAiSetting(2)); + interpreter.installSegment5 (opcodeGetFleeExplicit, new OpGetAiSetting(2)); + interpreter.installSegment5 (opcodeGetAlarm, new OpGetAiSetting(3)); + interpreter.installSegment5 (opcodeGetAlarmExplicit, new OpGetAiSetting(3)); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index f45b75bb13..541cffcf4a 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -232,5 +232,21 @@ op 0x20001b3: Equip op 0x20001b4: Equip, explicit op 0x20001b5: SameFaction op 0x20001b6: SameFaction, explicit -opcodes 0x20001b7-0x3ffffff unused +op 0x20001b7: ModHello +op 0x20001b8: ModHello, explicit reference +op 0x20001b9: ModFight +op 0x20001ba: ModFight, explicit reference +op 0x20001bb: ModFlee +op 0x20001bc: ModFlee, explicit reference +op 0x20001bd: ModAlarm +op 0x20001be: ModAlarm, explicit reference +op 0x20001bf: GetHello +op 0x20001c0: GetHello, explicit reference +op 0x20001c1: GetFight +op 0x20001c2: GetFight, explicit reference +op 0x20001c3: GetFlee +op 0x20001c4: GetFlee, explicit reference +op 0x20001c5: GetAlarm +op 0x20001c6: GetAlarm, explicit reference +opcodes 0x20001c7-0x3ffffff unused From 10329c780d9f4b3278e69cf7e4d59b107476e84b Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 21:31:10 +0100 Subject: [PATCH 06/13] GetLocked --- apps/openmw/mwscript/docs/vmformat.txt | 2 ++ apps/openmw/mwscript/miscextensions.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 541cffcf4a..d6aafc8d87 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -248,5 +248,7 @@ op 0x20001c3: GetFlee op 0x20001c4: GetFlee, explicit reference op 0x20001c5: GetAlarm op 0x20001c6: GetAlarm, explicit reference +op 0x20001c7: GetLocked +op 0x20001c8: GetLocked, explicit reference opcodes 0x20001c7-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index c09f0c860f..11637c65bb 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -272,6 +272,19 @@ namespace MWScript }; bool OpToggleVanityMode::sActivate = true; + template + class OpGetLocked : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push (ptr.getCellRef ().mLockLevel > 0); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -291,6 +304,8 @@ namespace MWScript const int opcodeToggleVanityMode = 0x2000174; const int opcodeGetPcSleep = 0x200019f; const int opcodeWakeUpPc = 0x20001a2; + const int opcodeGetLocked = 0x20001c7; + const int opcodeGetLockedExplicit = 0x20001c8; void registerExtensions (Compiler::Extensions& extensions) { @@ -317,6 +332,7 @@ namespace MWScript extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode); extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); + extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -340,6 +356,8 @@ namespace MWScript interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode); interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep); interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc); + interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked); + interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked); } } } From e8ef4dba1ef68e25a656646e952838da0930194c Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:02:49 +0100 Subject: [PATCH 07/13] getPcRunning, getPcSneaking, getForceRun, getForceSneak --- apps/openmw/mwscript/docs/vmformat.txt | 8 ++- apps/openmw/mwscript/miscextensions.cpp | 71 +++++++++++++++++++++++++ apps/openmw/mwworld/player.hpp | 1 + 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index d6aafc8d87..11405cbcbb 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -250,5 +250,11 @@ op 0x20001c5: GetAlarm op 0x20001c6: GetAlarm, explicit reference op 0x20001c7: GetLocked op 0x20001c8: GetLocked, explicit reference -opcodes 0x20001c7-0x3ffffff unused +op 0x20001c9: GetPcRunning +op 0x20001ca: GetPcSneaking +op 0x20001cb: GetForceRun +op 0x20001cc: GetForceSneak +op 0x20001cd: GetForceRun, explicit +op 0x20001ce: GetForceSneak, explicit +opcodes 0x20001cd-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 11637c65bb..60451c03f7 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -13,6 +13,9 @@ #include "../mwbase/windowmanager.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/player.hpp" + +#include "../mwmechanics/npcstats.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -285,6 +288,58 @@ namespace MWScript } }; + template + class OpGetForceRun : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); + + runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); + } + }; + + template + class OpGetForceSneak : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); + + runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); + } + }; + + class OpGetPcRunning : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); + runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Run)); + } + }; + + class OpGetPcSneaking : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); + runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Sneak)); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -306,6 +361,12 @@ namespace MWScript const int opcodeWakeUpPc = 0x20001a2; const int opcodeGetLocked = 0x20001c7; const int opcodeGetLockedExplicit = 0x20001c8; + const int opcodeGetPcRunning = 0x20001c9; + const int opcodeGetPcSneaking = 0x20001ca; + const int opcodeGetForceRun = 0x20001cb; + const int opcodeGetForceSneak = 0x20001cc; + const int opcodeGetForceRunExplicit = 0x20001cd; + const int opcodeGetForceSneakExplicit = 0x20001ce; void registerExtensions (Compiler::Extensions& extensions) { @@ -333,6 +394,10 @@ namespace MWScript extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); + extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning); + extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); + extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); + extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -358,6 +423,12 @@ namespace MWScript interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc); interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked); interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked); + interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning); + interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking); + interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun); + interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); + interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); + interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); } } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 1c1ef76cf0..eab6d6b8d0 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -66,6 +66,7 @@ namespace MWWorld void setUpDown(int value); void toggleRunning(); + void getRunning(); }; } #endif From d7811624d53b49ce7b018ccb0e2f4b39c08c1c2d Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:15:55 +0100 Subject: [PATCH 08/13] GetEffect --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 11405cbcbb..365779a9a3 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -256,5 +256,7 @@ op 0x20001cb: GetForceRun op 0x20001cc: GetForceSneak op 0x20001cd: GetForceRun, explicit op 0x20001ce: GetForceSneak, explicit -opcodes 0x20001cd-0x3ffffff unused +op 0x20001cf: GetEffect +op 0x20001d0: GetEffect, explicit +opcodes 0x20001d1-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 60451c03f7..5a342026e9 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -16,6 +16,7 @@ #include "../mwworld/player.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -340,6 +341,23 @@ namespace MWScript } }; + template + class OpGetEffect : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + int key = runtime[0].mInteger; + runtime.pop(); + + runtime.push (MWWorld::Class::get(ptr).getCreatureStats (ptr).getMagicEffects ().get ( + MWMechanics::EffectKey(key)).mMagnitude > 0); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -367,6 +385,8 @@ namespace MWScript const int opcodeGetForceSneak = 0x20001cc; const int opcodeGetForceRunExplicit = 0x20001cd; const int opcodeGetForceSneakExplicit = 0x20001ce; + const int opcodeGetEffect = 0x20001cf; + const int opcodeGetEffectExplicit = 0x20001d0; void registerExtensions (Compiler::Extensions& extensions) { @@ -398,6 +418,7 @@ namespace MWScript extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); + extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -429,6 +450,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); + interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect); + interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); } } } From a596d23203149d5468423e0f6f095f4ebf8a99ec Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:38:10 +0100 Subject: [PATCH 09/13] GetArmorType --- apps/openmw/mwscript/containerextensions.cpp | 79 ++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 4 +- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index dd4c62a696..c5566c92bd 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -157,6 +157,79 @@ namespace MWScript } }; + template + class OpGetArmorType : public Interpreter::Opcode0 + { + public: + + virtual void execute(Interpreter::Runtime &runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer location = runtime[0].mInteger; + runtime.pop(); + + int slot; + switch (location) + { + case 0: + slot = MWWorld::InventoryStore::Slot_Helmet; + break; + case 1: + slot = MWWorld::InventoryStore::Slot_Cuirass; + break; + case 2: + slot = MWWorld::InventoryStore::Slot_LeftPauldron; + break; + case 3: + slot = MWWorld::InventoryStore::Slot_RightPauldron; + break; + case 4: + slot = MWWorld::InventoryStore::Slot_Greaves; + break; + case 5: + slot = MWWorld::InventoryStore::Slot_Boots; + break; + case 6: + slot = MWWorld::InventoryStore::Slot_LeftGauntlet; + break; + case 7: + slot = MWWorld::InventoryStore::Slot_RightGauntlet; + break; + case 8: + slot = MWWorld::InventoryStore::Slot_CarriedLeft; // shield + break; + case 9: + slot = MWWorld::InventoryStore::Slot_LeftGauntlet; + break; + case 10: + slot = MWWorld::InventoryStore::Slot_RightGauntlet; + break; + default: + throw std::runtime_error ("armor index out of range"); + } + + MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); + + MWWorld::ContainerStoreIterator it = invStore.getSlot (slot); + if (it == invStore.end()) + { + runtime.push(-1); + return; + } + + int skill = MWWorld::Class::get(*it).getEquipmentSkill (*it) ; + if (skill == ESM::Skill::HeavyArmor) + runtime.push(2); + else if (skill == ESM::Skill::MediumArmor) + runtime.push(1); + else if (skill == ESM::Skill::LightArmor) + runtime.push(0); + else + runtime.push(-1); + } + }; + const int opcodeAddItem = 0x2000076; const int opcodeAddItemExplicit = 0x2000077; const int opcodeGetItemCount = 0x2000078; @@ -165,6 +238,8 @@ namespace MWScript const int opcodeRemoveItemExplicit = 0x200007b; const int opcodeEquip = 0x20001b3; const int opcodeEquipExplicit = 0x20001b4; + const int opcodeGetArmorType = 0x20001d1; + const int opcodeGetArmorTypeExplicit = 0x20001d2; void registerExtensions (Compiler::Extensions& extensions) { @@ -174,6 +249,7 @@ namespace MWScript extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem, opcodeRemoveItemExplicit); extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit); + extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -186,6 +262,9 @@ namespace MWScript interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem); interpreter.installSegment5 (opcodeEquip, new OpEquip); interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip); + interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType); + interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType); + } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 365779a9a3..894fd5f051 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -258,5 +258,7 @@ op 0x20001cd: GetForceRun, explicit op 0x20001ce: GetForceSneak, explicit op 0x20001cf: GetEffect op 0x20001d0: GetEffect, explicit -opcodes 0x20001d1-0x3ffffff unused +op 0x20001d1: GetArmorType +op 0x20001d2: GetArmorType, explicit +opcodes 0x20001d3-0x3ffffff unused From 50baf6dac73ee16a76ea6e87c7387adeadda51ae Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:45:25 +0100 Subject: [PATCH 10/13] moved to controlextensions --- apps/openmw/mwscript/controlextensions.cpp | 68 ++++++++++++++++++++++ apps/openmw/mwscript/miscextensions.cpp | 68 ---------------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 0096c69ab9..8d65dfdd5b 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -106,6 +106,58 @@ namespace MWScript } }; + template + class OpGetForceRun : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); + + runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); + } + }; + + template + class OpGetForceSneak : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); + + runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); + } + }; + + class OpGetPcRunning : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); + runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Run)); + } + }; + + class OpGetPcSneaking : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); + runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Sneak)); + } + }; + const int numberOfControls = 7; const int opcodeEnable = 0x200007e; @@ -120,6 +172,12 @@ namespace MWScript const int opcodeForceSneak = 0x200015a; const int opcodeForceSneakExplicit = 0x200015b; const int opcodeGetDisabled = 0x2000175; + const int opcodeGetPcRunning = 0x20001c9; + const int opcodeGetPcSneaking = 0x20001ca; + const int opcodeGetForceRun = 0x20001cb; + const int opcodeGetForceSneak = 0x20001cc; + const int opcodeGetForceRunExplicit = 0x20001cd; + const int opcodeGetForceSneakExplicit = 0x20001ce; const char *controls[numberOfControls] = { @@ -151,6 +209,10 @@ namespace MWScript opcodeClearForceSneakExplicit); extensions.registerInstruction ("forcesneak", "", opcodeForceSneak, opcodeForceSneakExplicit); + extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning); + extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); + extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); + extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -181,6 +243,12 @@ namespace MWScript new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); interpreter.installSegment5 (opcodeForceSneakExplicit, new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); + interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning); + interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking); + interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun); + interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); + interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); + interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); } } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 5a342026e9..85e6ab494b 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -289,58 +289,6 @@ namespace MWScript } }; - template - class OpGetForceRun : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = R()(runtime); - - MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); - - runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); - } - }; - - template - class OpGetForceSneak : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = R()(runtime); - - MWMechanics::NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats (ptr); - - runtime.push (npcStats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); - } - }; - - class OpGetPcRunning : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); - runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Run)); - } - }; - - class OpGetPcSneaking : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer(); - runtime.push (MWWorld::Class::get(ptr).getStance (ptr, MWWorld::Class::Sneak)); - } - }; - template class OpGetEffect : public Interpreter::Opcode0 { @@ -379,12 +327,6 @@ namespace MWScript const int opcodeWakeUpPc = 0x20001a2; const int opcodeGetLocked = 0x20001c7; const int opcodeGetLockedExplicit = 0x20001c8; - const int opcodeGetPcRunning = 0x20001c9; - const int opcodeGetPcSneaking = 0x20001ca; - const int opcodeGetForceRun = 0x20001cb; - const int opcodeGetForceSneak = 0x20001cc; - const int opcodeGetForceRunExplicit = 0x20001cd; - const int opcodeGetForceSneakExplicit = 0x20001ce; const int opcodeGetEffect = 0x20001cf; const int opcodeGetEffectExplicit = 0x20001d0; @@ -414,10 +356,6 @@ namespace MWScript extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); - extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning); - extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); - extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); - extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); } @@ -444,12 +382,6 @@ namespace MWScript interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc); interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked); interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked); - interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning); - interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking); - interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun); - interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); - interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); - interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect); interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); } From 600ed5f38a370bc357bfb3532b2d3504aa783ddf Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:48:53 +0100 Subject: [PATCH 11/13] GetAttacked --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 894fd5f051..9c1084c5c9 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -260,5 +260,7 @@ op 0x20001cf: GetEffect op 0x20001d0: GetEffect, explicit op 0x20001d1: GetArmorType op 0x20001d2: GetArmorType, explicit -opcodes 0x20001d3-0x3ffffff unused +op 0x20001d3: GetAttacked +op 0x20001d4: GetAttacked, explicit +opcodes 0x20001d5-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 85e6ab494b..204014e742 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -306,6 +306,19 @@ namespace MWScript } }; + template + class OpGetAttacked : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push(MWWorld::Class::get(ptr).getCreatureStats (ptr).getAttacked ()); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -329,6 +342,8 @@ namespace MWScript const int opcodeGetLockedExplicit = 0x20001c8; const int opcodeGetEffect = 0x20001cf; const int opcodeGetEffectExplicit = 0x20001d0; + const int opcodeGetAttacked = 0x20001d3; + const int opcodeGetAttackedExplicit = 0x20001d4; void registerExtensions (Compiler::Extensions& extensions) { @@ -357,6 +372,7 @@ namespace MWScript extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); + extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -384,6 +400,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked); interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect); interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); + interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked); + interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked); } } } From be82d1452f0d9b51db5ba289ba931e4a8fd49bc9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:59:44 +0100 Subject: [PATCH 12/13] HasItemEquipped --- apps/openmw/mwscript/containerextensions.cpp | 31 ++++++++++++++++++++ apps/openmw/mwscript/docs/vmformat.txt | 2 ++ 2 files changed, 33 insertions(+) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index c5566c92bd..66cf21c5b6 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -230,6 +230,32 @@ namespace MWScript } }; + template + class OpHasItemEquipped : public Interpreter::Opcode0 + { + public: + + virtual void execute(Interpreter::Runtime &runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + std::string item = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore (ptr); + for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) + { + MWWorld::ContainerStoreIterator it = invStore.getSlot (slot); + if (it != invStore.end() && toLower(it->getCellRef().mRefID) == toLower(item)) + { + runtime.push(1); + return; + } + } + runtime.push(0); + } + }; + const int opcodeAddItem = 0x2000076; const int opcodeAddItemExplicit = 0x2000077; const int opcodeGetItemCount = 0x2000078; @@ -240,6 +266,8 @@ namespace MWScript const int opcodeEquipExplicit = 0x20001b4; const int opcodeGetArmorType = 0x20001d1; const int opcodeGetArmorTypeExplicit = 0x20001d2; + const int opcodeHasItemEquipped = 0x20001d5; + const int opcodeHasItemEquippedExplicit = 0x20001d6; void registerExtensions (Compiler::Extensions& extensions) { @@ -250,6 +278,7 @@ namespace MWScript opcodeRemoveItemExplicit); extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit); extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit); + extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -264,6 +293,8 @@ namespace MWScript interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip); interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType); interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType); + interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped); + interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 9c1084c5c9..e964e747e8 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -262,5 +262,7 @@ op 0x20001d1: GetArmorType op 0x20001d2: GetArmorType, explicit op 0x20001d3: GetAttacked op 0x20001d4: GetAttacked, explicit +op 0x20001d5: HasItemEquipped +op 0x20001d6: HasItemEquipped, explicit opcodes 0x20001d5-0x3ffffff unused From 70aa7459f541b25ddb1ce27613e0630546722856 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 03:04:26 +0100 Subject: [PATCH 13/13] GetWeaponDrawn --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index e964e747e8..498e1572fc 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -264,5 +264,7 @@ op 0x20001d3: GetAttacked op 0x20001d4: GetAttacked, explicit op 0x20001d5: HasItemEquipped op 0x20001d6: HasItemEquipped, explicit -opcodes 0x20001d5-0x3ffffff unused +op 0x20001d7: GetWeaponDrawn +op 0x20001d8: GetWeaponDrawn, explicit +opcodes 0x20001d9-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 204014e742..505dbdf7de 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -319,6 +319,19 @@ namespace MWScript } }; + template + class OpGetWeaponDrawn : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push(MWWorld::Class::get(ptr).getNpcStats (ptr).getDrawState () == MWMechanics::DrawState_Weapon); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -344,6 +357,8 @@ namespace MWScript const int opcodeGetEffectExplicit = 0x20001d0; const int opcodeGetAttacked = 0x20001d3; const int opcodeGetAttackedExplicit = 0x20001d4; + const int opcodeGetWeaponDrawn = 0x20001d7; + const int opcodeGetWeaponDrawnExplicit = 0x20001d8; void registerExtensions (Compiler::Extensions& extensions) { @@ -373,6 +388,7 @@ namespace MWScript extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit); + extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -402,6 +418,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked); interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked); + interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn); + interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn); } } }