Merge branch 'master' of https://github.com/OpenMW/openmw into return

Conflicts:
	apps/openmw/mwmechanics/aisequence.cpp
	apps/openmw/mwmechanics/aiwander.cpp
actorid
scrawl 11 years ago
commit 1fd7a07b5e

@ -333,7 +333,7 @@ int load(Arguments& info)
// Is the user interested in this record type? // Is the user interested in this record type?
bool interested = true; bool interested = true;
if (info.types.size() > 0) if (!info.types.empty())
{ {
std::vector<std::string>::iterator match; std::vector<std::string>::iterator match;
match = std::find(info.types.begin(), info.types.end(), match = std::find(info.types.begin(), info.types.end(),

@ -124,7 +124,7 @@ void printEffectList(ESM::EffectList effects)
{ {
int i = 0; int i = 0;
std::vector<ESM::ENAMstruct>::iterator eit; std::vector<ESM::ENAMstruct>::iterator eit;
for (eit = effects.mList.begin(); eit != effects.mList.end(); eit++) for (eit = effects.mList.begin(); eit != effects.mList.end(); ++eit)
{ {
std::cout << " Effect[" << i << "]: " << magicEffectLabel(eit->mEffectID) std::cout << " Effect[" << i << "]: " << magicEffectLabel(eit->mEffectID)
<< " (" << eit->mEffectID << ")" << std::endl; << " (" << eit->mEffectID << ")" << std::endl;

@ -214,13 +214,13 @@ QStringList Launcher::GraphicsPage::getAvailableOptions(const QString &key, Ogre
uint row = 0; uint row = 0;
Ogre::ConfigOptionMap options = renderer->getConfigOptions(); Ogre::ConfigOptionMap options = renderer->getConfigOptions();
for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); i++, row++) for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); ++i, ++row)
{ {
Ogre::StringVector::iterator opt_it; Ogre::StringVector::iterator opt_it;
uint idx = 0; uint idx = 0;
for (opt_it = i->second.possibleValues.begin(); for (opt_it = i->second.possibleValues.begin();
opt_it != i->second.possibleValues.end(); opt_it++, idx++) opt_it != i->second.possibleValues.end(); ++opt_it, ++idx)
{ {
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0) { if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0) {
result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified(); result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified();

@ -95,6 +95,7 @@ opencs_units (view/settings
booleanview booleanview
textview textview
listview listview
rangeview
resizeablestackedwidget resizeablestackedwidget
) )

@ -12,15 +12,14 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
{ {
buildDefaultSetting(); buildDefaultSetting();
int vType = static_cast <int> (typ); int settingType = static_cast <int> (typ);
if ((vType % 2) == 0) //even-numbered setting types are multi-valued
setProperty (Property_IsMultiValue, if ((settingType % 2) == 0)
QVariant(true).toString()); setProperty (Property_IsMultiValue, QVariant(true).toString());
else
vType--;
setProperty (Property_ViewType, QVariant (vType / 2).toString()); //view type is related to setting type by an order of magnitude
setProperty (Property_ViewType, QVariant (settingType / 10).toString());
setProperty (Property_Page, pageName); setProperty (Property_Page, pageName);
setProperty (Property_Name, settingName); setProperty (Property_Name, settingName);
setProperty (Property_DeclaredValues, values); setProperty (Property_DeclaredValues, values);
@ -267,9 +266,9 @@ void CSMSettings::Setting::setProperty (SettingProperty prop,
QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting) QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting)
{ {
stream << setting.properties(); // stream << setting.properties();
stream << setting.proxies(); // stream << setting.proxies();
return stream; return stream;
} }

@ -47,14 +47,27 @@ namespace CSMSettings
enum SettingType enum SettingType
{ {
Type_MultiBool = 0, /*
Type_SingleBool = 1, * 0 - 9 - Boolean widgets
Type_MultiList = 2, * 10-19 - List widgets
Type_SingleList = 3, * 21-29 - Range widgets
Type_MultiRange = 4, * 31-39 - Text widgets
Type_SingleRange = 5, *
Type_MultiText = 6, * Each range corresponds to a View_Type enum by a factor of 10.
Type_SingleText = 7 *
* Even-numbered values are single-value widgets
* Odd-numbered values are multi-valued widgets
*/
Type_CheckBox = 0,
Type_RadioButton = 1,
Type_ListView = 10,
Type_ComboBox = 11,
Type_SpinBox = 21,
Type_Slider = 23,
Type_Dial = 24,
Type_TextArea = 30,
Type_LineEdit = 31
}; };
enum MergeMethod enum MergeMethod

@ -47,8 +47,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
{ {
QString section = "Window Size"; QString section = "Window Size";
{ {
Setting *width = createSetting (Type_SingleText, section, "Width"); Setting *width = createSetting (Type_LineEdit, section, "Width");
Setting *height = createSetting (Type_SingleText, section, "Height"); Setting *height = createSetting (Type_LineEdit, section, "Height");
width->setWidgetWidth (5); width->setWidgetWidth (5);
height->setWidgetWidth (5); height->setWidgetWidth (5);
@ -65,7 +65,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
/* /*
*Create the proxy setting for predefined values *Create the proxy setting for predefined values
*/ */
Setting *preDefined = createSetting (Type_SingleList, section, Setting *preDefined = createSetting (Type_ComboBox, section,
"Pre-Defined", "Pre-Defined",
QStringList() QStringList()
<< "640 x 480" << "640 x 480"
@ -94,11 +94,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
QStringList values = QStringList() QStringList values = QStringList()
<< defaultValue << "Icon Only" << "Text Only"; << defaultValue << "Icon Only" << "Text Only";
Setting *rsd = createSetting (Type_SingleBool, Setting *rsd = createSetting (Type_RadioButton,
section, "Record Status Display", section, "Record Status Display",
values); values);
Setting *ritd = createSetting (Type_SingleBool, Setting *ritd = createSetting (Type_RadioButton,
section, "Referenceable ID Type Display", section, "Referenceable ID Type Display",
values); values);
@ -110,24 +110,24 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
{ {
//create three setting objects, specifying the basic widget type, //create three setting objects, specifying the basic widget type,
//the setting view name, the page name, and the default value //the setting view name, the page name, and the default value
Setting *masterBoolean = createSetting (Type_SingleBool, section, Setting *masterBoolean = createSetting (Type_RadioButton, section,
"Master Proxy", "Master Proxy",
QStringList() QStringList()
<< "Profile One" << "Profile Two" << "Profile One" << "Profile Two"
<< "Profile Three" << "Profile Four" << "Profile Three" << "Profile Four"
); );
Setting *slaveBoolean = createSetting (Type_MultiBool, section, Setting *slaveBoolean = createSetting (Type_CheckBox, section,
"Proxy Checkboxes", "Proxy Checkboxes",
QStringList() << "One" << "Two" QStringList() << "One" << "Two"
<< "Three" << "Four" << "Five" << "Three" << "Four" << "Five"
); );
Setting *slaveSingleText = createSetting (Type_SingleText, section, Setting *slaveSingleText = createSetting (Type_LineEdit, section,
"Proxy TextBox 1" "Proxy TextBox 1"
); );
Setting *slaveMultiText = createSetting (Type_SingleText, section, Setting *slaveMultiText = createSetting (Type_LineEdit, section,
"ProxyTextBox 2" "ProxyTextBox 2"
); );

@ -1,5 +1,5 @@
#ifndef CSVSETTINGS_BOOLEANVIEW_HPP #ifndef CSVSETTINGS_BOOLEANVIEW_HPP
#define CSVSETTINGS_BOOELANVIEW_HPP #define CSVSETTINGS_BOOLEANVIEW_HPP
#include <QWidget> #include <QWidget>
#include <QAbstractButton> #include <QAbstractButton>

@ -3,6 +3,7 @@
#include "booleanview.hpp" #include "booleanview.hpp"
#include "textview.hpp" #include "textview.hpp"
#include "listview.hpp" #include "listview.hpp"
#include "rangeview.hpp"
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
#include "../../model/settings/connector.hpp" #include "../../model/settings/connector.hpp"
@ -85,4 +86,5 @@ void CSVSettings::Page::buildFactories()
mViewFactories[ViewType_Boolean] = new BooleanViewFactory (this); mViewFactories[ViewType_Boolean] = new BooleanViewFactory (this);
mViewFactories[ViewType_Text] = new TextViewFactory (this); mViewFactories[ViewType_Text] = new TextViewFactory (this);
mViewFactories[ViewType_List] = new ListViewFactory (this); mViewFactories[ViewType_List] = new ListViewFactory (this);
mViewFactories[ViewType_Range] = new RangeViewFactory (this);
} }

@ -0,0 +1,94 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QRadioButton>
#include <QGroupBox>
#include <QAbstractButton>
#include "rangeview.hpp"
#include "../../model/settings/setting.hpp"
#include <QDebug>
CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
Page *parent)
: View (setting, parent)
{
foreach (const QString &value, setting->declaredValues())
{
QAbstractButton *button = 0;
if (isMultiValue())
button = new QCheckBox (value, this);
else
button = new QRadioButton (value, this);
connect (button, SIGNAL (clicked (bool)),
this, SLOT (slotToggled (bool)));
button->setObjectName (value);
addWidget (button);
mButtons[value] = button;
}
}
void CSVSettings::RangeView::slotToggled (bool state)
{
//test only for true to avoid multiple selection updates with radiobuttons
if (!isMultiValue() && !state)
return;
QStringList values;
foreach (QString key, mButtons.keys())
{
if (mButtons.value(key)->isChecked())
values.append (key);
}
setSelectedValues (values, false);
View::updateView();
}
void CSVSettings::RangeView::updateView (bool signalUpdate) const
{
QStringList values = selectedValues();
foreach (const QString &buttonName, mButtons.keys())
{
QAbstractButton *button = mButtons[buttonName];
//if the value is not found in the list, the widget is checked false
bool buttonValue = values.contains(buttonName);
//skip if the butotn value will not change
if (button->isChecked() == buttonValue)
continue;
//disable autoexclusive if it's enabled and we're setting
//the button value to false
bool switchExclusive = (!buttonValue && button->autoExclusive());
if (switchExclusive)
button->setAutoExclusive (false);
button->setChecked (buttonValue);
if (switchExclusive)
button->setAutoExclusive(true);
}
View::updateView (signalUpdate);
}
CSVSettings::RangeView *CSVSettings::RangeViewFactory::createView
(CSMSettings::Setting *setting,
Page *parent)
{
return new RangeView (setting, parent);
}

@ -0,0 +1,44 @@
#ifndef CSVSETTINGS_RANGEVIEW_HPP
#define CSVSETTINGS_RANGEVIEW_HPP
#include <QWidget>
#include <QAbstractButton>
#include "view.hpp"
#include "../../model/settings/support.hpp"
class QStringListModel;
namespace CSVSettings
{
class RangeView : public View
{
Q_OBJECT
QMap <QString, QAbstractButton *> mButtons;
public:
explicit RangeView (CSMSettings::Setting *setting,
Page *parent);
protected:
void updateView (bool signalUpdate = true) const;
private slots:
void slotToggled (bool state);
};
class RangeViewFactory : public QObject, public IViewFactory
{
Q_OBJECT
public:
explicit RangeViewFactory (QWidget *parent = 0)
: QObject (parent)
{}
RangeView *createView (CSMSettings::Setting *setting,
Page *parent);
};
}
#endif // CSVSETTINGS_RANGEVIEW_HPP

@ -19,7 +19,7 @@ void CSVSettings::SettingWindow::createPages()
QList <CSMSettings::Setting *> connectedSettings; QList <CSMSettings::Setting *> connectedSettings;
foreach (const QString &pageName, pageMap.keys()) foreach (const QString &pageName, pageMap.keys())
{ {
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName); QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName);
mPages.append (new Page (pageName, pageSettings, this)); mPages.append (new Page (pageName, pageSettings, this));

@ -25,7 +25,7 @@ CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
void CSVWorld::DataDisplayDelegate::buildPixmaps () void CSVWorld::DataDisplayDelegate::buildPixmaps ()
{ {
if (mPixmaps.size() > 0) if (!mPixmaps.empty())
mPixmaps.clear(); mPixmaps.clear();
IconList::iterator it = mIcons.begin(); IconList::iterator it = mIcons.begin();
@ -33,7 +33,7 @@ void CSVWorld::DataDisplayDelegate::buildPixmaps ()
while (it != mIcons.end()) while (it != mIcons.end())
{ {
mPixmaps.push_back (std::make_pair (it->first, it->second.pixmap (mIconSize) ) ); mPixmaps.push_back (std::make_pair (it->first, it->second.pixmap (mIconSize) ) );
it++; ++it;
} }
} }

@ -298,7 +298,7 @@ void CSVWorld::Table::revertRecord()
{ {
std::vector<std::string> revertableIds = listRevertableSelectedIds(); std::vector<std::string> revertableIds = listRevertableSelectedIds();
if (revertableIds.size()>0) if (!revertableIds.empty())
{ {
if (revertableIds.size()>1) if (revertableIds.size()>1)
mDocument.getUndoStack().beginMacro (tr ("Revert multiple records")); mDocument.getUndoStack().beginMacro (tr ("Revert multiple records"));
@ -318,7 +318,7 @@ void CSVWorld::Table::deleteRecord()
{ {
std::vector<std::string> deletableIds = listDeletableSelectedIds(); std::vector<std::string> deletableIds = listDeletableSelectedIds();
if (deletableIds.size()>0) if (!deletableIds.empty())
{ {
if (deletableIds.size()>1) if (deletableIds.size()>1)
mDocument.getUndoStack().beginMacro (tr ("Delete multiple records")); mDocument.getUndoStack().beginMacro (tr ("Delete multiple records"));

@ -59,9 +59,6 @@ void OMW::Engine::executeLocalScripts()
MWScript::InterpreterContext interpreterContext ( MWScript::InterpreterContext interpreterContext (
&script.second.getRefData().getLocals(), script.second); &script.second.getRefData().getLocals(), script.second);
MWBase::Environment::get().getScriptManager()->run (script.first, interpreterContext); MWBase::Environment::get().getScriptManager()->run (script.first, interpreterContext);
if (MWBase::Environment::get().getWorld()->hasCellChanged())
break;
} }
localScripts.setIgnore (MWWorld::Ptr()); localScripts.setIgnore (MWWorld::Ptr());
@ -101,15 +98,10 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// global scripts // global scripts
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run(); MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
bool changed = MWBase::Environment::get().getWorld()->hasCellChanged();
// local scripts // local scripts
executeLocalScripts(); // This does not handle the case where a global script causes a executeLocalScripts();
// cell change, followed by a cell change in a local script during
// the same frame.
if (changed) // keep change flag for another frame, if cell changed happened in local script MWBase::Environment::get().getWorld()->markCellAsUnchanged();
MWBase::Environment::get().getWorld()->markCellAsUnchanged();
if (!paused) if (!paused)
MWBase::Environment::get().getWorld()->advanceTime( MWBase::Environment::get().getWorld()->advanceTime(

@ -28,7 +28,7 @@ namespace MWGui
{ {
getWidget(mVersionText, "VersionText"); getWidget(mVersionText, "VersionText");
std::stringstream sstream; std::stringstream sstream;
sstream << "OpenMW version: " << OPENMW_VERSION; sstream << "OpenMW Version: " << OPENMW_VERSION;
// adding info about git hash if available // adding info about git hash if available
std::string rev = OPENMW_VERSION_COMMITHASH; std::string rev = OPENMW_VERSION_COMMITHASH;
@ -36,7 +36,7 @@ namespace MWGui
if (!rev.empty() && !tag.empty()) if (!rev.empty() && !tag.empty())
{ {
rev = rev.substr(0,10); rev = rev.substr(0,10);
sstream << "\nrevision: " << rev; sstream << "\nRevision: " << rev;
} }
std::string output = sstream.str(); std::string output = sstream.str();

@ -78,13 +78,13 @@ namespace MWGui
} }
void TradeWindow::startTrade(const MWWorld::Ptr& actor) void TradeWindow::startTrade(const MWWorld::Ptr& actor)
{ {
mPtr = actor; mPtr = actor;
mCurrentBalance = 0; mCurrentBalance = 0;
mCurrentMerchantOffer = 0; mCurrentMerchantOffer = 0;
checkTradeTime(); checkTradeTime();
std::vector<MWWorld::Ptr> itemSources; std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources); MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
@ -245,7 +245,7 @@ namespace MWGui
// were there any items traded at all? // were there any items traded at all?
std::vector<ItemStack> playerBought = playerItemModel->getItemsBorrowedToUs(); std::vector<ItemStack> playerBought = playerItemModel->getItemsBorrowedToUs();
std::vector<ItemStack> merchantBought = mTradeModel->getItemsBorrowedToUs(); std::vector<ItemStack> merchantBought = mTradeModel->getItemsBorrowedToUs();
if (!playerBought.size() && !merchantBought.size()) if (playerBought.empty() && merchantBought.empty())
{ {
// user notification // user notification
MWBase::Environment::get().getWindowManager()-> MWBase::Environment::get().getWindowManager()->
@ -476,7 +476,7 @@ namespace MWGui
} }
// Relates to NPC gold reset delay // Relates to NPC gold reset delay
void TradeWindow::checkTradeTime() void TradeWindow::checkTradeTime()
{ {
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr); MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt()); double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
@ -488,14 +488,14 @@ namespace MWGui
} }
} }
void TradeWindow::updateTradeTime() void TradeWindow::updateTradeTime()
{ {
MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr); MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr);
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr); MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt()); double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
// If trade timestamp is within reset delay don't set // If trade timestamp is within reset delay don't set
if ( ! (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() && if ( ! (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() &&
MWBase::Environment::get().getWorld()->getTimeStamp() < sellerStats.getTradeTime() + delay) ) MWBase::Environment::get().getWorld()->getTimeStamp() < sellerStats.getTradeTime() + delay) )
{ {
sellerStats.setTradeTime(MWBase::Environment::get().getWorld()->getTimeStamp()); sellerStats.setTradeTime(MWBase::Environment::get().getWorld()->getTimeStamp());

@ -206,7 +206,7 @@ namespace MWMechanics
if (effectIt->mKey.mId == effectId) if (effectIt->mKey.mId == effectId)
effectIt = it->second.mEffects.erase(effectIt); effectIt = it->second.mEffects.erase(effectIt);
else else
effectIt++; ++effectIt;
} }
} }
mSpellsChanged = true; mSpellsChanged = true;
@ -224,7 +224,7 @@ namespace MWMechanics
&& it->second.mCasterHandle == actorHandle) && it->second.mCasterHandle == actorHandle)
effectIt = it->second.mEffects.erase(effectIt); effectIt = it->second.mEffects.erase(effectIt);
else else
effectIt++; ++effectIt;
} }
} }
mSpellsChanged = true; mSpellsChanged = true;

@ -879,12 +879,23 @@ namespace MWMechanics
iter->second->update(duration); iter->second->update(duration);
} }
// Kill dead actors // 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 = MWWorld::Class::get(iter->first);
CreatureStats &stats = cls.getCreatureStats(iter->first); CreatureStats &stats = cls.getCreatureStats(iter->first);
//KnockedOutOneFrameLogic
//Used for "OnKnockedOut" command
//Put here to ensure that it's run for PRECISELY one frame.
if(stats.getKnockedDown() && !stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Start it for one frame if nessesary
stats.setKnockedDownOneFrame(true);
}
else if (stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Turn off KnockedOutOneframe
stats.setKnockedDownOneFrame(false);
stats.setKnockedDownOverOneFrame(true);
}
if(!stats.isDead()) if(!stats.isDead())
{ {
if(iter->second->isDead()) if(iter->second->isDead())
@ -1018,7 +1029,6 @@ namespace MWMechanics
{ {
const MWWorld::Class &cls = MWWorld::Class::get(iter->first); const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
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());
@ -1040,7 +1050,6 @@ namespace MWMechanics
{ {
const MWWorld::Class &cls = MWWorld::Class::get(*iter); const MWWorld::Class &cls = MWWorld::Class::get(*iter);
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)
{ {
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage()); MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());

@ -38,7 +38,7 @@ MWMechanics::AiSequence& MWMechanics::AiSequence::operator= (const AiSequence& s
copy (sequence); copy (sequence);
mDone = sequence.mDone; mDone = sequence.mDone;
} }
return *this; return *this;
} }
@ -51,7 +51,7 @@ int MWMechanics::AiSequence::getTypeId() const
{ {
if (mPackages.empty()) if (mPackages.empty())
return -1; return -1;
return mPackages.front()->getTypeId(); return mPackages.front()->getTypeId();
} }
@ -102,7 +102,7 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
} }
else else
{ {
mDone = false; mDone = false;
} }
} }
} }
@ -128,7 +128,7 @@ void MWMechanics::AiSequence::stack (const AiPackage& package, const MWWorld::Pt
} }
} }
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); it++) for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
{ {
if(mPackages.front()->getPriority() <= package.getPriority()) if(mPackages.front()->getPriority() <= package.getPriority())
{ {

@ -1,6 +1,7 @@
#include "aiwander.hpp" #include "aiwander.hpp"
#include <OgreVector3.h> #include <OgreVector3.h>
#include <OgreSceneNode.h>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -213,7 +214,7 @@ namespace MWMechanics
// Reduce the turning animation glitch by using a *HUGE* value of // Reduce the turning animation glitch by using a *HUGE* value of
// epsilon... TODO: a proper fix might be in either the physics or the // epsilon... TODO: a proper fix might be in either the physics or the
// animation subsystem // animation subsystem
if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(12))) if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(5)))
mRotate = false; mRotate = false;
} }
@ -366,18 +367,7 @@ namespace MWMechanics
if(mChooseAction) if(mChooseAction)
{ {
mPlayedIdle = 0; mPlayedIdle = 0;
unsigned short idleRoll = 0; getRandomIdle(); // NOTE: sets mPlayedIdle with a random selection
for(unsigned int counter = 0; counter < mIdle.size(); counter++)
{
unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter];
unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier));
if(randSelect < idleChance && randSelect > idleRoll)
{
mPlayedIdle = counter+2;
idleRoll = randSelect;
}
}
if(!mPlayedIdle && mDistance) if(!mPlayedIdle && mDistance)
{ {
@ -428,6 +418,8 @@ namespace MWMechanics
mMoveNow = false; mMoveNow = false;
mWalking = false; mWalking = false;
mObstacleCheck.clear(); mObstacleCheck.clear();
mIdleNow = true;
getRandomIdle();
} }
if(!mRotate) if(!mRotate)
@ -435,11 +427,11 @@ namespace MWMechanics
Ogre::Vector3 dir = playerPos - actorPos; Ogre::Vector3 dir = playerPos - actorPos;
float length = dir.length(); float length = dir.length();
// FIXME: horrible hack
float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) * float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) *
((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees(); ((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees();
float actorAngle = actor.getRefData().getBaseNode()->getOrientation().getRoll().valueDegrees();
// an attempt at reducing the turning animation glitch // an attempt at reducing the turning animation glitch
if(abs(faceAngle) > 10) if(abs(abs(faceAngle) - abs(actorAngle)) >= 5) // TODO: is there a better way?
{ {
mTargetAngle = faceAngle; mTargetAngle = faceAngle;
mRotate = true; mRotate = true;
@ -465,7 +457,8 @@ namespace MWMechanics
} }
// Check if idle animation finished // Check if idle animation finished
if(!checkIdle(actor, mPlayedIdle)) // FIXME: don't stay forever
if(!checkIdle(actor, mPlayedIdle) && playerDistSqr > helloDistance*helloDistance)
{ {
mPlayedIdle = 0; mPlayedIdle = 0;
mIdleNow = false; mIdleNow = false;
@ -624,5 +617,21 @@ namespace MWMechanics
{ {
mHasReturnPosition = true; mReturnPosition = position; mHasReturnPosition = true; mReturnPosition = position;
} }
void AiWander::getRandomIdle()
{
unsigned short idleRoll = 0;
for(unsigned int counter = 0; counter < mIdle.size(); counter++)
{
unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter];
unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier));
if(randSelect < idleChance && randSelect > idleRoll)
{
mPlayedIdle = counter+2;
idleRoll = randSelect;
}
}
}
} }

@ -33,6 +33,7 @@ namespace MWMechanics
void stopWalking(const MWWorld::Ptr& actor); void stopWalking(const MWWorld::Ptr& actor);
void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect);
void getRandomIdle();
int mDistance; // how far the actor can wander from the spawn point int mDistance; // how far the actor can wander from the spawn point
int mDuration; int mDuration;

@ -17,7 +17,7 @@ namespace MWMechanics
mAttacked (false), mHostile (false), mAttacked (false), mHostile (false),
mAttackingOrSpell(false), mAttackingOrSpell(false),
mIsWerewolf(false), mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false), mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f) mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)
{ {
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
@ -387,6 +387,8 @@ namespace MWMechanics
void CreatureStats::setKnockedDown(bool value) void CreatureStats::setKnockedDown(bool value)
{ {
mKnockdown = value; mKnockdown = value;
if(!value) //Resets the "OverOneFrame" flag
setKnockedDownOverOneFrame(false);
} }
bool CreatureStats::getKnockedDown() const bool CreatureStats::getKnockedDown() const
@ -394,6 +396,23 @@ namespace MWMechanics
return mKnockdown; return mKnockdown;
} }
void CreatureStats::setKnockedDownOneFrame(bool value)
{
mKnockdownOneFrame = value;
}
bool CreatureStats::getKnockedDownOneFrame() const
{
return mKnockdownOneFrame;
}
void CreatureStats::setKnockedDownOverOneFrame(bool value) {
mKnockdownOverOneFrame = value;
}
bool CreatureStats::getKnockedDownOverOneFrame() const {
return mKnockdownOverOneFrame;
}
void CreatureStats::setHitRecovery(bool value) void CreatureStats::setHitRecovery(bool value)
{ {
mHitRecovery = value; mHitRecovery = value;
@ -479,7 +498,7 @@ namespace MWMechanics
} }
// Relates to NPC gold reset delay // Relates to NPC gold reset delay
void CreatureStats::setTradeTime(MWWorld::TimeStamp tradeTime) void CreatureStats::setTradeTime(MWWorld::TimeStamp tradeTime)
{ {
mTradeTime = tradeTime; mTradeTime = tradeTime;
} }
@ -489,11 +508,11 @@ namespace MWMechanics
return mTradeTime; return mTradeTime;
} }
void CreatureStats::setGoldPool(int pool) void CreatureStats::setGoldPool(int pool)
{ {
mGoldPool = pool; mGoldPool = pool;
} }
int CreatureStats::getGoldPool() const int CreatureStats::getGoldPool() const
{ {
return mGoldPool; return mGoldPool;
} }

@ -41,6 +41,8 @@ namespace MWMechanics
bool mHostile; bool mHostile;
bool mAttackingOrSpell; bool mAttackingOrSpell;
bool mKnockdown; bool mKnockdown;
bool mKnockdownOneFrame;
bool mKnockdownOverOneFrame;
bool mHitRecovery; bool mHitRecovery;
bool mBlock; bool mBlock;
unsigned int mMovementFlags; unsigned int mMovementFlags;
@ -188,7 +190,14 @@ namespace MWMechanics
float getEvasion() const; float getEvasion() const;
void setKnockedDown(bool value); void setKnockedDown(bool value);
///Returns true for the entire duration of the actor being knocked down
bool getKnockedDown() const; bool getKnockedDown() const;
void setKnockedDownOneFrame(bool value);
///Returns true only for the first frame of the actor being knocked out; used for "onKnockedOut" command
bool getKnockedDownOneFrame() const;
void setKnockedDownOverOneFrame(bool value);
///Returns true for all but the first frame of being knocked out; used to know to not reset mKnockedDownOneFrame
bool getKnockedDownOverOneFrame() const;
void setHitRecovery(bool value); void setHitRecovery(bool value);
bool getHitRecovery() const; bool getHitRecovery() const;
void setBlock(bool value); void setBlock(bool value);

@ -860,7 +860,8 @@ namespace MWMechanics
// Find an actor who witnessed the crime // Find an actor who witnessed the crime
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
{ {
if (*it == ptr) continue; // not the player if ( *it == ptr
|| !it->getClass().isNpc()) continue; // not the player and is an NPC
// Was the crime seen? // Was the crime seen?
if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) ||
@ -876,7 +877,8 @@ namespace MWMechanics
// Tell everyone, including yourself // Tell everyone, including yourself
for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1)
{ {
if (*it1 == ptr) continue; // not the player if ( *it == ptr
|| !it->getClass().isNpc()) continue; // not the player and is an NPC
// TODO: Add more messages // TODO: Add more messages
if (type == OT_Theft) if (type == OT_Theft)

@ -296,7 +296,7 @@ namespace MWMechanics
// add this edge to openset, lowest cost goes to the front // add this edge to openset, lowest cost goes to the front
// TODO: if this causes performance problems a hash table may help // TODO: if this causes performance problems a hash table may help
std::list<int>::iterator it = openset.begin(); std::list<int>::iterator it = openset.begin();
for(it = openset.begin(); it!= openset.end(); it++) for(it = openset.begin(); it!= openset.end(); ++it)
{ {
if(fScore[*it] > fScore[dest]) if(fScore[*it] > fScore[dest])
break; break;

@ -401,10 +401,10 @@ namespace MWMechanics
if (!exploded) if (!exploded)
MWBase::Environment::get().getWorld()->explodeSpell(mHitPosition, mTarget, effects, caster, mId, mSourceName); MWBase::Environment::get().getWorld()->explodeSpell(mHitPosition, mTarget, effects, caster, mId, mSourceName);
if (reflectedEffects.mList.size()) if (!reflectedEffects.mList.empty())
inflict(caster, target, reflectedEffects, range, true); inflict(caster, target, reflectedEffects, range, true);
if (appliedLastingEffects.size()) if (!appliedLastingEffects.empty())
target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects, target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects,
mSourceName, caster.getRefData().getHandle()); mSourceName, caster.getRefData().getHandle());

@ -129,7 +129,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Disease) if (spell->mData.mType == ESM::Spell::ST_Disease)
mSpells.erase(iter++); mSpells.erase(iter++);
else else
iter++; ++iter;
} }
} }
@ -143,7 +143,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Blight) if (spell->mData.mType == ESM::Spell::ST_Blight)
mSpells.erase(iter++); mSpells.erase(iter++);
else else
iter++; ++iter;
} }
} }
@ -157,7 +157,7 @@ namespace MWMechanics
if (Misc::StringUtils::ciEqual(spell->mId, "corprus")) if (Misc::StringUtils::ciEqual(spell->mId, "corprus"))
mSpells.erase(iter++); mSpells.erase(iter++);
else else
iter++; ++iter;
} }
} }
@ -171,7 +171,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Curse) if (spell->mData.mType == ESM::Spell::ST_Curse)
mSpells.erase(iter++); mSpells.erase(iter++);
else else
iter++; ++iter;
} }
} }

@ -411,7 +411,7 @@ Ogre::Node *Animation::getNode(const std::string &name)
NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::TextKeyMap &keys, const std::string &groupname) NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::TextKeyMap &keys, const std::string &groupname)
{ {
NifOgre::TextKeyMap::const_iterator iter(keys.begin()); NifOgre::TextKeyMap::const_iterator iter(keys.begin());
for(;iter != keys.end();iter++) for(;iter != keys.end();++iter)
{ {
if(iter->second.compare(0, groupname.size(), groupname) == 0 && if(iter->second.compare(0, groupname.size(), groupname) == 0 &&
iter->second.compare(groupname.size(), 2, ": ") == 0) iter->second.compare(groupname.size(), 2, ": ") == 0)
@ -424,7 +424,7 @@ NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::Tex
bool Animation::hasAnimation(const std::string &anim) bool Animation::hasAnimation(const std::string &anim)
{ {
AnimSourceList::const_iterator iter(mAnimSources.begin()); AnimSourceList::const_iterator iter(mAnimSources.begin());
for(;iter != mAnimSources.end();iter++) for(;iter != mAnimSources.end();++iter)
{ {
const NifOgre::TextKeyMap &keys = (*iter)->mTextKeys; const NifOgre::TextKeyMap &keys = (*iter)->mTextKeys;
if(findGroupStart(keys, anim) != keys.end()) if(findGroupStart(keys, anim) != keys.end())
@ -465,7 +465,7 @@ float Animation::calcAnimVelocity(const NifOgre::TextKeyMap &keys, NifOgre::Node
stoptime = keyiter->first; stoptime = keyiter->first;
break; break;
} }
keyiter++; ++keyiter;
} }
if(stoptime > starttime) if(stoptime > starttime)
@ -585,13 +585,13 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
std::string starttag = groupname+": "+start; std::string starttag = groupname+": "+start;
NifOgre::TextKeyMap::const_iterator startkey(groupstart); NifOgre::TextKeyMap::const_iterator startkey(groupstart);
while(startkey != keys.end() && startkey->second != starttag) while(startkey != keys.end() && startkey->second != starttag)
startkey++; ++startkey;
if(startkey == keys.end() && start == "loop start") if(startkey == keys.end() && start == "loop start")
{ {
starttag = groupname+": start"; starttag = groupname+": start";
startkey = groupstart; startkey = groupstart;
while(startkey != keys.end() && startkey->second != starttag) while(startkey != keys.end() && startkey->second != starttag)
startkey++; ++startkey;
} }
if(startkey == keys.end()) if(startkey == keys.end())
return false; return false;
@ -603,7 +603,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
// The Scrib's idle3 animation has "Idle3: Stop." instead of "Idle3: Stop". // The Scrib's idle3 animation has "Idle3: Stop." instead of "Idle3: Stop".
// Why, just why? :( // Why, just why? :(
&& (stopkey->second.size() < stoptag.size() || stopkey->second.substr(0,stoptag.size()) != stoptag)) && (stopkey->second.size() < stoptag.size() || stopkey->second.substr(0,stoptag.size()) != stoptag))
stopkey++; ++stopkey;
if(stopkey == keys.end()) if(stopkey == keys.end())
return false; return false;
@ -627,7 +627,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
state.mLoopStartTime = key->first; state.mLoopStartTime = key->first;
else if(key->second == loopstoptag) else if(key->second == loopstoptag)
state.mLoopStopTime = key->first; state.mLoopStopTime = key->first;
key++; ++key;
} }
} }
@ -776,7 +776,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
/* Look in reverse; last-inserted source has priority. */ /* Look in reverse; last-inserted source has priority. */
AnimSourceList::reverse_iterator iter(mAnimSources.rbegin()); AnimSourceList::reverse_iterator iter(mAnimSources.rbegin());
for(;iter != mAnimSources.rend();iter++) for(;iter != mAnimSources.rend();++iter)
{ {
const NifOgre::TextKeyMap &textkeys = (*iter)->mTextKeys; const NifOgre::TextKeyMap &textkeys = (*iter)->mTextKeys;
AnimState state; AnimState state;
@ -795,7 +795,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
while(textkey != textkeys.end() && textkey->first <= state.mTime) while(textkey != textkeys.end() && textkey->first <= state.mTime)
{ {
handleTextKey(state, groupname, textkey); handleTextKey(state, groupname, textkey);
textkey++; ++textkey;
} }
if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0) if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0)
@ -810,7 +810,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
while(textkey != textkeys.end() && textkey->first <= state.mTime) while(textkey != textkeys.end() && textkey->first <= state.mTime)
{ {
handleTextKey(state, groupname, textkey); handleTextKey(state, groupname, textkey);
textkey++; ++textkey;
} }
} }
@ -965,7 +965,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
while(textkey != textkeys.end() && textkey->first <= state.mTime) while(textkey != textkeys.end() && textkey->first <= state.mTime)
{ {
handleTextKey(state, stateiter->first, textkey); handleTextKey(state, stateiter->first, textkey);
textkey++; ++textkey;
} }
if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0) if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0)
@ -979,7 +979,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
while(textkey != textkeys.end() && textkey->first <= state.mTime) while(textkey != textkeys.end() && textkey->first <= state.mTime)
{ {
handleTextKey(state, stateiter->first, textkey); handleTextKey(state, stateiter->first, textkey);
textkey++; ++textkey;
} }
if(state.mTime >= state.mLoopStopTime) if(state.mTime >= state.mLoopStopTime)

@ -106,7 +106,7 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
uint32 startIndex = 0; uint32 startIndex = 0;
for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin(); for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin();
it != pathgrid->mPoints.end(); it != pathgrid->mPoints.end();
it++, startIndex += 6) ++it, startIndex += 6)
{ {
Vector3 pointPos(it->mX, it->mY, it->mZ); Vector3 pointPos(it->mX, it->mY, it->mZ);

@ -240,25 +240,25 @@ Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::CellStore* cell)
void Objects::enableLights() void Objects::enableLights()
{ {
PtrAnimationMap::const_iterator it = mObjects.begin(); PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++) for(;it != mObjects.end();++it)
it->second->enableLights(true); it->second->enableLights(true);
} }
void Objects::disableLights() void Objects::disableLights()
{ {
PtrAnimationMap::const_iterator it = mObjects.begin(); PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++) for(;it != mObjects.end();++it)
it->second->enableLights(false); it->second->enableLights(false);
} }
void Objects::update(float dt, Ogre::Camera* camera) void Objects::update(float dt, Ogre::Camera* camera)
{ {
PtrAnimationMap::const_iterator it = mObjects.begin(); PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++) for(;it != mObjects.end();++it)
it->second->runAnimation(dt); it->second->runAnimation(dt);
it = mObjects.begin(); it = mObjects.begin();
for(;it != mObjects.end();it++) for(;it != mObjects.end();++it)
it->second->preRender(camera); it->second->preRender(camera);
} }

@ -388,5 +388,7 @@ op 0x200023c: StopCombat
op 0x200023d: StopCombatExplicit op 0x200023d: StopCombatExplicit
op 0x200023e: GetPcInJail op 0x200023e: GetPcInJail
op 0x200023f: GetPcTraveling op 0x200023f: GetPcTraveling
op 0x2000240: onKnockout
op 0x2000241: onKnockoutExplicit
opcodes 0x2000240-0x3ffffff unused opcodes 0x2000242-0x3ffffff unused

@ -1060,6 +1060,22 @@ namespace MWScript
} }
}; };
template <class R>
class OpOnKnockout : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value =
MWWorld::Class::get (ptr).getCreatureStats (ptr).getKnockedDownOneFrame();
runtime.push (value);
}
};
template <class R> template <class R>
class OpIsWerewolf : public Interpreter::Opcode0 class OpIsWerewolf : public Interpreter::Opcode0
{ {
@ -1236,6 +1252,8 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Stats::opcodeOnDeath, new OpOnDeath<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeOnDeath, new OpOnDeath<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath<ExplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockout, new OpOnKnockout<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockoutExplicit, new OpOnKnockout<ExplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf<ExplicitRef>);
@ -1245,7 +1263,7 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolf, new OpSetWerewolf<ImplicitRef, false>); interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolf, new OpSetWerewolf<ImplicitRef, false>);
interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolfExplicit, new OpSetWerewolf<ExplicitRef, false>); interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolfExplicit, new OpSetWerewolf<ExplicitRef, false>);
interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobatics, new OpSetWerewolfAcrobatics<ImplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobatics, new OpSetWerewolfAcrobatics<ImplicitRef>);
interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit, new OpSetWerewolfAcrobatics<ExplicitRef>); interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit, new OpSetWerewolfAcrobatics<ExplicitRef>);
} }
} }
} }

@ -442,7 +442,7 @@ namespace MWSound
{ {
snditer->first->setFadeout(duration); snditer->first->setFadeout(duration);
} }
snditer++; ++snditer;
} }
} }

@ -20,7 +20,7 @@ namespace MWWorld
//find any NPC that is following the actor and teleport him too //find any NPC that is following the actor and teleport him too
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor); std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();it++) for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
{ {
std::cout << "teleporting someone!" << (*it).getCellRef().mRefID; std::cout << "teleporting someone!" << (*it).getCellRef().mRefID;
executeImp(*it); executeImp(*it);

@ -433,7 +433,6 @@ namespace MWWorld
while(mCell->getNextRef(esm[index], ref, deleted)) while(mCell->getNextRef(esm[index], ref, deleted))
{ {
// Don't load reference if it was moved to a different cell. // Don't load reference if it was moved to a different cell.
std::string lowerCase = Misc::StringUtils::lowerCase(ref.mRefID);
ESM::MovedCellRefTracker::const_iterator iter = ESM::MovedCellRefTracker::const_iterator iter =
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum); std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum);
if (iter != mCell->mMovedRefs.end()) { if (iter != mCell->mMovedRefs.end()) {

@ -671,7 +671,7 @@ namespace MWWorld
void PhysicsSystem::queueObjectMovement(const Ptr &ptr, const Ogre::Vector3 &movement) void PhysicsSystem::queueObjectMovement(const Ptr &ptr, const Ogre::Vector3 &movement)
{ {
PtrVelocityList::iterator iter = mMovementQueue.begin(); PtrVelocityList::iterator iter = mMovementQueue.begin();
for(;iter != mMovementQueue.end();iter++) for(;iter != mMovementQueue.end();++iter)
{ {
if(iter->first == ptr) if(iter->first == ptr)
{ {
@ -692,7 +692,7 @@ namespace MWWorld
{ {
const MWBase::World *world = MWBase::Environment::get().getWorld(); const MWBase::World *world = MWBase::Environment::get().getWorld();
PtrVelocityList::iterator iter = mMovementQueue.begin(); PtrVelocityList::iterator iter = mMovementQueue.begin();
for(;iter != mMovementQueue.end();iter++) for(;iter != mMovementQueue.end();++iter)
{ {
float waterlevel = -std::numeric_limits<float>::max(); float waterlevel = -std::numeric_limits<float>::max();
const ESM::Cell *cell = iter->first.getCell()->getCell(); const ESM::Cell *cell = iter->first.getCell()->getCell();

@ -141,17 +141,17 @@ namespace MWWorld
// Find all the actors who might be able to see the player // Find all the actors who might be able to see the player
std::vector<MWWorld::Ptr> neighbors; std::vector<MWWorld::Ptr> neighbors;
MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos), MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos),
esmStore.get<ESM::GameSetting>().find("fSneakUseDist")->getInt(), neighbors); esmStore.get<ESM::GameSetting>().find("fSneakUseDist")->getInt(), neighbors);
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
{ {
if ( MWBase::Environment::get().getMechanicsManager()->awarenessCheck(ptr, *it) ) if ( MWBase::Environment::get().getMechanicsManager()->awarenessCheck(ptr, *it) )
{ {
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false); MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
break; break;
} }
} }
if (neighbors.size() == 0) if (neighbors.empty())
MWBase::Environment::get().getWindowManager()->setSneakVisibility(true); MWBase::Environment::get().getWindowManager()->setSneakVisibility(true);
} }
} }

@ -95,7 +95,7 @@ namespace MWWorld
bool wasTeleported() const; bool wasTeleported() const;
void setTeleported(bool teleported); void setTeleported(bool teleported);
///Checks all actors to see if anyone has an aipackage against you ///Checks all nearby actors to see if anyone has an aipackage against you
bool isInCombat(); bool isInCombat();
void clear(); void clear();

@ -444,6 +444,7 @@ namespace Compiler
extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit); extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit);
extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath, opcodeOnDeathExplicit); extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath, opcodeOnDeathExplicit);
extensions.registerFunction ("onknockout", 'l', "", opcodeOnKnockout, opcodeOnKnockoutExplicit);
extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit); extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit);

@ -377,6 +377,8 @@ namespace Compiler
const int opcodeLowerRankExplicit = 0x20001eb; const int opcodeLowerRankExplicit = 0x20001eb;
const int opcodeOnDeath = 0x20001fc; const int opcodeOnDeath = 0x20001fc;
const int opcodeOnDeathExplicit = 0x2000205; const int opcodeOnDeathExplicit = 0x2000205;
const int opcodeOnKnockout = 0x2000240;
const int opcodeOnKnockoutExplicit = 0x2000241;
const int opcodeBecomeWerewolf = 0x2000217; const int opcodeBecomeWerewolf = 0x2000217;
const int opcodeBecomeWerewolfExplicit = 0x2000218; const int opcodeBecomeWerewolfExplicit = 0x2000218;

@ -4,7 +4,7 @@
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 300 130" name="_Main"> <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 300 130" name="_Main">
<Property key="Visible" value="false"/> <Property key="Visible" value="false"/>
<Widget type="EditBox" skin="MW_TextEditClient" position="8 8 284 400" name="Message" align="Left Top Stretch"> <Widget type="EditBox" skin="MW_TextEditClient" position="16 8 268 130" name="Message" align="Center Top">
<Property key="FontName" value="Default"/> <Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Top HCenter"/> <Property key="TextAlign" value="Top HCenter"/>
<Property key="TextColour" value="0.75 0.6 0.35"/> <Property key="TextColour" value="0.75 0.6 0.35"/>
@ -13,18 +13,19 @@
<Property key="MultiLine" value="true"/> <Property key="MultiLine" value="true"/>
</Widget> </Widget>
<Widget type="HBox" position="0 89 284 24" align="Right Bottom"> <Widget type="VBox" position="0 89 292 24" align="Right Bottom">
<Widget type="Widget"> <Widget type="HBox">
<UserString key="HStretch" value="true"/> <Property key="Spacing" value="8"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton" align="Right Bottom"> <Widget type="AutoSizedButton" skin="MW_Button" name="OkButton" align="Right Bottom">
<Property key="Caption" value="#{sCancel}"/> <Property key="Caption" value="#{sYes}"/>
</Widget> </Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="OkButton" align="Right Bottom"> <Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton" align="Right Bottom">
<Property key="Caption" value="#{sOk}"/> <Property key="Caption" value="#{sNo}"/>
</Widget>
</Widget> </Widget>
</Widget>
<Widget type="Widget"/>
</Widget>
</Widget> </Widget>
</MyGUI> </MyGUI>

@ -2,11 +2,11 @@
<MyGUI type="Layout"> <MyGUI type="Layout">
<!-- The entire screen --> <!-- The entire screen -->
<Widget type="Widget" layer="Windows" position="0 0 300 300" name="_Main" > <Widget type="Widget" layer="Windows" position="0 0 300 300" name="_Main">
<Widget type="TextBox" skin="SandText" position="0 250 300 50" align="Bottom" name="VersionText"> <Widget type="TextBox" skin="SandText" position="0 250 280 50" align="Bottom Right" name="VersionText">
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Right"/>
<Property key="TextShadow" value="true"/> <Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/> <Property key="TextShadowColour" value="0 0 0"/>
</Widget> </Widget>
</Widget> </Widget>
</MyGUI> </MyGUI>

Loading…
Cancel
Save