diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 4b47bb025..38a06940f 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -257,6 +257,8 @@ void StatsWindow::onFrame () MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); setBirthSign(signId); + setReputation (PCstats.getReputation ()); + setBounty (PCstats.getBounty ()); if (mChanged) updateSkillArea(); diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 5186b6328..f43682c96 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -38,8 +38,8 @@ namespace MWGui void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat& value); void configureSkills (const SkillList& major, const SkillList& minor); - void setReputation (int reputation) { this->mReputation = reputation; } - void setBounty (int bounty) { this->mBounty = bounty; } + void setReputation (int reputation) { if (reputation != mReputation) mChanged = true; this->mReputation = reputation; } + void setBounty (int bounty) { if (bounty != mBounty) mChanged = true; this->mBounty = bounty; } void updateSkillArea(); private: diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 21c21acf0..72ae25724 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -11,6 +11,9 @@ #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/journal.hpp" +#include "../mwworld/class.hpp" +#include "../mwmechanics/npcstats.hpp" + #include "interpretercontext.hpp" #include "ref.hpp" @@ -126,6 +129,37 @@ namespace MWScript } }; + template + class OpModReputation : 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).getNpcStats (ptr).setReputation (MWWorld::Class::get(ptr).getNpcStats (ptr).getReputation () + value); + } + }; + + template + class OpSetReputation : 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).getNpcStats (ptr).setReputation (value); + } + }; + + const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; @@ -134,6 +168,10 @@ namespace MWScript const int opcodeForceGreeting = 0x200014f; const int opcodeForceGreetingExplicit = 0x2000150; const int opcodeGoodbye = 0x2000152; + const int opcodeSetReputation = 0x20001ad; + const int opcodeModReputation = 0x20001ae; + const int opcodeSetReputationExplicit = 0x20001af; + const int opcodeModReputationExplicit = 0x20001b0; void registerExtensions (Compiler::Extensions& extensions) { @@ -146,6 +184,10 @@ namespace MWScript extensions.registerInstruction("forcegreeting","",opcodeForceGreeting, opcodeForceGreetingExplicit); extensions.registerInstruction("goodbye", "", opcodeGoodbye); + extensions.registerInstruction("setreputation", "l", opcodeSetReputation, + opcodeSetReputationExplicit); + extensions.registerInstruction("modreputation", "l", opcodeModReputation, + opcodeModReputationExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -158,6 +200,10 @@ namespace MWScript interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting); interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting); interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye); + interpreter.installSegment5 (opcodeSetReputation, new OpSetReputation); + interpreter.installSegment5 (opcodeModReputation, new OpModReputation); + interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation); + interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index fdc4f4974..b130aa954 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -222,5 +222,9 @@ op 0x20001a9: CommonDisease, explicit reference op 0x20001aa: BlightDisease op 0x20001ab: BlightDisease, explicit reference op 0x20001ac: ToggleCollisionBoxes -opcodes 0x20001ac-0x3ffffff unused +op 0x20001ad: SetReputation +op 0x20001ae: ModReputation +op 0x20001af: SetReputation, explicit +op 0x20001b0: ModReputation, explicit +opcodes 0x20001b1-0x3ffffff unused