diff --git a/cheat-library/src/user/cheat/world/CustomWeather.cpp b/cheat-library/src/user/cheat/world/CustomWeather.cpp index 960a873..141811a 100644 --- a/cheat-library/src/user/cheat/world/CustomWeather.cpp +++ b/cheat-library/src/user/cheat/world/CustomWeather.cpp @@ -8,43 +8,22 @@ namespace cheat::feature { - const char* WeatherType[]{ "ClearSky", "Cloudy", "Foggy", "Storm", "RainHeavy", "FountainRain", "SnowLight", "EastCoast" }; - std::string CustomWeather::GetWeather() { - switch (current_weather) - { - case 0: - return "Data/Environment/Weather/BigWorld/Weather_ClearSky"; - - case 1: - return "Data/Environment/Weather/BigWorld/Weather_Cloudy"; - - case 2: - return "Data/Environment/Weather/BigWorld/Weather_Foggy"; - - case 3: - return "Data/Environment/Weather/BigWorld/Weather_Storm"; - - case 4: - return "Data/Environment/Weather/BigWorld/Weather_Dq_Tabeisha_Rain_Heavy"; - - case 5: - return "Data/Environment/Weather/BigWorld/Weather_LY_Fountain_Rain"; - - case 6: - return "Data/Environment/Weather/BigWorld/Weather_Snowmountain_Snow_Light"; - - case 7: - return "Data/Environment/Weather/BigWorld/Weather_Snowmountain_EastCoast"; - - default: - return "Data/Environment/Weather/BigWorld/Weather_ClearSky"; - } - } + static std::map weather + { + { CustomWeather::WeatherType::ClearSky, "Data/Environment/Weather/BigWorld/Weather_ClearSky" }, + { CustomWeather::WeatherType::Cloudy, "Data/Environment/Weather/BigWorld/Weather_Cloudy" }, + { CustomWeather::WeatherType::Foggy, "Data/Environment/Weather/BigWorld/Weather_Foggy" }, + { CustomWeather::WeatherType::Storm, "Data/Environment/Weather/BigWorld/Weather_Storm" }, + { CustomWeather::WeatherType::RainHeavy, "Data/Environment/Weather/BigWorld/Weather_Dq_Tabeisha_Rain_Heavy" }, + { CustomWeather::WeatherType::FountainRain, "Data/Environment/Weather/BigWorld/Weather_LY_Fountain_Rain" }, + { CustomWeather::WeatherType::SnowLight, "Data/Environment/Weather/BigWorld/Weather_Snowmountain_Snow_Light" }, + { CustomWeather::WeatherType::EastCoast, "Data/Environment/Weather/BigWorld/Weather_Snowmountain_EastCoast" }, + }; CustomWeather::CustomWeather() : Feature(), - NF(f_Enabled, "Custom Weather", "World", false), - NF(f_Lightning, "Lightning", "World", false), - toBeUpdate(), nextUpdate(0) + NF(f_Enabled, "Custom Weather", "CustomWeather", false), + NF(f_Lightning, "Lightning", "CustomWeather", false), + NF(f_WeatherType, "WeatherType", "CustomWeather", CustomWeather::WeatherType::ClearSky) { events::GameUpdateEvent += MY_METHOD_HANDLER(CustomWeather::OnGameUpdate); } @@ -56,11 +35,10 @@ namespace cheat::feature } void CustomWeather::DrawMain() - { + { ConfigWidget(f_Enabled, "Custom Weather."); - if (f_Enabled) { - ImGui::Combo(("Weather Type"), ¤t_weather, WeatherType, ARRAYSIZE(WeatherType)); - } + if (f_Enabled) + ConfigWidget(f_WeatherType, "Select weather type."); ConfigWidget(f_Lightning, "Lightning target enemy, works with RainHeavy weather."); } @@ -73,7 +51,7 @@ namespace cheat::feature { ImGui::Text("Custom Weather"); if (f_Lightning) - ImGui::Text("Lightning"); + ImGui::Text("Lightning"); } CustomWeather& CustomWeather::GetInstance() @@ -87,28 +65,28 @@ namespace cheat::feature if (!f_Enabled) return; - auto currentTime = util::GetCurrentTimeMillisec(); - if (currentTime < nextUpdate) - return; + UPDATE_DELAY(100); auto Enviro = app::EnviroSky_get_Instance(nullptr); - if (Enviro != nullptr) { - app::EnviroSky_ChangeWeather(Enviro, string_to_il2cppi(GetWeather()), 1, 1, nullptr); + if (Enviro != nullptr) + { + app::EnviroSky_ChangeWeather(Enviro, string_to_il2cppi(weather.at(f_WeatherType.value())), 1, 1, nullptr); - if (f_Lightning && current_weather == 4) { + if (f_Lightning && f_WeatherType.value() == CustomWeather::WeatherType::RainHeavy) + { auto& manager = game::EntityManager::instance(); - - for (auto& Monsters : manager.entities(game::filters::combined::Monsters)) { + + for (auto& Monsters : manager.entities(game::filters::combined::Monsters)) + { if (manager.avatar()->distance(Monsters) >= 30) continue; - for (auto& entity : manager.entities(game::filters::combined::Lightning)) { + for (auto& entity : manager.entities(game::filters::combined::Lightning)) + { entity->setRelativePosition(Monsters->relativePosition()); - } + } } } } - - nextUpdate = currentTime + (int)f_DelayUpdate; } } \ No newline at end of file diff --git a/cheat-library/src/user/cheat/world/CustomWeather.h b/cheat-library/src/user/cheat/world/CustomWeather.h index 738b38a..5724165 100644 --- a/cheat-library/src/user/cheat/world/CustomWeather.h +++ b/cheat-library/src/user/cheat/world/CustomWeather.h @@ -1,27 +1,36 @@ #pragma once #include #include -#include namespace cheat::feature { class CustomWeather : public Feature { public: + + enum class WeatherType + { + ClearSky, + Cloudy, + Foggy, + Storm, + RainHeavy, + FountainRain, + SnowLight, + EastCoast, + }; + config::Field> f_Enabled; config::Field> f_Lightning; + config::Field> f_WeatherType; static CustomWeather& GetInstance(); const FeatureGUIInfo& GetGUIInfo() const override; void DrawMain() override; bool NeedStatusDraw() const override; void DrawStatus() override; + private: - int current_weather; - std::string GetWeather(); - SafeQueue toBeUpdate; - SafeValue nextUpdate; - int f_DelayUpdate = 1; void OnGameUpdate(); CustomWeather(); };