mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 18:40:01 +00:00
test stuff
This commit is contained in:
parent
f9bb19fcdc
commit
0c61f0d294
@ -123,4 +123,5 @@ op 0x200013d: FadeOut
|
|||||||
op 0x200013e: FadeTo
|
op 0x200013e: FadeTo
|
||||||
op 0x200013f: GetCurrentWeather
|
op 0x200013f: GetCurrentWeather
|
||||||
op 0x2000140: ChangeWeather
|
op 0x2000140: ChangeWeather
|
||||||
opcodes 0x2000141-0x3ffffff unused
|
op 0x2000141: OpPCJoinFaction
|
||||||
|
opcodes 0x2000142-0x3ffffff unused
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
#include "../mwworld/environment.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
@ -280,6 +282,36 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpPCJoinFaction : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
context.getEnvironment().mWorld->getPlayer().addFaction(factionID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class OpPCRaiseRank : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string factionID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
context.getEnvironment().mWorld->getPlayer().raiseRank(factionID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int numberOfAttributes = 8;
|
const int numberOfAttributes = 8;
|
||||||
|
|
||||||
const int opcodeGetAttribute = 0x2000027;
|
const int opcodeGetAttribute = 0x2000027;
|
||||||
@ -310,6 +342,8 @@ namespace MWScript
|
|||||||
const int opcodeSetSkillExplicit = 0x20000df;
|
const int opcodeSetSkillExplicit = 0x20000df;
|
||||||
const int opcodeModSkill = 0x20000fa;
|
const int opcodeModSkill = 0x20000fa;
|
||||||
const int opcodeModSkillExplicit = 0x2000115;
|
const int opcodeModSkillExplicit = 0x2000115;
|
||||||
|
const int opcodePCJoinFaction = 0x2000141;
|
||||||
|
const int opcodePCRaiseRank = 0x2000142;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
@ -381,6 +415,8 @@ namespace MWScript
|
|||||||
extensions.registerInstruction (mod + skills[i], "l",
|
extensions.registerInstruction (mod + skills[i], "l",
|
||||||
opcodeModSkill+i, opcodeModSkillExplicit+i);
|
opcodeModSkill+i, opcodeModSkillExplicit+i);
|
||||||
}
|
}
|
||||||
|
extensions.registerInstruction("PCJoinFaction","S",opcodePCJoinFaction);
|
||||||
|
extensions.registerInstruction("PCRaiseRank","S",opcodePCRaiseRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
@ -436,6 +472,9 @@ namespace MWScript
|
|||||||
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
|
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
|
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interpreter.installSegment5(opcodePCJoinFaction,new OpPCJoinFaction);
|
||||||
|
interpreter.installSegment5(opcodePCRaiseRank,new OpPCRaiseRank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,11 @@ namespace MWWorld
|
|||||||
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
|
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Faction Player::getFaction(std::string faction)
|
Player::Faction Player::getFaction(std::string factionID)
|
||||||
{
|
{
|
||||||
for(std::list<Player::Faction>::iterator it = mFactions.begin(); it != mFactions.end();it++)
|
for(std::list<Player::Faction>::iterator it = mFactions.begin(); it != mFactions.end();it++)
|
||||||
{
|
{
|
||||||
if(it->name == faction) return *it;
|
if(it->name == factionID) return *it;
|
||||||
}
|
}
|
||||||
//faction was not found->dummy faction
|
//faction was not found->dummy faction
|
||||||
Player::Faction fact;
|
Player::Faction fact;
|
||||||
@ -105,41 +105,66 @@ namespace MWWorld
|
|||||||
return fact;
|
return fact;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::addFaction(std::string faction)
|
void Player::addFaction(std::string factionID)
|
||||||
{
|
{
|
||||||
if(getFaction(faction).name == "not found")
|
if(getFaction(factionID).name == "not found")
|
||||||
{
|
{
|
||||||
Player::Faction fact;
|
Player::Faction fact;
|
||||||
const ESM::Faction* eFact = mWorld.getStore().factions.find(faction);
|
const ESM::Faction* eFact = mWorld.getStore().factions.find(factionID);
|
||||||
fact.expelled = false;
|
fact.expelled = false;
|
||||||
fact.rank = 0;
|
fact.rank = 0;
|
||||||
fact.name = faction;
|
fact.name = eFact->name;
|
||||||
fact.id = eFact->id;
|
fact.id = eFact->id;
|
||||||
mFactions.push_back(fact);
|
mFactions.push_back(fact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::getRank(std::string faction)
|
int Player::getRank(std::string factionID)
|
||||||
{
|
{
|
||||||
Player::Faction fact = getFaction(faction);
|
Player::Faction fact = getFaction(factionID);
|
||||||
return fact.rank;
|
return fact.rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setRank(std::string faction,int rank)
|
void Player::setRank(std::string factionID,int rank)
|
||||||
{
|
{
|
||||||
Player::Faction fact = getFaction(faction);
|
Player::Faction fact = getFaction(factionID);
|
||||||
fact.rank = rank;
|
fact.rank = rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::isExpelled(std::string faction)
|
void Player::raiseRank(std::string factionID)
|
||||||
{
|
{
|
||||||
Player::Faction fact = getFaction(faction);
|
if(getFaction(factionID).name == "not found")
|
||||||
|
{
|
||||||
|
addFaction(factionID);
|
||||||
|
setRank(factionID,1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setRank(factionID,getRank(factionID) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::lowerRank(std::string factionID)
|
||||||
|
{
|
||||||
|
if(getFaction(factionID).name == "not found")
|
||||||
|
{
|
||||||
|
std::cout << "cannot lower the rank of the player: faction no found. Faction: "<< factionID << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setRank(factionID,getRank(factionID) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Player::isExpelled(std::string factionID)
|
||||||
|
{
|
||||||
|
Player::Faction fact = getFaction(factionID);
|
||||||
return fact.expelled;
|
return fact.expelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setExpelled(std::string faction,bool expelled)
|
void Player::setExpelled(std::string factionID,bool expelled)
|
||||||
{
|
{
|
||||||
Player::Faction fact = getFaction(faction);
|
Player::Faction fact = getFaction(factionID);
|
||||||
fact.expelled = expelled;
|
fact.expelled = expelled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,15 +119,19 @@ namespace MWWorld
|
|||||||
|
|
||||||
void setAutoMove (bool enable);
|
void setAutoMove (bool enable);
|
||||||
|
|
||||||
void addFaction(std::string faction);
|
void addFaction(std::string factionID);
|
||||||
|
|
||||||
int getRank(std::string faction);
|
int getRank(std::string factionID);
|
||||||
|
|
||||||
void setRank(std::string faction,int rank);
|
void setRank(std::string factionID,int rank);
|
||||||
|
|
||||||
bool isExpelled(std::string faction);
|
void raiseRank(std::string factionID);
|
||||||
|
|
||||||
void setExpelled(std::string faction,bool expelled);
|
void lowerRank(std::string factionID);
|
||||||
|
|
||||||
|
bool isExpelled(std::string factionID);
|
||||||
|
|
||||||
|
void setExpelled(std::string factionID,bool expelled);
|
||||||
|
|
||||||
void setLeftRight (int value);
|
void setLeftRight (int value);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user