forked from mirror/openmw-tes3mp
Merge branch 'master' of git://github.com/zinnschlag/openmw into globalmap
This commit is contained in:
commit
8ef3edd416
26 changed files with 872 additions and 204 deletions
|
@ -63,7 +63,7 @@ add_openmw_dir (mwclass
|
|||
|
||||
add_openmw_dir (mwmechanics
|
||||
mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells
|
||||
activespells npcstats aipackage aisequence alchemy
|
||||
activespells npcstats aipackage aisequence alchemy aiwander aitravel aifollow aiescort aiactivate
|
||||
)
|
||||
|
||||
add_openmw_dir (mwbase
|
||||
|
|
|
@ -356,7 +356,7 @@ void OMW::Engine::go()
|
|||
|
||||
// Create dialog system
|
||||
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
|
||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts));
|
||||
|
||||
// Sets up the input system
|
||||
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
||||
|
|
|
@ -75,11 +75,11 @@ namespace
|
|||
|
||||
namespace MWDialogue
|
||||
{
|
||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions) :
|
||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) :
|
||||
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
|
||||
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
|
||||
, mTemporaryDispositionChange(0.f)
|
||||
, mPermanentDispositionChange(0.f)
|
||||
, mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose)
|
||||
{
|
||||
mChoice = -1;
|
||||
mIsInChoice = false;
|
||||
|
@ -174,6 +174,8 @@ namespace MWDialogue
|
|||
|
||||
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
try
|
||||
{
|
||||
mErrorHandler.reset();
|
||||
|
@ -195,23 +197,33 @@ namespace MWDialogue
|
|||
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
|
||||
|
||||
scanner.scan (parser);
|
||||
if(mErrorHandler.isGood())
|
||||
{
|
||||
parser.getCode(code);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!mErrorHandler.isGood())
|
||||
success = false;
|
||||
|
||||
if (success)
|
||||
parser.getCode (code);
|
||||
}
|
||||
catch (const Compiler::SourceException& /* error */)
|
||||
{
|
||||
// error has already been reported via error handler
|
||||
success = false;
|
||||
}
|
||||
catch (const std::exception& error)
|
||||
{
|
||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||
std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl;
|
||||
success = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!success && mScriptVerbose)
|
||||
{
|
||||
std::cerr
|
||||
<< "compiling failed (dialogue script)" << std::endl
|
||||
<< cmd
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void DialogueManager::executeScript (const std::string& script)
|
||||
|
@ -228,7 +240,7 @@ namespace MWDialogue
|
|||
}
|
||||
catch (const std::exception& error)
|
||||
{
|
||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||
std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace MWDialogue
|
|||
|
||||
float mTemporaryDispositionChange;
|
||||
float mPermanentDispositionChange;
|
||||
bool mScriptVerbose;
|
||||
|
||||
void parseText (const std::string& text);
|
||||
|
||||
|
@ -47,7 +48,7 @@ namespace MWDialogue
|
|||
|
||||
public:
|
||||
|
||||
DialogueManager (const Compiler::Extensions& extensions);
|
||||
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose);
|
||||
|
||||
virtual void startDialogue (const MWWorld::Ptr& actor);
|
||||
|
||||
|
|
|
@ -338,6 +338,58 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
|||
|
||||
return MWWorld::Class::get (player).getNpcStats (player).getReputation();
|
||||
|
||||
case SelectWrapper::Function_Weather:
|
||||
|
||||
return MWBase::Environment::get().getWorld()->getCurrentWeather();
|
||||
|
||||
case SelectWrapper::Function_Reputation:
|
||||
|
||||
return MWWorld::Class::get (mActor).getNpcStats (mActor).getReputation();
|
||||
|
||||
case SelectWrapper::Function_FactionRankDiff:
|
||||
{
|
||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
||||
return 0;
|
||||
|
||||
std::pair<std::string, int> faction =
|
||||
*MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin();
|
||||
|
||||
int rank = getFactionRank (player, faction.first);
|
||||
|
||||
return rank-faction.second;
|
||||
}
|
||||
|
||||
case SelectWrapper::Function_WerewolfKills:
|
||||
|
||||
return MWWorld::Class::get (player).getNpcStats (player).getWerewolfKills();
|
||||
|
||||
case SelectWrapper::Function_RankLow:
|
||||
case SelectWrapper::Function_RankHigh:
|
||||
{
|
||||
bool low = select.getFunction()==SelectWrapper::Function_RankLow;
|
||||
|
||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
||||
return 0;
|
||||
|
||||
std::string factionId =
|
||||
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
||||
|
||||
int value = 0;
|
||||
|
||||
const ESM::Faction& faction =
|
||||
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
||||
|
||||
MWMechanics::NpcStats& playerStats = MWWorld::Class::get (player).getNpcStats (player);
|
||||
|
||||
for (std::vector<ESM::Faction::Reaction>::const_iterator iter (faction.mReactions.begin());
|
||||
iter!=faction.mReactions.end(); ++iter)
|
||||
if (playerStats.getFactionRanks().find (iter->mFaction)!=playerStats.getFactionRanks().end())
|
||||
if (low ? iter->mReaction<value : iter->mReaction>value)
|
||||
value = iter->mReaction;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
throw std::runtime_error ("unknown integer select function");
|
||||
|
@ -423,6 +475,30 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
|||
|
||||
return mTalkedToPlayer;
|
||||
|
||||
case SelectWrapper::Function_Alarmed:
|
||||
|
||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isAlarmed();
|
||||
|
||||
case SelectWrapper::Function_Detected:
|
||||
|
||||
return MWWorld::Class::get (mActor).hasDetected (mActor, player);
|
||||
|
||||
case SelectWrapper::Function_Attacked:
|
||||
|
||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAttacked();
|
||||
|
||||
case SelectWrapper::Function_ShouldAttack:
|
||||
|
||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isHostile();
|
||||
|
||||
case SelectWrapper::Function_CreatureTargetted:
|
||||
|
||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getCreatureTargetted();
|
||||
|
||||
case SelectWrapper::Function_PCWerewolf:
|
||||
|
||||
return MWWorld::Class::get (player).getNpcStats (player).isWerewolf();
|
||||
|
||||
default:
|
||||
|
||||
throw std::runtime_error ("unknown boolean select function");
|
||||
|
|
|
@ -61,9 +61,10 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
|||
|
||||
switch (index)
|
||||
{
|
||||
// 0, 1
|
||||
case 0: return Function_RankLow;
|
||||
case 1: return Function_RankHigh;
|
||||
case 2: return Function_RankRequirement;
|
||||
// 3
|
||||
case 3: return Function_Reputation;
|
||||
case 4: return Function_HealthPercent;
|
||||
case 5: return Function_PCReputation;
|
||||
case 6: return Function_PcLevel;
|
||||
|
@ -82,20 +83,24 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
|||
case 44: return Function_SameGender;
|
||||
case 45: return Function_SameRace;
|
||||
case 46: return Function_SameFaction;
|
||||
// 47-49
|
||||
case 47: return Function_FactionRankDiff;
|
||||
case 48: return Function_Detected;
|
||||
case 49: return Function_Alarmed;
|
||||
case 50: return Function_Choice;
|
||||
case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute;
|
||||
case 58: return Function_PcCorprus;
|
||||
// 59
|
||||
case 59: return Function_Weather;
|
||||
case 60: return Function_PcVampire;
|
||||
case 61: return Function_Level;
|
||||
// 62
|
||||
case 62: return Function_Attacked;
|
||||
case 63: return Function_TalkedToPc;
|
||||
case 64: return Function_PcDynamicStat;
|
||||
// 65
|
||||
case 65: return Function_CreatureTargetted;
|
||||
case 66: return Function_FriendlyHit;
|
||||
case 67: case 68: case 69: case 70: return Function_AiSetting;
|
||||
// 71
|
||||
case 71: return Function_ShouldAttack;
|
||||
case 72: return Function_PCWerewolf;
|
||||
case 73: return Function_WerewolfKills;
|
||||
}
|
||||
|
||||
return Function_False;
|
||||
|
@ -204,6 +209,10 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||
Function_PcCrimeLevel,
|
||||
Function_RankRequirement,
|
||||
Function_Level, Function_PCReputation,
|
||||
Function_Weather,
|
||||
Function_Reputation, Function_FactionRankDiff,
|
||||
Function_WerewolfKills,
|
||||
Function_RankLow, Function_RankHigh,
|
||||
Function_None // end marker
|
||||
};
|
||||
|
||||
|
@ -223,6 +232,10 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
|
||||
Function_PcExpelled,
|
||||
Function_PcVampire, Function_TalkedToPc,
|
||||
Function_Alarmed, Function_Detected,
|
||||
Function_Attacked, Function_ShouldAttack,
|
||||
Function_CreatureTargetted,
|
||||
Function_PCWerewolf,
|
||||
Function_None // end marker
|
||||
};
|
||||
|
||||
|
@ -261,6 +274,9 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const
|
|||
Function_PcVampire,
|
||||
Function_PcCrimeLevel,
|
||||
Function_RankRequirement,
|
||||
Function_Reputation, Function_FactionRankDiff,
|
||||
Function_PCWerewolf, Function_WerewolfKills,
|
||||
Function_RankLow, Function_RankHigh,
|
||||
Function_None // end marker
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,13 @@ namespace MWDialogue
|
|||
Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat,
|
||||
Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel,
|
||||
Function_RankRequirement,
|
||||
Function_HealthPercent, Function_Level, Function_PCReputation
|
||||
Function_HealthPercent, Function_Level, Function_PCReputation,
|
||||
Function_Weather,
|
||||
Function_Reputation, Function_Alarmed, Function_FactionRankDiff, Function_Detected,
|
||||
Function_Attacked, Function_ShouldAttack,
|
||||
Function_CreatureTargetted,
|
||||
Function_PCWerewolf, Function_WerewolfKills,
|
||||
Function_RankLow, Function_RankHigh
|
||||
};
|
||||
|
||||
enum Type
|
||||
|
|
21
apps/openmw/mwmechanics/aiactivate.cpp
Normal file
21
apps/openmw/mwmechanics/aiactivate.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "aiactivate.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiActivate::AiActivate(const std::string &objectId)
|
||||
: mObjectId(objectId)
|
||||
{
|
||||
}
|
||||
MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const
|
||||
{
|
||||
return new AiActivate(*this);
|
||||
}
|
||||
bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "AiActivate completed.\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
int MWMechanics::AiActivate::getTypeId() const
|
||||
{
|
||||
return 4;
|
||||
}
|
23
apps/openmw/mwmechanics/aiactivate.hpp
Normal file
23
apps/openmw/mwmechanics/aiactivate.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef GAME_MWMECHANICS_AIACTIVATE_H
|
||||
#define GAME_MWMECHANICS_AIACTIVATE_H
|
||||
|
||||
#include "aipackage.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
class AiActivate : public AiPackage
|
||||
{
|
||||
public:
|
||||
AiActivate(const std::string &objectId);
|
||||
virtual AiActivate *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
std::string mObjectId;
|
||||
};
|
||||
}
|
||||
#endif // GAME_MWMECHANICS_AIACTIVATE_H
|
24
apps/openmw/mwmechanics/aiescort.cpp
Normal file
24
apps/openmw/mwmechanics/aiescort.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "aiescort.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiEscort::AiEscort(const std::string &actorId,int duration, float x, float y, float z)
|
||||
: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration)
|
||||
{
|
||||
}
|
||||
|
||||
MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const
|
||||
{
|
||||
return new AiEscort(*this);
|
||||
}
|
||||
|
||||
bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "AiEscort completed. \n";
|
||||
return true;
|
||||
}
|
||||
|
||||
int MWMechanics::AiEscort::getTypeId() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
29
apps/openmw/mwmechanics/aiescort.hpp
Normal file
29
apps/openmw/mwmechanics/aiescort.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef GAME_MWMECHANICS_AIESCORT_H
|
||||
#define GAME_MWMECHANICS_AIESCORT_H
|
||||
|
||||
#include "aipackage.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class AiEscort : public AiPackage
|
||||
{
|
||||
public:
|
||||
AiEscort(const std::string &actorId,int duration, float x, float y, float z);
|
||||
virtual AiEscort *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
std::string mActorId;
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
int mDuration;
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
22
apps/openmw/mwmechanics/aifollow.cpp
Normal file
22
apps/openmw/mwmechanics/aifollow.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "aifollow.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
|
||||
: mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId)
|
||||
{
|
||||
}
|
||||
MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const
|
||||
{
|
||||
return new AiFollow(*this);
|
||||
}
|
||||
|
||||
bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "AiFollow completed.\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
int MWMechanics::AiFollow::getTypeId() const
|
||||
{
|
||||
return 3;
|
||||
}
|
27
apps/openmw/mwmechanics/aifollow.hpp
Normal file
27
apps/openmw/mwmechanics/aifollow.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef GAME_MWMECHANICS_AIFALLOW_H
|
||||
#define GAME_MWMECHANICS_AIFALLOW_H
|
||||
|
||||
#include "aipackage.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
class AiFollow : public AiPackage
|
||||
{
|
||||
public:
|
||||
AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z);
|
||||
virtual AiFollow *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
float mDuration;
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
std::string mActorId;
|
||||
};
|
||||
}
|
||||
#endif
|
25
apps/openmw/mwmechanics/aitravel.cpp
Normal file
25
apps/openmw/mwmechanics/aitravel.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "aitravel.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiTravel::AiTravel(float x, float y, float z)
|
||||
: mX(x),mY(y),mZ(z)
|
||||
{
|
||||
}
|
||||
|
||||
MWMechanics::AiTravel * MWMechanics::AiTravel::clone() const
|
||||
{
|
||||
return new AiTravel(*this);
|
||||
}
|
||||
|
||||
bool MWMechanics::AiTravel::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "AiTravel completed.\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
int MWMechanics::AiTravel::getTypeId() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
27
apps/openmw/mwmechanics/aitravel.hpp
Normal file
27
apps/openmw/mwmechanics/aitravel.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef GAME_MWMECHANICS_AITRAVEL_H
|
||||
#define GAME_MWMECHANICS_AITRAVEL_H
|
||||
|
||||
#include "aipackage.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class AiTravel : public AiPackage
|
||||
{
|
||||
public:
|
||||
AiTravel(float x, float y, float z);
|
||||
virtual AiTravel *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
float mX;
|
||||
float mY;
|
||||
float mZ;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
23
apps/openmw/mwmechanics/aiwander.cpp
Normal file
23
apps/openmw/mwmechanics/aiwander.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "aiwander.hpp"
|
||||
#include <iostream>
|
||||
|
||||
MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle):
|
||||
mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle)
|
||||
{
|
||||
}
|
||||
|
||||
MWMechanics::AiPackage * MWMechanics::AiWander::clone() const
|
||||
{
|
||||
return new AiWander(*this);
|
||||
}
|
||||
|
||||
bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor)
|
||||
{
|
||||
std::cout << "AiWadner completed.\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
int MWMechanics::AiWander::getTypeId() const
|
||||
{
|
||||
return 0;
|
||||
}
|
29
apps/openmw/mwmechanics/aiwander.hpp
Normal file
29
apps/openmw/mwmechanics/aiwander.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef GAME_MWMECHANICS_AIWANDER_H
|
||||
#define GAME_MWMECHANICS_AIWANDER_H
|
||||
|
||||
#include "aipackage.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
class AiWander : public AiPackage
|
||||
{
|
||||
public:
|
||||
|
||||
AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle);
|
||||
virtual AiPackage *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
///< 0: Wander
|
||||
|
||||
private:
|
||||
int mDistance;
|
||||
int mDuration;
|
||||
int mTimeOfDay;
|
||||
std::vector<int> mIdle;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -10,7 +10,8 @@
|
|||
namespace MWMechanics
|
||||
{
|
||||
CreatureStats::CreatureStats()
|
||||
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false)
|
||||
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false), mAlarmed (false),
|
||||
mAttacked (false), mHostile (false)
|
||||
{
|
||||
for (int i=0; i<4; ++i)
|
||||
mAiSettings[i] = 0;
|
||||
|
@ -236,4 +237,39 @@ namespace MWMechanics
|
|||
{
|
||||
mTalkedTo = true;
|
||||
}
|
||||
|
||||
bool CreatureStats::isAlarmed() const
|
||||
{
|
||||
return mAlarmed;
|
||||
}
|
||||
|
||||
void CreatureStats::setAlarmed (bool alarmed)
|
||||
{
|
||||
mAlarmed = alarmed;
|
||||
}
|
||||
|
||||
bool CreatureStats::getAttacked() const
|
||||
{
|
||||
return mAttacked;
|
||||
}
|
||||
|
||||
void CreatureStats::setAttacked (bool attacked)
|
||||
{
|
||||
mAttacked = attacked;
|
||||
}
|
||||
|
||||
bool CreatureStats::isHostile() const
|
||||
{
|
||||
return mHostile;
|
||||
}
|
||||
|
||||
void CreatureStats::setHostile (bool hostile)
|
||||
{
|
||||
mHostile = hostile;
|
||||
}
|
||||
|
||||
bool CreatureStats::getCreatureTargetted() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ namespace MWMechanics
|
|||
bool mDead;
|
||||
int mFriendlyHits;
|
||||
bool mTalkedTo;
|
||||
bool mAlarmed;
|
||||
bool mAttacked;
|
||||
bool mHostile;
|
||||
|
||||
public:
|
||||
CreatureStats();
|
||||
|
@ -113,6 +116,20 @@ namespace MWMechanics
|
|||
///< Has this creature talked with the player before?
|
||||
|
||||
void talkedToPlayer();
|
||||
|
||||
bool isAlarmed() const;
|
||||
|
||||
void setAlarmed (bool alarmed);
|
||||
|
||||
bool getAttacked() const;
|
||||
|
||||
void setAttacked (bool attacked);
|
||||
|
||||
bool isHostile() const;
|
||||
|
||||
void setHostile (bool hostile);
|
||||
|
||||
bool getCreatureTargetted() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
MWMechanics::NpcStats::NpcStats()
|
||||
: mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0)
|
||||
, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0)
|
||||
, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0), mWerewolf (false), mWerewolfKills (0)
|
||||
{
|
||||
mSkillIncreases.resize (ESM::Attribute::Length);
|
||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||
|
@ -337,3 +337,17 @@ bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int
|
|||
return *++iter>=rankData.mSkill2;
|
||||
}
|
||||
|
||||
bool MWMechanics::NpcStats::isWerewolf() const
|
||||
{
|
||||
return mWerewolf;
|
||||
}
|
||||
|
||||
void MWMechanics::NpcStats::setWerewolf (bool set)
|
||||
{
|
||||
mWerewolf = set;
|
||||
}
|
||||
|
||||
int MWMechanics::NpcStats::getWerewolfKills() const
|
||||
{
|
||||
return mWerewolfKills;
|
||||
}
|
|
@ -51,6 +51,8 @@ namespace MWMechanics
|
|||
std::map<std::string, int> mFactionReputation;
|
||||
bool mVampire;
|
||||
int mReputation;
|
||||
bool mWerewolf;
|
||||
int mWerewolfKills;
|
||||
|
||||
int mLevelProgress; // 0-10
|
||||
|
||||
|
@ -125,6 +127,12 @@ namespace MWMechanics
|
|||
void setVampire (bool set);
|
||||
|
||||
bool hasSkillsForRank (const std::string& factionId, int rank) const;
|
||||
|
||||
bool isWerewolf() const;
|
||||
|
||||
void setWerewolf (bool set);
|
||||
|
||||
int getWerewolfKills() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,13 @@ op 0x2000e: PCGetRank implicit
|
|||
op 0x2000f: PCGetRank explicit
|
||||
op 0x20010: AiWander
|
||||
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:
|
||||
(not implemented yet)
|
||||
|
@ -207,5 +213,13 @@ op 0x20001a0: ShowMap
|
|||
op 0x20001a1: FillMap
|
||||
op 0x20001a2: WakeUpPc
|
||||
op 0x20001a3: GetDeadCount
|
||||
opcodes 0x20001a4-0x3ffffff unused
|
||||
op 0x20001a4: SetDisposition
|
||||
op 0x20001a5: SetDisposition, Explicit
|
||||
op 0x20001a6: GetDisposition
|
||||
op 0x20001a7: GetDisposition, Explicit
|
||||
op 0x20001a8: CommonDisease
|
||||
op 0x20001a9: CommonDisease, explicit reference
|
||||
op 0x20001aa: BlightDisease
|
||||
op 0x20001ab: BlightDisease, explicit reference
|
||||
opcodes 0x20001ac-0x3ffffff unused
|
||||
|
||||
|
|
|
@ -565,7 +565,7 @@ namespace MWScript
|
|||
{
|
||||
if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
|
||||
{
|
||||
//throw exception?
|
||||
factionID = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -601,10 +601,40 @@ namespace MWScript
|
|||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
// Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
/// \todo modify disposition towards the player
|
||||
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();
|
||||
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -619,6 +649,137 @@ 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);
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetCommonDisease : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (MWWorld::Class::get (ptr).getCreatureStats (ptr).hasCommonDisease());
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetBlightDisease : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
|
||||
runtime.push (MWWorld::Class::get (ptr).getCreatureStats (ptr).hasBlightDisease());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const int numberOfAttributes = 8;
|
||||
|
||||
|
@ -665,6 +826,10 @@ 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;
|
||||
|
@ -673,6 +838,18 @@ 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;
|
||||
|
||||
const int opcodeGetCommonDisease = 0x20001a8;
|
||||
const int opcodeGetCommonDiseaseExplicit = 0x20001a9;
|
||||
const int opcodeGetBlightDisease = 0x20001aa;
|
||||
const int opcodeGetBlightDiseaseExplicit = 0x20001ab;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
static const char *attributes[numberOfAttributes] =
|
||||
|
@ -752,14 +929,27 @@ 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", "l/c", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit);
|
||||
extensions.registerInstruction ("modpcfacrep", "l/c", opcodeModPCFacRep, opcodeModPCFacRepExplicit);
|
||||
|
||||
extensions.registerFunction ("getcommondisease", 'l', "", opcodeGetCommonDisease,
|
||||
opcodeGetCommonDiseaseExplicit);
|
||||
extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease,
|
||||
opcodeGetBlightDiseaseExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -827,17 +1017,34 @@ 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>);
|
||||
|
||||
interpreter.installSegment5 (opcodeGetCommonDisease, new OpGetCommonDisease<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,6 +162,11 @@ namespace MWWorld
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Class::hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
|
|
|
@ -191,6 +191,11 @@ namespace MWWorld
|
|||
///
|
||||
/// (default implementation: return false)
|
||||
|
||||
virtual bool hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const;
|
||||
///< Has \æ ptr detected \a ptr2?
|
||||
///
|
||||
/// (default implementation: return false)
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ Jason Hooks (jhooks)
|
|||
Karl-Felix Glatzer (k1ll)
|
||||
Leon Saunders (emoose)
|
||||
Lukasz Gromanowski (lgro)
|
||||
Marcin Hulist (Gohan)
|
||||
Michael Mc Donnell
|
||||
Michael Papageorgiou (werdanith)
|
||||
Nikolay Kasyanov (corristo)
|
||||
|
|
Loading…
Reference in a new issue