mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-25 16:30:15 +00:00
feat: add WEATHER_CHANGED event and GetWeatherInfo query
Fire WEATHER_CHANGED(weatherType, intensity) when the server sends SMSG_WEATHER with a new weather state. Enables weather-aware addons to react to rain/snow/storm transitions. GetWeatherInfo() returns current weatherType (0=clear, 1=rain, 2=snow, 3=storm) and intensity (0.0-1.0). Weather data is already tracked by game_handler and used by the renderer for particle effects and fog.
This commit is contained in:
parent
2947e31375
commit
d1d3645d2b
2 changed files with 11 additions and 0 deletions
|
|
@ -5062,6 +5062,14 @@ void LuaEngine::registerCoreAPI() {
|
|||
lua_pushboolean(L, 1); // isCastable
|
||||
return 4;
|
||||
}},
|
||||
// --- Weather ---
|
||||
{"GetWeatherInfo", [](lua_State* L) -> int {
|
||||
auto* gh = getGameHandler(L);
|
||||
if (!gh) { lua_pushnumber(L, 0); lua_pushnumber(L, 0); return 2; }
|
||||
lua_pushnumber(L, gh->getWeatherType());
|
||||
lua_pushnumber(L, gh->getWeatherIntensity());
|
||||
return 2;
|
||||
}},
|
||||
// --- Vendor Buy/Sell ---
|
||||
{"BuyMerchantItem", [](lua_State* L) -> int {
|
||||
auto* gh = getGameHandler(L);
|
||||
|
|
|
|||
|
|
@ -5221,6 +5221,9 @@ void GameHandler::handlePacket(network::Packet& packet) {
|
|||
}
|
||||
if (weatherMsg) addSystemChatMessage(weatherMsg);
|
||||
}
|
||||
// Notify addons of weather change
|
||||
if (addonEventCallback_)
|
||||
addonEventCallback_("WEATHER_CHANGED", {std::to_string(wType), std::to_string(wIntensity)});
|
||||
// Storm transition: trigger a low-frequency thunder rumble shake
|
||||
if (wType == 3 && wIntensity > 0.3f && cameraShakeCallback_) {
|
||||
float mag = 0.03f + wIntensity * 0.04f; // 0.03–0.07 units
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue