|
|
|
@ -33,13 +33,13 @@ namespace
|
|
|
|
|
std::string getDialogueActorFaction()
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr actor = MWBase::Environment::get().getDialogueManager()->getActor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::NpcStats stats = MWWorld::Class::get (actor).getNpcStats (actor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stats.getFactionRanks().empty())
|
|
|
|
|
throw std::runtime_error (
|
|
|
|
|
"failed to determine dialogue actors faction (because actor is factionless)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return stats.getFactionRanks().begin()->first;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -208,7 +208,7 @@ namespace MWScript
|
|
|
|
|
.getDynamic (mIndex));
|
|
|
|
|
|
|
|
|
|
stat.setModified (value, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -565,7 +565,7 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
|
|
|
|
{
|
|
|
|
|
//throw exception?
|
|
|
|
|
factionID = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -601,13 +601,43 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
// Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
MWWorld::Class::get (ptr).getNpcStats (ptr).setBaseDisposition
|
|
|
|
|
(MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition() + value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpSetDisposition : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
/// \todo modify disposition towards the player
|
|
|
|
|
MWWorld::Class::get (ptr).getNpcStats (ptr).setBaseDisposition (value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
|
class OpGetDisposition : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
|
|
|
|
|
|
runtime.push (MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OpGetDeadCount : public Interpreter::Opcode0
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -617,7 +647,112 @@ namespace MWScript
|
|
|
|
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
|
|
|
runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths (id);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
@ -665,14 +800,26 @@ namespace MWScript
|
|
|
|
|
const int opcodeGetPCRankExplicit = 0x2000f;
|
|
|
|
|
const int opcodeModDisposition = 0x200014d;
|
|
|
|
|
const int opcodeModDispositionExplicit = 0x200014e;
|
|
|
|
|
const int opcodeSetDisposition = 0x20001a4;
|
|
|
|
|
const int opcodeSetDispositionExplicit = 0x20001a5;
|
|
|
|
|
const int opcodeGetDisposition = 0x20001a6;
|
|
|
|
|
const int opcodeGetDispositionExplicit = 0x20001a7;
|
|
|
|
|
|
|
|
|
|
const int opcodeGetLevel = 0x200018c;
|
|
|
|
|
const int opcodeGetLevelExplicit = 0x200018d;
|
|
|
|
|
const int opcodeSetLevel = 0x200018e;
|
|
|
|
|
const int opcodeSetLevelExplicit = 0x200018f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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] =
|
|
|
|
@ -752,14 +899,22 @@ namespace MWScript
|
|
|
|
|
extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank);
|
|
|
|
|
extensions.registerInstruction("pclowerrank","/S",opcodePCLowerRank);
|
|
|
|
|
extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction);
|
|
|
|
|
extensions.registerInstruction("moddisposition","l",opcodeModDisposition,
|
|
|
|
|
extensions.registerInstruction ("moddisposition","l",opcodeModDisposition,
|
|
|
|
|
opcodeModDispositionExplicit);
|
|
|
|
|
extensions.registerInstruction ("setdisposition","l",opcodeSetDisposition,
|
|
|
|
|
opcodeSetDispositionExplicit);
|
|
|
|
|
extensions.registerFunction ("getdisposition",'l', "",opcodeGetDisposition,
|
|
|
|
|
opcodeGetDispositionExplicit);
|
|
|
|
|
extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit);
|
|
|
|
|
|
|
|
|
|
extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit);
|
|
|
|
|
extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit);
|
|
|
|
|
|
|
|
|
|
extensions.registerFunction("getdeadcount", 'l', "c", opcodeGetDeadCount);
|
|
|
|
|
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)
|
|
|
|
@ -827,17 +982,29 @@ namespace MWScript
|
|
|
|
|
interpreter.installSegment3(opcodePCRaiseRank,new OpPCRaiseRank);
|
|
|
|
|
interpreter.installSegment3(opcodePCLowerRank,new OpPCLowerRank);
|
|
|
|
|
interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction);
|
|
|
|
|
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment3(opcodeGetPCRank,new OpGetPCRank<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank<ExplicitRef>);
|
|
|
|
|
|
|
|
|
|
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeSetDisposition,new OpSetDisposition<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeSetDispositionExplicit,new OpSetDisposition<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeGetDisposition,new OpGetDisposition<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5(opcodeGetDispositionExplicit,new OpGetDisposition<ExplicitRef>);
|
|
|
|
|
|
|
|
|
|
interpreter.installSegment5 (opcodeGetLevel, new OpGetLevel<ImplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (opcodeGetLevelExplicit, new OpGetLevel<ExplicitRef>);
|
|
|
|
|
interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>);
|
|
|
|
|
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>);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|