1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-22 00:23:51 +00:00

Merge remote-tracking branch 'zini/master' into nifogre

This commit is contained in:
Chris Robinson 2013-04-20 00:25:00 -07:00
commit 4122b0b55f
6 changed files with 111 additions and 19 deletions

View file

@ -49,6 +49,67 @@ namespace
{ {
return new CustomData (*this); return new CustomData (*this);
} }
void autoCalculateAttributes (const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats)
{
// race bonus
const ESM::Race *race =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc->mRace);
bool male = (npc->mFlags & ESM::NPC::Female) == 0;
int level = creatureStats.getLevel();
for (int i=0; i<ESM::Attribute::Length; ++i)
{
const ESM::Race::MaleFemale& attribute = race->mData.mAttributeValues[i];
creatureStats.getAttribute(i).setBase (male ? attribute.mMale : attribute.mFemale);
}
// class bonus
const ESM::Class *class_ =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
for (int i=0; i<2; ++i)
{
int attribute = class_->mData.mAttribute[i];
if (attribute>=0 && attribute<8)
{
creatureStats.getAttribute(attribute).setBase (
creatureStats.getAttribute(attribute).getBase() + 10);
}
}
// skill bonus
for (int attribute=0; attribute<ESM::Attribute::Length; ++attribute)
{
float modifierSum = 0;
for (int j=0; j<ESM::Skill::Length; ++j)
{
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(j);
if (skill->mData.mAttribute != attribute)
continue;
// is this a minor or major skill?
float add=0.2;
for (int k=0; k<5; ++k)
{
if (class_->mData.mSkills[k][0] == j)
add=0.5;
}
for (int k=0; k<5; ++k)
{
if (class_->mData.mSkills[k][1] == j)
add=1.0;
}
modifierSum += add;
}
creatureStats.getAttribute(attribute).setBase ( std::min(creatureStats.getAttribute(attribute).getBase()
+ static_cast<int>((level-1) * modifierSum+0.5), 100) );
}
}
} }
namespace MWClass namespace MWClass
@ -126,15 +187,14 @@ namespace MWClass
} }
else else
{ {
for (int i=0; i<8; ++i)
data->mCreatureStats.getAttribute (i).set (10);
for (int i=0; i<3; ++i) for (int i=0; i<3; ++i)
data->mCreatureStats.setDynamic (i, 10); data->mCreatureStats.setDynamic (i, 10);
data->mCreatureStats.setLevel(ref->mBase->mNpdt12.mLevel); data->mCreatureStats.setLevel(ref->mBase->mNpdt12.mLevel);
data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt12.mDisposition); data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt12.mDisposition);
data->mNpcStats.setReputation(ref->mBase->mNpdt12.mReputation); data->mNpcStats.setReputation(ref->mBase->mNpdt12.mReputation);
autoCalculateAttributes(ref->mBase, data->mCreatureStats);
} }
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello); data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);

View file

@ -426,6 +426,7 @@ namespace MWDialogue
void DialogueManager::questionAnswered (const std::string& answer) void DialogueManager::questionAnswered (const std::string& answer)
{ {
if (mChoiceMap.find(answer) != mChoiceMap.end()) if (mChoiceMap.find(answer) != mChoiceMap.end())
{ {
mChoice = mChoiceMap[answer]; mChoice = mChoiceMap[answer];
@ -442,6 +443,10 @@ namespace MWDialogue
std::string text = info->mResponse; std::string text = info->mResponse;
parseText (text); parseText (text);
mChoiceMap.clear();
mChoice = -1;
mIsInChoice = false;
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addText (Interpreter::fixDefinesDialog(text, interpreterContext)); MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addText (Interpreter::fixDefinesDialog(text, interpreterContext));
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId); MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId);
@ -449,9 +454,6 @@ namespace MWDialogue
mLastDialogue = *info; mLastDialogue = *info;
} }
} }
mChoiceMap.clear();
mChoice = -1;
mIsInChoice = false;
} }
updateTopics(); updateTopics();

View file

@ -21,13 +21,15 @@ namespace MWRender
CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name, CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
Ogre::Vector3 position, Ogre::Vector3 lookAt) Ogre::Vector3 position, Ogre::Vector3 lookAt)
: mSizeX(sizeX)
, mSizeY(sizeY) : mSceneMgr (0)
, mName(name)
, mPosition(position) , mPosition(position)
, mLookAt(lookAt) , mLookAt(lookAt)
, mCharacter(character) , mCharacter(character)
, mAnimation(NULL) , mAnimation(NULL)
, mName(name)
, mSizeX(sizeX)
, mSizeY(sizeY)
{ {
} }
@ -88,16 +90,20 @@ namespace MWRender
CharacterPreview::~CharacterPreview () CharacterPreview::~CharacterPreview ()
{ {
//Ogre::TextureManager::getSingleton().remove(mName); if (mSceneMgr)
mSceneMgr->destroyCamera (mName); {
delete mAnimation; //Ogre::TextureManager::getSingleton().remove(mName);
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr); mSceneMgr->destroyAllCameras();
delete mAnimation;
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
}
} }
void CharacterPreview::rebuild() void CharacterPreview::rebuild()
{ {
assert(mAnimation); assert(mAnimation);
delete mAnimation; delete mAnimation;
mAnimation = 0;
mAnimation = new NpcAnimation(mCharacter, mNode, MWWorld::Class::get(mCharacter).getInventoryStore(mCharacter), mAnimation = new NpcAnimation(mCharacter, mNode, MWWorld::Class::get(mCharacter).getInventoryStore(mCharacter),
0, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal)); 0, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));

View file

@ -559,6 +559,8 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
assert(mgr); assert(mgr);
mSceneMgr = mgr; mSceneMgr = mgr;
mShaderRenderManager = NULL;
mRenderManager = NULL;
using namespace MyGUI; using namespace MyGUI;
@ -574,7 +576,10 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
// Set up OGRE platform (bypassing OgrePlatform). We might make this more generic later. // Set up OGRE platform (bypassing OgrePlatform). We might make this more generic later.
mLogManager = new LogManager(); mLogManager = new LogManager();
mRenderManager = new MyGUI::ShaderBasedRenderManager(); if (!Ogre::Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION))
mShaderRenderManager = new MyGUI::ShaderBasedRenderManager();
else
mRenderManager = new MyGUI::OgreRenderManager();
mDataManager = new MyGUI::FixedOgreDataManager(); mDataManager = new MyGUI::FixedOgreDataManager();
LogManager::getInstance().setSTDOutputEnabled(logging); LogManager::getInstance().setSTDOutputEnabled(logging);
@ -582,7 +587,10 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
if (!theLogFile.empty()) if (!theLogFile.empty())
LogManager::getInstance().createDefaultSource(theLogFile); LogManager::getInstance().createDefaultSource(theLogFile);
mRenderManager->initialise(wnd, mgr); if (mShaderRenderManager)
mShaderRenderManager->initialise(wnd, mgr);
else
mRenderManager->initialise(wnd, mgr);
mDataManager->initialise("General"); mDataManager->initialise("General");
// Create GUI // Create GUI
@ -592,8 +600,16 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd) void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd)
{ {
mRenderManager->setRenderWindow (wnd); if (mShaderRenderManager)
mRenderManager->setActiveViewport(0); {
mShaderRenderManager->setRenderWindow (wnd);
mShaderRenderManager->setActiveViewport(0);
}
else
{
mRenderManager->setRenderWindow (wnd);
mRenderManager->setActiveViewport(0);
}
} }
void MyGUIManager::shutdown() void MyGUIManager::shutdown()
@ -606,6 +622,12 @@ void MyGUIManager::shutdown()
delete mRenderManager; delete mRenderManager;
mRenderManager = NULL; mRenderManager = NULL;
} }
if(mShaderRenderManager)
{
mShaderRenderManager->shutdown();
delete mShaderRenderManager;
mShaderRenderManager = NULL;
}
if(mDataManager) if(mDataManager)
{ {
mDataManager->shutdown(); mDataManager->shutdown();

View file

@ -8,6 +8,7 @@ namespace MyGUI
class Gui; class Gui;
class LogManager; class LogManager;
class OgreDataManager; class OgreDataManager;
class OgreRenderManager;
class ShaderBasedRenderManager; class ShaderBasedRenderManager;
} }
@ -25,12 +26,12 @@ namespace GUI
MyGUI::Gui *mGui; MyGUI::Gui *mGui;
MyGUI::LogManager* mLogManager; MyGUI::LogManager* mLogManager;
MyGUI::OgreDataManager* mDataManager; MyGUI::OgreDataManager* mDataManager;
MyGUI::ShaderBasedRenderManager* mRenderManager; MyGUI::OgreRenderManager* mRenderManager;
MyGUI::ShaderBasedRenderManager* mShaderRenderManager;
Ogre::SceneManager* mSceneMgr; Ogre::SceneManager* mSceneMgr;
public: public:
MyGUIManager() : mLogManager(NULL), mDataManager(NULL), mRenderManager(NULL), mGui(NULL) {}
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string("")) MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""))
{ {
setup(wnd,mgr,logging, logDir); setup(wnd,mgr,logging, logDir);

View file

@ -136,6 +136,7 @@ Bug #700: "On the rocks" mod does not load its UV coordinates correctly.
Bug #702: Some race mods don't work Bug #702: Some race mods don't work
Bug #711: Crash during character creation Bug #711: Crash during character creation
Bug #715: Growing Tauryon Bug #715: Growing Tauryon
Bug #725: Auto calculate stats
Feature #55/657: Item Repairing Feature #55/657: Item Repairing
Feature #62/87: Enchanting Feature #62/87: Enchanting
Feature #99: Pathfinding Feature #99: Pathfinding