mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:23:53 +00:00
pcRaiseRank works. Player can now join factions.
This commit is contained in:
parent
aaa5368fe9
commit
e5b1e27fa6
3 changed files with 55 additions and 19 deletions
|
@ -181,7 +181,17 @@ namespace MWDialogue
|
|||
break;
|
||||
|
||||
case 46://Same faction
|
||||
if(!selectCompare<int,int>(comp,0,select.i)) return false;
|
||||
{
|
||||
MWMechanics::NpcStats PCstats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer());
|
||||
MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor);
|
||||
int sameFaction = 0;
|
||||
if(!NPCstats.mFactionRank.empty())
|
||||
{
|
||||
std::string NPCFaction = NPCstats.mFactionRank.begin()->first;
|
||||
if(PCstats.mFactionRank.find(NPCFaction) != PCstats.mFactionRank.end()) sameFaction = 1;
|
||||
}
|
||||
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 48://Detected
|
||||
|
@ -193,7 +203,6 @@ namespace MWDialogue
|
|||
break;
|
||||
|
||||
case 50://choice
|
||||
|
||||
if(choice)
|
||||
{
|
||||
if(!selectCompare<int,int>(comp,mChoice,select.i)) return false;
|
||||
|
@ -447,9 +456,6 @@ namespace MWDialogue
|
|||
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
|
||||
return false;
|
||||
|
||||
//PC Faction
|
||||
if(!info.pcFaction.empty()) return false;
|
||||
|
||||
//NPC race
|
||||
if (!info.race.empty())
|
||||
{
|
||||
|
@ -495,8 +501,8 @@ namespace MWDialogue
|
|||
// TODO check player faction
|
||||
if(!info.pcFaction.empty())
|
||||
{
|
||||
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer());
|
||||
std::map<std::string,int>::iterator it = stats.mFactionRank.find(info.npcFaction);
|
||||
MWMechanics::NpcStats stats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer());
|
||||
std::map<std::string,int>::iterator it = stats.mFactionRank.find(info.pcFaction);
|
||||
if(it!=stats.mFactionRank.end())
|
||||
{
|
||||
//check rank
|
||||
|
@ -816,7 +822,7 @@ namespace MWDialogue
|
|||
std::string DialogueManager::getFaction()
|
||||
{
|
||||
std::string factionID("");
|
||||
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer());
|
||||
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
|
||||
if(stats.mFactionRank.empty())
|
||||
{
|
||||
std::cout << "No faction for this actor!";
|
||||
|
|
|
@ -24,7 +24,8 @@ op 0x20007: PlayAnim, explicit reference
|
|||
op 0x20008: LoopAnim
|
||||
op 0x20009: LoopAnim, explicit reference
|
||||
op 0x2000a: Choice
|
||||
opcodes 0x2000b-0x3ffff unused
|
||||
op 0x2000b: PCRaiseRank
|
||||
opcodes 0x2000c-0x3ffff unused
|
||||
|
||||
Segment 4:
|
||||
(not implemented yet)
|
||||
|
@ -127,5 +128,5 @@ op 0x2000141: GetWaterLevel
|
|||
op 0x2000142: SetWaterLevel
|
||||
op 0x2000143: ModWaterLevel
|
||||
op 0x2000144: ToggleWater, twa
|
||||
op 0x2000145: PCRaiseRank
|
||||
op 0x2000145: ModDisposition
|
||||
opcodes 0x2000146-0x3ffffff unused
|
||||
|
|
|
@ -299,27 +299,54 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpPCRaiseRank : public Interpreter::Opcode0
|
||||
class OpPCRaiseRank : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
std::cout << "arg0:" << arg0<< std::endl;
|
||||
std::cout << "try to rais rank...";
|
||||
std::string factionID = "";
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string factionID = context.getEnvironment().mDialogueManager->getFaction();
|
||||
if(arg0==0)
|
||||
{
|
||||
std::cout << "slurpppp";
|
||||
factionID = context.getEnvironment().mDialogueManager->getFaction();
|
||||
}
|
||||
else
|
||||
{
|
||||
factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
}
|
||||
if(factionID != "")
|
||||
{
|
||||
std::cout << "raiserank!!!!!";
|
||||
MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer();
|
||||
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 1;
|
||||
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end())
|
||||
{
|
||||
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] +1;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpModDisposition : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfAttributes = 8;
|
||||
|
||||
const int opcodeGetAttribute = 0x2000027;
|
||||
|
@ -351,7 +378,8 @@ namespace MWScript
|
|||
const int opcodeModSkill = 0x20000fa;
|
||||
const int opcodeModSkillExplicit = 0x2000115;
|
||||
//const int opcodePCJoinFaction = 0x2000141;
|
||||
const int opcodePCRaiseRank = 0x2000145;
|
||||
const int opcodePCRaiseRank = 0x2000b;
|
||||
const int opcodeModDisposition = 0x2000145;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
|
@ -424,8 +452,8 @@ namespace MWScript
|
|||
opcodeModSkill+i, opcodeModSkillExplicit+i);
|
||||
}
|
||||
//extensions.registerInstruction("PCJoinFaction","S",opcodePCJoinFaction);
|
||||
std::cout << "rgister raiserank";
|
||||
extensions.registerInstruction("pcraiserank","",opcodePCRaiseRank);
|
||||
extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank);
|
||||
extensions.registerInstruction("moddisposition","l",opcodeModDisposition);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -483,7 +511,8 @@ namespace MWScript
|
|||
}
|
||||
|
||||
//interpreter.installSegment5(opcodePCJoinFaction,new OpPCJoinFaction);
|
||||
interpreter.installSegment5(opcodePCRaiseRank,new OpPCRaiseRank);
|
||||
interpreter.installSegment3(opcodePCRaiseRank,new OpPCRaiseRank);
|
||||
interpreter.installSegment5(opcodeModDisposition,new OpModDisposition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue