mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:53:51 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
34b163233b
187 changed files with 2230 additions and 1225 deletions
|
@ -119,6 +119,7 @@ set(OENGINE_OGRE
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OENGINE_GUI
|
set(OENGINE_GUI
|
||||||
|
${LIBDIR}/openengine/gui/loglistener.cpp
|
||||||
${LIBDIR}/openengine/gui/manager.cpp
|
${LIBDIR}/openengine/gui/manager.cpp
|
||||||
${LIBDIR}/openengine/gui/layout.hpp
|
${LIBDIR}/openengine/gui/layout.hpp
|
||||||
)
|
)
|
||||||
|
@ -224,6 +225,9 @@ endif ()
|
||||||
|
|
||||||
|
|
||||||
set(BOOST_COMPONENTS system filesystem program_options)
|
set(BOOST_COMPONENTS system filesystem program_options)
|
||||||
|
if(WIN32)
|
||||||
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
IF(BOOST_STATIC)
|
IF(BOOST_STATIC)
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
set(Boost_USE_STATIC_LIBS ON)
|
||||||
|
|
|
@ -387,7 +387,7 @@ std::string magicEffectLabel(int idx)
|
||||||
"sEffectSummonCreature04",
|
"sEffectSummonCreature04",
|
||||||
"sEffectSummonCreature05"
|
"sEffectSummonCreature05"
|
||||||
};
|
};
|
||||||
if (idx >= 0 && idx <= 143)
|
if (idx >= 0 && idx <= 142)
|
||||||
return magicEffectLabels[idx];
|
return magicEffectLabels[idx];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
|
@ -471,7 +471,7 @@ std::string skillLabel(int idx)
|
||||||
"Speechcraft",
|
"Speechcraft",
|
||||||
"Hand-to-hand"
|
"Hand-to-hand"
|
||||||
};
|
};
|
||||||
if (idx >= 0 && idx <= 27)
|
if (idx >= 0 && idx <= 26)
|
||||||
return skillLabels[idx];
|
return skillLabels[idx];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
|
@ -498,7 +498,7 @@ std::string rangeTypeLabel(int idx)
|
||||||
"Touch",
|
"Touch",
|
||||||
"Target"
|
"Target"
|
||||||
};
|
};
|
||||||
if (idx >= 0 && idx <= 3)
|
if (idx >= 0 && idx <= 2)
|
||||||
return rangeTypeLabels[idx];
|
return rangeTypeLabels[idx];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
|
|
|
@ -707,9 +707,9 @@ void Record<ESM::Faction>::print()
|
||||||
std::cout << " Faction Reaction: "
|
std::cout << " Faction Reaction: "
|
||||||
<< mData.mData.mRankData[i].mFactReaction << std::endl;
|
<< mData.mData.mRankData[i].mFactReaction << std::endl;
|
||||||
}
|
}
|
||||||
std::vector<ESM::Faction::Reaction>::iterator rit;
|
std::map<std::string, int>::iterator rit;
|
||||||
for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++)
|
for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++)
|
||||||
std::cout << " Reaction: " << rit->mReaction << " = " << rit->mFaction << std::endl;
|
std::cout << " Reaction: " << rit->second << " = " << rit->first << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -41,11 +41,11 @@ Launcher::MainDialog::MainDialog(QWidget *parent)
|
||||||
// Check if the font is installed
|
// Check if the font is installed
|
||||||
if (!fonts.contains("EB Garamond")) {
|
if (!fonts.contains("EB Garamond")) {
|
||||||
|
|
||||||
QString font = QString::fromStdString(mCfgMgr.getGlobalDataPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
QString font = QString::fromUtf8(mCfgMgr.getGlobalDataPath().string().c_str()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
||||||
file.setFileName(font);
|
file.setFileName(font);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
font = QString::fromStdString(mCfgMgr.getLocalPath().string()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
font = QString::fromUtf8(mCfgMgr.getLocalPath().string().c_str()) + QString("resources/mygui/EBGaramond-Regular.ttf");
|
||||||
}
|
}
|
||||||
|
|
||||||
fontDatabase.addApplicationFont(font);
|
fontDatabase.addApplicationFont(font);
|
||||||
|
@ -243,7 +243,7 @@ bool Launcher::MainDialog::showFirstRunDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the file if it doesn't already exist, else the importer will fail
|
// Create the file if it doesn't already exist, else the importer will fail
|
||||||
QString path = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + QString("openmw.cfg");
|
QString path = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str()) + QString("openmw.cfg");
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -358,7 +358,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
|
||||||
{
|
{
|
||||||
mLauncherSettings.setMultiValueEnabled(true);
|
mLauncherSettings.setMultiValueEnabled(true);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
|
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
paths.append(QString("launcher.cfg"));
|
paths.append(QString("launcher.cfg"));
|
||||||
|
@ -464,8 +464,8 @@ bool Launcher::expansions(Launcher::UnshieldThread& cd)
|
||||||
|
|
||||||
bool Launcher::MainDialog::setupGameSettings()
|
bool Launcher::MainDialog::setupGameSettings()
|
||||||
{
|
{
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
|
||||||
|
|
||||||
// Load the user config file first, separately
|
// Load the user config file first, separately
|
||||||
// So we can write it properly, uncontaminated
|
// So we can write it properly, uncontaminated
|
||||||
|
@ -594,7 +594,7 @@ bool Launcher::MainDialog::setupGameSettings()
|
||||||
|
|
||||||
while(expansions(cd));
|
while(expansions(cd));
|
||||||
|
|
||||||
selectedFile = QString::fromStdString(cd.GetMWEsmPath());
|
selectedFile = QString::fromUtf8(cd.GetMWEsmPath().c_str());
|
||||||
}
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
@ -615,8 +615,8 @@ bool Launcher::MainDialog::setupGraphicsSettings()
|
||||||
{
|
{
|
||||||
mGraphicsSettings.setMultiValueEnabled(false);
|
mGraphicsSettings.setMultiValueEnabled(false);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
|
||||||
|
|
||||||
QFile localDefault(QString("settings-default.cfg"));
|
QFile localDefault(QString("settings-default.cfg"));
|
||||||
QFile globalDefault(globalPath + QString("settings-default.cfg"));
|
QFile globalDefault(globalPath + QString("settings-default.cfg"));
|
||||||
|
@ -702,7 +702,7 @@ bool Launcher::MainDialog::writeSettings()
|
||||||
mGraphicsPage->saveSettings();
|
mGraphicsPage->saveSettings();
|
||||||
mDataFilesPage->saveSettings();
|
mDataFilesPage->saveSettings();
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
QDir dir(userPath);
|
QDir dir(userPath);
|
||||||
|
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
|
@ -806,7 +806,7 @@ void Launcher::MainDialog::play()
|
||||||
msgBox.setWindowTitle(tr("No game file selected"));
|
msgBox.setWindowTitle(tr("No game file selected"));
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setText(tr("<br><b>You do not have no game file selected.</b><br><br> \
|
msgBox.setText(tr("<br><b>You do not have a game file selected.</b><br><br> \
|
||||||
OpenMW will not start without a game file selected.<br>"));
|
OpenMW will not start without a game file selected.<br>"));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -45,7 +45,8 @@ void Launcher::GameSettings::validatePaths()
|
||||||
Files::PathContainer dataDirs;
|
Files::PathContainer dataDirs;
|
||||||
|
|
||||||
foreach (const QString &path, paths) {
|
foreach (const QString &path, paths) {
|
||||||
dataDirs.push_back(Files::PathContainer::value_type(path.toStdString()));
|
QByteArray bytes = path.toUtf8();
|
||||||
|
dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the data dirs to convert the tokenized paths
|
// Parse the data dirs to convert the tokenized paths
|
||||||
|
@ -53,7 +54,7 @@ void Launcher::GameSettings::validatePaths()
|
||||||
mDataDirs.clear();
|
mDataDirs.clear();
|
||||||
|
|
||||||
for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) {
|
for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) {
|
||||||
QString path = QString::fromStdString(it->string());
|
QString path = QString::fromUtf8(it->string().c_str());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
@ -68,12 +69,13 @@ void Launcher::GameSettings::validatePaths()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dataDirs.clear();
|
dataDirs.clear();
|
||||||
dataDirs.push_back(Files::PathContainer::value_type(local.toStdString()));
|
QByteArray bytes = local.toUtf8();
|
||||||
|
dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
|
||||||
|
|
||||||
mCfgMgr.processPaths(dataDirs);
|
mCfgMgr.processPaths(dataDirs);
|
||||||
|
|
||||||
if (!dataDirs.empty()) {
|
if (!dataDirs.empty()) {
|
||||||
QString path = QString::fromStdString(dataDirs.front().string());
|
QString path = QString::fromUtf8(dataDirs.front().string().c_str());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "unshieldthread.hpp"
|
#include "unshieldthread.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
namespace bfs = boost::filesystem;
|
namespace bfs = boost::filesystem;
|
||||||
|
@ -49,7 +49,7 @@ namespace
|
||||||
|
|
||||||
std::string read_to_string(const bfs::path& path)
|
std::string read_to_string(const bfs::path& path)
|
||||||
{
|
{
|
||||||
std::ifstream strstream(path.c_str(), std::ios::in | std::ios::binary);
|
bfs::ifstream strstream(path, std::ios::in | std::ios::binary);
|
||||||
std::string str;
|
std::string str;
|
||||||
|
|
||||||
strstream.seekg(0, std::ios::end);
|
strstream.seekg(0, std::ios::end);
|
||||||
|
@ -201,7 +201,7 @@ namespace
|
||||||
add_setting("Archives", "Archive 1", "Bloodmoon.bsa", ini);
|
add_setting("Archives", "Archive 1", "Bloodmoon.bsa", ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream inistream(ini_path.c_str());
|
bfs::ofstream inistream((ini_path));
|
||||||
inistream << ini;
|
inistream << ini;
|
||||||
inistream.close();
|
inistream.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "importer.hpp"
|
#include "importer.hpp"
|
||||||
#include <boost/iostreams/device/file.hpp>
|
|
||||||
#include <boost/iostreams/stream.hpp>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -9,6 +8,10 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
MwIniImporter::MwIniImporter()
|
MwIniImporter::MwIniImporter()
|
||||||
: mVerbose(false)
|
: mVerbose(false)
|
||||||
|
@ -661,7 +664,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
|
||||||
|
|
||||||
std::string section("");
|
std::string section("");
|
||||||
MwIniImporter::multistrmap map;
|
MwIniImporter::multistrmap map;
|
||||||
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
|
bfs::ifstream file((bfs::path(filename)));
|
||||||
ToUTF8::Utf8Encoder encoder(mEncoding);
|
ToUTF8::Utf8Encoder encoder(mEncoding);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
|
@ -674,6 +677,10 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
|
||||||
line = line.substr(0, line.length()-1);
|
line = line.substr(0, line.length()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(line.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(line[0] == '[') {
|
if(line[0] == '[') {
|
||||||
int pos = line.find(']');
|
int pos = line.find(']');
|
||||||
if(pos < 2) {
|
if(pos < 2) {
|
||||||
|
@ -690,10 +697,6 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam
|
||||||
line = line.substr(0,comment_pos);
|
line = line.substr(0,comment_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pos = line.find("=");
|
int pos = line.find("=");
|
||||||
if(pos < 1) {
|
if(pos < 1) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -720,7 +723,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::string& filenam
|
||||||
std::cout << "load cfg file: " << filename << std::endl;
|
std::cout << "load cfg file: " << filename << std::endl;
|
||||||
|
|
||||||
MwIniImporter::multistrmap map;
|
MwIniImporter::multistrmap map;
|
||||||
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
|
bfs::ifstream file((bfs::path(filename)));
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
|
@ -858,7 +861,7 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini) co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwIniImporter::writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg) {
|
void MwIniImporter::writeToFile(std::ostream &out, const multistrmap &cfg) {
|
||||||
|
|
||||||
for(multistrmap::const_iterator it=cfg.begin(); it != cfg.end(); ++it) {
|
for(multistrmap::const_iterator it=cfg.begin(); it != cfg.end(); ++it) {
|
||||||
for(std::vector<std::string>::const_iterator entry=it->second.begin(); entry != it->second.end(); ++entry) {
|
for(std::vector<std::string>::const_iterator entry=it->second.begin(); entry != it->second.end(); ++entry) {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef MWINIIMPORTER_IMPORTER
|
#ifndef MWINIIMPORTER_IMPORTER
|
||||||
#define MWINIIMPORTER_IMPORTER 1
|
#define MWINIIMPORTER_IMPORTER 1
|
||||||
|
|
||||||
#include <boost/iostreams/device/file.hpp>
|
|
||||||
#include <boost/iostreams/stream.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ class MwIniImporter {
|
||||||
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
|
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
|
||||||
void importGameFiles(multistrmap &cfg, const multistrmap &ini) const;
|
void importGameFiles(multistrmap &cfg, const multistrmap &ini) const;
|
||||||
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
|
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
|
||||||
static void writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg);
|
static void writeToFile(std::ostream &out, const multistrmap &cfg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);
|
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);
|
||||||
|
|
|
@ -1,14 +1,59 @@
|
||||||
#include "importer.hpp"
|
#include "importer.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Include on Windows only
|
||||||
|
#include <boost/locale.hpp>
|
||||||
|
|
||||||
|
class utf8argv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
utf8argv(int argc, wchar_t *wargv[])
|
||||||
|
{
|
||||||
|
args.reserve(argc);
|
||||||
|
argv = new const char *[argc];
|
||||||
|
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
args.push_back(boost::locale::conv::utf_to_utf<char>(wargv[i]));
|
||||||
|
argv[i] = args.back().c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~utf8argv() { delete[] argv; }
|
||||||
|
char **get() const { return const_cast<char **>(argv); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
const char **argv;
|
||||||
|
std::vector<std::string> args;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The only way to pass Unicode on Winodws with CLI is to use wide
|
||||||
|
characters interface which presents UTF-16 encoding. The rest of
|
||||||
|
OpenMW application stack assumes UTF-8 encoding, therefore this
|
||||||
|
conversion.
|
||||||
|
|
||||||
|
For boost::filesystem::path::imbue see components/files/windowspath.cpp
|
||||||
|
*/
|
||||||
|
int wmain(int argc, wchar_t *wargv[]) {
|
||||||
|
utf8argv converter(argc, wargv);
|
||||||
|
char **argv = converter.get();
|
||||||
|
boost::filesystem::path::imbue(boost::locale::generator().generate(""));
|
||||||
|
#endif
|
||||||
bpo::options_description desc("Syntax: mwiniimporter <options> inifile configfile\nAllowed options");
|
bpo::options_description desc("Syntax: mwiniimporter <options> inifile configfile\nAllowed options");
|
||||||
bpo::positional_options_description p_desc;
|
bpo::positional_options_description p_desc;
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
|
@ -94,7 +139,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "write to: " << outputFile << std::endl;
|
std::cout << "write to: " << outputFile << std::endl;
|
||||||
boost::iostreams::stream<boost::iostreams::file_sink> file(outputFile);
|
bfs::ofstream file((bfs::path(outputFile)));
|
||||||
importer.writeToFile(file, cfg);
|
importer.writeToFile(file, cfg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -145,6 +145,10 @@ if(WIN32)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
set(BOOST_COMPONENTS system filesystem program_options thread wave)
|
set(BOOST_COMPONENTS system filesystem program_options thread wave)
|
||||||
|
if(WIN32)
|
||||||
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||||
|
|
||||||
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
|
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
|
||||||
|
|
|
@ -27,7 +27,9 @@ void CSMDoc::OpenSaveStage::perform (int stage, Messages& messages)
|
||||||
{
|
{
|
||||||
mState.start (mDocument, mProjectFile);
|
mState.start (mDocument, mProjectFile);
|
||||||
|
|
||||||
mState.getStream().open ((mProjectFile ? mState.getPath() : mState.getTmpPath()).string().c_str());
|
mState.getStream().open (
|
||||||
|
mProjectFile ? mState.getPath() : mState.getTmpPath(),
|
||||||
|
std::ios::binary);
|
||||||
|
|
||||||
if (!mState.getStream().is_open())
|
if (!mState.getStream().is_open())
|
||||||
throw std::runtime_error ("failed to open stream for saving");
|
throw std::runtime_error ("failed to open stream for saving");
|
||||||
|
@ -260,4 +262,4 @@ void CSMDoc::FinalSavingStage::perform (int stage, Messages& messages)
|
||||||
|
|
||||||
mDocument.getUndoStack().setClean();
|
mDocument.getUndoStack().setClean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ const boost::filesystem::path& CSMDoc::SavingState::getTmpPath() const
|
||||||
return mTmpPath;
|
return mTmpPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream& CSMDoc::SavingState::getStream()
|
boost::filesystem::ofstream& CSMDoc::SavingState::getStream()
|
||||||
{
|
{
|
||||||
return mStream;
|
return mStream;
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,4 @@ ESM::ESMWriter& CSMDoc::SavingState::getWriter()
|
||||||
bool CSMDoc::SavingState::isProjectFile() const
|
bool CSMDoc::SavingState::isProjectFile() const
|
||||||
{
|
{
|
||||||
return mProjectFile;
|
return mProjectFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#include <components/esm/esmwriter.hpp>
|
#include <components/esm/esmwriter.hpp>
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ namespace CSMDoc
|
||||||
boost::filesystem::path mPath;
|
boost::filesystem::path mPath;
|
||||||
boost::filesystem::path mTmpPath;
|
boost::filesystem::path mTmpPath;
|
||||||
ToUTF8::Utf8Encoder mEncoder;
|
ToUTF8::Utf8Encoder mEncoder;
|
||||||
std::ofstream mStream;
|
boost::filesystem::ofstream mStream;
|
||||||
ESM::ESMWriter mWriter;
|
ESM::ESMWriter mWriter;
|
||||||
boost::filesystem::path mProjectPath;
|
boost::filesystem::path mProjectPath;
|
||||||
bool mProjectFile;
|
bool mProjectFile;
|
||||||
|
@ -39,7 +40,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
const boost::filesystem::path& getTmpPath() const;
|
const boost::filesystem::path& getTmpPath() const;
|
||||||
|
|
||||||
std::ofstream& getStream();
|
boost::filesystem::ofstream& getStream();
|
||||||
|
|
||||||
ESM::ESMWriter& getWriter();
|
ESM::ESMWriter& getWriter();
|
||||||
|
|
||||||
|
@ -50,4 +51,4 @@ namespace CSMDoc
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,7 +57,7 @@ add_openmw_dir (mwworld
|
||||||
cells localscripts customdata weather inventorystore ptr actionopen actionread
|
cells localscripts customdata weather inventorystore ptr actionopen actionread
|
||||||
actionequip timestamp actionalchemy cellstore actionapply actioneat
|
actionequip timestamp actionalchemy cellstore actionapply actioneat
|
||||||
esmstore store recordcmp fallback actionrepair actionsoulgem livecellref actiondoor
|
esmstore store recordcmp fallback actionrepair actionsoulgem livecellref actiondoor
|
||||||
contentloader esmloader omwloader actiontrap cellreflist projectilemanager
|
contentloader esmloader omwloader actiontrap cellreflist projectilemanager cellref
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwclass
|
add_openmw_dir (mwclass
|
||||||
|
@ -83,6 +83,10 @@ add_openmw_dir (mwbase
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
set(BOOST_COMPONENTS system filesystem program_options thread wave)
|
set(BOOST_COMPONENTS system filesystem program_options thread wave)
|
||||||
|
if(WIN32)
|
||||||
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||||
|
|
||||||
IF(OGRE_STATIC)
|
IF(OGRE_STATIC)
|
||||||
|
|
|
@ -236,7 +236,7 @@ void OMW::Engine::addArchive (const std::string& archive) {
|
||||||
// Set resource dir
|
// Set resource dir
|
||||||
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
|
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
|
||||||
{
|
{
|
||||||
mResDir = boost::filesystem::system_complete(parResDir);
|
mResDir = parResDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set start cell name (only interiors for now)
|
// Set start cell name (only interiors for now)
|
||||||
|
@ -492,11 +492,11 @@ void OMW::Engine::activate()
|
||||||
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action =
|
boost::shared_ptr<MWWorld::Action> action =
|
||||||
MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
|
ptr.getClass().activate (ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||||
|
|
||||||
interpreterContext.activate (ptr, action);
|
interpreterContext.activate (ptr, action);
|
||||||
|
|
||||||
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
|
std::string script = ptr.getClass().getScript (ptr);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->breakInvisibility(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
MWBase::Environment::get().getWorld()->breakInvisibility(MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,12 @@ namespace MWBase
|
||||||
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const = 0;
|
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const = 0;
|
||||||
|
|
||||||
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
|
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
|
||||||
|
|
||||||
|
/// Changes faction1's opinion of faction2 by \a diff.
|
||||||
|
virtual void modFactionReaction (const std::string& faction1, const std::string& faction2, int diff) = 0;
|
||||||
|
|
||||||
|
/// @return faction1's opinion of faction2
|
||||||
|
virtual int getFactionReaction (const std::string& faction1, const std::string& faction2) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,8 @@ namespace MWClass
|
||||||
std::string text;
|
std::string text;
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
||||||
{
|
{
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
info.text = text;
|
info.text = text;
|
||||||
|
@ -108,7 +108,7 @@ namespace MWClass
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
|
boost::shared_ptr<MWWorld::Action> Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
|
||||||
{
|
{
|
||||||
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator");
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator");
|
||||||
|
|
|
@ -127,8 +127,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
info.text = text;
|
info.text = text;
|
||||||
|
|
|
@ -168,10 +168,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == -1)
|
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||||
return ref->mBase->mData.mValue;
|
|
||||||
else
|
|
||||||
return ref->mBase->mData.mValue * (static_cast<float>(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Armor::registerSelf()
|
void Armor::registerSelf()
|
||||||
|
@ -242,7 +239,7 @@ namespace MWClass
|
||||||
|
|
||||||
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor);
|
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor);
|
||||||
|
|
||||||
int remainingHealth = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mHealth;
|
int remainingHealth = getItemHealth(ptr);
|
||||||
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
|
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
|
||||||
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
|
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
|
||||||
|
|
||||||
|
@ -250,14 +247,14 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
info.enchant = ref->mBase->mEnchant;
|
info.enchant = ref->mBase->mEnchant;
|
||||||
if (!info.enchant.empty())
|
if (!info.enchant.empty())
|
||||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge();
|
||||||
|
|
||||||
info.text = text;
|
info.text = text;
|
||||||
|
|
||||||
|
@ -272,7 +269,7 @@ namespace MWClass
|
||||||
return ref->mBase->mEnchant;
|
return ref->mBase->mEnchant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Armor::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
std::string Armor::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
@ -283,19 +280,18 @@ namespace MWClass
|
||||||
newItem.mData.mEnchant=enchCharge;
|
newItem.mData.mEnchant=enchCharge;
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Armor *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Armor *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
return record->mId;
|
||||||
ref->mRef.mRefID = record->mId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == 0)
|
if (ptr.getCellRef().getCharge() == 0)
|
||||||
return std::make_pair(0, "#{sInventoryMessage1}");
|
return std::make_pair(0, "#{sInventoryMessage1}");
|
||||||
|
|
||||||
// slots that this item can be equipped in
|
// slots that this item can be equipped in
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
|
||||||
|
|
||||||
if (slots_.first.empty())
|
if (slots_.first.empty())
|
||||||
return std::make_pair(0, "");
|
return std::make_pair(0, "");
|
||||||
|
|
|
@ -67,7 +67,8 @@ namespace MWClass
|
||||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||||
|
|
||||||
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace MWClass
|
||||||
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem");
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem");
|
||||||
|
@ -139,8 +139,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ namespace MWClass
|
||||||
return ref->mBase->mEnchant;
|
return ref->mBase->mEnchant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Book::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
std::string Book::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Book> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
@ -171,8 +171,7 @@ namespace MWClass
|
||||||
newItem.mData.mEnchant=enchCharge;
|
newItem.mData.mEnchant=enchCharge;
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Book *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Book *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
return record->mId;
|
||||||
ref->mRef.mRefID = record->mId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const
|
||||||
|
|
|
@ -51,7 +51,8 @@ namespace MWClass
|
||||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
|
@ -193,14 +193,14 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
info.enchant = ref->mBase->mEnchant;
|
info.enchant = ref->mBase->mEnchant;
|
||||||
if (!info.enchant.empty())
|
if (!info.enchant.empty())
|
||||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge();
|
||||||
|
|
||||||
info.text = text;
|
info.text = text;
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ namespace MWClass
|
||||||
return ref->mBase->mEnchant;
|
return ref->mBase->mEnchant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clothing::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
std::string Clothing::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
@ -226,14 +226,13 @@ namespace MWClass
|
||||||
newItem.mData.mEnchant=enchCharge;
|
newItem.mData.mEnchant=enchCharge;
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Clothing *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Clothing *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
return record->mId;
|
||||||
ref->mRef.mRefID = record->mId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
{
|
{
|
||||||
// slots that this item can be equipped in
|
// slots that this item can be equipped in
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
|
||||||
|
|
||||||
if (slots_.first.empty())
|
if (slots_.first.empty())
|
||||||
return std::make_pair(0, "");
|
return std::make_pair(0, "");
|
||||||
|
|
|
@ -59,7 +59,8 @@ namespace MWClass
|
||||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||||
|
|
||||||
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace MWClass
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
data->mContainerStore.fill(
|
data->mContainerStore.fill(
|
||||||
ref->mBase->mInventory, ptr.getCellRef().mOwner, ptr.getCellRef().mFaction, MWBase::Environment::get().getWorld()->getStore());
|
ref->mBase->mInventory, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction(), MWBase::Environment::get().getWorld()->getStore());
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
|
@ -75,7 +75,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
|
MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().mOwner, ptr.getCellRef().mFaction);
|
store.restock(list, ptr, ptr.getCellRef().getOwner(), ptr.getCellRef().getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
|
@ -112,7 +112,7 @@ namespace MWClass
|
||||||
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
|
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
|
||||||
|
|
||||||
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfContainer");
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfContainer");
|
||||||
|
@ -127,23 +127,23 @@ namespace MWClass
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
bool needKey = ptr.getCellRef().mLockLevel > 0;
|
bool needKey = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool hasKey = false;
|
bool hasKey = false;
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
|
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
std::string keyId = ptr.getCellRef().mKey;
|
std::string keyId = ptr.getCellRef().getKey();
|
||||||
Misc::StringUtils::toLower(keyId);
|
Misc::StringUtils::toLower(keyId);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
||||||
{
|
{
|
||||||
std::string refId = it->getCellRef().mRefID;
|
std::string refId = it->getCellRef().getRefId();
|
||||||
Misc::StringUtils::toLower(refId);
|
Misc::StringUtils::toLower(refId);
|
||||||
if (refId == keyId)
|
if (refId == keyId)
|
||||||
{
|
{
|
||||||
hasKey = true;
|
hasKey = true;
|
||||||
keyName = MWWorld::Class::get(*it).getName(*it);
|
keyName = it->getClass().getName(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,13 +152,13 @@ namespace MWClass
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
||||||
unlock(ptr);
|
unlock(ptr);
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
ptr.getCellRef().mTrap = "";
|
ptr.getCellRef().setTrap("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!needKey || hasKey)
|
if (!needKey || hasKey)
|
||||||
{
|
{
|
||||||
if(ptr.getCellRef().mTrap.empty())
|
if(ptr.getCellRef().getTrap().empty())
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
||||||
return action;
|
return action;
|
||||||
|
@ -166,7 +166,7 @@ namespace MWClass
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Activate trap
|
// Activate trap
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().mTrap, ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().getTrap(), ptr));
|
||||||
action->setSound(trapActivationSound);
|
action->setSound(trapActivationSound);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
@ -227,16 +227,16 @@ namespace MWClass
|
||||||
info.caption = ref->mBase->mName;
|
info.caption = ref->mBase->mName;
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
if (ref->mRef.mLockLevel > 0)
|
if (ptr.getCellRef().getLockLevel() > 0)
|
||||||
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ptr.getCellRef().getLockLevel());
|
||||||
else if (ref->mRef.mLockLevel < 0)
|
else if (ptr.getCellRef().getLockLevel() < 0)
|
||||||
text += "\n#{sUnlocked}";
|
text += "\n#{sUnlocked}";
|
||||||
if (ref->mRef.mTrap != "")
|
if (ptr.getCellRef().getTrap() != "")
|
||||||
text += "\n#{sTrapped}";
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,14 +261,14 @@ namespace MWClass
|
||||||
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
||||||
{
|
{
|
||||||
if(lockLevel!=0)
|
if(lockLevel!=0)
|
||||||
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
|
ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, in positive
|
||||||
else
|
else
|
||||||
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the oriional one
|
ptr.getCellRef().setLockLevel(abs(ptr.getCellRef().getLockLevel())); //No locklevel given, just flip the original one
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::unlock (const MWWorld::Ptr& ptr) const
|
void Container::unlock (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
|
ptr.getCellRef().setLockLevel(-abs(ptr.getCellRef().getLockLevel())); //Makes lockLevel negative
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ namespace MWClass
|
||||||
|
|
||||||
if (!weapon.isEmpty())
|
if (!weapon.isEmpty())
|
||||||
{
|
{
|
||||||
const bool weaphashealth = get(weapon).hasItemHealth(weapon);
|
const bool weaphashealth = weapon.getClass().hasItemHealth(weapon);
|
||||||
const unsigned char *attack = NULL;
|
const unsigned char *attack = NULL;
|
||||||
if(type == ESM::Weapon::AT_Chop)
|
if(type == ESM::Weapon::AT_Chop)
|
||||||
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
||||||
|
@ -291,20 +291,24 @@ namespace MWClass
|
||||||
weaponDamage *= 0.5f + (stats.getAttribute(ESM::Attribute::Luck).getModified() / 100.0f);
|
weaponDamage *= 0.5f + (stats.getAttribute(ESM::Attribute::Luck).getModified() / 100.0f);
|
||||||
if(weaphashealth)
|
if(weaphashealth)
|
||||||
{
|
{
|
||||||
int weapmaxhealth = weapon.get<ESM::Weapon>()->mBase->mData.mHealth;
|
int weapmaxhealth = weapon.getClass().getItemMaxHealth(weapon);
|
||||||
if(weapon.getCellRef().mCharge == -1)
|
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
||||||
weapon.getCellRef().mCharge = weapmaxhealth;
|
weaponDamage *= float(weaphealth) / weapmaxhealth;
|
||||||
weaponDamage *= float(weapon.getCellRef().mCharge) / weapmaxhealth;
|
|
||||||
|
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
{
|
||||||
|
// Reduce weapon charge by at least one, but cap at 0
|
||||||
|
weaphealth -= std::min(std::max(1,
|
||||||
|
(int)(damage * gmst.find("fWeaponDamageMult")->getFloat())), weaphealth);
|
||||||
|
|
||||||
|
weapon.getCellRef().setCharge(weaphealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weapon broken? unequip it
|
||||||
|
if (weapon.getCellRef().getCharge() == 0)
|
||||||
|
weapon = *getInventoryStore(ptr).unequipItem(weapon, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
|
||||||
weapon.getCellRef().mCharge -= std::min(std::max(1,
|
|
||||||
(int)(damage * gmst.find("fWeaponDamageMult")->getFloat())), weapon.getCellRef().mCharge);
|
|
||||||
|
|
||||||
// Weapon broken? unequip it
|
|
||||||
if (weapon.getCellRef().mCharge == 0)
|
|
||||||
weapon = *getInventoryStore(ptr).unequipItem(weapon, ptr);
|
|
||||||
|
|
||||||
damage += weaponDamage;
|
damage += weaponDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +358,7 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!object.isEmpty())
|
if(!object.isEmpty())
|
||||||
getCreatureStats(ptr).setLastHitObject(MWWorld::Class::get(object).getId(object));
|
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
|
||||||
|
|
||||||
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
|
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
|
||||||
{
|
{
|
||||||
|
@ -444,7 +448,7 @@ namespace MWClass
|
||||||
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfCreature");
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfCreature");
|
||||||
|
@ -825,14 +829,14 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
|
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
|
||||||
// This also means we cannot respawn dynamically placed references with no content file connection.
|
// This also means we cannot respawn dynamically placed references with no content file connection.
|
||||||
if (ptr.getCellRef().mRefNum.mContentFile != -1)
|
if (ptr.getCellRef().getRefNum().mContentFile != -1)
|
||||||
{
|
{
|
||||||
if (ptr.getRefData().getCount() == 0)
|
if (ptr.getRefData().getCount() == 0)
|
||||||
ptr.getRefData().setCount(1);
|
ptr.getRefData().setCount(1);
|
||||||
|
|
||||||
// Reset to original position
|
// Reset to original position
|
||||||
ESM::Position& pos = ptr.getRefData().getPosition();
|
ESM::Position& pos = ptr.getRefData().getPosition();
|
||||||
pos = ptr.getCellRef().mPos;
|
pos = ptr.getCellRef().getPosition();
|
||||||
|
|
||||||
ptr.getRefData().setCustomData(NULL);
|
ptr.getRefData().setCustomData(NULL);
|
||||||
}
|
}
|
||||||
|
@ -844,7 +848,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().mRefID, ptr.getCellRef().mFaction);
|
store.restock(list, ptr, ptr.getCellRef().getRefId(), ptr.getCellRef().getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
||||||
|
|
|
@ -73,8 +73,8 @@ namespace MWClass
|
||||||
|
|
||||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
MWWorld::ManualRef ref(store, id);
|
MWWorld::ManualRef ref(store, id);
|
||||||
ref.getPtr().getCellRef().mPos = ptr.getCellRef().mPos;
|
ref.getPtr().getCellRef().setPosition(ptr.getCellRef().getPosition());
|
||||||
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), ptr.getCell() , ptr.getCellRef().mPos);
|
MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), ptr.getCell() , ptr.getCellRef().getPosition());
|
||||||
customData.mSpawnActorId = placed.getClass().getCreatureStats(placed).getActorId();
|
customData.mSpawnActorId = placed.getClass().getCreatureStats(placed).getActorId();
|
||||||
customData.mSpawn = false;
|
customData.mSpawn = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,8 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Door> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
if (ref->mRef.mTeleport && !ref->mRef.mDestCell.empty()) // TODO doors that lead to exteriors
|
if (ptr.getCellRef().getTeleport() && !ptr.getCellRef().getDestCell().empty()) // TODO doors that lead to exteriors
|
||||||
return ref->mRef.mDestCell;
|
return ptr.getCellRef().getDestCell();
|
||||||
|
|
||||||
return ref->mBase->mName;
|
return ref->mBase->mName;
|
||||||
}
|
}
|
||||||
|
@ -99,23 +99,23 @@ namespace MWClass
|
||||||
const std::string lockedSound = "LockedDoor";
|
const std::string lockedSound = "LockedDoor";
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
MWWorld::ContainerStore &invStore = get(actor).getContainerStore(actor);
|
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||||
|
|
||||||
bool needKey = ptr.getCellRef().mLockLevel > 0;
|
bool needKey = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool hasKey = false;
|
bool hasKey = false;
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
|
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
std::string keyId = ptr.getCellRef().mKey;
|
std::string keyId = ptr.getCellRef().getKey();
|
||||||
Misc::StringUtils::toLower(keyId);
|
Misc::StringUtils::toLower(keyId);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
||||||
{
|
{
|
||||||
std::string refId = it->getCellRef().mRefID;
|
std::string refId = it->getCellRef().getRefId();
|
||||||
Misc::StringUtils::toLower(refId);
|
Misc::StringUtils::toLower(refId);
|
||||||
if (refId == keyId)
|
if (refId == keyId)
|
||||||
{
|
{
|
||||||
hasKey = true;
|
hasKey = true;
|
||||||
keyName = get(*it).getName(*it);
|
keyName = it->getClass().getName(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,22 +125,22 @@ namespace MWClass
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
||||||
unlock(ptr); //Call the function here. because that makes sense.
|
unlock(ptr); //Call the function here. because that makes sense.
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
ptr.getCellRef().mTrap = "";
|
ptr.getCellRef().getTrap() = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!needKey || hasKey)
|
if (!needKey || hasKey)
|
||||||
{
|
{
|
||||||
if(!ptr.getCellRef().mTrap.empty())
|
if(!ptr.getCellRef().getTrap().empty())
|
||||||
{
|
{
|
||||||
// Trap activation
|
// Trap activation
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().mTrap, ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(actor, ptr.getCellRef().getTrap(), ptr));
|
||||||
action->setSound(trapActivationSound);
|
action->setSound(trapActivationSound);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref->mRef.mTeleport)
|
if (ptr.getCellRef().getTeleport())
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest()));
|
||||||
|
|
||||||
action->setSound(openSound);
|
action->setSound(openSound);
|
||||||
|
|
||||||
|
@ -191,14 +191,14 @@ namespace MWClass
|
||||||
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
||||||
{
|
{
|
||||||
if(lockLevel!=0)
|
if(lockLevel!=0)
|
||||||
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
|
ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, in positive
|
||||||
else
|
else
|
||||||
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the origional one
|
ptr.getCellRef().setLockLevel(abs(ptr.getCellRef().getLockLevel())); //No locklevel given, just flip the origional one
|
||||||
}
|
}
|
||||||
|
|
||||||
void Door::unlock (const MWWorld::Ptr& ptr) const
|
void Door::unlock (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
|
ptr.getCellRef().setLockLevel(-abs(ptr.getCellRef().getLockLevel())); //Makes lockLevel negative
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -234,17 +234,17 @@ namespace MWClass
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
if (ref->mRef.mTeleport)
|
if (ptr.getCellRef().getTeleport())
|
||||||
{
|
{
|
||||||
text += "\n#{sTo}";
|
text += "\n#{sTo}";
|
||||||
text += "\n" + getDestination(*ref);
|
text += "\n" + getDestination(*ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref->mRef.mLockLevel > 0)
|
if (ptr.getCellRef().getLockLevel() > 0)
|
||||||
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ptr.getCellRef().getLockLevel());
|
||||||
else if (ref->mRef.mLockLevel < 0)
|
else if (ptr.getCellRef().getLockLevel() < 0)
|
||||||
text += "\n#{sUnlocked}";
|
text += "\n#{sUnlocked}";
|
||||||
if (ref->mRef.mTrap != "")
|
if (ptr.getCellRef().getTrap() != "")
|
||||||
text += "\n#{sTrapped}";
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
||||||
|
@ -260,16 +260,16 @@ namespace MWClass
|
||||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
std::string dest;
|
std::string dest;
|
||||||
if (door.mRef.mDestCell != "")
|
if (door.mRef.getDestCell() != "")
|
||||||
{
|
{
|
||||||
// door leads to an interior, use interior name as tooltip
|
// door leads to an interior, use interior name as tooltip
|
||||||
dest = door.mRef.mDestCell;
|
dest = door.mRef.getDestCell();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// door leads to exterior, use cell name (if any), otherwise translated region name
|
// door leads to exterior, use cell name (if any), otherwise translated region name
|
||||||
int x,y;
|
int x,y;
|
||||||
MWBase::Environment::get().getWorld()->positionToIndex (door.mRef.mDoorDest.pos[0], door.mRef.mDoorDest.pos[1], x, y);
|
MWBase::Environment::get().getWorld()->positionToIndex (door.mRef.getDoorDest().pos[0], door.mRef.getDoorDest().pos[1], x, y);
|
||||||
const ESM::Cell* cell = store.get<ESM::Cell>().find(x,y);
|
const ESM::Cell* cell = store.get<ESM::Cell>().find(x,y);
|
||||||
if (cell->mName != "")
|
if (cell->mName != "")
|
||||||
dest = cell->mName;
|
dest = cell->mName;
|
||||||
|
|
|
@ -147,13 +147,13 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player);
|
||||||
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
||||||
|
|
||||||
static const float fWortChanceValue =
|
static const float fWortChanceValue =
|
||||||
|
|
|
@ -187,8 +187,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(npc).getInventoryStore(npc);
|
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
||||||
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
|
||||||
if(weapon == invStore.end())
|
if(weapon == invStore.end())
|
||||||
|
|
|
@ -86,10 +86,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
|
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
|
||||||
ptr.get<ESM::Lockpick>();
|
ptr.get<ESM::Lockpick>();
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == -1)
|
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||||
return ref->mBase->mData.mValue;
|
|
||||||
else
|
|
||||||
return ref->mBase->mData.mValue * (static_cast<float>(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockpick::registerSelf()
|
void Lockpick::registerSelf()
|
||||||
|
@ -136,7 +133,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
|
int remainingUses = getItemHealth(ptr);
|
||||||
|
|
||||||
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
||||||
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
||||||
|
@ -144,8 +141,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ namespace
|
||||||
{
|
{
|
||||||
bool isGold (const MWWorld::Ptr& ptr)
|
bool isGold (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
return Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_001")
|
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_005")
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_010")
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025")
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100");
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,12 +94,12 @@ namespace MWClass
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
int value = ref->mBase->mData.mValue;
|
int value = ref->mBase->mData.mValue;
|
||||||
if (ptr.getCellRef().mGoldValue > 1 && ptr.getRefData().getCount() == 1)
|
if (ptr.getCellRef().getGoldValue() > 1 && ptr.getRefData().getCount() == 1)
|
||||||
value = ptr.getCellRef().mGoldValue;
|
value = ptr.getCellRef().getGoldValue();
|
||||||
|
|
||||||
if (ptr.getCellRef().mSoul != "")
|
if (ptr.getCellRef().getSoul() != "")
|
||||||
{
|
{
|
||||||
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(ref->mRef.mSoul);
|
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(ref->mRef.getSoul());
|
||||||
value *= creature->mData.mSoul;
|
value *= creature->mData.mSoul;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ namespace MWClass
|
||||||
info.caption = ref->mBase->mName + countString;
|
info.caption = ref->mBase->mName + countString;
|
||||||
info.icon = ref->mBase->mIcon;
|
info.icon = ref->mBase->mIcon;
|
||||||
|
|
||||||
if (ref->mRef.mSoul != "")
|
if (ref->mRef.getSoul() != "")
|
||||||
{
|
{
|
||||||
const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.mSoul);
|
const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.getSoul());
|
||||||
info.caption += " (" + creature->mName + ")";
|
info.caption += " (" + creature->mName + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +182,8 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
newRef.getPtr().get<ESM::Miscellaneous>();
|
newRef.getPtr().get<ESM::Miscellaneous>();
|
||||||
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
|
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
|
||||||
newPtr.getCellRef().mGoldValue = goldAmount;
|
newPtr.getCellRef().setGoldValue(goldAmount);
|
||||||
newPtr.getRefData().setCount(1);
|
newPtr.getRefData().setCount(1);
|
||||||
} else {
|
} else {
|
||||||
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
@ -231,7 +231,7 @@ namespace MWClass
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
if (ptr.getCellRef().mSoul == "")
|
if (ptr.getCellRef().getSoul().empty())
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
|
||||||
else
|
else
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
|
||||||
|
@ -242,12 +242,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
item.get<ESM::Miscellaneous>();
|
item.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return !ref->mBase->mData.mIsKey && (npcServices & ESM::NPC::Misc)
|
return !ref->mBase->mData.mIsKey && (npcServices & ESM::NPC::Misc) && !isGold(item);
|
||||||
&& !Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_001")
|
|
||||||
&& !Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_005")
|
|
||||||
&& !Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_010")
|
|
||||||
&& !Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_025")
|
|
||||||
&& !Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_100");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Miscellaneous::getWeight(const MWWorld::Ptr &ptr) const
|
float Miscellaneous::getWeight(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -484,10 +484,10 @@ namespace MWClass
|
||||||
if(victim.isEmpty()) // Didn't hit anything
|
if(victim.isEmpty()) // Didn't hit anything
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MWWorld::Class &othercls = MWWorld::Class::get(victim);
|
const MWWorld::Class &othercls = victim.getClass();
|
||||||
if(!othercls.isActor()) // Can't hit non-actors
|
if(!othercls.isActor()) // Can't hit non-actors
|
||||||
return;
|
return;
|
||||||
MWMechanics::CreatureStats &otherstats = victim.getClass().getCreatureStats(victim);
|
MWMechanics::CreatureStats &otherstats = othercls.getCreatureStats(victim);
|
||||||
if(otherstats.isDead()) // Can't hit dead actors
|
if(otherstats.isDead()) // Can't hit dead actors
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ namespace MWClass
|
||||||
|
|
||||||
int weapskill = ESM::Skill::HandToHand;
|
int weapskill = ESM::Skill::HandToHand;
|
||||||
if(!weapon.isEmpty())
|
if(!weapon.isEmpty())
|
||||||
weapskill = get(weapon).getEquipmentSkill(weapon);
|
weapskill = weapon.getClass().getEquipmentSkill(weapon);
|
||||||
|
|
||||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ namespace MWClass
|
||||||
MWMechanics::NpcStats &stats = getNpcStats(ptr);
|
MWMechanics::NpcStats &stats = getNpcStats(ptr);
|
||||||
if(!weapon.isEmpty())
|
if(!weapon.isEmpty())
|
||||||
{
|
{
|
||||||
const bool weaphashealth = get(weapon).hasItemHealth(weapon);
|
const bool weaphashealth = weapon.getClass().hasItemHealth(weapon);
|
||||||
const unsigned char *attack = NULL;
|
const unsigned char *attack = NULL;
|
||||||
if(type == ESM::Weapon::AT_Chop)
|
if(type == ESM::Weapon::AT_Chop)
|
||||||
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
||||||
|
@ -526,20 +526,24 @@ namespace MWClass
|
||||||
(stats.getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult->getFloat() * 0.1);
|
(stats.getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult->getFloat() * 0.1);
|
||||||
if(weaphashealth)
|
if(weaphashealth)
|
||||||
{
|
{
|
||||||
int weapmaxhealth = weapon.get<ESM::Weapon>()->mBase->mData.mHealth;
|
int weapmaxhealth = weapon.getClass().getItemMaxHealth(weapon);
|
||||||
if(weapon.getCellRef().mCharge == -1)
|
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
||||||
weapon.getCellRef().mCharge = weapmaxhealth;
|
|
||||||
damage *= float(weapon.getCellRef().mCharge) / weapmaxhealth;
|
damage *= float(weaphealth) / weapmaxhealth;
|
||||||
|
|
||||||
|
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
{
|
||||||
|
// Reduce weapon charge by at least one, but cap at 0
|
||||||
|
weaphealth -= std::min(std::max(1,
|
||||||
|
(int)(damage * gmst.find("fWeaponDamageMult")->getFloat())), weaphealth);
|
||||||
|
|
||||||
|
weapon.getCellRef().setCharge(weaphealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weapon broken? unequip it
|
||||||
|
if (weaphealth == 0)
|
||||||
|
weapon = *inv.unequipItem(weapon, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
|
||||||
weapon.getCellRef().mCharge -= std::min(std::max(1,
|
|
||||||
(int)(damage * gmst.find("fWeaponDamageMult")->getFloat())), weapon.getCellRef().mCharge);
|
|
||||||
|
|
||||||
// Weapon broken? unequip it
|
|
||||||
if (weapon.getCellRef().mCharge == 0)
|
|
||||||
weapon = *inv.unequipItem(weapon, ptr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
healthdmg = true;
|
healthdmg = true;
|
||||||
}
|
}
|
||||||
|
@ -637,7 +641,7 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!object.isEmpty())
|
if(!object.isEmpty())
|
||||||
getCreatureStats(ptr).setLastHitObject(get(object).getId(object));
|
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
|
||||||
|
|
||||||
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
|
if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player")
|
||||||
{
|
{
|
||||||
|
@ -705,20 +709,19 @@ namespace MWClass
|
||||||
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
||||||
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
||||||
{
|
{
|
||||||
ESM::CellRef &armorref = armor.getCellRef();
|
int armorhealth = armor.getClass().getItemHealth(armor);
|
||||||
if(armorref.mCharge == -1)
|
armorhealth -= std::min(std::max(1, (int)damagediff),
|
||||||
armorref.mCharge = armor.get<ESM::Armor>()->mBase->mData.mHealth;
|
armorhealth);
|
||||||
armorref.mCharge -= std::min(std::max(1, (int)damagediff),
|
armor.getCellRef().setCharge(armorhealth);
|
||||||
armorref.mCharge);
|
|
||||||
|
|
||||||
// Armor broken? unequip it
|
// Armor broken? unequip it
|
||||||
if (armorref.mCharge == 0)
|
if (armorhealth == 0)
|
||||||
inv.unequipItem(armor, ptr);
|
inv.unequipItem(armor, ptr);
|
||||||
|
|
||||||
if (ptr.getRefData().getHandle() == "player")
|
if (ptr.getRefData().getHandle() == "player")
|
||||||
skillUsageSucceeded(ptr, get(armor).getEquipmentSkill(armor), 0);
|
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
|
||||||
|
|
||||||
switch(get(armor).getEquipmentSkill(armor))
|
switch(armor.getClass().getEquipmentSkill(armor))
|
||||||
{
|
{
|
||||||
case ESM::Skill::LightArmor:
|
case ESM::Skill::LightArmor:
|
||||||
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
|
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
|
||||||
|
@ -802,7 +805,7 @@ namespace MWClass
|
||||||
if(ptr.getRefData().getHandle() == "player")
|
if(ptr.getRefData().getHandle() == "player")
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor));
|
||||||
|
|
||||||
if(get(actor).isNpc() && get(actor).getNpcStats(actor).isWerewolf())
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfNPC");
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfNPC");
|
||||||
|
@ -814,7 +817,7 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
if(getCreatureStats(ptr).isDead())
|
if(getCreatureStats(ptr).isDead())
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
|
||||||
if(get(ptr).getCreatureStats(ptr).isHostile())
|
if(ptr.getClass().getCreatureStats(ptr).isHostile())
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
|
||||||
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
|
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
|
||||||
|
@ -943,7 +946,7 @@ namespace MWClass
|
||||||
|
|
||||||
if (fallHeight >= fallDistanceMin)
|
if (fallHeight >= fallDistanceMin)
|
||||||
{
|
{
|
||||||
const float acrobaticsSkill = MWWorld::Class::get(ptr).getNpcStats (ptr).getSkill(ESM::Skill::Acrobatics).getModified();
|
const float acrobaticsSkill = ptr.getClass().getNpcStats (ptr).getSkill(ESM::Skill::Acrobatics).getModified();
|
||||||
const NpcCustomData *npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
|
const NpcCustomData *npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
|
||||||
const float jumpSpellBonus = npcdata->mNpcStats.getMagicEffects().get(ESM::MagicEffect::Jump).mMagnitude;
|
const float jumpSpellBonus = npcdata->mNpcStats.getMagicEffects().get(ESM::MagicEffect::Jump).mMagnitude;
|
||||||
const float fallAcroBase = gmst.find("fFallAcroBase")->getFloat();
|
const float fallAcroBase = gmst.find("fFallAcroBase")->getFloat();
|
||||||
|
@ -1107,7 +1110,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Armor> *ref = it->get<ESM::Armor>();
|
MWWorld::LiveCellRef<ESM::Armor> *ref = it->get<ESM::Armor>();
|
||||||
|
|
||||||
int armorSkillType = MWWorld::Class::get(*it).getEquipmentSkill(*it);
|
int armorSkillType = it->getClass().getEquipmentSkill(*it);
|
||||||
int armorSkill = stats.getSkill(armorSkillType).getModified();
|
int armorSkill = stats.getSkill(armorSkillType).getModified();
|
||||||
|
|
||||||
if(ref->mBase->mData.mWeight == 0)
|
if(ref->mBase->mData.mWeight == 0)
|
||||||
|
@ -1177,7 +1180,7 @@ namespace MWClass
|
||||||
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
||||||
return "FootBareLeft";
|
return "FootBareLeft";
|
||||||
|
|
||||||
switch(Class::get(*boots).getEquipmentSkill(*boots))
|
switch(boots->getClass().getEquipmentSkill(*boots))
|
||||||
{
|
{
|
||||||
case ESM::Skill::LightArmor:
|
case ESM::Skill::LightArmor:
|
||||||
return "FootLightLeft";
|
return "FootLightLeft";
|
||||||
|
@ -1204,7 +1207,7 @@ namespace MWClass
|
||||||
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
||||||
return "FootBareRight";
|
return "FootBareRight";
|
||||||
|
|
||||||
switch(Class::get(*boots).getEquipmentSkill(*boots))
|
switch(boots->getClass().getEquipmentSkill(*boots))
|
||||||
{
|
{
|
||||||
case ESM::Skill::LightArmor:
|
case ESM::Skill::LightArmor:
|
||||||
return "FootLightRight";
|
return "FootLightRight";
|
||||||
|
@ -1316,14 +1319,14 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
|
// Note we do not respawn moved references in the cell they were moved to. Instead they are respawned in the original cell.
|
||||||
// This also means we cannot respawn dynamically placed references with no content file connection.
|
// This also means we cannot respawn dynamically placed references with no content file connection.
|
||||||
if (ptr.getCellRef().mRefNum.mContentFile != -1)
|
if (ptr.getCellRef().getRefNum().mContentFile != -1)
|
||||||
{
|
{
|
||||||
if (ptr.getRefData().getCount() == 0)
|
if (ptr.getRefData().getCount() == 0)
|
||||||
ptr.getRefData().setCount(1);
|
ptr.getRefData().setCount(1);
|
||||||
|
|
||||||
// Reset to original position
|
// Reset to original position
|
||||||
ESM::Position& pos = ptr.getRefData().getPosition();
|
ESM::Position& pos = ptr.getRefData().getPosition();
|
||||||
pos = ptr.getCellRef().mPos;
|
pos = ptr.getCellRef().getPosition();
|
||||||
|
|
||||||
ptr.getRefData().setCustomData(NULL);
|
ptr.getRefData().setCustomData(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1335,7 +1338,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
const ESM::InventoryList& list = ref->mBase->mInventory;
|
const ESM::InventoryList& list = ref->mBase->mInventory;
|
||||||
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
MWWorld::ContainerStore& store = getContainerStore(ptr);
|
||||||
store.restock(list, ptr, ptr.getCellRef().mRefID, ptr.getCellRef().mFaction);
|
store.restock(list, ptr, ptr.getCellRef().getRefId(), ptr.getCellRef().getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace MWClass
|
||||||
|
|
||||||
// hide effects the player doesnt know about
|
// hide effects the player doesnt know about
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player);
|
||||||
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
||||||
int i=0;
|
int i=0;
|
||||||
static const float fWortChanceValue =
|
static const float fWortChanceValue =
|
||||||
|
@ -151,8 +151,8 @@ namespace MWClass
|
||||||
info.isPotion = true;
|
info.isPotion = true;
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == -1)
|
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||||
return ref->mBase->mData.mValue;
|
|
||||||
else
|
|
||||||
return ref->mBase->mData.mValue * (static_cast<float>(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Probe::registerSelf()
|
void Probe::registerSelf()
|
||||||
|
@ -135,7 +132,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
|
int remainingUses = getItemHealth(ptr);
|
||||||
|
|
||||||
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
||||||
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
||||||
|
@ -143,8 +140,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == -1)
|
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||||
return ref->mBase->mData.mValue;
|
|
||||||
else
|
|
||||||
return ref->mBase->mData.mValue * (static_cast<float>(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Repair::registerSelf()
|
void Repair::registerSelf()
|
||||||
|
@ -139,7 +136,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
|
int remainingUses = getItemHealth(ptr);
|
||||||
|
|
||||||
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
|
||||||
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
|
||||||
|
@ -147,8 +144,8 @@ namespace MWClass
|
||||||
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,10 +154,7 @@ namespace MWClass
|
||||||
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
if (ptr.getCellRef().mCharge == -1)
|
return ref->mBase->mData.mValue * (static_cast<float>(getItemHealth(ptr)) / getItemMaxHealth(ptr));
|
||||||
return ref->mBase->mData.mValue;
|
|
||||||
else
|
|
||||||
return ref->mBase->mData.mValue * (static_cast<float>(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::registerSelf()
|
void Weapon::registerSelf()
|
||||||
|
@ -340,7 +337,7 @@ namespace MWClass
|
||||||
|
|
||||||
if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity
|
if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity
|
||||||
{
|
{
|
||||||
int remainingHealth = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mHealth;
|
int remainingHealth = getItemHealth(ptr);
|
||||||
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
|
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
|
||||||
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
|
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
|
||||||
}
|
}
|
||||||
|
@ -351,11 +348,11 @@ namespace MWClass
|
||||||
info.enchant = ref->mBase->mEnchant;
|
info.enchant = ref->mBase->mEnchant;
|
||||||
|
|
||||||
if (!info.enchant.empty())
|
if (!info.enchant.empty())
|
||||||
info.remainingEnchantCharge = ptr.getCellRef().mEnchantmentCharge;
|
info.remainingEnchantCharge = ptr.getCellRef().getEnchantmentCharge();
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getOwner(), "Owner");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mRef.mFaction, "Faction");
|
text += MWGui::ToolTips::getMiscString(ptr.getCellRef().getFaction(), "Faction");
|
||||||
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +369,7 @@ namespace MWClass
|
||||||
return ref->mBase->mEnchant;
|
return ref->mBase->mEnchant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
std::string Weapon::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
@ -383,16 +380,15 @@ namespace MWClass
|
||||||
newItem.mData.mEnchant=enchCharge;
|
newItem.mData.mEnchant=enchCharge;
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
return record->mId;
|
||||||
ref->mRef.mRefID = record->mId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
{
|
{
|
||||||
if (ptr.getCellRef().mCharge == 0)
|
if (ptr.getCellRef().getCharge() == 0)
|
||||||
return std::make_pair(0, "#{sInventoryMessage1}");
|
return std::make_pair(0, "#{sInventoryMessage1}");
|
||||||
|
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);
|
||||||
|
|
||||||
if (slots_.first.empty())
|
if (slots_.first.empty())
|
||||||
return std::make_pair (0, "");
|
return std::make_pair (0, "");
|
||||||
|
|
|
@ -68,7 +68,8 @@ namespace MWClass
|
||||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||||
|
|
||||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||||
|
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
|
||||||
|
|
||||||
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
||||||
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
|
||||||
|
|
|
@ -134,13 +134,13 @@ namespace MWDialogue
|
||||||
|
|
||||||
mActor = actor;
|
mActor = actor;
|
||||||
|
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor);
|
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats (actor);
|
||||||
mTalkedTo = creatureStats.hasTalkedToPlayer();
|
mTalkedTo = creatureStats.hasTalkedToPlayer();
|
||||||
|
|
||||||
mActorKnownTopics.clear();
|
mActorKnownTopics.clear();
|
||||||
|
|
||||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
win->startDialogue(actor, MWWorld::Class::get (actor).getName (actor));
|
win->startDialogue(actor, actor.getClass().getName (actor));
|
||||||
|
|
||||||
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
|
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
|
||||||
updateTopics();
|
updateTopics();
|
||||||
|
@ -194,7 +194,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
Compiler::Locals locals;
|
Compiler::Locals locals;
|
||||||
|
|
||||||
std::string actorScript = MWWorld::Class::get (mActor).getScript (mActor);
|
std::string actorScript = mActor.getClass().getScript (mActor);
|
||||||
|
|
||||||
if (!actorScript.empty())
|
if (!actorScript.empty())
|
||||||
{
|
{
|
||||||
|
@ -435,7 +435,7 @@ namespace MWDialogue
|
||||||
// Apply disposition change to NPC's base disposition
|
// Apply disposition change to NPC's base disposition
|
||||||
if (mActor.getClass().isNpc())
|
if (mActor.getClass().isNpc())
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor);
|
MWMechanics::NpcStats& npcStats = mActor.getClass().getNpcStats(mActor);
|
||||||
npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange);
|
npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange);
|
||||||
}
|
}
|
||||||
mPermanentDispositionChange = 0;
|
mPermanentDispositionChange = 0;
|
||||||
|
@ -642,6 +642,8 @@ namespace MWDialogue
|
||||||
if (iter->second)
|
if (iter->second)
|
||||||
state.mKnownTopics.push_back (iter->first);
|
state.mKnownTopics.push_back (iter->first);
|
||||||
|
|
||||||
|
state.mModFactionReaction = mModFactionReaction;
|
||||||
|
|
||||||
writer.startRecord (ESM::REC_DIAS);
|
writer.startRecord (ESM::REC_DIAS);
|
||||||
state.save (writer);
|
state.save (writer);
|
||||||
writer.endRecord (ESM::REC_DIAS);
|
writer.endRecord (ESM::REC_DIAS);
|
||||||
|
@ -661,9 +663,46 @@ namespace MWDialogue
|
||||||
iter!=state.mKnownTopics.end(); ++iter)
|
iter!=state.mKnownTopics.end(); ++iter)
|
||||||
if (store.get<ESM::Dialogue>().search (*iter))
|
if (store.get<ESM::Dialogue>().search (*iter))
|
||||||
mKnownTopics.insert (std::make_pair (*iter, true));
|
mKnownTopics.insert (std::make_pair (*iter, true));
|
||||||
|
|
||||||
|
mModFactionReaction = state.mModFactionReaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogueManager::modFactionReaction(const std::string &faction1, const std::string &faction2, int diff)
|
||||||
|
{
|
||||||
|
std::string fact1 = Misc::StringUtils::lowerCase(faction1);
|
||||||
|
std::string fact2 = Misc::StringUtils::lowerCase(faction2);
|
||||||
|
|
||||||
|
// Make sure the factions exist
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact1);
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact2);
|
||||||
|
|
||||||
|
std::map<std::string, int>& map = mModFactionReaction[fact1];
|
||||||
|
if (map.find(fact2) == map.end())
|
||||||
|
map[fact2] = 0;
|
||||||
|
map[fact2] += diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogueManager::getFactionReaction(const std::string &faction1, const std::string &faction2) const
|
||||||
|
{
|
||||||
|
std::string fact1 = Misc::StringUtils::lowerCase(faction1);
|
||||||
|
std::string fact2 = Misc::StringUtils::lowerCase(faction2);
|
||||||
|
|
||||||
|
ModFactionReactionMap::const_iterator map = mModFactionReaction.find(fact1);
|
||||||
|
int diff = 0;
|
||||||
|
if (map != mModFactionReaction.end() && map->second.find(fact2) != map->second.end())
|
||||||
|
diff = map->second.at(fact2);
|
||||||
|
|
||||||
|
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(fact1);
|
||||||
|
|
||||||
|
std::map<std::string, int>::const_iterator it = faction->mReactions.begin();
|
||||||
|
for (; it != faction->mReactions.end(); ++it)
|
||||||
|
{
|
||||||
|
if (Misc::StringUtils::ciEqual(it->first, fact2))
|
||||||
|
return it->second + diff;
|
||||||
|
}
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HyperTextToken> ParseHyperText(const std::string& text)
|
std::vector<HyperTextToken> ParseHyperText(const std::string& text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,11 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
std::map<std::string, ESM::Dialogue> mDialogueMap;
|
std::map<std::string, ESM::Dialogue> mDialogueMap;
|
||||||
std::map<std::string, bool> mKnownTopics;// Those are the topics the player knows.
|
std::map<std::string, bool> mKnownTopics;// Those are the topics the player knows.
|
||||||
|
|
||||||
|
// Modified faction reactions. <Faction1, <Faction2, Difference> >
|
||||||
|
typedef std::map<std::string, std::map<std::string, int> > ModFactionReactionMap;
|
||||||
|
ModFactionReactionMap mModFactionReaction;
|
||||||
|
|
||||||
std::list<std::string> mActorKnownTopics;
|
std::list<std::string> mActorKnownTopics;
|
||||||
|
|
||||||
Translation::Storage& mTranslationDataStorage;
|
Translation::Storage& mTranslationDataStorage;
|
||||||
|
@ -86,6 +91,12 @@ namespace MWDialogue
|
||||||
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
||||||
|
|
||||||
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
|
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
|
||||||
|
|
||||||
|
/// Changes faction1's opinion of faction2 by \a diff.
|
||||||
|
virtual void modFactionReaction (const std::string& faction1, const std::string& faction2, int diff);
|
||||||
|
|
||||||
|
/// @return faction1's opinion of faction2
|
||||||
|
virtual int getFactionReaction (const std::string& faction1, const std::string& faction2) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
|
||||||
// actor id
|
// actor id
|
||||||
if (!info.mActor.empty())
|
if (!info.mActor.empty())
|
||||||
{
|
{
|
||||||
if ( !Misc::StringUtils::ciEqual(info.mActor, MWWorld::Class::get (mActor).getId (mActor)))
|
if ( !Misc::StringUtils::ciEqual(info.mActor, mActor.getClass().getId (mActor)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (isCreature)
|
else if (isCreature)
|
||||||
|
@ -64,7 +64,7 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
|
||||||
if (isCreature)
|
if (isCreature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MWMechanics::NpcStats& stats = MWWorld::Class::get (mActor).getNpcStats (mActor);
|
MWMechanics::NpcStats& stats = mActor.getClass().getNpcStats (mActor);
|
||||||
std::map<std::string, int>::iterator iter = stats.getFactionRanks().find ( Misc::StringUtils::lowerCase (info.mFaction));
|
std::map<std::string, int>::iterator iter = stats.getFactionRanks().find ( Misc::StringUtils::lowerCase (info.mFaction));
|
||||||
|
|
||||||
if (iter==stats.getFactionRanks().end())
|
if (iter==stats.getFactionRanks().end())
|
||||||
|
@ -98,7 +98,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
|
||||||
// check player faction
|
// check player faction
|
||||||
if (!info.mPcFaction.empty())
|
if (!info.mPcFaction.empty())
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = MWWorld::Class::get (player).getNpcStats (player);
|
MWMechanics::NpcStats& stats = player.getClass().getNpcStats (player);
|
||||||
std::map<std::string,int>::iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction));
|
std::map<std::string,int>::iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction));
|
||||||
|
|
||||||
if(iter==stats.getFactionRanks().end())
|
if(iter==stats.getFactionRanks().end())
|
||||||
|
@ -182,7 +182,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
||||||
|
|
||||||
case SelectWrapper::Function_Local:
|
case SelectWrapper::Function_Local:
|
||||||
{
|
{
|
||||||
std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor);
|
std::string scriptName = mActor.getClass().getScript (mActor);
|
||||||
|
|
||||||
if (scriptName.empty())
|
if (scriptName.empty())
|
||||||
return false; // no script
|
return false; // no script
|
||||||
|
@ -220,8 +220,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
|
||||||
float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() /
|
float ratio = player.getClass().getCreatureStats (player).getHealth().getCurrent() /
|
||||||
MWWorld::Class::get (player).getCreatureStats (player).getHealth().getModified();
|
player.getClass().getCreatureStats (player).getHealth().getModified();
|
||||||
|
|
||||||
return select.selectCompare (static_cast<int>(ratio*100));
|
return select.selectCompare (static_cast<int>(ratio*100));
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
|
||||||
float value = MWWorld::Class::get (player).getCreatureStats (player).
|
float value = player.getClass().getCreatureStats (player).
|
||||||
getDynamic (select.getArgument()).getCurrent();
|
getDynamic (select.getArgument()).getCurrent();
|
||||||
|
|
||||||
return select.selectCompare (value);
|
return select.selectCompare (value);
|
||||||
|
@ -238,8 +238,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
||||||
|
|
||||||
case SelectWrapper::Function_HealthPercent:
|
case SelectWrapper::Function_HealthPercent:
|
||||||
{
|
{
|
||||||
float ratio = MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getCurrent() /
|
float ratio = mActor.getClass().getCreatureStats (mActor).getHealth().getCurrent() /
|
||||||
MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getModified();
|
mActor.getClass().getCreatureStats (mActor).getHealth().getModified();
|
||||||
|
|
||||||
return select.selectCompare (ratio);
|
return select.selectCompare (ratio);
|
||||||
}
|
}
|
||||||
|
@ -262,17 +262,9 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_Item:
|
case SelectWrapper::Function_Item:
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore (player);
|
||||||
|
|
||||||
int sum = 0;
|
return store.count(select.getName());
|
||||||
|
|
||||||
std::string name = select.getName();
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
|
|
||||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, name))
|
|
||||||
sum += iter->getRefData().getCount();
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_Dead:
|
case SelectWrapper::Function_Dead:
|
||||||
|
@ -285,29 +277,29 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_AiSetting:
|
case SelectWrapper::Function_AiSetting:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAiSetting (
|
return mActor.getClass().getCreatureStats (mActor).getAiSetting (
|
||||||
(MWMechanics::CreatureStats::AiSetting)select.getArgument()).getModified();
|
(MWMechanics::CreatureStats::AiSetting)select.getArgument()).getModified();
|
||||||
|
|
||||||
case SelectWrapper::Function_PcAttribute:
|
case SelectWrapper::Function_PcAttribute:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats (player).
|
return player.getClass().getCreatureStats (player).
|
||||||
getAttribute (select.getArgument()).getModified();
|
getAttribute (select.getArgument()).getModified();
|
||||||
|
|
||||||
case SelectWrapper::Function_PcSkill:
|
case SelectWrapper::Function_PcSkill:
|
||||||
|
|
||||||
return static_cast<int> (MWWorld::Class::get (player).
|
return static_cast<int> (player.getClass().
|
||||||
getNpcStats (player).getSkill (select.getArgument()).getModified());
|
getNpcStats (player).getSkill (select.getArgument()).getModified());
|
||||||
|
|
||||||
case SelectWrapper::Function_FriendlyHit:
|
case SelectWrapper::Function_FriendlyHit:
|
||||||
{
|
{
|
||||||
int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits();
|
int hits = mActor.getClass().getCreatureStats (mActor).getFriendlyHits();
|
||||||
|
|
||||||
return hits>4 ? 4 : hits;
|
return hits>4 ? 4 : hits;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_PcLevel:
|
case SelectWrapper::Function_PcLevel:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats (player).getLevel();
|
return player.getClass().getCreatureStats (player).getLevel();
|
||||||
|
|
||||||
case SelectWrapper::Function_PcGender:
|
case SelectWrapper::Function_PcGender:
|
||||||
|
|
||||||
|
@ -315,7 +307,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_PcClothingModifier:
|
case SelectWrapper::Function_PcClothingModifier:
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore (player);
|
||||||
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
|
@ -324,7 +316,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
MWWorld::ContainerStoreIterator slot = store.getSlot (i);
|
MWWorld::ContainerStoreIterator slot = store.getSlot (i);
|
||||||
|
|
||||||
if (slot!=store.end())
|
if (slot!=store.end())
|
||||||
value += MWWorld::Class::get (*slot).getValue (*slot);
|
value += slot->getClass().getValue (*slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -332,15 +324,15 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_PcCrimeLevel:
|
case SelectWrapper::Function_PcCrimeLevel:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getNpcStats (player).getBounty();
|
return player.getClass().getNpcStats (player).getBounty();
|
||||||
|
|
||||||
case SelectWrapper::Function_RankRequirement:
|
case SelectWrapper::Function_RankRequirement:
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string faction =
|
std::string faction =
|
||||||
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
|
||||||
|
|
||||||
int rank = getFactionRank (player, faction);
|
int rank = getFactionRank (player, faction);
|
||||||
|
|
||||||
|
@ -360,11 +352,11 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_Level:
|
case SelectWrapper::Function_Level:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getLevel();
|
return mActor.getClass().getCreatureStats (mActor).getLevel();
|
||||||
|
|
||||||
case SelectWrapper::Function_PCReputation:
|
case SelectWrapper::Function_PCReputation:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getNpcStats (player).getReputation();
|
return player.getClass().getNpcStats (player).getReputation();
|
||||||
|
|
||||||
case SelectWrapper::Function_Weather:
|
case SelectWrapper::Function_Weather:
|
||||||
|
|
||||||
|
@ -372,15 +364,15 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_Reputation:
|
case SelectWrapper::Function_Reputation:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getNpcStats (mActor).getReputation();
|
return mActor.getClass().getNpcStats (mActor).getReputation();
|
||||||
|
|
||||||
case SelectWrapper::Function_FactionRankDiff:
|
case SelectWrapper::Function_FactionRankDiff:
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::pair<std::string, int> faction =
|
std::pair<std::string, int> faction =
|
||||||
*MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin();
|
*mActor.getClass().getNpcStats (mActor).getFactionRanks().begin();
|
||||||
|
|
||||||
int rank = getFactionRank (player, faction.first);
|
int rank = getFactionRank (player, faction.first);
|
||||||
|
|
||||||
|
@ -389,31 +381,30 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_WerewolfKills:
|
case SelectWrapper::Function_WerewolfKills:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getNpcStats (player).getWerewolfKills();
|
return player.getClass().getNpcStats (player).getWerewolfKills();
|
||||||
|
|
||||||
case SelectWrapper::Function_RankLow:
|
case SelectWrapper::Function_RankLow:
|
||||||
case SelectWrapper::Function_RankHigh:
|
case SelectWrapper::Function_RankHigh:
|
||||||
{
|
{
|
||||||
bool low = select.getFunction()==SelectWrapper::Function_RankLow;
|
bool low = select.getFunction()==SelectWrapper::Function_RankLow;
|
||||||
|
|
||||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string factionId =
|
std::string factionId =
|
||||||
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
|
||||||
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
const ESM::Faction& faction =
|
MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats (player);
|
||||||
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
|
||||||
|
|
||||||
MWMechanics::NpcStats& playerStats = MWWorld::Class::get (player).getNpcStats (player);
|
std::map<std::string, int>::const_iterator playerFactionIt = playerStats.getFactionRanks().begin();
|
||||||
|
for (; playerFactionIt != playerStats.getFactionRanks().end(); ++playerFactionIt)
|
||||||
for (std::vector<ESM::Faction::Reaction>::const_iterator iter (faction.mReactions.begin());
|
{
|
||||||
iter!=faction.mReactions.end(); ++iter)
|
int reaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(factionId, playerFactionIt->first);
|
||||||
if (playerStats.getFactionRanks().find (iter->mFaction)!=playerStats.getFactionRanks().end())
|
if (low ? reaction < value : reaction > value)
|
||||||
if (low ? iter->mReaction<value : iter->mReaction>value)
|
value = reaction;
|
||||||
value = iter->mReaction;
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -436,7 +427,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_NotId:
|
case SelectWrapper::Function_NotId:
|
||||||
|
|
||||||
return !Misc::StringUtils::ciEqual(MWWorld::Class::get (mActor).getId (mActor), select.getName());
|
return !Misc::StringUtils::ciEqual(mActor.getClass().getId (mActor), select.getName());
|
||||||
|
|
||||||
case SelectWrapper::Function_NotFaction:
|
case SelectWrapper::Function_NotFaction:
|
||||||
|
|
||||||
|
@ -456,7 +447,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_NotLocal:
|
case SelectWrapper::Function_NotLocal:
|
||||||
{
|
{
|
||||||
std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor);
|
std::string scriptName = mActor.getClass().getScript (mActor);
|
||||||
|
|
||||||
if (scriptName.empty())
|
if (scriptName.empty())
|
||||||
// This actor has no attached script, so there is no local variable
|
// This actor has no attached script, so there is no local variable
|
||||||
|
@ -489,36 +480,36 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_SameFaction:
|
case SelectWrapper::Function_SameFaction:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction (
|
return mActor.getClass().getNpcStats (mActor).isSameFaction (
|
||||||
MWWorld::Class::get (player).getNpcStats (player));
|
player.getClass().getNpcStats (player));
|
||||||
|
|
||||||
case SelectWrapper::Function_PcCommonDisease:
|
case SelectWrapper::Function_PcCommonDisease:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats (player).hasCommonDisease();
|
return player.getClass().getCreatureStats (player).hasCommonDisease();
|
||||||
|
|
||||||
case SelectWrapper::Function_PcBlightDisease:
|
case SelectWrapper::Function_PcBlightDisease:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats (player).hasBlightDisease();
|
return player.getClass().getCreatureStats (player).hasBlightDisease();
|
||||||
|
|
||||||
case SelectWrapper::Function_PcCorprus:
|
case SelectWrapper::Function_PcCorprus:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats (player).
|
return player.getClass().getCreatureStats (player).
|
||||||
getMagicEffects().get (ESM::MagicEffect::Corprus).mMagnitude!=0;
|
getMagicEffects().get (ESM::MagicEffect::Corprus).mMagnitude!=0;
|
||||||
|
|
||||||
case SelectWrapper::Function_PcExpelled:
|
case SelectWrapper::Function_PcExpelled:
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
|
if (mActor.getClass().getNpcStats (mActor).getFactionRanks().empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string faction =
|
std::string faction =
|
||||||
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
|
mActor.getClass().getNpcStats (mActor).getFactionRanks().begin()->first;
|
||||||
|
|
||||||
return player.getClass().getNpcStats(player).getExpelled(faction);
|
return player.getClass().getNpcStats(player).getExpelled(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_PcVampire:
|
case SelectWrapper::Function_PcVampire:
|
||||||
|
|
||||||
return MWWorld::Class::get (player).getCreatureStats(player).getMagicEffects().
|
return player.getClass().getCreatureStats(player).getMagicEffects().
|
||||||
get(ESM::MagicEffect::Vampirism).mMagnitude > 0;
|
get(ESM::MagicEffect::Vampirism).mMagnitude > 0;
|
||||||
|
|
||||||
case SelectWrapper::Function_TalkedToPc:
|
case SelectWrapper::Function_TalkedToPc:
|
||||||
|
@ -527,7 +518,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_Alarmed:
|
case SelectWrapper::Function_Alarmed:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isAlarmed();
|
return mActor.getClass().getCreatureStats (mActor).isAlarmed();
|
||||||
|
|
||||||
case SelectWrapper::Function_Detected:
|
case SelectWrapper::Function_Detected:
|
||||||
|
|
||||||
|
@ -535,11 +526,11 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_Attacked:
|
case SelectWrapper::Function_Attacked:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAttacked();
|
return mActor.getClass().getCreatureStats (mActor).getAttacked();
|
||||||
|
|
||||||
case SelectWrapper::Function_ShouldAttack:
|
case SelectWrapper::Function_ShouldAttack:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isHostile();
|
return mActor.getClass().getCreatureStats(mActor).getAiSetting(MWMechanics::CreatureStats::AI_Fight).getModified() >= 80;
|
||||||
|
|
||||||
case SelectWrapper::Function_CreatureTargetted:
|
case SelectWrapper::Function_CreatureTargetted:
|
||||||
|
|
||||||
|
@ -547,7 +538,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
case SelectWrapper::Function_Werewolf:
|
case SelectWrapper::Function_Werewolf:
|
||||||
|
|
||||||
return MWWorld::Class::get (mActor).getNpcStats (mActor).isWerewolf();
|
return mActor.getClass().getNpcStats (mActor).isWerewolf();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
@ -557,7 +548,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
|
|
||||||
int MWDialogue::Filter::getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const
|
int MWDialogue::Filter::getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor);
|
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats (actor);
|
||||||
|
|
||||||
std::map<std::string, int>::const_iterator iter = stats.getFactionRanks().find (factionId);
|
std::map<std::string, int>::const_iterator iter = stats.getFactionRanks().find (factionId);
|
||||||
|
|
||||||
|
@ -573,13 +564,13 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements (const MWWorld::Ptr& ac
|
||||||
if (rank<0 || rank>=10)
|
if (rank<0 || rank>=10)
|
||||||
throw std::runtime_error ("rank index out of range");
|
throw std::runtime_error ("rank index out of range");
|
||||||
|
|
||||||
if (!MWWorld::Class::get (actor).getNpcStats (actor).hasSkillsForRank (factionId, rank))
|
if (!actor.getClass().getNpcStats (actor).hasSkillsForRank (factionId, rank))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ESM::Faction& faction =
|
const ESM::Faction& faction =
|
||||||
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (actor).getCreatureStats (actor);
|
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats (actor);
|
||||||
|
|
||||||
return stats.getAttribute (faction.mData.mAttribute[0]).getBase()>=faction.mData.mRankData[rank].mAttribute1 &&
|
return stats.getAttribute (faction.mData.mAttribute[0]).getBase()>=faction.mData.mRankData[rank].mAttribute1 &&
|
||||||
stats.getAttribute (faction.mData.mAttribute[1]).getBase()>=faction.mData.mRankData[rank].mAttribute2;
|
stats.getAttribute (faction.mData.mAttribute[1]).getBase()>=faction.mData.mRankData[rank].mAttribute2;
|
||||||
|
@ -591,7 +582,7 @@ bool MWDialogue::Filter::hasFactionRankReputationRequirements (const MWWorld::Pt
|
||||||
if (rank<0 || rank>=10)
|
if (rank<0 || rank>=10)
|
||||||
throw std::runtime_error ("rank index out of range");
|
throw std::runtime_error ("rank index out of range");
|
||||||
|
|
||||||
MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor);
|
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats (actor);
|
||||||
|
|
||||||
const ESM::Faction& faction =
|
const ESM::Faction& faction =
|
||||||
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace
|
||||||
std::string getIconPath(MWWorld::Ptr ptr)
|
std::string getIconPath(MWWorld::Ptr ptr)
|
||||||
{
|
{
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(ptr).getInventoryIcon(ptr);
|
path += ptr.getClass().getInventoryIcon(ptr);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -174,7 +174,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
|
||||||
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
|
std::string sound = item.getClass().getUpSoundId(item);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace
|
||||||
void updatePlayerHealth()
|
void updatePlayerHealth()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats(player);
|
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
|
||||||
npcStats.updateHealth();
|
npcStats.updateHealth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ namespace MWGui
|
||||||
|
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
|
|
||||||
mReviewDialog->setHealth ( stats.getHealth() );
|
mReviewDialog->setHealth ( stats.getHealth() );
|
||||||
mReviewDialog->setMagicka( stats.getMagicka() );
|
mReviewDialog->setMagicka( stats.getMagicka() );
|
||||||
|
|
|
@ -61,7 +61,7 @@ void CompanionWindow::onItemSelected(int index)
|
||||||
if (count > 1 && !shift)
|
if (count > 1 && !shift)
|
||||||
{
|
{
|
||||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||||
dialog->open(MWWorld::Class::get(object).getName(object), "#{sTake}", count);
|
dialog->open(object.getClass().getName(object), "#{sTake}", count);
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &CompanionWindow::dragItem);
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &CompanionWindow::dragItem);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ void CompanionWindow::open(const MWWorld::Ptr& npc)
|
||||||
mSortModel = new SortFilterItemModel(mModel);
|
mSortModel = new SortFilterItemModel(mModel);
|
||||||
mItemView->setModel(mSortModel);
|
mItemView->setModel(mSortModel);
|
||||||
|
|
||||||
setTitle(MWWorld::Class::get(npc).getName(npc));
|
setTitle(npc.getClass().getName(npc));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompanionWindow::onFrame()
|
void CompanionWindow::onFrame()
|
||||||
|
@ -104,22 +104,22 @@ void CompanionWindow::updateEncumbranceBar()
|
||||||
{
|
{
|
||||||
if (mPtr.isEmpty())
|
if (mPtr.isEmpty())
|
||||||
return;
|
return;
|
||||||
float capacity = MWWorld::Class::get(mPtr).getCapacity(mPtr);
|
float capacity = mPtr.getClass().getCapacity(mPtr);
|
||||||
float encumbrance = MWWorld::Class::get(mPtr).getEncumbrance(mPtr);
|
float encumbrance = mPtr.getClass().getEncumbrance(mPtr);
|
||||||
mEncumbranceBar->setValue(encumbrance, capacity);
|
mEncumbranceBar->setValue(encumbrance, capacity);
|
||||||
|
|
||||||
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
|
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
|
||||||
mProfitLabel->setCaption("");
|
mProfitLabel->setCaption("");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = MWWorld::Class::get(mPtr).getNpcStats(mPtr);
|
MWMechanics::NpcStats& stats = mPtr.getClass().getNpcStats(mPtr);
|
||||||
mProfitLabel->setCaptionWithReplacing("#{sProfitValue} " + boost::lexical_cast<std::string>(stats.getProfit()));
|
mProfitLabel->setCaptionWithReplacing("#{sProfitValue} " + boost::lexical_cast<std::string>(stats.getProfit()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && MWWorld::Class::get(mPtr).getNpcStats(mPtr).getProfit() < 0)
|
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && mPtr.getClass().getNpcStats(mPtr).getProfit() < 0)
|
||||||
{
|
{
|
||||||
std::vector<std::string> buttons;
|
std::vector<std::string> buttons;
|
||||||
buttons.push_back("#{sCompanionWarningButtonOne}");
|
buttons.push_back("#{sCompanionWarningButtonOne}");
|
||||||
|
@ -135,8 +135,8 @@ void CompanionWindow::onMessageBoxButtonClicked(int button)
|
||||||
{
|
{
|
||||||
if (button == 0)
|
if (button == 0)
|
||||||
{
|
{
|
||||||
mPtr.getRefData().getLocals().setVarByInt(MWWorld::Class::get(mPtr).getScript(mPtr),
|
mPtr.getRefData().getLocals().setVarByInt(mPtr.getClass().getScript(mPtr),
|
||||||
"minimumProfit", MWWorld::Class::get(mPtr).getNpcStats(mPtr).getProfit());
|
"minimumProfit", mPtr.getClass().getNpcStats(mPtr).getProfit());
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion);
|
||||||
MWBase::Environment::get().getDialogueManager()->startDialogue (mPtr);
|
MWBase::Environment::get().getDialogueManager()->startDialogue (mPtr);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#include <components/compiler/exception.hpp>
|
#include <components/compiler/exception.hpp>
|
||||||
#include <components/compiler/extensions0.hpp>
|
#include <components/compiler/extensions0.hpp>
|
||||||
|
|
||||||
|
@ -194,7 +197,8 @@ namespace MWGui
|
||||||
|
|
||||||
void Console::executeFile (const std::string& path)
|
void Console::executeFile (const std::string& path)
|
||||||
{
|
{
|
||||||
std::ifstream stream (path.c_str());
|
namespace bfs = boost::filesystem;
|
||||||
|
bfs::ifstream stream ((bfs::path(path)));
|
||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
printError ("failed to open file: " + path);
|
printError ("failed to open file: " + path);
|
||||||
|
@ -409,7 +413,7 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setTitle("#{sConsoleTitle} (" + object.getCellRef().mRefID + ")");
|
setTitle("#{sConsoleTitle} (" + object.getCellRef().getRefId() + ")");
|
||||||
mPtr = object;
|
mPtr = object;
|
||||||
}
|
}
|
||||||
// User clicked on an object. Restore focus to the console command line.
|
// User clicked on an object. Restore focus to the console command line.
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace MWGui
|
||||||
mIsOnDragAndDrop = true;
|
mIsOnDragAndDrop = true;
|
||||||
mDragAndDropWidget->setVisible(true);
|
mDragAndDropWidget->setVisible(true);
|
||||||
|
|
||||||
std::string sound = MWWorld::Class::get(mItem.mBase).getUpSoundId(mItem.mBase);
|
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
if (mSourceSortModel)
|
if (mSourceSortModel)
|
||||||
|
@ -47,7 +47,7 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(mItem.mBase).getInventoryIcon(mItem.mBase);
|
path += mItem.mBase.getClass().getInventoryIcon(mItem.mBase);
|
||||||
MyGUI::ImageBox* baseWidget = mDragAndDropWidget->createWidget<MyGUI::ImageBox>
|
MyGUI::ImageBox* baseWidget = mDragAndDropWidget->createWidget<MyGUI::ImageBox>
|
||||||
("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||||
mDraggedWidget = baseWidget;
|
mDraggedWidget = baseWidget;
|
||||||
|
@ -76,7 +76,7 @@ namespace MWGui
|
||||||
|
|
||||||
void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView)
|
void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView)
|
||||||
{
|
{
|
||||||
std::string sound = MWWorld::Class::get(mItem.mBase).getDownSoundId(mItem.mBase);
|
std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
mDragAndDropWidget->setVisible(false);
|
mDragAndDropWidget->setVisible(false);
|
||||||
|
@ -155,7 +155,7 @@ namespace MWGui
|
||||||
if (count > 1 && !shift)
|
if (count > 1 && !shift)
|
||||||
{
|
{
|
||||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||||
dialog->open(MWWorld::Class::get(object).getName(object), "#{sTake}", count);
|
dialog->open(object.getClass().getName(object), "#{sTake}", count);
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
|
||||||
}
|
}
|
||||||
|
@ -177,8 +177,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// check that we don't exceed container capacity
|
// check that we don't exceed container capacity
|
||||||
MWWorld::Ptr item = mDragAndDrop->mItem.mBase;
|
MWWorld::Ptr item = mDragAndDrop->mItem.mBase;
|
||||||
float weight = MWWorld::Class::get(item).getWeight(item) * mDragAndDrop->mDraggedCount;
|
float weight = item.getClass().getWeight(item) * mDragAndDrop->mDraggedCount;
|
||||||
if (MWWorld::Class::get(mPtr).getCapacity(mPtr) < MWWorld::Class::get(mPtr).getEncumbrance(mPtr) + weight)
|
if (mPtr.getClass().getCapacity(mPtr) < mPtr.getClass().getEncumbrance(mPtr) + weight)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage3}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage3}");
|
||||||
return;
|
return;
|
||||||
|
@ -227,7 +227,7 @@ namespace MWGui
|
||||||
|
|
||||||
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
||||||
// or we end up using a possibly invalid model.
|
// or we end up using a possibly invalid model.
|
||||||
setTitle(MWWorld::Class::get(container).getName(container));
|
setTitle(container.getClass().getName(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerWindow::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
void ContainerWindow::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||||
|
@ -284,7 +284,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// play the sound of the first object
|
// play the sound of the first object
|
||||||
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
||||||
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
|
std::string sound = item.getClass().getUpSoundId(item);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
onTakeAllButtonClicked(mTakeButton);
|
onTakeAllButtonClicked(mTakeButton);
|
||||||
|
|
||||||
if (MWWorld::Class::get(mPtr).isPersistent(mPtr))
|
if (mPtr.getClass().isPersistent(mPtr))
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
|
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
|
||||||
|
|
|
@ -85,7 +85,7 @@ void ContainerItemModel::removeItem (const ItemStack& item, size_t count)
|
||||||
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
|
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(*source).getContainerStore(*source);
|
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source);
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,7 @@ void ContainerItemModel::update()
|
||||||
mItems.clear();
|
mItems.clear();
|
||||||
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
|
for (std::vector<MWWorld::Ptr>::iterator source = mItemSources.begin(); source != mItemSources.end(); ++source)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(*source).getContainerStore(*source);
|
MWWorld::ContainerStore& store = source->getClass().getContainerStore(*source);
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,8 +386,8 @@ namespace MWGui
|
||||||
mTopicLinks.clear();
|
mTopicLinks.clear();
|
||||||
mKeywordSearch.clear();
|
mKeywordSearch.clear();
|
||||||
|
|
||||||
bool isCompanion = !MWWorld::Class::get(mPtr).getScript(mPtr).empty()
|
bool isCompanion = !mPtr.getClass().getScript(mPtr).empty()
|
||||||
&& mPtr.getRefData().getLocals().getIntVar(MWWorld::Class::get(mPtr).getScript(mPtr), "companion");
|
&& mPtr.getRefData().getLocals().getIntVar(mPtr.getClass().getScript(mPtr), "companion");
|
||||||
|
|
||||||
bool anyService = mServices > 0 || isCompanion || mPtr.getTypeName() == typeid(ESM::NPC).name();
|
bool anyService = mServices > 0 || isCompanion || mPtr.getTypeName() == typeid(ESM::NPC).name();
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(soulgem).getInventoryIcon(soulgem);
|
path += soulgem.getClass().getInventoryIcon(soulgem);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -164,7 +164,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ImageBox* image = mItemBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = mItemBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -207,7 +207,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = mSoulBox->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -306,7 +306,7 @@ namespace MWGui
|
||||||
for (int i=0; i<2; ++i)
|
for (int i=0; i<2; ++i)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = (i == 0) ? mEnchanting.getOldItem() : mEnchanting.getGem();
|
MWWorld::Ptr item = (i == 0) ? mEnchanting.getOldItem() : mEnchanting.getGem();
|
||||||
if (Misc::StringUtils::ciEqual(item.getCellRef().mOwner, mPtr.getCellRef().mRefID))
|
if (Misc::StringUtils::ciEqual(item.getCellRef().getOwner(), mPtr.getCellRef().getRefId()))
|
||||||
{
|
{
|
||||||
std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage49")->getString();
|
std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage49")->getString();
|
||||||
if (msg.find("%s") != std::string::npos)
|
if (msg.find("%s") != std::string::npos)
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace MWGui
|
||||||
else
|
else
|
||||||
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count);
|
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count);
|
||||||
if (setNewOwner)
|
if (setNewOwner)
|
||||||
dropped.getCellRef().mOwner = "";
|
dropped.getCellRef().setOwner("");
|
||||||
|
|
||||||
return dropped;
|
return dropped;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ namespace MWGui
|
||||||
void HUD::onWeaponClicked(MyGUI::Widget* _sender)
|
void HUD::onWeaponClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
||||||
return;
|
return;
|
||||||
|
@ -360,7 +360,7 @@ namespace MWGui
|
||||||
void HUD::onMagicClicked(MyGUI::Widget* _sender)
|
void HUD::onMagicClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sWerewolfRefusal}");
|
||||||
return;
|
return;
|
||||||
|
@ -443,7 +443,7 @@ namespace MWGui
|
||||||
|
|
||||||
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
||||||
{
|
{
|
||||||
std::string itemName = MWWorld::Class::get(item).getName(item);
|
std::string itemName = item.getClass().getName(item);
|
||||||
if (itemName != mSpellName && mSpellVisible)
|
if (itemName != mSpellName && mSpellVisible)
|
||||||
{
|
{
|
||||||
mWeaponSpellTimer = 5.0f;
|
mWeaponSpellTimer = 5.0f;
|
||||||
|
@ -466,7 +466,7 @@ namespace MWGui
|
||||||
, MyGUI::Align::Stretch);
|
, MyGUI::Align::Stretch);
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path+=MWWorld::Class::get(item).getInventoryIcon(item);
|
path+=item.getClass().getInventoryIcon(item);
|
||||||
Widgets::fixTexturePath(path);
|
Widgets::fixTexturePath(path);
|
||||||
itemBox->setImageTexture(path);
|
itemBox->setImageTexture(path);
|
||||||
itemBox->setNeedMouseFocus(false);
|
itemBox->setNeedMouseFocus(false);
|
||||||
|
@ -474,7 +474,7 @@ namespace MWGui
|
||||||
|
|
||||||
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
||||||
{
|
{
|
||||||
std::string itemName = MWWorld::Class::get(item).getName(item);
|
std::string itemName = item.getClass().getName(item);
|
||||||
if (itemName != mWeaponName && mWeaponVisible)
|
if (itemName != mWeaponName && mWeaponVisible)
|
||||||
{
|
{
|
||||||
mWeaponSpellTimer = 5.0f;
|
mWeaponSpellTimer = 5.0f;
|
||||||
|
@ -493,10 +493,10 @@ namespace MWGui
|
||||||
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path+=MWWorld::Class::get(item).getInventoryIcon(item);
|
path+=item.getClass().getInventoryIcon(item);
|
||||||
Widgets::fixTexturePath(path);
|
Widgets::fixTexturePath(path);
|
||||||
|
|
||||||
if (MWWorld::Class::get(item).getEnchantment(item) != "")
|
if (item.getClass().getEnchantment(item) != "")
|
||||||
{
|
{
|
||||||
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||||
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||||
|
@ -545,7 +545,7 @@ namespace MWGui
|
||||||
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
MWWorld::Ptr player = world->getPlayerPtr();
|
MWWorld::Ptr player = world->getPlayerPtr();
|
||||||
if (MWWorld::Class::get(player).getNpcStats(player).isWerewolf())
|
if (player.getClass().getNpcStats(player).isWerewolf())
|
||||||
mWeapImage->setImageTexture("icons\\k\\tx_werewolf_hand.dds");
|
mWeapImage->setImageTexture("icons\\k\\tx_werewolf_hand.dds");
|
||||||
else
|
else
|
||||||
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
||||||
|
@ -636,7 +636,7 @@ namespace MWGui
|
||||||
|
|
||||||
void HUD::updateEnemyHealthBar()
|
void HUD::updateEnemyHealthBar()
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(mEnemy).getCreatureStats(mEnemy);
|
MWMechanics::CreatureStats& stats = mEnemy.getClass().getCreatureStats(mEnemy);
|
||||||
mEnemyHealth->setProgressRange(100);
|
mEnemyHealth->setProgressRange(100);
|
||||||
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
||||||
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
||||||
|
|
|
@ -50,7 +50,7 @@ MWWorld::Ptr InventoryItemModel::copyItem (const ItemStack& item, size_t count,
|
||||||
|
|
||||||
void InventoryItemModel::removeItem (const ItemStack& item, size_t count)
|
void InventoryItemModel::removeItem (const ItemStack& item, size_t count)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);
|
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
|
||||||
int removed = store.remove(item.mBase, count, mActor);
|
int removed = store.remove(item.mBase, count, mActor);
|
||||||
|
|
||||||
if (removed == 0)
|
if (removed == 0)
|
||||||
|
@ -67,7 +67,7 @@ MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack &item, size_t count, I
|
||||||
if (mActor.getClass().isActor() && mActor.getClass().getCreatureStats(mActor).isDead()
|
if (mActor.getClass().isActor() && mActor.getClass().getCreatureStats(mActor).isDead()
|
||||||
// Make sure that the item is actually owned by the dead actor
|
// Make sure that the item is actually owned by the dead actor
|
||||||
// Prevents a potential exploit for resetting the owner of any item, by placing the item in a corpse
|
// Prevents a potential exploit for resetting the owner of any item, by placing the item in a corpse
|
||||||
&& Misc::StringUtils::ciEqual(item.mBase.getCellRef().mOwner, mActor.getCellRef().mRefID))
|
&& Misc::StringUtils::ciEqual(item.mBase.getCellRef().getOwner(), mActor.getCellRef().getRefId()))
|
||||||
setNewOwner = true;
|
setNewOwner = true;
|
||||||
|
|
||||||
MWWorld::Ptr ret = otherModel->copyItem(item, count, setNewOwner);
|
MWWorld::Ptr ret = otherModel->copyItem(item, count, setNewOwner);
|
||||||
|
@ -77,7 +77,7 @@ MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack &item, size_t count, I
|
||||||
|
|
||||||
void InventoryItemModel::update()
|
void InventoryItemModel::update()
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);
|
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
|
||||||
|
|
||||||
mItems.clear();
|
mItems.clear();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void InventoryItemModel::update()
|
||||||
// NOTE: Don't show WerewolfRobe objects in the inventory, or allow them to be taken.
|
// NOTE: Don't show WerewolfRobe objects in the inventory, or allow them to be taken.
|
||||||
// Vanilla likely uses a hack like this since there's no other way to prevent it from
|
// Vanilla likely uses a hack like this since there's no other way to prevent it from
|
||||||
// being shown or taken.
|
// being shown or taken.
|
||||||
if(item.getCellRef().mRefID == "werewolfrobe")
|
if(item.getCellRef().getRefId() == "werewolfrobe")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemStack newItem (item, this, item.getRefData().getCount());
|
ItemStack newItem (item, this, item.getRefData().getCount());
|
||||||
|
|
|
@ -162,14 +162,14 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
const ItemStack& item = mTradeModel->getItem(index);
|
const ItemStack& item = mTradeModel->getItem(index);
|
||||||
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
|
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||||
|
|
||||||
MWWorld::Ptr object = item.mBase;
|
MWWorld::Ptr object = item.mBase;
|
||||||
int count = item.mCount;
|
int count = item.mCount;
|
||||||
|
|
||||||
// Bound items may not be moved
|
// Bound items may not be moved
|
||||||
if (item.mBase.getCellRef().mRefID.size() > 6
|
if (item.mBase.getCellRef().getRefId().size() > 6
|
||||||
&& item.mBase.getCellRef().mRefID.substr(0,6) == "bound_")
|
&& item.mBase.getCellRef().getRefId().substr(0,6) == "bound_")
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}");
|
||||||
|
@ -184,7 +184,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// check if merchant accepts item
|
// check if merchant accepts item
|
||||||
int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices();
|
int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices();
|
||||||
if (!MWWorld::Class::get(object).canSell(object, services))
|
if (!object.getClass().canSell(object, services))
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
MWBase::Environment::get().getWindowManager()->
|
MWBase::Environment::get().getWindowManager()->
|
||||||
|
@ -197,7 +197,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||||
std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
|
std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
|
||||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
dialog->open(object.getClass().getName(object), message, count);
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
if (mTrading)
|
if (mTrading)
|
||||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::sellItem);
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::sellItem);
|
||||||
|
@ -223,7 +223,7 @@ namespace MWGui
|
||||||
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
||||||
if (item.mType == ItemStack::Type_Equipped)
|
if (item.mType == ItemStack::Type_Equipped)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
|
MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);
|
||||||
|
|
||||||
// The unequipped item was re-stacked. We have to update the index
|
// The unequipped item was re-stacked. We have to update the index
|
||||||
|
@ -259,7 +259,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
ensureSelectedItemUnequipped();
|
ensureSelectedItemUnequipped();
|
||||||
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
||||||
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
|
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
if (item.mType == ItemStack::Type_Barter)
|
if (item.mType == ItemStack::Type_Barter)
|
||||||
|
@ -382,7 +382,7 @@ namespace MWGui
|
||||||
|
|
||||||
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
|
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
|
boost::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr);
|
||||||
|
|
||||||
action->execute (MWBase::Environment::get().getWorld()->getPlayerPtr());
|
action->execute (MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||||
|
|
||||||
|
@ -447,14 +447,14 @@ namespace MWGui
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
return MWWorld::Ptr();
|
return MWWorld::Ptr();
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
if(invStore.getSlot(slot) != invStore.end())
|
if(invStore.getSlot(slot) != invStore.end())
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = *invStore.getSlot(slot);
|
MWWorld::Ptr item = *invStore.getSlot(slot);
|
||||||
// NOTE: Don't allow users to select WerewolfRobe objects in the inventory. Vanilla
|
// NOTE: Don't allow users to select WerewolfRobe objects in the inventory. Vanilla
|
||||||
// likely uses a hack like this since there's no other way to prevent it from being
|
// likely uses a hack like this since there's no other way to prevent it from being
|
||||||
// taken.
|
// taken.
|
||||||
if(item.getCellRef().mRefID == "werewolfrobe")
|
if(item.getCellRef().getRefId() == "werewolfrobe")
|
||||||
return MWWorld::Ptr();
|
return MWWorld::Ptr();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -466,8 +466,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
|
||||||
float capacity = MWWorld::Class::get(player).getCapacity(player);
|
float capacity = player.getClass().getCapacity(player);
|
||||||
float encumbrance = MWWorld::Class::get(player).getEncumbrance(player);
|
float encumbrance = player.getClass().getEncumbrance(player);
|
||||||
mEncumbranceBar->setValue(encumbrance, capacity);
|
mEncumbranceBar->setValue(encumbrance, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,9 +498,9 @@ namespace MWGui
|
||||||
mAvatarImage->setImageTile(MyGUI::IntSize(std::min(512, size.width), std::min(1024, size.height)));
|
mAvatarImage->setImageTile(MyGUI::IntSize(std::min(512, size.width), std::min(1024, size.height)));
|
||||||
|
|
||||||
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
|
mArmorRating->setCaptionWithReplacing ("#{sArmor}: "
|
||||||
+ boost::lexical_cast<std::string>(static_cast<int>(MWWorld::Class::get(mPtr).getArmorRating(mPtr))));
|
+ boost::lexical_cast<std::string>(static_cast<int>(mPtr.getClass().getArmorRating(mPtr))));
|
||||||
if (mArmorRating->getTextSize().width > mArmorRating->getSize().width)
|
if (mArmorRating->getTextSize().width > mArmorRating->getSize().width)
|
||||||
mArmorRating->setCaptionWithReplacing (boost::lexical_cast<std::string>(static_cast<int>(MWWorld::Class::get(mPtr).getArmorRating(mPtr))));
|
mArmorRating->setCaptionWithReplacing (boost::lexical_cast<std::string>(static_cast<int>(mPtr.getClass().getArmorRating(mPtr))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ namespace MWGui
|
||||||
&& (type != typeid(ESM::Potion).name()))
|
&& (type != typeid(ESM::Potion).name()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (MWWorld::Class::get(object).getName(object) == "") // objects without name presented to user can never be picked up
|
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int count = object.getRefData().getCount();
|
int count = object.getRefData().getCount();
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace MWGui
|
||||||
, mType(Type_Normal)
|
, mType(Type_Normal)
|
||||||
, mBase(base)
|
, mBase(base)
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get(base).getEnchantment(base) != "")
|
if (base.getClass().getEnchantment(base) != "")
|
||||||
mFlags |= Flag_Enchanted;
|
mFlags |= Flag_Enchanted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void ItemView::update()
|
||||||
|
|
||||||
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
|
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item.mBase).getInventoryIcon(item.mBase);
|
path += item.mBase.getClass().getInventoryIcon(item.mBase);
|
||||||
|
|
||||||
// background widget (for the "equipped" frame and magic item background image)
|
// background widget (for the "equipped" frame and magic item background image)
|
||||||
bool isMagic = (item.mFlags & ItemStack::Flag_Enchanted);
|
bool isMagic = (item.mFlags & ItemStack::Flag_Enchanted);
|
||||||
|
|
|
@ -61,8 +61,8 @@ namespace MWGui
|
||||||
void LevelupDialog::setAttributeValues()
|
void LevelupDialog::setAttributeValues()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
|
MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player);
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
|
@ -117,8 +117,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
MWWorld::Ptr player = world->getPlayerPtr();
|
MWWorld::Ptr player = world->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
|
MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player);
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
||||||
|
|
||||||
mSpentAttributes.clear();
|
mSpentAttributes.clear();
|
||||||
resetCoins();
|
resetCoins();
|
||||||
|
@ -172,7 +172,7 @@ namespace MWGui
|
||||||
void LevelupDialog::onOkButtonClicked (MyGUI::Widget* sender)
|
void LevelupDialog::onOkButtonClicked (MyGUI::Widget* sender)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
||||||
|
|
||||||
if (mSpentAttributes.size() < 3)
|
if (mSpentAttributes.size() < 3)
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage36}");
|
MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage36}");
|
||||||
|
|
|
@ -165,15 +165,15 @@ namespace MWGui
|
||||||
|
|
||||||
buttons.push_back("newgame");
|
buttons.push_back("newgame");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getStateManager()->characterBegin()!=
|
|
||||||
MWBase::Environment::get().getStateManager()->characterEnd())
|
|
||||||
buttons.push_back("loadgame");
|
|
||||||
|
|
||||||
if (state==MWBase::StateManager::State_Running &&
|
if (state==MWBase::StateManager::State_Running &&
|
||||||
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1 &&
|
MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1 &&
|
||||||
MWBase::Environment::get().getWindowManager()->isSavingAllowed())
|
MWBase::Environment::get().getWindowManager()->isSavingAllowed())
|
||||||
buttons.push_back("savegame");
|
buttons.push_back("savegame");
|
||||||
|
|
||||||
|
if (MWBase::Environment::get().getStateManager()->characterBegin()!=
|
||||||
|
MWBase::Environment::get().getStateManager()->characterEnd())
|
||||||
|
buttons.push_back("loadgame");
|
||||||
|
|
||||||
buttons.push_back("options");
|
buttons.push_back("options");
|
||||||
|
|
||||||
if (state==MWBase::StateManager::State_NoGame)
|
if (state==MWBase::StateManager::State_NoGame)
|
||||||
|
|
|
@ -39,19 +39,19 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
||||||
|
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get(*iter).hasItemHealth(*iter))
|
if (iter->getClass().hasItemHealth(*iter))
|
||||||
{
|
{
|
||||||
int maxDurability = MWWorld::Class::get(*iter).getItemMaxHealth(*iter);
|
int maxDurability = iter->getClass().getItemMaxHealth(*iter);
|
||||||
int durability = (iter->getCellRef().mCharge == -1) ? maxDurability : iter->getCellRef().mCharge;
|
int durability = iter->getClass().getItemHealth(*iter);
|
||||||
if (maxDurability == durability)
|
if (maxDurability == durability)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int basePrice = MWWorld::Class::get(*iter).getValue(*iter);
|
int basePrice = iter->getClass().getValue(*iter);
|
||||||
float fRepairMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
float fRepairMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
.find("fRepairMult")->getFloat();
|
.find("fRepairMult")->getFloat();
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
|
||||||
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
|
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
|
||||||
|
|
||||||
|
|
||||||
std::string name = MWWorld::Class::get(*iter).getName(*iter)
|
std::string name = iter->getClass().getName(*iter)
|
||||||
+ " - " + boost::lexical_cast<std::string>(price)
|
+ " - " + boost::lexical_cast<std::string>(price)
|
||||||
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
.find("sgp")->getString();;
|
.find("sgp")->getString();;
|
||||||
|
@ -114,7 +114,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
|
||||||
{
|
{
|
||||||
// repair
|
// repair
|
||||||
MWWorld::Ptr item = *sender->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *sender->getUserData<MWWorld::Ptr>();
|
||||||
item.getCellRef().mCharge = MWWorld::Class::get(item).getItemMaxHealth(item);
|
item.getCellRef().setCharge(item.getClass().getItemMaxHealth(item));
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
|
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace MWGui
|
||||||
const ItemStack& item = mSourceModel->getItem(i);
|
const ItemStack& item = mSourceModel->getItem(i);
|
||||||
|
|
||||||
// Bound items may not be stolen
|
// Bound items may not be stolen
|
||||||
if (item.mBase.getCellRef().mRefID.size() > 6
|
if (item.mBase.getCellRef().getRefId().size() > 6
|
||||||
&& item.mBase.getCellRef().mRefID.substr(0,6) == "bound_")
|
&& item.mBase.getCellRef().getRefId().substr(0,6) == "bound_")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ namespace MWGui
|
||||||
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -200,7 +200,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -265,7 +265,7 @@ namespace MWGui
|
||||||
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
QuickKeyType type = *button->getUserData<QuickKeyType>();
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
if (type == Type_Item || type == Type_MagicItem)
|
if (type == Type_Item || type == Type_MagicItem)
|
||||||
{
|
{
|
||||||
|
@ -274,11 +274,11 @@ namespace MWGui
|
||||||
if (item.getRefData ().getCount() < 1)
|
if (item.getRefData ().getCount() < 1)
|
||||||
{
|
{
|
||||||
// Try searching for a compatible replacement
|
// Try searching for a compatible replacement
|
||||||
std::string id = item.getCellRef().mRefID;
|
std::string id = item.getCellRef().getRefId();
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, id))
|
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), id))
|
||||||
{
|
{
|
||||||
item = *it;
|
item = *it;
|
||||||
button->getChildAt(0)->setUserData(item);
|
button->getChildAt(0)->setUserData(item);
|
||||||
|
@ -290,7 +290,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// No replacement was found
|
// No replacement was found
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox (
|
MWBase::Environment::get().getWindowManager ()->messageBox (
|
||||||
"#{sQuickMenu5} " + MWWorld::Class::get(item).getName(item));
|
"#{sQuickMenu5} " + item.getClass().getName(item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ namespace MWGui
|
||||||
assert(it != store.end());
|
assert(it != store.end());
|
||||||
|
|
||||||
// equip, if it can be equipped
|
// equip, if it can be equipped
|
||||||
if (!MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
if (!item.getClass().getEquipmentSlots(item).first.empty())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ namespace MWGui
|
||||||
case Type_MagicItem:
|
case Type_MagicItem:
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = *button->getChildAt(0)->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *button->getChildAt(0)->getUserData<MWWorld::Ptr>();
|
||||||
key.mId = item.getCellRef().mRefID;
|
key.mId = item.getCellRef().getRefId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type_Magic:
|
case Type_Magic:
|
||||||
|
@ -458,11 +458,12 @@ namespace MWGui
|
||||||
MWWorld::Ptr item;
|
MWWorld::Ptr item;
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, id))
|
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), id))
|
||||||
{
|
{
|
||||||
if (item.isEmpty() ||
|
if (item.isEmpty() ||
|
||||||
// Prefer the stack with the lowest remaining uses
|
// Prefer the stack with the lowest remaining uses
|
||||||
(it->getCellRef().mCharge != -1 && (item.getCellRef().mCharge == -1 || it->getCellRef().mCharge < item.getCellRef().mCharge) ))
|
!item.getClass().hasItemHealth(*it) ||
|
||||||
|
it->getClass().getItemHealth(*it) < item.getClass().getItemHealth(item))
|
||||||
{
|
{
|
||||||
item = *it;
|
item = *it;
|
||||||
}
|
}
|
||||||
|
@ -522,8 +523,8 @@ namespace MWGui
|
||||||
const int spellHeight = 18;
|
const int spellHeight = 18;
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
/// \todo lots of copy&pasted code from SpellWindow
|
/// \todo lots of copy&pasted code from SpellWindow
|
||||||
|
@ -566,7 +567,7 @@ namespace MWGui
|
||||||
std::vector<MWWorld::Ptr> items;
|
std::vector<MWWorld::Ptr> items;
|
||||||
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
std::string enchantId = MWWorld::Class::get(*it).getEnchantment(*it);
|
std::string enchantId = it->getClass().getEnchantment(*it);
|
||||||
if (enchantId != "")
|
if (enchantId != "")
|
||||||
{
|
{
|
||||||
// only add items with "Cast once" or "Cast on use"
|
// only add items with "Cast once" or "Cast on use"
|
||||||
|
@ -645,7 +646,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
||||||
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
||||||
t->setCaption(MWWorld::Class::get(item).getName(item));
|
t->setCaption(item.getClass().getName(item));
|
||||||
t->setTextAlign(MyGUI::Align::Left);
|
t->setTextAlign(MyGUI::Align::Left);
|
||||||
t->setUserData(item);
|
t->setUserData(item);
|
||||||
t->setUserString("ToolTipType", "ItemPtr");
|
t->setUserString("ToolTipType", "ItemPtr");
|
||||||
|
|
|
@ -41,7 +41,7 @@ void Recharge::open()
|
||||||
void Recharge::start (const MWWorld::Ptr &item)
|
void Recharge::start (const MWWorld::Ptr &item)
|
||||||
{
|
{
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -56,7 +56,7 @@ void Recharge::updateView()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();
|
||||||
|
|
||||||
std::string soul = gem.getCellRef().mSoul;
|
std::string soul = gem.getCellRef().getSoul();
|
||||||
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
|
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
|
||||||
|
|
||||||
mChargeLabel->setCaptionWithReplacing("#{sCharges} " + boost::lexical_cast<std::string>(creature->mData.mSoul));
|
mChargeLabel->setCaptionWithReplacing("#{sCharges} " + boost::lexical_cast<std::string>(creature->mData.mSoul));
|
||||||
|
@ -85,7 +85,7 @@ void Recharge::updateView()
|
||||||
int currentY = 0;
|
int currentY = 0;
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin());
|
for (MWWorld::ContainerStoreIterator iter (store.begin());
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -93,20 +93,20 @@ void Recharge::updateView()
|
||||||
if (enchantmentName.empty())
|
if (enchantmentName.empty())
|
||||||
continue;
|
continue;
|
||||||
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
|
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
|
||||||
if (iter->getCellRef().mEnchantmentCharge >= enchantment->mData.mCharge
|
if (iter->getCellRef().getEnchantmentCharge() >= enchantment->mData.mCharge
|
||||||
|| iter->getCellRef().mEnchantmentCharge == -1)
|
|| iter->getCellRef().getEnchantmentCharge() == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MyGUI::TextBox* text = mView->createWidget<MyGUI::TextBox> (
|
MyGUI::TextBox* text = mView->createWidget<MyGUI::TextBox> (
|
||||||
"SandText", MyGUI::IntCoord(8, currentY, mView->getWidth()-8, 18), MyGUI::Align::Default);
|
"SandText", MyGUI::IntCoord(8, currentY, mView->getWidth()-8, 18), MyGUI::Align::Default);
|
||||||
text->setCaption(MWWorld::Class::get(*iter).getName(*iter));
|
text->setCaption(iter->getClass().getName(*iter));
|
||||||
text->setNeedMouseFocus(false);
|
text->setNeedMouseFocus(false);
|
||||||
currentY += 19;
|
currentY += 19;
|
||||||
|
|
||||||
MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> (
|
MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> (
|
||||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
path += iter->getClass().getInventoryIcon(*iter);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -118,7 +118,7 @@ void Recharge::updateView()
|
||||||
|
|
||||||
Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat>
|
Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat>
|
||||||
("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default);
|
("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default);
|
||||||
chargeWidget->setValue(iter->getCellRef().mEnchantmentCharge, enchantment->mData.mCharge);
|
chargeWidget->setValue(iter->getCellRef().getEnchantmentCharge(), enchantment->mData.mCharge);
|
||||||
chargeWidget->setNeedMouseFocus(false);
|
chargeWidget->setNeedMouseFocus(false);
|
||||||
|
|
||||||
currentY += 32 + 4;
|
currentY += 32 + 4;
|
||||||
|
@ -159,15 +159,15 @@ void Recharge::onItemClicked(MyGUI::Widget *sender)
|
||||||
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||||
if (roll < x)
|
if (roll < x)
|
||||||
{
|
{
|
||||||
std::string soul = gem.getCellRef().mSoul;
|
std::string soul = gem.getCellRef().getSoul();
|
||||||
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
|
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
|
||||||
|
|
||||||
float restored = creature->mData.mSoul * (roll / x);
|
float restored = creature->mData.mSoul * (roll / x);
|
||||||
|
|
||||||
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
|
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
|
||||||
item.getClass().getEnchantment(item));
|
item.getClass().getEnchantment(item));
|
||||||
item.getCellRef().mEnchantmentCharge =
|
item.getCellRef().setEnchantmentCharge(
|
||||||
std::min(item.getCellRef().mEnchantmentCharge + restored, static_cast<float>(enchantment->mData.mCharge));
|
std::min(item.getCellRef().getEnchantmentCharge() + restored, static_cast<float>(enchantment->mData.mCharge)));
|
||||||
|
|
||||||
player.getClass().skillUsageSucceeded (player, ESM::Skill::Enchant, 0);
|
player.getClass().skillUsageSucceeded (player, ESM::Skill::Enchant, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ void Repair::startRepairItem(const MWWorld::Ptr &item)
|
||||||
mRepair.setTool(item);
|
mRepair.setTool(item);
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
path += item.getClass().getInventoryIcon(item);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
@ -56,7 +56,7 @@ void Repair::updateRepairView()
|
||||||
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
mRepair.getTool().get<ESM::Repair>();
|
mRepair.getTool().get<ESM::Repair>();
|
||||||
|
|
||||||
int uses = (mRepair.getTool().getCellRef().mCharge != -1) ? mRepair.getTool().getCellRef().mCharge : ref->mBase->mData.mUses;
|
int uses = mRepair.getTool().getClass().getItemHealth(mRepair.getTool());
|
||||||
|
|
||||||
float quality = ref->mBase->mData.mQuality;
|
float quality = ref->mBase->mData.mQuality;
|
||||||
|
|
||||||
|
@ -90,28 +90,28 @@ void Repair::updateRepairView()
|
||||||
int currentY = 0;
|
int currentY = 0;
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get(*iter).hasItemHealth(*iter))
|
if (iter->getClass().hasItemHealth(*iter))
|
||||||
{
|
{
|
||||||
int maxDurability = MWWorld::Class::get(*iter).getItemMaxHealth(*iter);
|
int maxDurability = iter->getClass().getItemMaxHealth(*iter);
|
||||||
int durability = (iter->getCellRef().mCharge == -1) ? maxDurability : iter->getCellRef().mCharge;
|
int durability = iter->getClass().getItemHealth(*iter);
|
||||||
if (maxDurability == durability)
|
if (maxDurability == durability)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MyGUI::TextBox* text = mRepairView->createWidget<MyGUI::TextBox> (
|
MyGUI::TextBox* text = mRepairView->createWidget<MyGUI::TextBox> (
|
||||||
"SandText", MyGUI::IntCoord(8, currentY, mRepairView->getWidth()-8, 18), MyGUI::Align::Default);
|
"SandText", MyGUI::IntCoord(8, currentY, mRepairView->getWidth()-8, 18), MyGUI::Align::Default);
|
||||||
text->setCaption(MWWorld::Class::get(*iter).getName(*iter));
|
text->setCaption(iter->getClass().getName(*iter));
|
||||||
text->setNeedMouseFocus(false);
|
text->setNeedMouseFocus(false);
|
||||||
currentY += 19;
|
currentY += 19;
|
||||||
|
|
||||||
MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> (
|
MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> (
|
||||||
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
"ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default);
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
path += iter->getClass().getInventoryIcon(*iter);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
|
|
|
@ -256,7 +256,16 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mSaveList->addItem(it->mProfile.mDescription);
|
mSaveList->addItem(it->mProfile.mDescription);
|
||||||
}
|
}
|
||||||
onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
|
// When loading, Auto-select the first save, if there is one
|
||||||
|
if (mSaveList->getItemCount() && !mSaving)
|
||||||
|
{
|
||||||
|
mSaveList->setIndexSelected(0);
|
||||||
|
onSlotSelected(mSaveList, 0);
|
||||||
|
// Give key focus to save list so we can confirm the selection with Enter
|
||||||
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mSaveList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveGameDialog::onSlotSelected(MyGUI::ListBox *sender, size_t pos)
|
void SaveGameDialog::onSlotSelected(MyGUI::ListBox *sender, size_t pos)
|
||||||
|
|
|
@ -47,8 +47,8 @@ namespace
|
||||||
|
|
||||||
if (left.mBase.getTypeName() == right.mBase.getTypeName())
|
if (left.mBase.getTypeName() == right.mBase.getTypeName())
|
||||||
{
|
{
|
||||||
int cmp = MWWorld::Class::get(left.mBase).getName(left.mBase).compare(
|
int cmp = left.mBase.getClass().getName(left.mBase).compare(
|
||||||
MWWorld::Class::get(right.mBase).getName(right.mBase));
|
right.mBase.getClass().getName(right.mBase));
|
||||||
return cmp < 0;
|
return cmp < 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -114,7 +114,7 @@ namespace MWGui
|
||||||
if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
|
if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
|
||||||
return false;
|
return false;
|
||||||
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|
||||||
|| base.getCellRef().mSoul == ""))
|
|| base.getCellRef().getSoul() == ""))
|
||||||
return false;
|
return false;
|
||||||
if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted
|
if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted
|
||||||
|| (base.getTypeName() != typeid(ESM::Armor).name()
|
|| (base.getTypeName() != typeid(ESM::Armor).name()
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace MWGui
|
||||||
mPtr = actor;
|
mPtr = actor;
|
||||||
clearSpells();
|
clearSpells();
|
||||||
|
|
||||||
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
|
MWMechanics::Spells& merchantSpells = actor.getClass().getCreatureStats (actor).getSpells();
|
||||||
|
|
||||||
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
|
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ namespace MWGui
|
||||||
bool SpellBuyingWindow::playerHasSpell(const std::string &id)
|
bool SpellBuyingWindow::playerHasSpell(const std::string &id)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
|
MWMechanics::Spells& playerSpells = player.getClass().getCreatureStats (player).getSpells();
|
||||||
for (MWMechanics::Spells::TIterator it = playerSpells.begin(); it != playerSpells.end(); ++it)
|
for (MWMechanics::Spells::TIterator it = playerSpells.begin(); it != playerSpells.end(); ++it)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(id, it->first))
|
if (Misc::StringUtils::ciEqual(id, it->first))
|
||||||
|
@ -121,7 +121,7 @@ namespace MWGui
|
||||||
int price = *_sender->getUserData<int>();
|
int price = *_sender->getUserData<int>();
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
spells.add (mSpellsWidgetMap.find(_sender)->second);
|
spells.add (mSpellsWidgetMap.find(_sender)->second);
|
||||||
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);
|
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);
|
||||||
|
|
|
@ -353,7 +353,7 @@ namespace MWGui
|
||||||
|
|
||||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell);
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell);
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
spells.add (spell->mId);
|
spells.add (spell->mId);
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ namespace MWGui
|
||||||
// get the list of magic effects that are known to the player
|
// get the list of magic effects that are known to the player
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
std::vector<short> knownEffects;
|
std::vector<short> knownEffects;
|
||||||
|
|
|
@ -40,14 +40,14 @@ namespace MWGui
|
||||||
// TODO: Tracking add/remove/expire would be better than force updating every frame
|
// TODO: Tracking add/remove/expire would be better than force updating every frame
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
|
|
||||||
|
|
||||||
EffectSourceVisitor visitor;
|
EffectSourceVisitor visitor;
|
||||||
|
|
||||||
// permanent item enchantments & permanent spells
|
// permanent item enchantments & permanent spells
|
||||||
visitor.mIsPermanent = true;
|
visitor.mIsPermanent = true;
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
store.visitEffectSources(visitor);
|
store.visitEffectSources(visitor);
|
||||||
stats.getSpells().visitEffectSources(visitor);
|
stats.getSpells().visitEffectSources(visitor);
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ namespace MWGui
|
||||||
// retrieve all player spells, divide them into Powers and Spells and sort them
|
// retrieve all player spells, divide them into Powers and Spells and sort them
|
||||||
std::vector<std::string> spellList;
|
std::vector<std::string> spellList;
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||||
|
@ -122,7 +122,7 @@ namespace MWGui
|
||||||
std::vector<MWWorld::Ptr> items;
|
std::vector<MWWorld::Ptr> items;
|
||||||
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
std::string enchantId = MWWorld::Class::get(*it).getEnchantment(*it);
|
std::string enchantId = it->getClass().getEnchantment(*it);
|
||||||
if (enchantId != "")
|
if (enchantId != "")
|
||||||
{
|
{
|
||||||
// only add items with "Cast once" or "Cast on use"
|
// only add items with "Cast once" or "Cast on use"
|
||||||
|
@ -203,7 +203,7 @@ namespace MWGui
|
||||||
MWWorld::Ptr item = *it;
|
MWWorld::Ptr item = *it;
|
||||||
|
|
||||||
const ESM::Enchantment* enchant =
|
const ESM::Enchantment* enchant =
|
||||||
esmStore.get<ESM::Enchantment>().find(MWWorld::Class::get(item).getEnchantment(item));
|
esmStore.get<ESM::Enchantment>().find(item.getClass().getEnchantment(item));
|
||||||
|
|
||||||
// check if the item is currently equipped (will display in a different color)
|
// check if the item is currently equipped (will display in a different color)
|
||||||
bool equipped = false;
|
bool equipped = false;
|
||||||
|
@ -218,7 +218,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
||||||
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
|
||||||
t->setCaption(MWWorld::Class::get(item).getName(item));
|
t->setCaption(item.getClass().getName(item));
|
||||||
t->setTextAlign(MyGUI::Align::Left);
|
t->setTextAlign(MyGUI::Align::Left);
|
||||||
t->setUserData(item);
|
t->setUserData(item);
|
||||||
t->setUserString("ToolTipType", "ItemPtr");
|
t->setUserString("ToolTipType", "ItemPtr");
|
||||||
|
@ -238,7 +238,7 @@ namespace MWGui
|
||||||
int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10));
|
int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10));
|
||||||
|
|
||||||
std::string cost = boost::lexical_cast<std::string>(castCost);
|
std::string cost = boost::lexical_cast<std::string>(castCost);
|
||||||
int currentCharge = int(item.getCellRef().mEnchantmentCharge);
|
int currentCharge = int(item.getCellRef().getEnchantmentCharge());
|
||||||
if (currentCharge == -1)
|
if (currentCharge == -1)
|
||||||
currentCharge = enchant->mData.mCharge;
|
currentCharge = enchant->mData.mCharge;
|
||||||
std::string charge = boost::lexical_cast<std::string>(currentCharge);
|
std::string charge = boost::lexical_cast<std::string>(currentCharge);
|
||||||
|
@ -300,7 +300,7 @@ namespace MWGui
|
||||||
void SpellWindow::onEnchantedItemSelected(MyGUI::Widget* _sender)
|
void SpellWindow::onEnchantedItemSelected(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
||||||
|
|
||||||
// retrieve ContainerStoreIterator to the item
|
// retrieve ContainerStoreIterator to the item
|
||||||
|
@ -316,7 +316,7 @@ namespace MWGui
|
||||||
|
|
||||||
// equip, if it can be equipped and is not already equipped
|
// equip, if it can be equipped and is not already equipped
|
||||||
if (_sender->getUserString("Equipped") == "false"
|
if (_sender->getUserString("Equipped") == "false"
|
||||||
&& !MWWorld::Class::get(item).getEquipmentSlots(item).first.empty())
|
&& !item.getClass().getEquipmentSlots(item).first.empty())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
std::string spellId = _sender->getUserString("Spell");
|
std::string spellId = _sender->getUserString("Spell");
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
||||||
{
|
{
|
||||||
|
@ -384,7 +384,7 @@ namespace MWGui
|
||||||
void SpellWindow::onDeleteSpellAccept()
|
void SpellWindow::onDeleteSpellAccept()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::Spells& spells = stats.getSpells();
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell() == mSpellToDelete)
|
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell() == mSpellToDelete)
|
||||||
|
|
|
@ -228,7 +228,7 @@ namespace MWGui
|
||||||
NoDrop::onFrame(dt);
|
NoDrop::onFrame(dt);
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::NpcStats &PCstats = MWWorld::Class::get(player).getNpcStats(player);
|
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
|
||||||
|
|
||||||
// level progress
|
// level progress
|
||||||
MyGUI::Widget* levelWidget;
|
MyGUI::Widget* levelWidget;
|
||||||
|
@ -459,7 +459,7 @@ namespace MWGui
|
||||||
addSeparator(coord1, coord2);
|
addSeparator(coord1, coord2);
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::NpcStats &PCstats = MWWorld::Class::get(player).getNpcStats(player);
|
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
|
||||||
const std::set<std::string> &expelled = PCstats.getExpelled();
|
const std::set<std::string> &expelled = PCstats.getExpelled();
|
||||||
|
|
||||||
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace MWGui
|
||||||
if (mFocusObject.isEmpty ())
|
if (mFocusObject.isEmpty ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MWWorld::Class& objectclass = MWWorld::Class::get (mFocusObject);
|
const MWWorld::Class& objectclass = mFocusObject.getClass();
|
||||||
|
|
||||||
MyGUI::IntSize tooltipSize;
|
MyGUI::IntSize tooltipSize;
|
||||||
if ((!objectclass.hasToolTip(mFocusObject))&&(MWBase::Environment::get().getWindowManager()->getMode() == GM_Console))
|
if ((!objectclass.hasToolTip(mFocusObject))&&(MWBase::Environment::get().getWindowManager()->getMode() == GM_Console))
|
||||||
|
@ -97,7 +97,7 @@ namespace MWGui
|
||||||
setCoord(0, 0, 300, 300);
|
setCoord(0, 0, 300, 300);
|
||||||
mDynamicToolTipBox->setVisible(true);
|
mDynamicToolTipBox->setVisible(true);
|
||||||
ToolTipInfo info;
|
ToolTipInfo info;
|
||||||
info.caption=mFocusObject.getCellRef().mRefID;
|
info.caption=mFocusObject.getCellRef().getRefId();
|
||||||
info.icon="";
|
info.icon="";
|
||||||
tooltipSize = createToolTip(info);
|
tooltipSize = createToolTip(info);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::IntSize tooltipSize;
|
MyGUI::IntSize tooltipSize;
|
||||||
|
|
||||||
const MWWorld::Class& object = MWWorld::Class::get (mFocusObject);
|
const MWWorld::Class& object = mFocusObject.getClass();
|
||||||
if (!object.hasToolTip(mFocusObject))
|
if (!object.hasToolTip(mFocusObject))
|
||||||
{
|
{
|
||||||
mDynamicToolTipBox->setVisible(false);
|
mDynamicToolTipBox->setVisible(false);
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace MWGui
|
||||||
|
|
||||||
int services = 0;
|
int services = 0;
|
||||||
if (!mMerchant.isEmpty())
|
if (!mMerchant.isEmpty())
|
||||||
services = MWWorld::Class::get(mMerchant).getServices(mMerchant);
|
services = mMerchant.getClass().getServices(mMerchant);
|
||||||
|
|
||||||
mItems.clear();
|
mItems.clear();
|
||||||
// add regular items
|
// add regular items
|
||||||
|
@ -148,14 +148,14 @@ namespace MWGui
|
||||||
if(!mMerchant.isEmpty())
|
if(!mMerchant.isEmpty())
|
||||||
{
|
{
|
||||||
MWWorld::Ptr base = item.mBase;
|
MWWorld::Ptr base = item.mBase;
|
||||||
if(Misc::StringUtils::ciEqual(base.getCellRef().mRefID, MWWorld::ContainerStore::sGoldId))
|
if(Misc::StringUtils::ciEqual(base.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
|
||||||
continue;
|
continue;
|
||||||
if(!MWWorld::Class::get(base).canSell(base, services))
|
if(!base.getClass().canSell(base, services))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Bound items may not be bought
|
// Bound items may not be bought
|
||||||
if (item.mBase.getCellRef().mRefID.size() > 6
|
if (item.mBase.getCellRef().getRefId().size() > 6
|
||||||
&& item.mBase.getCellRef().mRefID.substr(0,6) == "bound_")
|
&& item.mBase.getCellRef().getRefId().substr(0,6) == "bound_")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ namespace MWGui
|
||||||
if(mMerchant.getClass().hasInventoryStore(mMerchant))
|
if(mMerchant.getClass().hasInventoryStore(mMerchant))
|
||||||
{
|
{
|
||||||
bool isEquipped = false;
|
bool isEquipped = false;
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get(mMerchant).getInventoryStore(mMerchant);
|
MWWorld::InventoryStore& store = mMerchant.getClass().getInventoryStore(mMerchant);
|
||||||
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator equipped = store.getSlot(slot);
|
MWWorld::ContainerStoreIterator equipped = store.getSlot(slot);
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace MWGui
|
||||||
|
|
||||||
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
||||||
// or we end up using a possibly invalid model.
|
// or we end up using a possibly invalid model.
|
||||||
setTitle(MWWorld::Class::get(actor).getName(actor));
|
setTitle(actor.getClass().getName(actor));
|
||||||
|
|
||||||
onFilterChanged(mFilterAll);
|
onFilterChanged(mFilterAll);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ namespace MWGui
|
||||||
|
|
||||||
int TradeWindow::getMerchantServices()
|
int TradeWindow::getMerchantServices()
|
||||||
{
|
{
|
||||||
return MWWorld::Class::get(mPtr).getServices(mPtr);
|
return mPtr.getClass().getServices(mPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TradeWindow::onItemSelected (int index)
|
void TradeWindow::onItemSelected (int index)
|
||||||
|
@ -150,7 +150,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||||
std::string message = "#{sQuanityMenuMessage02}";
|
std::string message = "#{sQuanityMenuMessage02}";
|
||||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
dialog->open(object.getClass().getName(object), message, count);
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);
|
||||||
mItemToSell = mSortModel->mapToSource(index);
|
mItemToSell = mSortModel->mapToSource(index);
|
||||||
|
@ -165,7 +165,7 @@ namespace MWGui
|
||||||
void TradeWindow::sellItem(MyGUI::Widget* sender, int count)
|
void TradeWindow::sellItem(MyGUI::Widget* sender, int count)
|
||||||
{
|
{
|
||||||
const ItemStack& item = mTradeModel->getItem(mItemToSell);
|
const ItemStack& item = mTradeModel->getItem(mItemToSell);
|
||||||
std::string sound = MWWorld::Class::get(item.mBase).getDownSoundId(item.mBase);
|
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
||||||
|
@ -208,7 +208,7 @@ namespace MWGui
|
||||||
|
|
||||||
void TradeWindow::addOrRemoveGold(int amount, const MWWorld::Ptr& actor)
|
void TradeWindow::addOrRemoveGold(int amount, const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(actor).getContainerStore(actor);
|
MWWorld::ContainerStore& store = actor.getClass().getContainerStore(actor);
|
||||||
|
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
{
|
{
|
||||||
|
@ -277,7 +277,7 @@ namespace MWGui
|
||||||
// check if the player is attempting to sell back an item stolen from this actor
|
// check if the player is attempting to sell back an item stolen from this actor
|
||||||
for (std::vector<ItemStack>::iterator it = merchantBought.begin(); it != merchantBought.end(); ++it)
|
for (std::vector<ItemStack>::iterator it = merchantBought.begin(); it != merchantBought.end(); ++it)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->mBase.getCellRef().mOwner, mPtr.getCellRef().mRefID))
|
if (Misc::StringUtils::ciEqual(it->mBase.getCellRef().getOwner(), mPtr.getCellRef().getRefId()))
|
||||||
{
|
{
|
||||||
std::string msg = gmst.find("sNotifyMessage49")->getString();
|
std::string msg = gmst.find("sNotifyMessage49")->getString();
|
||||||
if (msg.find("%s") != std::string::npos)
|
if (msg.find("%s") != std::string::npos)
|
||||||
|
@ -442,7 +442,7 @@ namespace MWGui
|
||||||
|
|
||||||
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
|
void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem)
|
||||||
{
|
{
|
||||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count, boughtItem);
|
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, boughtItem);
|
||||||
|
|
||||||
mCurrentBalance += diff;
|
mCurrentBalance += diff;
|
||||||
mCurrentMerchantOffer += diff;
|
mCurrentMerchantOffer += diff;
|
||||||
|
@ -452,7 +452,7 @@ namespace MWGui
|
||||||
|
|
||||||
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
|
void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem)
|
||||||
{
|
{
|
||||||
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count, !soldItem);
|
int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, item.getClass().getValue(item) * count, !soldItem);
|
||||||
|
|
||||||
mCurrentBalance -= diff;
|
mCurrentBalance -= diff;
|
||||||
mCurrentMerchantOffer -= diff;
|
mCurrentMerchantOffer -= diff;
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace MWGui
|
||||||
|
|
||||||
mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
|
mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
|
||||||
|
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(actor).getNpcStats (actor);
|
MWMechanics::NpcStats& npcStats = actor.getClass().getNpcStats (actor);
|
||||||
|
|
||||||
// NPC can train you in his best 3 skills
|
// NPC can train you in his best 3 skills
|
||||||
std::vector< std::pair<int, int> > bestSkills;
|
std::vector< std::pair<int, int> > bestSkills;
|
||||||
|
@ -73,7 +73,7 @@ namespace MWGui
|
||||||
MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator ();
|
MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator ();
|
||||||
MyGUI::Gui::getInstance ().destroyWidgets (widgets);
|
MyGUI::Gui::getInstance ().destroyWidgets (widgets);
|
||||||
|
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
||||||
|
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
@ -115,7 +115,7 @@ namespace MWGui
|
||||||
int skillId = *sender->getUserData<int>();
|
int skillId = *sender->getUserData<int>();
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);
|
||||||
|
|
||||||
const MWWorld::ESMStore &store =
|
const MWWorld::ESMStore &store =
|
||||||
MWBase::Environment::get().getWorld()->getStore();
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
@ -123,7 +123,7 @@ namespace MWGui
|
||||||
int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt ();
|
int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt ();
|
||||||
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
|
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
|
||||||
|
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mPtr).getNpcStats (mPtr);
|
MWMechanics::NpcStats& npcStats = mPtr.getClass().getNpcStats (mPtr);
|
||||||
if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ())
|
if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sServiceTrainingWords}");
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sServiceTrainingWords}");
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWorld()->changeToExteriorCell(pos);
|
MWBase::Environment::get().getWorld()->changeToExteriorCell(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Class::get(player).adjustPosition(player);
|
player.getClass().adjustPosition(player);
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
|
||||||
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0);
|
MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0);
|
||||||
|
|
|
@ -118,11 +118,12 @@ namespace MWGui
|
||||||
|
|
||||||
void WaitDialog::startWaiting(int hoursToWait)
|
void WaitDialog::startWaiting(int hoursToWait)
|
||||||
{
|
{
|
||||||
|
if(Settings::Manager::getBool("autosave","Saves") && mSleeping) //autosaves when enabled and sleeping
|
||||||
|
MWBase::Environment::get().getStateManager()->quickSave("Autosave");
|
||||||
|
|
||||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
world->getFader ()->fadeOut(0.2);
|
world->getFader ()->fadeOut(0.2);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
if(Settings::Manager::getBool("autosave","Saves") && mSleeping) //autosaves when enabled and sleeping (Not resting, apparently)
|
|
||||||
MWBase::Environment::get().getStateManager()->quickSave("Autosave");
|
|
||||||
mProgressBar.setVisible (true);
|
mProgressBar.setVisible (true);
|
||||||
|
|
||||||
mWaiting = true;
|
mWaiting = true;
|
||||||
|
@ -171,11 +172,11 @@ namespace MWGui
|
||||||
void WaitDialog::setCanRest (bool canRest)
|
void WaitDialog::setCanRest (bool canRest)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
bool full = (stats.getFatigue().getCurrent() >= stats.getFatigue().getModified())
|
bool full = (stats.getFatigue().getCurrent() >= stats.getFatigue().getModified())
|
||||||
&& (stats.getHealth().getCurrent() >= stats.getHealth().getModified())
|
&& (stats.getHealth().getCurrent() >= stats.getHealth().getModified())
|
||||||
&& (stats.getMagicka().getCurrent() >= stats.getMagicka().getModified());
|
&& (stats.getMagicka().getCurrent() >= stats.getMagicka().getModified());
|
||||||
MWMechanics::NpcStats& npcstats = MWWorld::Class::get(player).getNpcStats(player);
|
MWMechanics::NpcStats& npcstats = player.getClass().getNpcStats(player);
|
||||||
bool werewolf = npcstats.isWerewolf();
|
bool werewolf = npcstats.isWerewolf();
|
||||||
|
|
||||||
mUntilHealedButton->setVisible(canRest && !full);
|
mUntilHealedButton->setVisible(canRest && !full);
|
||||||
|
@ -218,8 +219,20 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurHour > mHours)
|
if (mCurHour > mHours)
|
||||||
|
{
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
|
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
const MWMechanics::NpcStats &pcstats = player.getClass().getNpcStats(player);
|
||||||
|
|
||||||
|
// trigger levelup if possible
|
||||||
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
if (mSleeping && pcstats.getLevelProgress () >= gmst.find("iLevelUpTotal")->getInt())
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (GM_Levelup);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitDialog::stopWaiting ()
|
void WaitDialog::stopWaiting ()
|
||||||
|
@ -229,17 +242,6 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Rest);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Rest);
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_RestBed);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_RestBed);
|
||||||
mWaiting = false;
|
mWaiting = false;
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
||||||
const MWMechanics::NpcStats &pcstats = MWWorld::Class::get(player).getNpcStats(player);
|
|
||||||
|
|
||||||
// trigger levelup if possible
|
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
||||||
if (mSleeping && pcstats.getLevelProgress () >= gmst.find("iLevelUpTotal")->getInt())
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (GM_Levelup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1027,20 +1027,20 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mSelectedSpell = "";
|
mSelectedSpell = "";
|
||||||
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
||||||
.find(MWWorld::Class::get(item).getEnchantment(item));
|
.find(item.getClass().getEnchantment(item));
|
||||||
|
|
||||||
int chargePercent = (item.getCellRef().mEnchantmentCharge == -1) ? 100
|
int chargePercent = (item.getCellRef().getEnchantmentCharge() == -1) ? 100
|
||||||
: (item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100);
|
: (item.getCellRef().getEnchantmentCharge() / static_cast<float>(ench->mData.mCharge) * 100);
|
||||||
mHud->setSelectedEnchantItem(item, chargePercent);
|
mHud->setSelectedEnchantItem(item, chargePercent);
|
||||||
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
mSpellWindow->setTitle(item.getClass().getName(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
||||||
{
|
{
|
||||||
int durabilityPercent = (item.getCellRef().mCharge == -1) ? 100
|
int durabilityPercent =
|
||||||
: (item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100);
|
(item.getClass().getItemHealth(item) / static_cast<float>(item.getClass().getItemMaxHealth(item)) * 100);
|
||||||
mHud->setSelectedWeapon(item, durabilityPercent);
|
mHud->setSelectedWeapon(item, durabilityPercent);
|
||||||
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
mInventoryWindow->setTitle(item.getClass().getName(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::unsetSelectedSpell()
|
void WindowManager::unsetSelectedSpell()
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace MWInput
|
||||||
|
|
||||||
if (action == A_Use)
|
if (action == A_Use)
|
||||||
{
|
{
|
||||||
MWWorld::Class::get(mPlayer->getPlayer()).getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
|
mPlayer->getPlayer().getClass().getCreatureStats(mPlayer->getPlayer()).setAttackingOrSpell(currentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentValue == 1)
|
if (currentValue == 1)
|
||||||
|
@ -359,7 +359,7 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
mOverencumberedMessageDelay -= dt;
|
mOverencumberedMessageDelay -= dt;
|
||||||
if (MWWorld::Class::get(player).getEncumbrance(player) >= MWWorld::Class::get(player).getCapacity(player))
|
if (player.getClass().getEncumbrance(player) >= player.getClass().getCapacity(player))
|
||||||
{
|
{
|
||||||
mPlayer->setAutoMove (false);
|
mPlayer->setAutoMove (false);
|
||||||
if (mOverencumberedMessageDelay <= 0)
|
if (mOverencumberedMessageDelay <= 0)
|
||||||
|
@ -492,7 +492,8 @@ namespace MWInput
|
||||||
}
|
}
|
||||||
if (arg.keysym.sym == SDLK_x && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
if (arg.keysym.sym == SDLK_x && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
||||||
{
|
{
|
||||||
std::string text = edit->getTextSelection();
|
// Discard color codes and other escape characters
|
||||||
|
std::string text = MyGUI::TextIterator::getOnlyText(edit->getTextSelection());
|
||||||
if (text.length())
|
if (text.length())
|
||||||
{
|
{
|
||||||
SDL_SetClipboardText(text.c_str());
|
SDL_SetClipboardText(text.c_str());
|
||||||
|
@ -504,7 +505,8 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
if (arg.keysym.sym == SDLK_c && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
if (arg.keysym.sym == SDLK_c && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
||||||
{
|
{
|
||||||
std::string text = edit->getTextSelection();
|
// Discard color codes and other escape characters
|
||||||
|
std::string text = MyGUI::TextIterator::getOnlyText(edit->getTextSelection());
|
||||||
if (text.length())
|
if (text.length())
|
||||||
SDL_SetClipboardText(text.c_str());
|
SDL_SetClipboardText(text.c_str());
|
||||||
}
|
}
|
||||||
|
@ -664,7 +666,7 @@ namespace MWInput
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Not allowed if no spell selected
|
// Not allowed if no spell selected
|
||||||
MWWorld::InventoryStore& inventory = MWWorld::Class::get(mPlayer->getPlayer()).getInventoryStore(mPlayer->getPlayer());
|
MWWorld::InventoryStore& inventory = mPlayer->getPlayer().getClass().getInventoryStore(mPlayer->getPlayer());
|
||||||
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() &&
|
if (MWBase::Environment::get().getWindowManager()->getSelectedSpell().empty() &&
|
||||||
inventory.getSelectedEnchantItem() == inventory.end())
|
inventory.getSelectedEnchantItem() == inventory.end())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -62,17 +62,17 @@ bool disintegrateSlot (MWWorld::Ptr ptr, int slot, float disintegrate)
|
||||||
{
|
{
|
||||||
if (!item->getClass().hasItemHealth(*item))
|
if (!item->getClass().hasItemHealth(*item))
|
||||||
return false;
|
return false;
|
||||||
if (item->getCellRef().mCharge == -1)
|
int charge = item->getClass().getItemHealth(*item);
|
||||||
item->getCellRef().mCharge = item->getClass().getItemMaxHealth(*item);
|
|
||||||
|
|
||||||
if (item->getCellRef().mCharge == 0)
|
if (charge == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
item->getCellRef().mCharge -=
|
charge -=
|
||||||
std::min(disintegrate,
|
std::min(disintegrate,
|
||||||
static_cast<float>(item->getCellRef().mCharge));
|
static_cast<float>(charge));
|
||||||
|
item->getCellRef().setCharge(charge);
|
||||||
|
|
||||||
if (item->getCellRef().mCharge == 0)
|
if (charge == 0)
|
||||||
{
|
{
|
||||||
// Will unequip the broken item and try to find a replacement
|
// Will unequip the broken item and try to find a replacement
|
||||||
if (ptr.getRefData().getHandle() != "player")
|
if (ptr.getRefData().getHandle() != "player")
|
||||||
|
@ -147,13 +147,13 @@ namespace MWMechanics
|
||||||
for (MWWorld::ContainerStoreIterator it = container.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
for (MWWorld::ContainerStoreIterator it = container.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||||
it != container.end(); ++it)
|
it != container.end(); ++it)
|
||||||
{
|
{
|
||||||
const std::string& id = it->getCellRef().mRefID;
|
const std::string& id = it->getCellRef().getRefId();
|
||||||
if (id.size() >= soulgemFilter.size()
|
if (id.size() >= soulgemFilter.size()
|
||||||
&& id.substr(0,soulgemFilter.size()) == soulgemFilter)
|
&& id.substr(0,soulgemFilter.size()) == soulgemFilter)
|
||||||
{
|
{
|
||||||
float thisGemCapacity = it->get<ESM::Miscellaneous>()->mBase->mData.mValue * fSoulgemMult;
|
float thisGemCapacity = it->get<ESM::Miscellaneous>()->mBase->mData.mValue * fSoulgemMult;
|
||||||
if (thisGemCapacity >= creatureSoulValue && thisGemCapacity < gemCapacity
|
if (thisGemCapacity >= creatureSoulValue && thisGemCapacity < gemCapacity
|
||||||
&& it->getCellRef().mSoul.empty())
|
&& it->getCellRef().getSoul().empty())
|
||||||
{
|
{
|
||||||
gem = it;
|
gem = it;
|
||||||
gemCapacity = thisGemCapacity;
|
gemCapacity = thisGemCapacity;
|
||||||
|
@ -166,7 +166,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
// Set the soul on just one of the gems, not the whole stack
|
// Set the soul on just one of the gems, not the whole stack
|
||||||
gem->getContainerStore()->unstack(*gem, caster);
|
gem->getContainerStore()->unstack(*gem, caster);
|
||||||
gem->getCellRef().mSoul = mCreature.getCellRef().mRefID;
|
gem->getCellRef().setSoul(mCreature.getCellRef().getRefId());
|
||||||
|
|
||||||
if (caster.getRefData().getHandle() == "player")
|
if (caster.getRefData().getHandle() == "player")
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}");
|
||||||
|
@ -187,10 +187,18 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer)
|
void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer)
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get(actor1).getCreatureStats(actor1);
|
CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1);
|
||||||
|
|
||||||
if (againstPlayer && creatureStats.isHostile()) return; // already fighting against player
|
if (againstPlayer && creatureStats.isHostile()) return; // already fighting against player
|
||||||
|
|
||||||
|
// pure water creatures won't try to fight with the target on the ground
|
||||||
|
// except that creature is already hostile
|
||||||
|
if ((againstPlayer || !creatureStats.isHostile())
|
||||||
|
&& ((actor1.getClass().canSwim(actor1) && !actor1.getClass().canWalk(actor1) // pure water creature
|
||||||
|
&& !MWBase::Environment::get().getWorld()->isSwimming(actor2))
|
||||||
|
|| (!actor1.getClass().canSwim(actor1) && MWBase::Environment::get().getWorld()->isSwimming(actor2)))) // creature can't swim to target
|
||||||
|
return;
|
||||||
|
|
||||||
float fight;
|
float fight;
|
||||||
|
|
||||||
if (againstPlayer)
|
if (againstPlayer)
|
||||||
|
@ -244,13 +252,13 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
|
void Actors::adjustMagicEffects (const MWWorld::Ptr& creature)
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature);
|
CreatureStats& creatureStats = creature.getClass().getCreatureStats (creature);
|
||||||
|
|
||||||
MagicEffects now = creatureStats.getSpells().getMagicEffects();
|
MagicEffects now = creatureStats.getSpells().getMagicEffects();
|
||||||
|
|
||||||
if (creature.getTypeName()==typeid (ESM::NPC).name())
|
if (creature.getTypeName()==typeid (ESM::NPC).name())
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = MWWorld::Class::get (creature).getInventoryStore (creature);
|
MWWorld::InventoryStore& store = creature.getClass().getInventoryStore (creature);
|
||||||
now += store.getMagicEffects();
|
now += store.getMagicEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +273,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
|
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
|
||||||
|
|
||||||
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getBase();
|
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getBase();
|
||||||
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getBase();
|
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getBase();
|
||||||
|
@ -333,7 +341,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
CreatureStats &creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
CreatureStats &creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||||
const MagicEffects &effects = creatureStats.getMagicEffects();
|
const MagicEffects &effects = creatureStats.getMagicEffects();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
@ -546,7 +554,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* store = ptr.getCell();
|
MWWorld::CellStore* store = ptr.getCell();
|
||||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1);
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), creatureID, 1);
|
||||||
ref.getPtr().getCellRef().mPos = ipos;
|
ref.getPtr().getCellRef().setPosition(ipos);
|
||||||
|
|
||||||
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
||||||
|
|
||||||
|
@ -600,7 +608,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr)
|
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
NpcStats &npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
NpcStats &npcStats = ptr.getClass().getNpcStats(ptr);
|
||||||
const MagicEffects &effects = npcStats.getMagicEffects();
|
const MagicEffects &effects = npcStats.getMagicEffects();
|
||||||
|
|
||||||
// skills
|
// skills
|
||||||
|
@ -656,7 +664,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
bool isPlayer = ptr.getRefData().getHandle()=="player";
|
bool isPlayer = ptr.getRefData().getHandle()=="player";
|
||||||
|
|
||||||
MWWorld::InventoryStore &inventoryStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
|
MWWorld::InventoryStore &inventoryStore = ptr.getClass().getInventoryStore(ptr);
|
||||||
MWWorld::ContainerStoreIterator heldIter =
|
MWWorld::ContainerStoreIterator heldIter =
|
||||||
inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
/**
|
/**
|
||||||
|
@ -678,7 +686,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (torch != inventoryStore.end())
|
if (torch != inventoryStore.end())
|
||||||
{
|
{
|
||||||
if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isHostile())
|
if (!ptr.getClass().getCreatureStats (ptr).isHostile())
|
||||||
{
|
{
|
||||||
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
||||||
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
||||||
|
@ -755,8 +763,8 @@ namespace MWMechanics
|
||||||
if (ptr != player && ptr.getClass().isNpc())
|
if (ptr != player && ptr.getClass().isNpc())
|
||||||
{
|
{
|
||||||
// get stats of witness
|
// get stats of witness
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||||
NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
NpcStats& npcStats = ptr.getClass().getNpcStats(ptr);
|
||||||
|
|
||||||
if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.isHostile())
|
if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.isHostile())
|
||||||
{
|
{
|
||||||
|
@ -824,7 +832,7 @@ namespace MWMechanics
|
||||||
void Actors::addActor (const MWWorld::Ptr& ptr, bool updateImmediately)
|
void Actors::addActor (const MWWorld::Ptr& ptr, bool updateImmediately)
|
||||||
{
|
{
|
||||||
// erase previous death events since we are currently only tracking them while in an active cell
|
// erase previous death events since we are currently only tracking them while in an active cell
|
||||||
MWWorld::Class::get(ptr).getCreatureStats(ptr).clearHasDied();
|
ptr.getClass().getCreatureStats(ptr).clearHasDied();
|
||||||
|
|
||||||
removeActor(ptr);
|
removeActor(ptr);
|
||||||
|
|
||||||
|
@ -964,7 +972,7 @@ namespace MWMechanics
|
||||||
// Kill dead actors, update some variables
|
// Kill dead actors, update some variables
|
||||||
for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
|
const MWWorld::Class &cls = iter->first.getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
||||||
|
|
||||||
//KnockedOutOneFrameLogic
|
//KnockedOutOneFrameLogic
|
||||||
|
@ -1137,12 +1145,12 @@ namespace MWMechanics
|
||||||
std::list<MWWorld::Ptr> list;
|
std::list<MWWorld::Ptr> list;
|
||||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
|
const MWWorld::Class &cls = iter->first.getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
||||||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
|
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
|
||||||
{
|
{
|
||||||
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
|
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
|
||||||
if(package->getFollowedActor() == actor.getCellRef().mRefID)
|
if(package->getFollowedActor() == actor.getCellRef().getRefId())
|
||||||
list.push_front(iter->first);
|
list.push_front(iter->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1166,7 @@ namespace MWMechanics
|
||||||
neighbors); //only care about those within the alarm disance
|
neighbors); //only care about those within the alarm disance
|
||||||
for(std::vector<MWWorld::Ptr>::iterator iter(neighbors.begin());iter != neighbors.end();iter++)
|
for(std::vector<MWWorld::Ptr>::iterator iter(neighbors.begin());iter != neighbors.end();iter++)
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(*iter);
|
const MWWorld::Class &cls = iter->getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(*iter);
|
CreatureStats &stats = cls.getCreatureStats(*iter);
|
||||||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close
|
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
||||||
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
|
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor,float duration
|
||||||
MWBase::Environment::get().getMechanicsManager()->getActorsInRange(Ogre::Vector3(pos.pos[0],pos.pos[1],pos.pos[2]),100,actors);
|
MWBase::Environment::get().getMechanicsManager()->getActorsInRange(Ogre::Vector3(pos.pos[0],pos.pos[1],pos.pos[2]),100,actors);
|
||||||
for(std::vector<MWWorld::Ptr>::iterator it = actors.begin(); it != actors.end(); it++) {
|
for(std::vector<MWWorld::Ptr>::iterator it = actors.begin(); it != actors.end(); it++) {
|
||||||
if(*it != MWBase::Environment::get().getWorld()->getPlayerPtr()) { //Not the player
|
if(*it != MWBase::Environment::get().getWorld()->getPlayerPtr()) { //Not the player
|
||||||
MWMechanics::AiSequence& seq = MWWorld::Class::get(*it).getCreatureStats(*it).getAiSequence();
|
MWMechanics::AiSequence& seq = it->getClass().getCreatureStats(*it).getAiSequence();
|
||||||
if(seq.getTypeId() != MWMechanics::AiPackage::TypeIdAvoidDoor) { //Only add it once
|
if(seq.getTypeId() != MWMechanics::AiPackage::TypeIdAvoidDoor) { //Only add it once
|
||||||
seq.stack(MWMechanics::AiAvoidDoor(mDoorPtr),*it);
|
seq.stack(MWMechanics::AiAvoidDoor(mDoorPtr),*it);
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,6 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor,float duration
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MWMechanics::AiAvoidDoor::getAvoidedDoor()
|
|
||||||
{
|
|
||||||
return mDoorPtr.getCellRef().mRefID;
|
|
||||||
}
|
|
||||||
|
|
||||||
MWMechanics::AiAvoidDoor *MWMechanics::AiAvoidDoor::clone() const
|
MWMechanics::AiAvoidDoor *MWMechanics::AiAvoidDoor::clone() const
|
||||||
{
|
{
|
||||||
return new AiAvoidDoor(*this);
|
return new AiAvoidDoor(*this);
|
||||||
|
|
|
@ -24,9 +24,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
/// Returns the door being avoided
|
|
||||||
std::string getAvoidedDoor();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float mDuration;
|
float mDuration;
|
||||||
MWWorld::Ptr mDoorPtr;
|
MWWorld::Ptr mDoorPtr;
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace
|
||||||
|
|
||||||
// cast up-down ray with some offset from actor position to check for pits/obstacles on the way to target;
|
// cast up-down ray with some offset from actor position to check for pits/obstacles on the way to target;
|
||||||
// magnitude of pits/obstacles is defined by PATHFIND_Z_REACH
|
// magnitude of pits/obstacles is defined by PATHFIND_Z_REACH
|
||||||
bool checkWayIsClear(const Ogre::Vector3& from, const Ogre::Vector3& to, float offset)
|
bool checkWayIsClear(const Ogre::Vector3& from, const Ogre::Vector3& to, float offsetXY)
|
||||||
{
|
{
|
||||||
if((to - from).length() >= PATHFIND_CAUTION_DIST || abs(from.z - to.z) <= PATHFIND_Z_REACH)
|
if((to - from).length() >= PATHFIND_CAUTION_DIST || abs(from.z - to.z) <= PATHFIND_Z_REACH)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace
|
||||||
dir.z = 0;
|
dir.z = 0;
|
||||||
dir.normalise();
|
dir.normalise();
|
||||||
float verticalOffset = 200; // instead of '200' here we want the height of the actor
|
float verticalOffset = 200; // instead of '200' here we want the height of the actor
|
||||||
Ogre::Vector3 _from = from + dir*offset + Ogre::Vector3::UNIT_Z * verticalOffset;
|
Ogre::Vector3 _from = from + dir*offsetXY + Ogre::Vector3::UNIT_Z * verticalOffset;
|
||||||
|
|
||||||
// cast up-down ray and find height in world space of hit
|
// cast up-down ray and find height in world space of hit
|
||||||
float h = _from.z - MWBase::Environment::get().getWorld()->getDistToNearestRayHit(_from, -Ogre::Vector3::UNIT_Z, verticalOffset + PATHFIND_Z_REACH + 1);
|
float h = _from.z - MWBase::Environment::get().getWorld()->getDistToNearestRayHit(_from, -Ogre::Vector3::UNIT_Z, verticalOffset + PATHFIND_Z_REACH + 1);
|
||||||
|
@ -149,13 +149,27 @@ namespace MWMechanics
|
||||||
bool AiCombat::execute (const MWWorld::Ptr& actor,float duration)
|
bool AiCombat::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
{
|
{
|
||||||
//General description
|
//General description
|
||||||
if(actor.getClass().getCreatureStats(actor).isDead()) return true;
|
if(actor.getClass().getCreatureStats(actor).isDead())
|
||||||
|
return true;
|
||||||
|
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
||||||
|
|
||||||
if(target.getClass().getCreatureStats(target).isDead())
|
if(target.getClass().getCreatureStats(target).isDead())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
const MWWorld::Class& actorClass = actor.getClass();
|
||||||
|
MWBase::World& world = *MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
if ((!actorClass.isNpc() && target == world.getPlayerPtr() &&
|
||||||
|
actorClass.canSwim(actor) && !actorClass.canWalk(actor) // pure water creature
|
||||||
|
&& !world.isSwimming(target)) // Player moved out of water
|
||||||
|
|| (!actorClass.canSwim(actor) && world.isSwimming(target))) // creature can't swim to Player
|
||||||
|
{
|
||||||
|
actorClass.getCreatureStats(actor).setHostile(false);
|
||||||
|
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//Update every frame
|
//Update every frame
|
||||||
if(mCombatMove)
|
if(mCombatMove)
|
||||||
{
|
{
|
||||||
|
@ -327,10 +341,11 @@ namespace MWMechanics
|
||||||
Ogre::Vector3 vActorPos(pos.pos);
|
Ogre::Vector3 vActorPos(pos.pos);
|
||||||
Ogre::Vector3 vTargetPos(target.getRefData().getPosition().pos);
|
Ogre::Vector3 vTargetPos(target.getRefData().getPosition().pos);
|
||||||
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
|
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
|
||||||
|
float distToTarget = vDirToTarget.length();
|
||||||
|
|
||||||
bool isStuck = false;
|
bool isStuck = false;
|
||||||
float speed = 0.0f;
|
float speed = 0.0f;
|
||||||
if(mMovement.mPosition[1] && (Ogre::Vector3(mLastPos.pos) - vActorPos).length() < (speed = actorCls.getSpeed(actor)) / 10.0f)
|
if(mMovement.mPosition[1] && (Ogre::Vector3(mLastPos.pos) - vActorPos).length() < (speed = actorCls.getSpeed(actor)) * tReaction / 2)
|
||||||
isStuck = true;
|
isStuck = true;
|
||||||
|
|
||||||
mLastPos = pos;
|
mLastPos = pos;
|
||||||
|
@ -342,16 +357,15 @@ namespace MWMechanics
|
||||||
// determine vertical angle to target
|
// determine vertical angle to target
|
||||||
// if actor can move along z-axis it will control movement dir
|
// if actor can move along z-axis it will control movement dir
|
||||||
// if can't - it will control correct aiming
|
// if can't - it will control correct aiming
|
||||||
mMovement.mRotation[0] = getXAngleToDir(vDirToTarget);
|
mMovement.mRotation[0] = getXAngleToDir(vDirToTarget, distToTarget);
|
||||||
|
|
||||||
vDirToTarget.z = 0;
|
|
||||||
float distToTarget = vDirToTarget.length();
|
|
||||||
|
|
||||||
// (within strike dist) || (not quite strike dist while following)
|
// (within strike dist) || (not quite strike dist while following)
|
||||||
if(distToTarget < rangeAttack || (distToTarget <= rangeFollow && mFollowTarget && !isStuck) )
|
if(distToTarget < rangeAttack || (distToTarget <= rangeFollow && mFollowTarget && !isStuck) )
|
||||||
{
|
{
|
||||||
//Melee and Close-up combat
|
//Melee and Close-up combat
|
||||||
mMovement.mRotation[2] = getZAngleToDir(vDirToTarget, distToTarget);
|
|
||||||
|
// if we preserve dir.z then horizontal angle can be inaccurate
|
||||||
|
mMovement.mRotation[2] = getZAngleToDir(Ogre::Vector3(vDirToTarget.x, vDirToTarget.y, 0));
|
||||||
|
|
||||||
// (not quite strike dist while following)
|
// (not quite strike dist while following)
|
||||||
if (mFollowTarget && distToTarget > rangeAttack)
|
if (mFollowTarget && distToTarget > rangeAttack)
|
||||||
|
@ -398,18 +412,14 @@ namespace MWMechanics
|
||||||
bool preferShortcut = false;
|
bool preferShortcut = false;
|
||||||
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, target);
|
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, target);
|
||||||
|
|
||||||
if(mReadyToAttack) isStuck = false;
|
|
||||||
|
|
||||||
// check if shortcut is available
|
// check if shortcut is available
|
||||||
if(!isStuck
|
if(inLOS && (!isStuck || mReadyToAttack)
|
||||||
&& (!mForceNoShortcut
|
&& (!mForceNoShortcut || (Ogre::Vector3(mShortcutFailPos.pos) - vActorPos).length() >= PATHFIND_SHORTCUT_RETRY_DIST))
|
||||||
|| (Ogre::Vector3(mShortcutFailPos.pos) - vActorPos).length() >= PATHFIND_SHORTCUT_RETRY_DIST)
|
|
||||||
&& inLOS)
|
|
||||||
{
|
{
|
||||||
if(speed == 0.0f) speed = actorCls.getSpeed(actor);
|
if(speed == 0.0f) speed = actorCls.getSpeed(actor);
|
||||||
// maximum dist before pit/obstacle for actor to avoid them depending on his speed
|
// maximum dist before pit/obstacle for actor to avoid them depending on his speed
|
||||||
float maxAvoidDist = tReaction * speed + speed / MAX_VEL_ANGULAR.valueRadians() * 2; // *2 - for reliability
|
float maxAvoidDist = tReaction * speed + speed / MAX_VEL_ANGULAR.valueRadians() * 2; // *2 - for reliability
|
||||||
preferShortcut = checkWayIsClear(vActorPos, vTargetPos, distToTarget > maxAvoidDist*1.5? maxAvoidDist : maxAvoidDist/2);
|
preferShortcut = checkWayIsClear(vActorPos, vTargetPos, Ogre::Vector3(vDirToTarget.x, vDirToTarget.y, 0).length() > maxAvoidDist*1.5? maxAvoidDist : maxAvoidDist/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't use pathgrid when actor can move in 3 dimensions
|
// don't use pathgrid when actor can move in 3 dimensions
|
||||||
|
@ -467,7 +477,7 @@ namespace MWMechanics
|
||||||
mReadyToAttack = false;
|
mReadyToAttack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(distToTarget > rangeAttack && !distantCombat)
|
if(!isStuck && distToTarget > rangeAttack && !distantCombat)
|
||||||
{
|
{
|
||||||
//special run attack; it shouldn't affect melee combat tactics
|
//special run attack; it shouldn't affect melee combat tactics
|
||||||
if(actorCls.getMovementSettings(actor).mPosition[1] == 1)
|
if(actorCls.getMovementSettings(actor).mPosition[1] == 1)
|
||||||
|
@ -517,7 +527,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter;
|
MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter;
|
||||||
float minSqr = 1.3*1.3*MIN_DIST_TO_DOOR_SQUARED; // for legibility
|
float minSqr = 1.3*1.3*MIN_DIST_TO_DOOR_SQUARED; // for legibility
|
||||||
if(vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr &&
|
if(vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.getPosition().pos)) < minSqr &&
|
||||||
ref.mData.getLocalRotation().rot[2] < 0.4f) // even small opening
|
ref.mData.getLocalRotation().rot[2] < 0.4f) // even small opening
|
||||||
{
|
{
|
||||||
//std::cout<<"closed door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
|
//std::cout<<"closed door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
|
||||||
|
@ -552,7 +562,7 @@ namespace MWMechanics
|
||||||
float minSqr = 1.6 * 1.6 * MIN_DIST_TO_DOOR_SQUARED; // for legibility
|
float minSqr = 1.6 * 1.6 * MIN_DIST_TO_DOOR_SQUARED; // for legibility
|
||||||
// TODO: add reaction to checking open doors
|
// TODO: add reaction to checking open doors
|
||||||
if(mBackOffDoor &&
|
if(mBackOffDoor &&
|
||||||
vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr)
|
vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.getPosition().pos)) < minSqr)
|
||||||
{
|
{
|
||||||
mMovement.mPosition[1] = -0.2; // back off, but slowly
|
mMovement.mPosition[1] = -0.2; // back off, but slowly
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
// Stop moving if the player is to far away
|
// Stop moving if the player is to far away
|
||||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
|
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
|
||||||
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
mMaxDist = 330;
|
mMaxDist = 330;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
||||||
MWWorld::Ptr door = getNearbyDoor(actor);
|
MWWorld::Ptr door = getNearbyDoor(actor);
|
||||||
if(door != MWWorld::Ptr()) // NOTE: checks interior cells only
|
if(door != MWWorld::Ptr()) // NOTE: checks interior cells only
|
||||||
{
|
{
|
||||||
if(door.getCellRef().mTrap.empty() && mLastDoorChecked != door) { //Open the door if untrapped
|
if(door.getCellRef().getTrap().empty() && mLastDoorChecked != door) { //Open the door if untrapped
|
||||||
door.getClass().activate(door, actor).get()->execute(actor);
|
door.getClass().activate(door, actor).get()->execute(actor);
|
||||||
mLastDoorChecked = door;
|
mLastDoorChecked = door;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
float nearestDist = std::numeric_limits<float>::max();
|
float nearestDist = std::numeric_limits<float>::max();
|
||||||
Ogre::Vector3 vActorPos = Ogre::Vector3(actor.getRefData().getPosition().pos);
|
Ogre::Vector3 vActorPos = Ogre::Vector3(actor.getRefData().getPosition().pos);
|
||||||
|
|
||||||
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();)
|
||||||
{
|
{
|
||||||
if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break;
|
if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
if (target.isEmpty())
|
if (target.isEmpty())
|
||||||
{
|
{
|
||||||
delete *it;
|
delete *it;
|
||||||
mPackages.erase(it++);
|
it = mPackages.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -159,20 +159,26 @@ void AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
nearestDist = distTo;
|
nearestDist = distTo;
|
||||||
itActualCombat = it;
|
itActualCombat = it;
|
||||||
}
|
}
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// all targets disappeared
|
if (!mPackages.empty())
|
||||||
if (nearestDist == std::numeric_limits<float>::max())
|
{
|
||||||
|
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
|
||||||
|
{
|
||||||
|
// move combat package with nearest target to the front
|
||||||
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
||||||
|
}
|
||||||
|
|
||||||
|
package = mPackages.front();
|
||||||
|
mLastAiPackage = package->getTypeId();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mDone = true;
|
mDone = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (mPackages.begin() != itActualCombat)
|
|
||||||
{
|
|
||||||
// move combat package with nearest target to the front
|
|
||||||
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (package->execute (actor,duration))
|
if (package->execute (actor,duration))
|
||||||
|
|
|
@ -572,7 +572,7 @@ namespace MWMechanics
|
||||||
void AiWander::stopWalking(const MWWorld::Ptr& actor)
|
void AiWander::stopWalking(const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
mPathFinder.clearPath();
|
mPathFinder.clearPath();
|
||||||
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)
|
void AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)
|
||||||
|
|
|
@ -292,13 +292,13 @@ void MWMechanics::Alchemy::addPotion (const std::string& name)
|
||||||
|
|
||||||
void MWMechanics::Alchemy::increaseSkill()
|
void MWMechanics::Alchemy::increaseSkill()
|
||||||
{
|
{
|
||||||
MWWorld::Class::get (mAlchemist).skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0);
|
mAlchemist.getClass().skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MWMechanics::Alchemy::getChance() const
|
float MWMechanics::Alchemy::getChance() const
|
||||||
{
|
{
|
||||||
const CreatureStats& creatureStats = MWWorld::Class::get (mAlchemist).getCreatureStats (mAlchemist);
|
const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist);
|
||||||
const NpcStats& npcStats = MWWorld::Class::get (mAlchemist).getNpcStats (mAlchemist);
|
const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist);
|
||||||
|
|
||||||
return
|
return
|
||||||
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
|
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
|
||||||
|
@ -331,7 +331,7 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc)
|
||||||
|
|
||||||
mEffects.clear();
|
mEffects.clear();
|
||||||
|
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get (npc).getContainerStore (npc);
|
MWWorld::ContainerStore& store = npc.getClass().getContainerStore (npc);
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin (MWWorld::ContainerStore::Type_Apparatus));
|
for (MWWorld::ContainerStoreIterator iter (store.begin (MWWorld::ContainerStore::Type_Apparatus));
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.end(); ++iter)
|
||||||
|
|
|
@ -407,29 +407,25 @@ MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::I
|
||||||
return inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
return inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterController::playRandomDeath(float startpoint)
|
void CharacterController::playDeath(float startpoint, CharacterState death)
|
||||||
{
|
{
|
||||||
if(MWBase::Environment::get().getWorld()->isSwimming(mPtr) && mAnimation->hasAnimation("swimdeath"))
|
switch (death)
|
||||||
{
|
{
|
||||||
mDeathState = CharState_SwimDeath;
|
case CharState_SwimDeath:
|
||||||
mCurrentDeath = "swimdeath";
|
mCurrentDeath = "swimdeath";
|
||||||
}
|
break;
|
||||||
else if (mHitState == CharState_KnockDown)
|
case CharState_DeathKnockDown:
|
||||||
{
|
|
||||||
mDeathState = CharState_DeathKnockDown;
|
|
||||||
mCurrentDeath = "deathknockdown";
|
mCurrentDeath = "deathknockdown";
|
||||||
}
|
break;
|
||||||
else if (mHitState == CharState_KnockOut)
|
case CharState_DeathKnockOut:
|
||||||
{
|
|
||||||
mDeathState = CharState_DeathKnockOut;
|
|
||||||
mCurrentDeath = "deathknockout";
|
mCurrentDeath = "deathknockout";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mCurrentDeath = "death" + Ogre::StringConverter::toString(death - CharState_Death1 + 1);
|
||||||
}
|
}
|
||||||
else
|
mDeathState = death;
|
||||||
{
|
|
||||||
int selected=0;
|
mPtr.getClass().getCreatureStats(mPtr).setDeathAnimation(mDeathState - CharState_Death1);
|
||||||
mCurrentDeath = chooseRandomGroup("death", &selected);
|
|
||||||
mDeathState = static_cast<CharacterState>(CharState_Death1 + (selected-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
|
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
|
||||||
mMovementState = CharState_None;
|
mMovementState = CharState_None;
|
||||||
|
@ -440,6 +436,29 @@ void CharacterController::playRandomDeath(float startpoint)
|
||||||
false, 1.0f, "start", "stop", startpoint, 0);
|
false, 1.0f, "start", "stop", startpoint, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::playRandomDeath(float startpoint)
|
||||||
|
{
|
||||||
|
if(MWBase::Environment::get().getWorld()->isSwimming(mPtr) && mAnimation->hasAnimation("swimdeath"))
|
||||||
|
{
|
||||||
|
mDeathState = CharState_SwimDeath;
|
||||||
|
}
|
||||||
|
else if (mHitState == CharState_KnockDown)
|
||||||
|
{
|
||||||
|
mDeathState = CharState_DeathKnockDown;
|
||||||
|
}
|
||||||
|
else if (mHitState == CharState_KnockOut)
|
||||||
|
{
|
||||||
|
mDeathState = CharState_DeathKnockOut;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int selected=0;
|
||||||
|
chooseRandomGroup("death", &selected);
|
||||||
|
mDeathState = static_cast<CharacterState>(CharState_Death1 + (selected-1));
|
||||||
|
}
|
||||||
|
playDeath(startpoint, mDeathState);
|
||||||
|
}
|
||||||
|
|
||||||
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
, mAnimation(anim)
|
, mAnimation(anim)
|
||||||
|
@ -459,7 +478,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
if(cls.isActor())
|
if(cls.isActor())
|
||||||
{
|
{
|
||||||
/* Accumulate along X/Y only for now, until we can figure out how we should
|
/* Accumulate along X/Y only for now, until we can figure out how we should
|
||||||
|
@ -497,7 +516,8 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
|
|
||||||
if(mDeathState != CharState_None)
|
if(mDeathState != CharState_None)
|
||||||
{
|
{
|
||||||
playRandomDeath(1.0f);
|
int deathindex = mPtr.getClass().getCreatureStats(mPtr).getDeathAnimation();
|
||||||
|
playDeath(1.0f, CharacterState(CharState_Death1 + deathindex));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
refreshCurrentAnims(mIdleState, mMovementState, true);
|
refreshCurrentAnims(mIdleState, mMovementState, true);
|
||||||
|
@ -549,7 +569,7 @@ bool CharacterController::updateCreatureState()
|
||||||
|
|
||||||
bool CharacterController::updateWeaponState()
|
bool CharacterController::updateWeaponState()
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(mPtr);
|
CreatureStats &stats = cls.getCreatureStats(mPtr);
|
||||||
WeaponType weaptype = WeapType_None;
|
WeaponType weaptype = WeapType_None;
|
||||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||||
|
@ -601,8 +621,8 @@ bool CharacterController::updateWeaponState()
|
||||||
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
|
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
|
||||||
{
|
{
|
||||||
std::string soundid = (weaptype == WeapType_None) ?
|
std::string soundid = (weaptype == WeapType_None) ?
|
||||||
MWWorld::Class::get(*weapon).getDownSoundId(*weapon) :
|
weapon->getClass().getDownSoundId(*weapon) :
|
||||||
MWWorld::Class::get(*weapon).getUpSoundId(*weapon);
|
weapon->getClass().getUpSoundId(*weapon);
|
||||||
if(!soundid.empty())
|
if(!soundid.empty())
|
||||||
{
|
{
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
|
@ -983,7 +1003,7 @@ bool CharacterController::updateWeaponState()
|
||||||
void CharacterController::update(float duration)
|
void CharacterController::update(float duration)
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
Ogre::Vector3 movement(0.0f);
|
Ogre::Vector3 movement(0.0f);
|
||||||
|
|
||||||
updateVisibility();
|
updateVisibility();
|
||||||
|
|
|
@ -181,6 +181,7 @@ class CharacterController
|
||||||
|
|
||||||
void updateVisibility();
|
void updateVisibility();
|
||||||
|
|
||||||
|
void playDeath(float startpoint, CharacterState death);
|
||||||
void playRandomDeath(float startpoint = 0.0f);
|
void playRandomDeath(float startpoint = 0.0f);
|
||||||
|
|
||||||
/// choose a random animation group with \a prefix and numeric suffix
|
/// choose a random animation group with \a prefix and numeric suffix
|
||||||
|
|
|
@ -102,10 +102,11 @@ namespace MWMechanics
|
||||||
if (roll < x)
|
if (roll < x)
|
||||||
{
|
{
|
||||||
// Reduce shield durability by incoming damage
|
// Reduce shield durability by incoming damage
|
||||||
if (shield->getCellRef().mCharge == -1)
|
int shieldhealth = shield->getClass().getItemHealth(*shield);
|
||||||
shield->getCellRef().mCharge = shield->getClass().getItemMaxHealth(*shield);
|
|
||||||
shield->getCellRef().mCharge -= std::min(shield->getCellRef().mCharge, int(damage));
|
shieldhealth -= std::min(shieldhealth, int(damage));
|
||||||
if (!shield->getCellRef().mCharge)
|
shield->getCellRef().setCharge(shieldhealth);
|
||||||
|
if (shieldhealth == 0)
|
||||||
inv.unequipItem(*shield, blocker);
|
inv.unequipItem(*shield, blocker);
|
||||||
|
|
||||||
// Reduce blocker fatigue
|
// Reduce blocker fatigue
|
||||||
|
|
|
@ -22,7 +22,8 @@ namespace MWMechanics
|
||||||
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
||||||
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
|
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
|
||||||
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
|
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
|
||||||
mLastRestock(0,0), mGoldPool(0), mActorId(-1)
|
mLastRestock(0,0), mGoldPool(0), mActorId(-1),
|
||||||
|
mDeathAnimation(0)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
mAiSettings[i] = 0;
|
mAiSettings[i] = 0;
|
||||||
|
@ -102,7 +103,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
Stat<int> CreatureStats::getAiSetting (AiSetting index) const
|
Stat<int> CreatureStats::getAiSetting (AiSetting index) const
|
||||||
{
|
{
|
||||||
assert (index>=0 && index<4);
|
|
||||||
return mAiSettings[index];
|
return mAiSettings[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
||||||
{
|
{
|
||||||
assert (index>=0 && index<4);
|
|
||||||
mAiSettings[index] = value;
|
mAiSettings[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +499,7 @@ namespace MWMechanics
|
||||||
state.mDrawState = mDrawState;
|
state.mDrawState = mDrawState;
|
||||||
state.mLevel = mLevel;
|
state.mLevel = mLevel;
|
||||||
state.mActorId = mActorId;
|
state.mActorId = mActorId;
|
||||||
|
state.mDeathAnimation = mDeathAnimation;
|
||||||
|
|
||||||
mSpells.writeState(state.mSpells);
|
mSpells.writeState(state.mSpells);
|
||||||
mActiveSpells.writeState(state.mActiveSpells);
|
mActiveSpells.writeState(state.mActiveSpells);
|
||||||
|
@ -539,6 +539,7 @@ namespace MWMechanics
|
||||||
mDrawState = DrawState_(state.mDrawState);
|
mDrawState = DrawState_(state.mDrawState);
|
||||||
mLevel = state.mLevel;
|
mLevel = state.mLevel;
|
||||||
mActorId = state.mActorId;
|
mActorId = state.mActorId;
|
||||||
|
mDeathAnimation = state.mDeathAnimation;
|
||||||
|
|
||||||
mSpells.readState(state.mSpells);
|
mSpells.readState(state.mSpells);
|
||||||
mActiveSpells.readState(state.mActiveSpells);
|
mActiveSpells.readState(state.mActiveSpells);
|
||||||
|
@ -592,4 +593,14 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
esm.getHNT(sActorId, "COUN");
|
esm.getHNT(sActorId, "COUN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char CreatureStats::getDeathAnimation() const
|
||||||
|
{
|
||||||
|
return mDeathAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatureStats::setDeathAnimation(unsigned char index)
|
||||||
|
{
|
||||||
|
mDeathAnimation = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
int mActorId;
|
int mActorId;
|
||||||
|
|
||||||
|
// The index of the death animation that was played
|
||||||
|
unsigned char mDeathAnimation;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// These two are only set by NpcStats, but they are declared in CreatureStats to prevent using virtual methods.
|
// These two are only set by NpcStats, but they are declared in CreatureStats to prevent using virtual methods.
|
||||||
bool mIsWerewolf;
|
bool mIsWerewolf;
|
||||||
|
@ -250,6 +253,9 @@ namespace MWMechanics
|
||||||
void setGoldPool(int pool);
|
void setGoldPool(int pool);
|
||||||
int getGoldPool() const;
|
int getGoldPool() const;
|
||||||
|
|
||||||
|
unsigned char getDeathAnimation() const;
|
||||||
|
void setDeathAnimation(unsigned char index);
|
||||||
|
|
||||||
int getActorId();
|
int getActorId();
|
||||||
///< Will generate an actor ID, if the actor does not have one yet.
|
///< Will generate an actor ID, if the actor does not have one yet.
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,10 @@ namespace MWMechanics
|
||||||
if(!itemEmpty())
|
if(!itemEmpty())
|
||||||
{
|
{
|
||||||
mObjectType = mOldItemPtr.getTypeName();
|
mObjectType = mOldItemPtr.getTypeName();
|
||||||
mOldItemId = mOldItemPtr.getCellRef().mRefID;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mObjectType="";
|
mObjectType="";
|
||||||
mOldItemId="";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ namespace MWMechanics
|
||||||
bool Enchanting::create()
|
bool Enchanting::create()
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
ESM::Enchantment enchantment;
|
ESM::Enchantment enchantment;
|
||||||
enchantment.mData.mCharge = getGemCharge();
|
enchantment.mData.mCharge = getGemCharge();
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ namespace MWMechanics
|
||||||
if(getEnchantChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
|
if(getEnchantChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
|
mEnchanter.getClass().skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mCastStyle==ESM::Enchantment::ConstantEffect)
|
if(mCastStyle==ESM::Enchantment::ConstantEffect)
|
||||||
|
@ -78,17 +76,13 @@ namespace MWMechanics
|
||||||
enchantment.mData.mCost = getEnchantPoints();
|
enchantment.mData.mCost = getEnchantPoints();
|
||||||
enchantment.mEffects = mEffectList;
|
enchantment.mEffects = mEffectList;
|
||||||
|
|
||||||
// Create a new item
|
|
||||||
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId, 1);
|
|
||||||
const MWWorld::Ptr& newItemPtr = ref.getPtr();
|
|
||||||
|
|
||||||
// Apply the enchantment
|
// Apply the enchantment
|
||||||
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
|
const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);
|
||||||
MWWorld::Class::get(newItemPtr).applyEnchantment(newItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
std::string newItemId = mOldItemPtr.getClass().applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
||||||
|
|
||||||
// Add the new item to player inventory and remove the old one
|
// Add the new item to player inventory and remove the old one
|
||||||
store.remove(mOldItemPtr, 1, player);
|
store.remove(mOldItemPtr, 1, player);
|
||||||
store.add(newItemPtr, 1, player);
|
store.add(newItemId, 1, player);
|
||||||
|
|
||||||
if(!mSelfEnchanting)
|
if(!mSelfEnchanting)
|
||||||
payForEnchantment();
|
payForEnchantment();
|
||||||
|
@ -212,7 +206,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
const float enchantCost = getEnchantPoints();
|
const float enchantCost = getEnchantPoints();
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player);
|
MWMechanics::NpcStats &stats = player.getClass().getNpcStats(player);
|
||||||
int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified();
|
int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -240,9 +234,9 @@ namespace MWMechanics
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
if(soulEmpty())
|
if(soulEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
if(mSoulGemPtr.getCellRef().mSoul=="")
|
if(mSoulGemPtr.getCellRef().getSoul()=="")
|
||||||
return 0;
|
return 0;
|
||||||
const ESM::Creature* soul = store.get<ESM::Creature>().find(mSoulGemPtr.getCellRef().mSoul);
|
const ESM::Creature* soul = store.get<ESM::Creature>().find(mSoulGemPtr.getCellRef().getSoul());
|
||||||
return soul->mData.mSoul;
|
return soul->mData.mSoul;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +271,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
float Enchanting::getEnchantChance() const
|
float Enchanting::getEnchantChance() const
|
||||||
{
|
{
|
||||||
const NpcStats& npcStats = MWWorld::Class::get (mEnchanter).getNpcStats (mEnchanter);
|
const NpcStats& npcStats = mEnchanter.getClass().getNpcStats (mEnchanter);
|
||||||
|
|
||||||
float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() +
|
float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() +
|
||||||
(0.25 * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
|
(0.25 * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
|
||||||
|
@ -295,7 +289,7 @@ namespace MWMechanics
|
||||||
void Enchanting::payForEnchantment() const
|
void Enchanting::payForEnchantment() const
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
const MWWorld::Ptr& player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
|
|
||||||
store.remove(MWWorld::ContainerStore::sGoldId, getEnchantPrice(), player);
|
store.remove(MWWorld::ContainerStore::sGoldId, getEnchantPrice(), player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
std::string mNewItemName;
|
std::string mNewItemName;
|
||||||
std::string mObjectType;
|
std::string mObjectType;
|
||||||
std::string mOldItemId;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Enchanting();
|
Enchanting();
|
||||||
|
|
|
@ -53,29 +53,27 @@ namespace MWMechanics
|
||||||
return std::string();
|
return std::string();
|
||||||
std::string item = candidates[std::rand()%candidates.size()];
|
std::string item = candidates[std::rand()%candidates.size()];
|
||||||
|
|
||||||
// Is this another levelled item or a real item?
|
// Vanilla doesn't fail on nonexistent items in levelled lists
|
||||||
try
|
if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item)))
|
||||||
{
|
{
|
||||||
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, 1);
|
std::cerr << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'" << std::endl;
|
||||||
if (ref.getPtr().getTypeName() != typeid(ESM::ItemLevList).name()
|
|
||||||
&& ref.getPtr().getTypeName() != typeid(ESM::CreatureLevList).name())
|
|
||||||
{
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ref.getPtr().getTypeName() == typeid(ESM::ItemLevList).name())
|
|
||||||
return getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, failChance);
|
|
||||||
else
|
|
||||||
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (std::logic_error&)
|
|
||||||
{
|
|
||||||
// Vanilla doesn't fail on nonexistent items in levelled lists
|
|
||||||
std::cerr << "Warning: ignoring nonexistent item '" << item << "'" << std::endl;
|
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is this another levelled item or a real item?
|
||||||
|
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, 1);
|
||||||
|
if (ref.getPtr().getTypeName() != typeid(ESM::ItemLevList).name()
|
||||||
|
&& ref.getPtr().getTypeName() != typeid(ESM::CreatureLevList).name())
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ref.getPtr().getTypeName() == typeid(ESM::ItemLevList).name())
|
||||||
|
return getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, failChance);
|
||||||
|
else
|
||||||
|
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ namespace
|
||||||
/// @return is \a ptr allowed to take/use \a item or is it a crime?
|
/// @return is \a ptr allowed to take/use \a item or is it a crime?
|
||||||
bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, MWWorld::Ptr& victim)
|
bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, MWWorld::Ptr& victim)
|
||||||
{
|
{
|
||||||
const std::string& owner = item.getCellRef().mOwner;
|
const std::string& owner = item.getCellRef().getOwner();
|
||||||
bool isOwned = !owner.empty() && owner != "player";
|
bool isOwned = !owner.empty() && owner != "player";
|
||||||
|
|
||||||
const std::string& faction = item.getCellRef().mFaction;
|
const std::string& faction = item.getCellRef().getFaction();
|
||||||
bool isFactionOwned = false;
|
bool isFactionOwned = false;
|
||||||
if (!faction.empty() && ptr.getClass().isNpc())
|
if (!faction.empty() && ptr.getClass().isNpc())
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,8 @@ namespace
|
||||||
isFactionOwned = true;
|
isFactionOwned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.getCellRef().mOwner.empty())
|
if (!item.getCellRef().getOwner().empty())
|
||||||
victim = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().mOwner, true);
|
victim = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().getOwner(), true);
|
||||||
|
|
||||||
return (!isOwned && !isFactionOwned);
|
return (!isOwned && !isFactionOwned);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
|
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats (ptr);
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
MWMechanics::NpcStats& npcStats = ptr.getClass().getNpcStats (ptr);
|
||||||
|
|
||||||
const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase;
|
const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::add(const MWWorld::Ptr& ptr)
|
void MechanicsManager::add(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
mActors.addActor(ptr);
|
mActors.addActor(ptr);
|
||||||
else
|
else
|
||||||
mObjects.addObject(ptr);
|
mObjects.addObject(ptr);
|
||||||
|
@ -234,7 +234,7 @@ namespace MWMechanics
|
||||||
if(old == mWatched)
|
if(old == mWatched)
|
||||||
mWatched = ptr;
|
mWatched = ptr;
|
||||||
|
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
mActors.updateActor(old, ptr);
|
mActors.updateActor(old, ptr);
|
||||||
else
|
else
|
||||||
mObjects.updateObject(old, ptr);
|
mObjects.updateObject(old, ptr);
|
||||||
|
@ -475,13 +475,13 @@ namespace MWMechanics
|
||||||
|
|
||||||
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
|
int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
const MWMechanics::NpcStats& npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr);
|
||||||
float x = npcSkill.getBaseDisposition();
|
float x = npcSkill.getBaseDisposition();
|
||||||
|
|
||||||
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
|
||||||
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>();
|
||||||
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
|
||||||
|
|
||||||
if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace))
|
if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace))
|
||||||
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispRaceMod")->getFloat();
|
x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispRaceMod")->getFloat();
|
||||||
|
@ -498,27 +498,24 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (playerStats.getFactionRanks().find(npcFaction) != playerStats.getFactionRanks().end())
|
if (playerStats.getFactionRanks().find(npcFaction) != playerStats.getFactionRanks().end())
|
||||||
{
|
{
|
||||||
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npcFaction)->mReactions.begin();
|
if (!playerStats.getExpelled(npcFaction))
|
||||||
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npcFaction)->mReactions.end(); ++it)
|
|
||||||
{
|
{
|
||||||
if(Misc::StringUtils::ciEqual(it->mFaction, npcFaction)
|
reaction = playerStats.getFactionReputation(npcFaction);
|
||||||
&& !playerStats.getExpelled(it->mFaction))
|
|
||||||
reaction = it->mReaction;
|
rank = playerStats.getFactionRanks().find(npcFaction)->second;
|
||||||
}
|
}
|
||||||
rank = playerStats.getFactionRanks().find(npcFaction)->second;
|
|
||||||
}
|
}
|
||||||
else if (npcFaction != "")
|
else if (!npcFaction.empty())
|
||||||
{
|
{
|
||||||
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npcFaction)->mReactions.begin();
|
std::map<std::string, int>::const_iterator playerFactionIt = playerStats.getFactionRanks().begin();
|
||||||
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(npcFaction)->mReactions.end();++it)
|
for (; playerFactionIt != playerStats.getFactionRanks().end(); ++playerFactionIt)
|
||||||
{
|
{
|
||||||
if(playerStats.getFactionRanks().find(Misc::StringUtils::lowerCase(it->mFaction)) != playerStats.getFactionRanks().end() )
|
std::string itFaction = playerFactionIt->first;
|
||||||
{
|
|
||||||
if(it->mReaction < reaction)
|
int itReaction = MWBase::Environment::get().getDialogueManager()->getFactionReaction(npcFaction, itFaction);
|
||||||
reaction = it->mReaction;
|
if (playerFactionIt == playerStats.getFactionRanks().begin() || itReaction < reaction)
|
||||||
}
|
reaction = itReaction;
|
||||||
}
|
}
|
||||||
rank = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -547,10 +544,10 @@ namespace MWMechanics
|
||||||
if (ptr.getTypeName() == typeid(ESM::Creature).name())
|
if (ptr.getTypeName() == typeid(ESM::Creature).name())
|
||||||
return basePrice;
|
return basePrice;
|
||||||
|
|
||||||
const MWMechanics::NpcStats &sellerStats = MWWorld::Class::get(ptr).getNpcStats(ptr);
|
const MWMechanics::NpcStats &sellerStats = ptr.getClass().getNpcStats(ptr);
|
||||||
|
|
||||||
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
|
||||||
|
|
||||||
// I suppose the temporary disposition change _has_ to be considered here,
|
// I suppose the temporary disposition change _has_ to be considered here,
|
||||||
// otherwise one would get different prices when exiting and re-entering the dialogue window...
|
// otherwise one would get different prices when exiting and re-entering the dialogue window...
|
||||||
|
@ -592,10 +589,10 @@ namespace MWMechanics
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(npc).getNpcStats(npc);
|
MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc);
|
||||||
|
|
||||||
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
const MWMechanics::NpcStats &playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
|
const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr);
|
||||||
|
|
||||||
float persTerm = playerStats.getAttribute(ESM::Attribute::Personality).getModified()
|
float persTerm = playerStats.getAttribute(ESM::Attribute::Personality).getModified()
|
||||||
/ gmst.find("fPersonalityMod")->getFloat();
|
/ gmst.find("fPersonalityMod")->getFloat();
|
||||||
|
@ -666,8 +663,6 @@ namespace MWMechanics
|
||||||
int fight = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Fight).getBase();
|
int fight = npcStats.getAiSetting(MWMechanics::CreatureStats::AI_Fight).getBase();
|
||||||
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Flee,
|
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Flee,
|
||||||
std::max(0, std::min(100, flee + int(std::max(iPerMinChange, s)))));
|
std::max(0, std::min(100, flee + int(std::max(iPerMinChange, s)))));
|
||||||
// TODO: initiate combat and quit dialogue if fight rating is too high
|
|
||||||
// or should setAiSetting handle this?
|
|
||||||
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Fight,
|
npcStats.setAiSetting (MWMechanics::CreatureStats::AI_Fight,
|
||||||
std::max(0, std::min(100, fight + int(std::min(-iPerMinChange, -s)))));
|
std::max(0, std::min(100, fight + int(std::min(-iPerMinChange, -s)))));
|
||||||
}
|
}
|
||||||
|
@ -741,27 +736,27 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::forceStateUpdate(const MWWorld::Ptr &ptr)
|
void MechanicsManager::forceStateUpdate(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
mActors.forceStateUpdate(ptr);
|
mActors.forceStateUpdate(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
void MechanicsManager::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
mActors.playAnimationGroup(ptr, groupName, mode, number);
|
mActors.playAnimationGroup(ptr, groupName, mode, number);
|
||||||
else
|
else
|
||||||
mObjects.playAnimationGroup(ptr, groupName, mode, number);
|
mObjects.playAnimationGroup(ptr, groupName, mode, number);
|
||||||
}
|
}
|
||||||
void MechanicsManager::skipAnimation(const MWWorld::Ptr& ptr)
|
void MechanicsManager::skipAnimation(const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
mActors.skipAnimation(ptr);
|
mActors.skipAnimation(ptr);
|
||||||
else
|
else
|
||||||
mObjects.skipAnimation(ptr);
|
mObjects.skipAnimation(ptr);
|
||||||
}
|
}
|
||||||
bool MechanicsManager::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string &groupName)
|
bool MechanicsManager::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string &groupName)
|
||||||
{
|
{
|
||||||
if(MWWorld::Class::get(ptr).isActor())
|
if(ptr.getClass().isActor())
|
||||||
return mActors.checkAnimationPlaying(ptr, groupName);
|
return mActors.checkAnimationPlaying(ptr, groupName);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -1024,7 +1019,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
void MechanicsManager::startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
if (ptr.getClass().isNpc())
|
||||||
|
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
||||||
|
|
||||||
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
||||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
||||||
|
|
|
@ -496,10 +496,10 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
|
||||||
mExpelled.insert (iter->first);
|
mExpelled.insert (iter->first);
|
||||||
|
|
||||||
if (iter->second.mRank >= 0)
|
if (iter->second.mRank >= 0)
|
||||||
mFactionRank.insert (std::make_pair (iter->first, iter->second.mRank));
|
mFactionRank[iter->first] = iter->second.mRank;
|
||||||
|
|
||||||
if (iter->second.mReputation)
|
if (iter->second.mReputation)
|
||||||
mFactionReputation.insert (std::make_pair (iter->first, iter->second.mReputation));
|
mFactionReputation[iter->first] = iter->second.mReputation;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDisposition = state.mDisposition;
|
mDisposition = state.mDisposition;
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace MWMechanics
|
||||||
for (; it != refList.end(); ++it)
|
for (; it != refList.end(); ++it)
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
||||||
if(pos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr)
|
if(pos.squaredDistance(Ogre::Vector3(ref.mData.getPosition().pos)) < minSqr)
|
||||||
if((closed && ref.mData.getLocalRotation().rot[2] == 0) ||
|
if((closed && ref.mData.getLocalRotation().rot[2] == 0) ||
|
||||||
(!closed && ref.mData.getLocalRotation().rot[2] >= 1))
|
(!closed && ref.mData.getLocalRotation().rot[2] >= 1))
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,11 +28,11 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
||||||
player.getClass().getContainerStore(player).unstack(mTool, player);
|
player.getClass().getContainerStore(player).unstack(mTool, player);
|
||||||
|
|
||||||
// reduce number of uses left
|
// reduce number of uses left
|
||||||
int uses = (mTool.getCellRef().mCharge != -1) ? mTool.getCellRef().mCharge : ref->mBase->mData.mUses;
|
int uses = mTool.getClass().getItemHealth(mTool);
|
||||||
mTool.getCellRef().mCharge = uses-1;
|
mTool.getCellRef().setCharge(uses-1);
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats(player);
|
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats(player);
|
||||||
|
|
||||||
float fatigueTerm = stats.getFatigueTerm();
|
float fatigueTerm = stats.getFatigueTerm();
|
||||||
int pcStrength = stats.getAttribute(ESM::Attribute::Strength).getModified();
|
int pcStrength = stats.getAttribute(ESM::Attribute::Strength).getModified();
|
||||||
|
@ -53,17 +53,17 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
||||||
y = std::max(1, y);
|
y = std::max(1, y);
|
||||||
|
|
||||||
// repair by 'y' points
|
// repair by 'y' points
|
||||||
itemToRepair.getCellRef().mCharge += y;
|
int charge = itemToRepair.getClass().getItemHealth(itemToRepair);
|
||||||
itemToRepair.getCellRef().mCharge = std::min(itemToRepair.getCellRef().mCharge,
|
charge = std::min(charge + y, itemToRepair.getClass().getItemMaxHealth(itemToRepair));
|
||||||
MWWorld::Class::get(itemToRepair).getItemMaxHealth(itemToRepair));
|
itemToRepair.getCellRef().setCharge(charge);
|
||||||
|
|
||||||
// set the OnPCRepair variable on the item's script
|
// set the OnPCRepair variable on the item's script
|
||||||
std::string script = MWWorld::Class::get(itemToRepair).getScript(itemToRepair);
|
std::string script = itemToRepair.getClass().getScript(itemToRepair);
|
||||||
if(script != "")
|
if(script != "")
|
||||||
itemToRepair.getRefData().getLocals().setVarByInt(script, "onpcrepair", 1);
|
itemToRepair.getRefData().getLocals().setVarByInt(script, "onpcrepair", 1);
|
||||||
|
|
||||||
// increase skill
|
// increase skill
|
||||||
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Armorer, 0);
|
player.getClass().skillUsageSucceeded(player, ESM::Skill::Armorer, 0);
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
|
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sRepairSuccess}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sRepairSuccess}");
|
||||||
|
@ -75,23 +75,23 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tool used up?
|
// tool used up?
|
||||||
if (mTool.getCellRef().mCharge == 0)
|
if (mTool.getCellRef().getCharge() == 0)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player);
|
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
|
|
||||||
store.remove(mTool, 1, player);
|
store.remove(mTool, 1, player);
|
||||||
|
|
||||||
std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
std::string message = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
.find("sNotifyMessage51")->getString();
|
.find("sNotifyMessage51")->getString();
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox((boost::format(message) % MWWorld::Class::get(mTool).getName(mTool)).str());
|
MWBase::Environment::get().getWindowManager()->messageBox((boost::format(message) % mTool.getClass().getName(mTool)).str());
|
||||||
|
|
||||||
// try to find a new tool of the same ID
|
// try to find a new tool of the same ID
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin());
|
for (MWWorld::ContainerStoreIterator iter (store.begin());
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().mRefID, mTool.getCellRef().mRefID))
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), mTool.getCellRef().getRefId()))
|
||||||
{
|
{
|
||||||
mTool = *iter;
|
mTool = *iter;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,8 +18,8 @@ namespace MWMechanics
|
||||||
Security::Security(const MWWorld::Ptr &actor)
|
Security::Security(const MWWorld::Ptr &actor)
|
||||||
: mActor(actor)
|
: mActor(actor)
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor);
|
CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||||
NpcStats& npcStats = MWWorld::Class::get(actor).getNpcStats(actor);
|
NpcStats& npcStats = actor.getClass().getNpcStats(actor);
|
||||||
mAgility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified();
|
mAgility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified();
|
||||||
mLuck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified();
|
mLuck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified();
|
||||||
mSecuritySkill = npcStats.getSkill(ESM::Skill::Security).getModified();
|
mSecuritySkill = npcStats.getSkill(ESM::Skill::Security).getModified();
|
||||||
|
@ -29,10 +29,10 @@ namespace MWMechanics
|
||||||
void Security::pickLock(const MWWorld::Ptr &lock, const MWWorld::Ptr &lockpick,
|
void Security::pickLock(const MWWorld::Ptr &lock, const MWWorld::Ptr &lockpick,
|
||||||
std::string& resultMessage, std::string& resultSound)
|
std::string& resultMessage, std::string& resultSound)
|
||||||
{
|
{
|
||||||
if (!(lock.getCellRef().mLockLevel > 0)) //If it's unlocked back out immediately
|
if (!(lock.getCellRef().getLockLevel() > 0)) //If it's unlocked back out immediately
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int lockStrength = lock.getCellRef().mLockLevel;
|
int lockStrength = lock.getCellRef().getLockLevel();
|
||||||
|
|
||||||
float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality;
|
float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality;
|
||||||
|
|
||||||
|
@ -51,31 +51,31 @@ namespace MWMechanics
|
||||||
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
||||||
if (roll <= x)
|
if (roll <= x)
|
||||||
{
|
{
|
||||||
MWWorld::Class::get(lock).unlock(lock);
|
lock.getClass().unlock(lock);
|
||||||
resultMessage = "#{sLockSuccess}";
|
resultMessage = "#{sLockSuccess}";
|
||||||
resultSound = "Open Lock";
|
resultSound = "Open Lock";
|
||||||
MWWorld::Class::get(mActor).skillUsageSucceeded(mActor, ESM::Skill::Security, 1);
|
mActor.getClass().skillUsageSucceeded(mActor, ESM::Skill::Security, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
resultMessage = "#{sLockFail}";
|
resultMessage = "#{sLockFail}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockpick.getCellRef().mCharge == -1)
|
int uses = lockpick.getClass().getItemHealth(lockpick);
|
||||||
lockpick.getCellRef().mCharge = lockpick.get<ESM::Lockpick>()->mBase->mData.mUses;
|
--uses;
|
||||||
--lockpick.getCellRef().mCharge;
|
lockpick.getCellRef().setCharge(uses);
|
||||||
if (!lockpick.getCellRef().mCharge)
|
if (!uses)
|
||||||
lockpick.getContainerStore()->remove(lockpick, 1, mActor);
|
lockpick.getContainerStore()->remove(lockpick, 1, mActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Security::probeTrap(const MWWorld::Ptr &trap, const MWWorld::Ptr &probe,
|
void Security::probeTrap(const MWWorld::Ptr &trap, const MWWorld::Ptr &probe,
|
||||||
std::string& resultMessage, std::string& resultSound)
|
std::string& resultMessage, std::string& resultSound)
|
||||||
{
|
{
|
||||||
if (trap.getCellRef().mTrap == "")
|
if (trap.getCellRef().getTrap() == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality;
|
float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality;
|
||||||
|
|
||||||
const ESM::Spell* trapSpell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(trap.getCellRef().mTrap);
|
const ESM::Spell* trapSpell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(trap.getCellRef().getTrap());
|
||||||
float trapSpellPoints = trapSpell->mData.mCost;
|
float trapSpellPoints = trapSpell->mData.mCost;
|
||||||
|
|
||||||
float fTrapCostMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTrapCostMult")->getFloat();
|
float fTrapCostMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTrapCostMult")->getFloat();
|
||||||
|
@ -93,20 +93,20 @@ namespace MWMechanics
|
||||||
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
int roll = static_cast<float> (std::rand()) / RAND_MAX * 100;
|
||||||
if (roll <= x)
|
if (roll <= x)
|
||||||
{
|
{
|
||||||
trap.getCellRef().mTrap = "";
|
trap.getCellRef().setTrap("");
|
||||||
|
|
||||||
resultSound = "Disarm Trap";
|
resultSound = "Disarm Trap";
|
||||||
resultMessage = "#{sTrapSuccess}";
|
resultMessage = "#{sTrapSuccess}";
|
||||||
MWWorld::Class::get(mActor).skillUsageSucceeded(mActor, ESM::Skill::Security, 0);
|
mActor.getClass().skillUsageSucceeded(mActor, ESM::Skill::Security, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
resultMessage = "#{sTrapFail}";
|
resultMessage = "#{sTrapFail}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probe.getCellRef().mCharge == -1)
|
int uses = probe.getClass().getItemHealth(probe);
|
||||||
probe.getCellRef().mCharge = probe.get<ESM::Probe>()->mBase->mData.mUses;
|
--uses;
|
||||||
--probe.getCellRef().mCharge;
|
probe.getCellRef().setCharge(uses);
|
||||||
if (!probe.getCellRef().mCharge)
|
if (!uses)
|
||||||
probe.getContainerStore()->remove(probe, 1, mActor);
|
probe.getContainerStore()->remove(probe, 1, mActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -470,21 +470,21 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (effectId == ESM::MagicEffect::Lock)
|
if (effectId == ESM::MagicEffect::Lock)
|
||||||
{
|
{
|
||||||
if (target.getCellRef().mLockLevel < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
|
if (target.getCellRef().getLockLevel() < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
|
||||||
target.getCellRef().mLockLevel = magnitude;
|
target.getCellRef().setLockLevel(magnitude);
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::Open)
|
else if (effectId == ESM::MagicEffect::Open)
|
||||||
{
|
{
|
||||||
if (target.getCellRef().mLockLevel <= magnitude)
|
if (target.getCellRef().getLockLevel() <= magnitude)
|
||||||
{
|
{
|
||||||
//Door not already unlocked
|
if (target.getCellRef().getLockLevel() > 0)
|
||||||
if (target.getCellRef().mLockLevel > 0)
|
|
||||||
{
|
{
|
||||||
|
//Door not already unlocked
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock", 1.f, 1.f);
|
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock", 1.f, 1.f);
|
||||||
if (!caster.isEmpty() && caster.getClass().isActor())
|
if (!caster.isEmpty() && caster.getClass().isActor())
|
||||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
|
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
|
||||||
}
|
}
|
||||||
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel); //unlocks the door
|
target.getCellRef().setLockLevel(-abs(target.getCellRef().getLockLevel())); //unlocks the door
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
||||||
|
@ -588,7 +588,7 @@ namespace MWMechanics
|
||||||
throw std::runtime_error("can't cast an item without an enchantment");
|
throw std::runtime_error("can't cast an item without an enchantment");
|
||||||
|
|
||||||
mSourceName = item.getClass().getName(item);
|
mSourceName = item.getClass().getName(item);
|
||||||
mId = item.getCellRef().mRefID;
|
mId = item.getCellRef().getRefId();
|
||||||
|
|
||||||
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
|
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
|
||||||
|
|
||||||
|
@ -601,10 +601,10 @@ namespace MWMechanics
|
||||||
int eSkill = mCaster.getClass().getSkill(mCaster, ESM::Skill::Enchant);
|
int eSkill = mCaster.getClass().getSkill(mCaster, ESM::Skill::Enchant);
|
||||||
const int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10));
|
const int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10));
|
||||||
|
|
||||||
if (item.getCellRef().mEnchantmentCharge == -1)
|
if (item.getCellRef().getEnchantmentCharge() == -1)
|
||||||
item.getCellRef().mEnchantmentCharge = enchantment->mData.mCharge;
|
item.getCellRef().setEnchantmentCharge(enchantment->mData.mCharge);
|
||||||
|
|
||||||
if (item.getCellRef().mEnchantmentCharge < castCost)
|
if (item.getCellRef().getEnchantmentCharge() < castCost)
|
||||||
{
|
{
|
||||||
// TODO: Should there be a sound here?
|
// TODO: Should there be a sound here?
|
||||||
if (mCaster.getRefData().getHandle() == "player")
|
if (mCaster.getRefData().getHandle() == "player")
|
||||||
|
@ -612,7 +612,7 @@ namespace MWMechanics
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Reduce charge
|
// Reduce charge
|
||||||
item.getCellRef().mEnchantmentCharge -= castCost;
|
item.getCellRef().setEnchantmentCharge(item.getCellRef().getEnchantmentCharge() - castCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed)
|
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue