From 9c170af30cd3b15051705af405d5490d268f250a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Nov 2012 20:57:08 +0100 Subject: [PATCH] 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 ec5d49b1f..f63623275 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 eda08cae0..f45b75bb1 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