mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
implemented GetCurrentWeather script function
This commit is contained in:
parent
8d5783d75d
commit
d77d5080bd
@ -119,4 +119,5 @@ op 0x200013b: twf
|
||||
op 0x200013c: FadeIn
|
||||
op 0x200013d: FadeOut
|
||||
op 0x200013e: FadeTo
|
||||
opcodes 0x200013f-0x3ffffff unused
|
||||
op 0x200013f: GetCurrentWeather
|
||||
opcodes 0x2000140-0x3ffffff unused
|
||||
|
@ -79,12 +79,26 @@ namespace MWScript
|
||||
runtime.push (context.getWorld().getSecundaPhase());
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetCurrentWeather : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
runtime.push (context.getWorld().getCurrentWeather());
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeToggleSky = 0x2000021;
|
||||
const int opcodeTurnMoonWhite = 0x2000022;
|
||||
const int opcodeTurnMoonRed = 0x2000023;
|
||||
const int opcodeGetMasserPhase = 0x2000024;
|
||||
const int opcodeGetSecundaPhase = 0x2000025;
|
||||
const int opcodeGetCurrentWeather = 0x200013f;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
@ -94,6 +108,7 @@ namespace MWScript
|
||||
extensions.registerInstruction ("turnmoonred", "", opcodeTurnMoonRed);
|
||||
extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase);
|
||||
extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase);
|
||||
extensions.registerFunction ("getcurrentweather", 'l', "", opcodeGetCurrentWeather);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
@ -103,6 +118,7 @@ namespace MWScript
|
||||
interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed);
|
||||
interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase);
|
||||
interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase);
|
||||
interpreter.installSegment5 (opcodeGetCurrentWeather, new OpGetCurrentWeather);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,6 +316,9 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen
|
||||
mWeatherSettings["blizzard"] = blizzard;
|
||||
|
||||
setWeather("foggy", true);
|
||||
|
||||
// const ESM::Region *region =
|
||||
// context.getWorld().getStore().regions.find (cell->region);
|
||||
}
|
||||
|
||||
void WeatherManager::setWeather(const String& weather, bool instant)
|
||||
@ -661,3 +664,32 @@ void WeatherManager::setDate(const int day, const int month)
|
||||
mDay = day;
|
||||
mMonth = month;
|
||||
}
|
||||
|
||||
unsigned int WeatherManager::getWeatherID() const
|
||||
{
|
||||
// Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather
|
||||
|
||||
if (mCurrentWeather == "clear")
|
||||
return 0;
|
||||
else if (mCurrentWeather == "cloudy")
|
||||
return 1;
|
||||
else if (mCurrentWeather == "foggy")
|
||||
return 2;
|
||||
else if (mCurrentWeather == "overcast")
|
||||
return 3;
|
||||
else if (mCurrentWeather == "rain")
|
||||
return 4;
|
||||
else if (mCurrentWeather == "thunder")
|
||||
return 5;
|
||||
else if (mCurrentWeather == "ashstorm")
|
||||
return 6;
|
||||
else if (mCurrentWeather == "blight")
|
||||
return 7;
|
||||
else if (mCurrentWeather == "snow")
|
||||
return 8;
|
||||
else if (mCurrentWeather == "blizzard")
|
||||
return 9;
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -233,6 +233,8 @@ namespace MWWorld
|
||||
|
||||
void setDate(const int day, const int month);
|
||||
|
||||
unsigned int getWeatherID() const;
|
||||
|
||||
private:
|
||||
float mHour;
|
||||
int mDay, mMonth;
|
||||
|
@ -736,6 +736,11 @@ namespace MWWorld
|
||||
return false;
|
||||
}
|
||||
|
||||
int World::getCurrentWeather() const
|
||||
{
|
||||
return mWeatherManager->getWeatherID();
|
||||
}
|
||||
|
||||
OEngine::Render::Fader* World::getFader()
|
||||
{
|
||||
return mRendering->getFader();
|
||||
|
@ -163,6 +163,8 @@ namespace MWWorld
|
||||
|
||||
bool toggleSky();
|
||||
///< \return Resulting mode
|
||||
|
||||
int getCurrentWeather() const;
|
||||
|
||||
int getMasserPhase() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user