mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 11:15:34 +00:00
added PCFacRep script instructions
This commit is contained in:
parent
2a1727d4c5
commit
b046687f46
2 changed files with 143 additions and 13 deletions
|
@ -31,7 +31,13 @@ op 0x2000e: PCGetRank implicit
|
||||||
op 0x2000f: PCGetRank explicit
|
op 0x2000f: PCGetRank explicit
|
||||||
op 0x20010: AiWander
|
op 0x20010: AiWander
|
||||||
op 0x20011: AiWander, explicit reference
|
op 0x20011: AiWander, explicit reference
|
||||||
op s 0x20012-0x3ffff unused
|
op 0x20012: GetPCFacRep
|
||||||
|
op 0x20013: GetPCFacRep, explicit reference
|
||||||
|
op 0x20014: SetPCFacRep
|
||||||
|
op 0x20015: SetPCFacRep, explicit reference
|
||||||
|
op 0x20016: ModPCFacRep
|
||||||
|
op 0x20017: ModPCFacRep, explicit reference
|
||||||
|
op s 0x20018-0x3ffff unused
|
||||||
|
|
||||||
Segment 4:
|
Segment 4:
|
||||||
(not implemented yet)
|
(not implemented yet)
|
||||||
|
|
|
@ -565,7 +565,7 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||||
{
|
{
|
||||||
factionID = -1;
|
factionID = "";
|
||||||
}
|
}
|
||||||
else
|
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;
|
const int numberOfAttributes = 8;
|
||||||
|
|
||||||
|
@ -707,6 +812,14 @@ namespace MWScript
|
||||||
|
|
||||||
const int opcodeGetDeadCount = 0x20001a3;
|
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)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
static const char *attributes[numberOfAttributes] =
|
static const char *attributes[numberOfAttributes] =
|
||||||
|
@ -797,7 +910,11 @@ namespace MWScript
|
||||||
extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit);
|
extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit);
|
||||||
extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit);
|
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)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -881,6 +998,13 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>);
|
interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>);
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount);
|
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>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue