mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 10:45:35 +00:00
Merge branch 'master' into water
Conflicts: files/settings-default.cfg
This commit is contained in:
commit
b1c84f28a9
40 changed files with 459 additions and 45 deletions
|
@ -346,7 +346,10 @@ if(WIN32)
|
|||
FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*")
|
||||
INSTALL(FILES ${files} DESTINATION ".")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
|
||||
INSTALL(FILES "${OpenMW_SOURCE_DIR}/readme.txt" DESTINATION ".")
|
||||
INSTALL(FILES
|
||||
"${OpenMW_SOURCE_DIR}/readme.txt"
|
||||
"${OpenMW_BINARY_DIR}/settings-default.cfg"
|
||||
DESTINATION ".")
|
||||
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
|
||||
|
||||
SET(CPACK_GENERATOR "NSIS")
|
||||
|
@ -356,8 +359,12 @@ if(WIN32)
|
|||
SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW;esmtool;Esmtool;omwlauncher;OpenMW Launcher")
|
||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Readme.lnk' '\$INSTDIR\\\\readme.txt'")
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW;omwlauncher;OpenMW Launcher")
|
||||
SET(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Readme.lnk' '\$INSTDIR\\\\readme.txt'")
|
||||
SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
|
||||
Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Readme.lnk\\\"
|
||||
")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${OpenMW_SOURCE_DIR}/GPL3.txt")
|
||||
SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
|
||||
|
|
|
@ -55,7 +55,7 @@ add_openmw_dir (mwclass
|
|||
)
|
||||
|
||||
add_openmw_dir (mwmechanics
|
||||
mechanicsmanager stat creaturestats magiceffects movement
|
||||
mechanicsmanager stat creaturestats magiceffects movement actors
|
||||
)
|
||||
|
||||
# Main executable
|
||||
|
|
|
@ -160,7 +160,8 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
|
||||
// update actors
|
||||
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
|
||||
mEnvironment.mMechanicsManager->update (movement);
|
||||
mEnvironment.mMechanicsManager->update (movement, mEnvironment.mFrameDuration,
|
||||
mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game);
|
||||
|
||||
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
||||
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
|
||||
|
@ -357,7 +358,7 @@ void OMW::Engine::go()
|
|||
// to find core.xml here.
|
||||
|
||||
//addResourcesDirectory(mResDir);
|
||||
|
||||
|
||||
addResourcesDirectory(mResDir / "mygui");
|
||||
addResourcesDirectory(mResDir / "water");
|
||||
addResourcesDirectory(mResDir / "gbuffer");
|
||||
|
|
|
@ -70,6 +70,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Apparatus::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Apparatus>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Apparatus::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Apparatus);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -160,6 +160,14 @@ namespace MWClass
|
|||
return ESM::Skill::HeavyArmor;
|
||||
}
|
||||
|
||||
int Armor::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Armor::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Armor);
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace MWClass
|
|||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -72,6 +72,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Book::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Book>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Book::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Book);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -123,6 +123,14 @@ namespace MWClass
|
|||
return -1;
|
||||
}
|
||||
|
||||
int Clothing::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Clothing>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Clothing::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Clothing);
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace MWClass
|
|||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -68,6 +68,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Ingredient::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Ingredient>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Ingredient::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Ingredient);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -110,6 +110,14 @@ namespace MWClass
|
|||
return std::make_pair (slots, false);
|
||||
}
|
||||
|
||||
int Light::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Light::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Light);
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -81,6 +81,14 @@ namespace MWClass
|
|||
return std::make_pair (slots, false);
|
||||
}
|
||||
|
||||
int Lockpick::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Tool>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Lockpick::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Lockpick);
|
||||
|
|
|
@ -29,6 +29,9 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -70,6 +70,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Miscellaneous::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Miscellaneous);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -70,6 +70,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Potion::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Potion::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Potion);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -80,6 +80,14 @@ namespace MWClass
|
|||
return std::make_pair (slots, false);
|
||||
}
|
||||
|
||||
int Probe::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Probe::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Probe);
|
||||
|
|
|
@ -29,6 +29,9 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -70,6 +70,14 @@ namespace MWClass
|
|||
return ref->base->script;
|
||||
}
|
||||
|
||||
int Repair::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Repair::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Repair);
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace MWClass
|
|||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of the script attached to ptr
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
|
@ -139,6 +139,14 @@ namespace MWClass
|
|||
return -1;
|
||||
}
|
||||
|
||||
int Weapon::getValue (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->base->data.value;
|
||||
}
|
||||
|
||||
void Weapon::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Weapon);
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace MWClass
|
|||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
|
||||
|
|
77
apps/openmw/mwmechanics/actors.cpp
Normal file
77
apps/openmw/mwmechanics/actors.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
#include "actors.hpp"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||
{
|
||||
if (!paused && ptr.getRefData().getHandle()!="player")
|
||||
MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip (
|
||||
MWWorld::Class::get (ptr).getNpcStats (ptr), mEnvironment);
|
||||
}
|
||||
|
||||
Actors::Actors (MWWorld::Environment& environment) : mEnvironment (environment), mDuration (0) {}
|
||||
|
||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mActors.insert (ptr);
|
||||
}
|
||||
|
||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mActors.erase (ptr);
|
||||
}
|
||||
|
||||
void Actors::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
||||
{
|
||||
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();
|
||||
|
||||
while (iter!=mActors.end())
|
||||
if (iter->getCell()==cellStore)
|
||||
{
|
||||
mActors.erase (iter++);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
|
||||
void Actors::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement, float duration,
|
||||
bool paused)
|
||||
{
|
||||
mDuration += duration;
|
||||
|
||||
if (mDuration>=0.25)
|
||||
{
|
||||
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter)
|
||||
{
|
||||
updateActor (*iter, mDuration);
|
||||
|
||||
if (iter->getTypeName()==typeid (ESM::NPC).name())
|
||||
updateNpc (*iter, mDuration, paused);
|
||||
}
|
||||
|
||||
mDuration = 0;
|
||||
}
|
||||
|
||||
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end();
|
||||
++iter)
|
||||
{
|
||||
Ogre::Vector3 vector = MWWorld::Class::get (*iter).getMovementVector (*iter);
|
||||
|
||||
if (vector!=Ogre::Vector3::ZERO)
|
||||
movement.push_back (std::make_pair (iter->getRefData().getHandle(), vector));
|
||||
}
|
||||
}
|
||||
}
|
51
apps/openmw/mwmechanics/actors.hpp
Normal file
51
apps/openmw/mwmechanics/actors.hpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef GAME_MWMECHANICS_ACTORS_H
|
||||
#define GAME_MWMECHANICS_ACTORS_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class Actors
|
||||
{
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::set<MWWorld::Ptr> mActors;
|
||||
float mDuration;
|
||||
|
||||
void updateActor (const MWWorld::Ptr& ptr, float duration);
|
||||
|
||||
void updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused);
|
||||
|
||||
public:
|
||||
|
||||
Actors (MWWorld::Environment& environment);
|
||||
|
||||
void addActor (const MWWorld::Ptr& ptr);
|
||||
///< Register an actor for stats management
|
||||
|
||||
void removeActor (const MWWorld::Ptr& ptr);
|
||||
///< Deregister an actor for stats management
|
||||
|
||||
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
|
||||
///< Deregister all actors in the given cell.
|
||||
|
||||
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
|
||||
float duration, bool paused);
|
||||
///< Update actor stats and store desired velocity vectors in \a movement
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -222,14 +222,14 @@ namespace MWMechanics
|
|||
|
||||
MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
|
||||
: mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false),
|
||||
mRaceSelected (false)
|
||||
mRaceSelected (false), mActors (environment)
|
||||
{
|
||||
buildPlayer();
|
||||
}
|
||||
|
||||
void MechanicsManager::addActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mActors.insert (ptr);
|
||||
mActors.addActor (ptr);
|
||||
}
|
||||
|
||||
void MechanicsManager::removeActor (const MWWorld::Ptr& ptr)
|
||||
|
@ -237,7 +237,7 @@ namespace MWMechanics
|
|||
if (ptr==mWatched)
|
||||
mWatched = MWWorld::Ptr();
|
||||
|
||||
mActors.erase (ptr);
|
||||
mActors.removeActor (ptr);
|
||||
}
|
||||
|
||||
void MechanicsManager::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
||||
|
@ -245,16 +245,7 @@ namespace MWMechanics
|
|||
if (!mWatched.isEmpty() && mWatched.getCell()==cellStore)
|
||||
mWatched = MWWorld::Ptr();
|
||||
|
||||
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();
|
||||
|
||||
while (iter!=mActors.end())
|
||||
if (iter->getCell()==cellStore)
|
||||
{
|
||||
//std::cout << "Erasing an actor";
|
||||
mActors.erase (iter++);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
mActors.dropActors (cellStore);
|
||||
}
|
||||
|
||||
void MechanicsManager::watchActor (const MWWorld::Ptr& ptr)
|
||||
|
@ -262,7 +253,8 @@ namespace MWMechanics
|
|||
mWatched = ptr;
|
||||
}
|
||||
|
||||
void MechanicsManager::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement)
|
||||
void MechanicsManager::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
|
||||
float duration, bool paused)
|
||||
{
|
||||
if (!mWatched.isEmpty())
|
||||
{
|
||||
|
@ -345,14 +337,7 @@ namespace MWMechanics
|
|||
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
|
||||
}
|
||||
|
||||
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end();
|
||||
++iter)
|
||||
{
|
||||
Ogre::Vector3 vector = MWWorld::Class::get (*iter).getMovementVector (*iter);
|
||||
|
||||
if (vector!=Ogre::Vector3::ZERO)
|
||||
movement.push_back (std::make_pair (iter->getRefData().getHandle(), vector));
|
||||
}
|
||||
mActors.update (movement, duration, paused);
|
||||
}
|
||||
|
||||
void MechanicsManager::setPlayerName (const std::string& name)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef GAME_MWMECHANICS_MECHANICSMANAGER_H
|
||||
#define GAME_MWMECHANICS_MECHANICSMANAGER_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -9,6 +8,7 @@
|
|||
|
||||
#include "creaturestats.hpp"
|
||||
#include "npcstats.hpp"
|
||||
#include "actors.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -25,13 +25,13 @@ namespace MWMechanics
|
|||
class MechanicsManager
|
||||
{
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::set<MWWorld::Ptr> mActors;
|
||||
MWWorld::Ptr mWatched;
|
||||
CreatureStats mWatchedCreature;
|
||||
NpcStats mWatchedNpc;
|
||||
bool mUpdatePlayer;
|
||||
bool mClassSelected;
|
||||
bool mRaceSelected;
|
||||
Actors mActors;
|
||||
|
||||
void buildPlayer();
|
||||
///< build player according to stored class/race/birthsign information. Will
|
||||
|
@ -60,8 +60,12 @@ namespace MWMechanics
|
|||
///< On each update look for changes in a previously registered actor and update the
|
||||
/// GUI accordingly.
|
||||
|
||||
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement);
|
||||
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement, float duration,
|
||||
bool paused);
|
||||
///< Update actor stats and store desired velocity vectors in \a movement
|
||||
///
|
||||
/// \param paused In game type does not currently advance (this usually means some GUI
|
||||
/// component is up).
|
||||
|
||||
void setPlayerName (const std::string& name);
|
||||
///< Set player name.
|
||||
|
|
|
@ -467,10 +467,15 @@ void OpenAL_Output::init(const std::string &devname)
|
|||
else
|
||||
fail("Failed to open \""+devname+"\"");
|
||||
}
|
||||
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER)<<"\"" << std::endl;
|
||||
else
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
||||
{
|
||||
const ALCchar *name = NULL;
|
||||
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
||||
name = alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER);
|
||||
if(alcGetError(mDevice) != AL_NO_ERROR || !name)
|
||||
name = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
|
||||
std::cout << "Opened \""<<name<<"\"" << std::endl;
|
||||
}
|
||||
|
||||
mContext = alcCreateContext(mDevice, NULL);
|
||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <OgreRoot.h>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
@ -49,11 +50,20 @@ namespace MWSound
|
|||
: mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
|
||||
, mEnvironment(environment)
|
||||
, mOutput(new DEFAULT_OUTPUT(*this))
|
||||
|
||||
, mMasterVolume(1.0f)
|
||||
, mSFXVolume(1.0f)
|
||||
, mMusicVolume(1.0f)
|
||||
{
|
||||
if(!useSound)
|
||||
return;
|
||||
|
||||
mMasterVolume = Settings::Manager::getFloat("master volume", "Sound");
|
||||
mMasterVolume = std::min(std::max(mMasterVolume, 0.0f), 1.0f);
|
||||
mSFXVolume = Settings::Manager::getFloat("sfx volume", "Sound");
|
||||
mSFXVolume = std::min(std::max(mSFXVolume, 0.0f), 1.0f);
|
||||
mMusicVolume = Settings::Manager::getFloat("music volume", "Sound");
|
||||
mMusicVolume = std::min(std::max(mMusicVolume, 0.0f), 1.0f);
|
||||
|
||||
std::cout << "Sound output: " << SOUND_OUT << std::endl;
|
||||
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
||||
|
||||
|
@ -64,7 +74,19 @@ namespace MWSound
|
|||
for(size_t i = 0;i < names.size();i++)
|
||||
std::cout <<" "<<names[i]<< std::endl;
|
||||
|
||||
mOutput->init();
|
||||
std::string devname = Settings::Manager::getString("device", "Sound");
|
||||
try
|
||||
{
|
||||
mOutput->init(devname);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
if(devname.empty())
|
||||
throw;
|
||||
std::cout <<"Failed to open device \""<<devname<<"\", trying default"<< std::endl;
|
||||
mOutput->init();
|
||||
Settings::Manager::setString("device", "Sound", "");
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
|
@ -141,9 +163,10 @@ namespace MWSound
|
|||
std::cout <<"Playing "<<filename<< std::endl;
|
||||
try
|
||||
{
|
||||
float basevol = mMasterVolume * mMusicVolume;
|
||||
stopMusic();
|
||||
mMusic = mOutput->streamSound(filename, 0.4f, 1.0f, Play_NoEnv);
|
||||
mMusic->mBaseVolume = 0.4f;
|
||||
mMusic = mOutput->streamSound(filename, basevol, 1.0f, Play_NoEnv);
|
||||
mMusic->mBaseVolume = basevol;
|
||||
mMusic->mFlags = Play_NoEnv;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -187,7 +210,7 @@ namespace MWSound
|
|||
try
|
||||
{
|
||||
// The range values are not tested
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
float basevol = mMasterVolume * mSFXVolume;
|
||||
std::string filePath = "Sound/"+filename;
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
@ -218,7 +241,7 @@ namespace MWSound
|
|||
return sound;
|
||||
try
|
||||
{
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
float basevol = mMasterVolume * mSFXVolume;
|
||||
float min, max;
|
||||
std::string file = lookup(soundId, basevol, min, max);
|
||||
|
||||
|
@ -248,7 +271,7 @@ namespace MWSound
|
|||
try
|
||||
{
|
||||
// Look up the sound in the ESM data
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
float basevol = mMasterVolume * mSFXVolume;
|
||||
float min, max;
|
||||
std::string file = lookup(soundId, basevol, min, max);
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
|
|
|
@ -56,6 +56,10 @@ namespace MWSound
|
|||
|
||||
std::auto_ptr<Sound_Output> mOutput;
|
||||
|
||||
float mMasterVolume;
|
||||
float mSFXVolume;
|
||||
float mMusicVolume;
|
||||
|
||||
boost::shared_ptr<Sound> mMusic;
|
||||
std::string mCurrentPlaylist;
|
||||
|
||||
|
|
|
@ -137,6 +137,11 @@ namespace MWWorld
|
|||
return -1;
|
||||
}
|
||||
|
||||
int Class::getValue (const Ptr& ptr) const
|
||||
{
|
||||
throw std::logic_error ("value not supported by this class");
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
|
|
|
@ -155,6 +155,10 @@ namespace MWWorld
|
|||
/// no such skill.
|
||||
/// (default implementation: return -1)
|
||||
|
||||
virtual int getValue (const Ptr& ptr) const;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
/// (default implementation: throws an exception)
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
#include <iterator>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
#include "class.hpp"
|
||||
|
||||
#include <iostream> /// \todo remove after rendering is implemented
|
||||
|
||||
void MWWorld::InventoryStore::copySlots (const InventoryStore& store)
|
||||
{
|
||||
// some const-trickery, required because of a flaw in the handling of MW-references and the
|
||||
|
@ -24,10 +28,15 @@ void MWWorld::InventoryStore::copySlots (const InventoryStore& store)
|
|||
}
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore::InventoryStore()
|
||||
void MWWorld::InventoryStore::initSlots (TSlots& slots)
|
||||
{
|
||||
for (int i=0; i<Slots; ++i)
|
||||
mSlots.push_back (end());
|
||||
slots.push_back (end());
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore::InventoryStore()
|
||||
{
|
||||
initSlots (mSlots);
|
||||
}
|
||||
|
||||
MWWorld::InventoryStore::InventoryStore (const InventoryStore& store)
|
||||
|
@ -86,3 +95,87 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)
|
|||
|
||||
return mSlots[slot];
|
||||
}
|
||||
|
||||
void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats,
|
||||
const Environment& environment)
|
||||
{
|
||||
TSlots slots;
|
||||
initSlots (slots);
|
||||
|
||||
for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter)
|
||||
{
|
||||
Ptr test = *iter;
|
||||
int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test, environment);
|
||||
|
||||
std::pair<std::vector<int>, bool> itemsSlots =
|
||||
MWWorld::Class::get (*iter).getEquipmentSlots (*iter);
|
||||
|
||||
for (std::vector<int>::const_iterator iter2 (itemsSlots.first.begin());
|
||||
iter2!=itemsSlots.first.end(); ++iter2)
|
||||
{
|
||||
bool use = false;
|
||||
|
||||
if (slots.at (*iter2)==end())
|
||||
use = true; // slot was empty before -> skill all further checks
|
||||
else
|
||||
{
|
||||
Ptr old = *slots.at (*iter2);
|
||||
|
||||
if (!use)
|
||||
{
|
||||
// check skill
|
||||
int oldSkill =
|
||||
MWWorld::Class::get (old).getEquipmentSkill (old, environment);
|
||||
|
||||
if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill)
|
||||
{
|
||||
if (stats.mSkill[oldSkill].getModified()>stats.mSkill[testSkill].getModified())
|
||||
continue; // rejected, because old item better matched the NPC's skills.
|
||||
|
||||
if (stats.mSkill[oldSkill].getModified()<stats.mSkill[testSkill].getModified())
|
||||
use = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!use)
|
||||
{
|
||||
// check value
|
||||
if (MWWorld::Class::get (old).getValue (old)>=
|
||||
MWWorld::Class::get (test).getValue (test))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
use = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// \todo unstack, if reqquired (itemsSlots.second)
|
||||
|
||||
slots[*iter2] = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
for (std::size_t i=0; i<slots.size(); ++i)
|
||||
if (slots[i]!=mSlots[i])
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
mSlots.swap (slots);
|
||||
flagAsModified();
|
||||
|
||||
/// \todo remove the following line after rendering is implemented
|
||||
for (std::size_t i=0; i<mSlots.size(); ++i)
|
||||
if (mSlots[i]!=end())
|
||||
{
|
||||
std::cout<<"NPC is equipping " << MWWorld::Class::get (*mSlots[i]).getName (*mSlots[i])
|
||||
<< " in slot " << i << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,15 @@
|
|||
|
||||
#include "containerstore.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
struct NpcStats;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
struct Environment;
|
||||
|
||||
///< \brief Variant of the ContainerStore for NPCs
|
||||
class InventoryStore : public ContainerStore
|
||||
{
|
||||
|
@ -36,10 +43,14 @@ namespace MWWorld
|
|||
|
||||
private:
|
||||
|
||||
mutable std::vector<ContainerStoreIterator> mSlots;
|
||||
typedef std::vector<ContainerStoreIterator> TSlots;
|
||||
|
||||
mutable TSlots mSlots;
|
||||
|
||||
void copySlots (const InventoryStore& store);
|
||||
|
||||
void initSlots (TSlots& slots);
|
||||
|
||||
public:
|
||||
|
||||
InventoryStore();
|
||||
|
@ -52,6 +63,9 @@ namespace MWWorld
|
|||
///< \note \a iteartor can be an end-iterator
|
||||
|
||||
ContainerStoreIterator getSlot (int slot);
|
||||
|
||||
void autoEquip (const MWMechanics::NpcStats& stats, const Environment& environment);
|
||||
///< Auto equip items according to stats and item value.
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace MWWorld
|
|||
return mPtr.empty();
|
||||
}
|
||||
|
||||
const std::type_info& getType()
|
||||
const std::type_info& getType() const
|
||||
{
|
||||
assert (!mPtr.empty());
|
||||
return mPtr.type();
|
||||
|
|
|
@ -70,3 +70,12 @@ reflect small statics = false
|
|||
reflect actors = true
|
||||
|
||||
reflect misc = false
|
||||
|
||||
[Sound]
|
||||
# Device name. Blank means default
|
||||
device =
|
||||
|
||||
# Volumes. Sfx and music volumes are both affected by the master volume
|
||||
master volume = 1.0
|
||||
sfx volume = 1.0
|
||||
music volume = 0.4
|
||||
|
|
Loading…
Reference in a new issue