mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:23:51 +00:00
Regional Sounds
This commit is contained in:
parent
a038c67e5a
commit
be1582a88f
2 changed files with 49 additions and 9 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <MyGUI_WidgetManager.h>
|
#include <MyGUI_WidgetManager.h>
|
||||||
#include "mwgui/class.hpp"
|
#include "mwgui/class.hpp"
|
||||||
|
|
||||||
|
|
||||||
void OMW::Engine::executeLocalScripts()
|
void OMW::Engine::executeLocalScripts()
|
||||||
{
|
{
|
||||||
for (MWWorld::World::ScriptList::const_iterator iter (
|
for (MWWorld::World::ScriptList::const_iterator iter (
|
||||||
|
@ -108,26 +109,60 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
startRandomTitle();
|
startRandomTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the region has changed
|
std::string effect;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
|
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
|
||||||
if(!(current->cell->data.flags & current->cell->Interior) && (test.name != current->cell->region)){
|
//If the region has changed
|
||||||
test = *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
||||||
|
timer.restart();
|
||||||
|
if (test.name != current->cell->region)
|
||||||
|
{
|
||||||
|
total = 0;
|
||||||
|
test = *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
||||||
|
}
|
||||||
|
|
||||||
if(test.soundList.size() > 0)
|
if(test.soundList.size() > 0)
|
||||||
{
|
{
|
||||||
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
|
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
|
||||||
mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
|
|
||||||
//mEnvironment.mSoundManager
|
//mEnvironment.mSoundManager
|
||||||
while (!(soundIter == test.soundList.end()))
|
if(total == 0){
|
||||||
{
|
while (!(soundIter == test.soundList.end()))
|
||||||
ESM::NAME32 go = soundIter->sound;
|
{
|
||||||
char chance = soundIter->chance;
|
ESM::NAME32 go = soundIter->sound;
|
||||||
std::cout << "Sound: " << go.name <<" Chance:" << (int) chance << "\n";
|
int chance = (int) soundIter->chance;
|
||||||
soundIter++;
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
||||||
|
soundIter++;
|
||||||
|
total += chance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srand ( time(NULL) );
|
||||||
|
int r = rand() % total; //old random code
|
||||||
|
int pos = 0;
|
||||||
|
soundIter = test.soundList.begin();
|
||||||
|
while (!(soundIter == test.soundList.end()))
|
||||||
|
{
|
||||||
|
const ESM::NAME32 go = soundIter->sound;
|
||||||
|
int chance = (int) soundIter->chance;
|
||||||
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
||||||
|
soundIter++;
|
||||||
|
if( r - pos < chance)
|
||||||
|
{
|
||||||
|
effect = go.name;
|
||||||
|
//play sound
|
||||||
|
std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
||||||
|
mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
pos += chance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0);
|
||||||
//printf("REGION: %s\n", test.name);
|
//printf("REGION: %s\n", test.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -296,6 +331,7 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
MP3Lookup();
|
MP3Lookup();
|
||||||
test.name = "";
|
test.name = "";
|
||||||
|
total = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
#include "mwworld/ptr.hpp"
|
#include "mwworld/ptr.hpp"
|
||||||
|
#include <boost/timer.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace Compiler
|
namespace Compiler
|
||||||
{
|
{
|
||||||
|
@ -62,6 +64,7 @@ namespace OMW
|
||||||
bool mVerboseScripts;
|
bool mVerboseScripts;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
bool mUseSound;
|
bool mUseSound;
|
||||||
|
int total;
|
||||||
|
|
||||||
MWWorld::Environment mEnvironment;
|
MWWorld::Environment mEnvironment;
|
||||||
MWScript::ScriptManager *mScriptManager;
|
MWScript::ScriptManager *mScriptManager;
|
||||||
|
@ -69,6 +72,7 @@ namespace OMW
|
||||||
Compiler::Context *mScriptContext;
|
Compiler::Context *mScriptContext;
|
||||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||||
ESM::Region test;
|
ESM::Region test;
|
||||||
|
boost::timer timer;
|
||||||
|
|
||||||
int focusFrameCounter;
|
int focusFrameCounter;
|
||||||
static const int focusUpdateFrame = 10;
|
static const int focusUpdateFrame = 10;
|
||||||
|
|
Loading…
Reference in a new issue