From aaa5368fe927b093b239862bb7d069c83099f140 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 4 Apr 2012 22:14:38 +0200 Subject: [PATCH] added script instruction pcraiserank. Does not work yet. --- apps/openmw/mwscript/docs/vmformat.txt | 3 ++- apps/openmw/mwscript/statsextensions.cpp | 27 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 7ff60a2035..27b426d0e0 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -127,4 +127,5 @@ op 0x2000141: GetWaterLevel op 0x2000142: SetWaterLevel op 0x2000143: ModWaterLevel op 0x2000144: ToggleWater, twa -opcodes 0x2000145-0x3ffffff unused +op 0x2000145: PCRaiseRank +opcodes 0x2000146-0x3ffffff unused diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 85ac54348a..be31321e98 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -17,6 +17,8 @@ #include "interpretercontext.hpp" #include "ref.hpp" +#include "../mwdialogue/dialoguemanager.hpp" + namespace MWScript { namespace Stats @@ -303,12 +305,18 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { + std::cout << "try to rais rank..."; MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - - std::string factionID = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - context.getEnvironment().mWorld->getPlayer().raiseRank(factionID); + + std::string factionID = context.getEnvironment().mDialogueManager->getFaction(); + if(factionID != "") + { + std::cout << "raiserank!!!!!"; + MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 1; + } + std::cout << std::endl; } }; @@ -342,8 +350,8 @@ namespace MWScript const int opcodeSetSkillExplicit = 0x20000df; const int opcodeModSkill = 0x20000fa; const int opcodeModSkillExplicit = 0x2000115; - const int opcodePCJoinFaction = 0x2000141; - const int opcodePCRaiseRank = 0x2000142; + //const int opcodePCJoinFaction = 0x2000141; + const int opcodePCRaiseRank = 0x2000145; void registerExtensions (Compiler::Extensions& extensions) { @@ -415,8 +423,9 @@ namespace MWScript extensions.registerInstruction (mod + skills[i], "l", opcodeModSkill+i, opcodeModSkillExplicit+i); } - extensions.registerInstruction("PCJoinFaction","S",opcodePCJoinFaction); - extensions.registerInstruction("PCRaiseRank","S",opcodePCRaiseRank); + //extensions.registerInstruction("PCJoinFaction","S",opcodePCJoinFaction); + std::cout << "rgister raiserank"; + extensions.registerInstruction("pcraiserank","",opcodePCRaiseRank); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -473,7 +482,7 @@ namespace MWScript interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill (i)); } - interpreter.installSegment5(opcodePCJoinFaction,new OpPCJoinFaction); + //interpreter.installSegment5(opcodePCJoinFaction,new OpPCJoinFaction); interpreter.installSegment5(opcodePCRaiseRank,new OpPCRaiseRank); } }