|
|
|
@ -565,7 +565,7 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
|
|
|
|
{
|
|
|
|
|
factionID = -1;
|
|
|
|
|
factionID = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -649,6 +649,111 @@ namespace MWScript
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpGetPCFacRep : public Interpreter::Opcode1
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
std::string factionId;
|
|
|
|
|
|
|
|
|
|
if (arg0==1)
|
|
|
|
|
{
|
|
|
|
|
factionId = runtime.getStringLiteral (runtime[0].mInteger);
|
|
|
|
|
runtime.pop();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty())
|
|
|
|
|
factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (factionId.empty())
|
|
|
|
|
throw std::runtime_error ("failed to determine faction");
|
|
|
|
|
|
|
|
|
|
boost::algorithm::to_lower (factionId);
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
runtime.push (
|
|
|
|
|
MWWorld::Class::get (player).getNpcStats (player).getFactionReputation (factionId));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpSetPCFacRep : public Interpreter::Opcode1
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
std::string factionId;
|
|
|
|
|
|
|
|
|
|
if (arg0==1)
|
|
|
|
|
{
|
|
|
|
|
factionId = runtime.getStringLiteral (runtime[0].mInteger);
|
|
|
|
|
runtime.pop();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty())
|
|
|
|
|
factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (factionId.empty())
|
|
|
|
|
throw std::runtime_error ("failed to determine faction");
|
|
|
|
|
|
|
|
|
|
boost::algorithm::to_lower (factionId);
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWWorld::Class::get (player).getNpcStats (player).setFactionReputation (factionId, value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpModPCFacRep : public Interpreter::Opcode1
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
|
|
|
{
|
|
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
std::string factionId;
|
|
|
|
|
|
|
|
|
|
if (arg0==1)
|
|
|
|
|
{
|
|
|
|
|
factionId = runtime.getStringLiteral (runtime[0].mInteger);
|
|
|
|
|
runtime.pop();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty())
|
|
|
|
|
factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (factionId.empty())
|
|
|
|
|
throw std::runtime_error ("failed to determine faction");
|
|
|
|
|
|
|
|
|
|
boost::algorithm::to_lower (factionId);
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWWorld::Class::get (player).getNpcStats (player).setFactionReputation (factionId,
|
|
|
|
|
MWWorld::Class::get (player).getNpcStats (player).getFactionReputation (factionId)+
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int numberOfAttributes = 8;
|
|
|
|
|
|
|
|
|
@ -707,6 +812,14 @@ namespace MWScript
|
|
|
|
|
|
|
|
|
|
const int opcodeGetDeadCount = 0x20001a3;
|
|
|
|
|
|
|
|
|
|
const int opcodeGetPCFacRep = 0x20012;
|
|
|
|
|
const int opcodeGetPCFacRepExplicit = 0x20013;
|
|
|
|
|
const int opcodeSetPCFacRep = 0x20014;
|
|
|
|
|
const int opcodeSetPCFacRepExplicit = 0x20015;
|
|
|
|
|
const int opcodeModPCFacRep = 0x20016;
|
|
|
|
|
const int opcodeModPCFacRepExplicit = 0x20017;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void registerExtensions (Compiler::Extensions& extensions)
|
|
|
|
|
{
|
|
|
|
|
static const char *attributes[numberOfAttributes] =
|
|
|
|
@ -798,6 +911,10 @@ namespace MWScript
|
|
|
|
|
extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit);
|
|
|
|
|
|
|
|
|
|
extensions.registerFunction ("getdeadcount", 'l', "c", opcodeGetDeadCount);
|
|
|
|
|
|
|
|
|
|
extensions.registerFunction ("getpcfacrep", 'l', "/c", opcodeGetPCFacRep, opcodeGetPCFacRepExplicit);
|
|
|
|
|
extensions.registerInstruction ("setpcfacrep", "/lc", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit);
|
|
|
|
|
extensions.registerInstruction ("modpcfacrep", "/lc", opcodeModPCFacRep, opcodeModPCFacRepExplicit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
|
|
|
@ -881,6 +998,13 @@ namespace MWScript
|
|
|
|
|
interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>);
|
|
|
|
|
|
|
|
|
|
interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount);
|
|
|
|
|
|
|
|
|
|
interpreter.installSegment3 (opcodeGetPCFacRep, new OpGetPCFacRep<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment3 (opcodeGetPCFacRepExplicit, new OpGetPCFacRep<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment3 (opcodeSetPCFacRep, new OpSetPCFacRep<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment3 (opcodeSetPCFacRepExplicit, new OpSetPCFacRep<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment3 (opcodeModPCFacRep, new OpModPCFacRep<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment3 (opcodeModPCFacRepExplicit, new OpModPCFacRep<ExplicitRef>);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|