mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-13 07:14:31 +00:00
Merge remote branch 'gus/Factions2'
This commit is contained in:
commit
585ba41557
@ -11,6 +11,7 @@
|
|||||||
#include "../mwdialogue/dialoguemanager.hpp"
|
#include "../mwdialogue/dialoguemanager.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
@ -115,12 +116,26 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpForceGreeting : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
context.getEnvironment().mDialogueManager->startDialogue (ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeJournal = 0x2000133;
|
const int opcodeJournal = 0x2000133;
|
||||||
const int opcodeSetJournalIndex = 0x2000134;
|
const int opcodeSetJournalIndex = 0x2000134;
|
||||||
const int opcodeGetJournalIndex = 0x2000135;
|
const int opcodeGetJournalIndex = 0x2000135;
|
||||||
const int opcodeAddTopic = 0x200013a;
|
const int opcodeAddTopic = 0x200013a;
|
||||||
const int opcodeChoice = 0x2000a;
|
const int opcodeChoice = 0x2000a;
|
||||||
|
const int opcodeForceGreeting = 0x200014f;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
@ -129,6 +144,7 @@ namespace MWScript
|
|||||||
extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex);
|
extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex);
|
||||||
extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic);
|
extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic);
|
||||||
extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
|
extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
|
||||||
|
extensions.registerInstruction("forcegreeting","",-1,opcodeForceGreeting);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
@ -138,6 +154,7 @@ namespace MWScript
|
|||||||
interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex);
|
interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex);
|
||||||
interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic);
|
interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic);
|
||||||
interpreter.installSegment3 (opcodeChoice,new OpChoice);
|
interpreter.installSegment3 (opcodeChoice,new OpChoice);
|
||||||
|
interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,10 @@ op 0x20009: LoopAnim, explicit reference
|
|||||||
op 0x2000a: Choice
|
op 0x2000a: Choice
|
||||||
op 0x2000b: PCRaiseRank
|
op 0x2000b: PCRaiseRank
|
||||||
op 0x2000c: PCLowerRank
|
op 0x2000c: PCLowerRank
|
||||||
op x20000d: PCJoinFaction
|
op 0x2000d: PCJoinFaction
|
||||||
opcodes 0x2000e-0x3ffff unused
|
op 0x2000e: PCGetRank implicit
|
||||||
|
op 0x2000f: PCGetRank explicit
|
||||||
|
opcodes 0x20010-0x3ffff unused
|
||||||
|
|
||||||
Segment 4:
|
Segment 4:
|
||||||
(not implemented yet)
|
(not implemented yet)
|
||||||
@ -140,4 +142,5 @@ op 0x200014b: GetSpell
|
|||||||
op 0x200014c: GetSpell, explicit reference
|
op 0x200014c: GetSpell, explicit reference
|
||||||
op 0x200014d: ModDisposition
|
op 0x200014d: ModDisposition
|
||||||
op 0x200014e: ModDisposition, explicit reference
|
op 0x200014e: ModDisposition, explicit reference
|
||||||
opcodes 0x200014f-0x3ffffff unused
|
op 0x200014f: ForceGreeting
|
||||||
|
opcodes 0x200015-0x3ffffff unused
|
||||||
|
@ -435,6 +435,53 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetPCRank : public Interpreter::Opcode1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
std::string factionID = "";
|
||||||
|
if(arg0 >0)
|
||||||
|
{
|
||||||
|
factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.empty())
|
||||||
|
{
|
||||||
|
//throw exception?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer();
|
||||||
|
if(factionID!="")
|
||||||
|
{
|
||||||
|
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end())
|
||||||
|
{
|
||||||
|
runtime.push(MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
runtime.push(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
runtime.push(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
class OpModDisposition : public Interpreter::Opcode0
|
class OpModDisposition : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
@ -492,6 +539,8 @@ namespace MWScript
|
|||||||
const int opcodePCRaiseRank = 0x2000b;
|
const int opcodePCRaiseRank = 0x2000b;
|
||||||
const int opcodePCLowerRank = 0x2000c;
|
const int opcodePCLowerRank = 0x2000c;
|
||||||
const int opcodePCJoinFaction = 0x2000d;
|
const int opcodePCJoinFaction = 0x2000d;
|
||||||
|
const int opcodeGetPCRank = 0x2000e;
|
||||||
|
const int opcodeGetPCRankExplicit = 0x2000f;
|
||||||
const int opcodeModDisposition = 0x200014d;
|
const int opcodeModDisposition = 0x200014d;
|
||||||
const int opcodeModDispositionExplicit = 0x200014e;
|
const int opcodeModDispositionExplicit = 0x200014e;
|
||||||
|
|
||||||
@ -576,6 +625,7 @@ namespace MWScript
|
|||||||
extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction);
|
extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction);
|
||||||
extensions.registerInstruction("moddisposition","l",opcodeModDisposition,
|
extensions.registerInstruction("moddisposition","l",opcodeModDisposition,
|
||||||
opcodeModDispositionExplicit);
|
opcodeModDispositionExplicit);
|
||||||
|
extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
@ -645,6 +695,8 @@ namespace MWScript
|
|||||||
interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction);
|
interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction);
|
||||||
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>);
|
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>);
|
||||||
interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>);
|
interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>);
|
||||||
|
interpreter.installSegment3(opcodeGetPCRank,new OpGetPCRank<ImplicitRef>);
|
||||||
|
interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user