This commit is contained in:
Joaquin 2022-09-08 01:12:45 -06:00
parent c8a4e1c840
commit d2daa11a27
2 changed files with 45 additions and 58 deletions

View File

@ -8,43 +8,22 @@
namespace cheat::feature namespace cheat::feature
{ {
const char* WeatherType[]{ "ClearSky", "Cloudy", "Foggy", "Storm", "RainHeavy", "FountainRain", "SnowLight", "EastCoast" }; static std::map<CustomWeather::WeatherType, std::string> weather
std::string CustomWeather::GetWeather() { {
switch (current_weather) { CustomWeather::WeatherType::ClearSky, "Data/Environment/Weather/BigWorld/Weather_ClearSky" },
{ { CustomWeather::WeatherType::Cloudy, "Data/Environment/Weather/BigWorld/Weather_Cloudy" },
case 0: { CustomWeather::WeatherType::Foggy, "Data/Environment/Weather/BigWorld/Weather_Foggy" },
return "Data/Environment/Weather/BigWorld/Weather_ClearSky"; { CustomWeather::WeatherType::Storm, "Data/Environment/Weather/BigWorld/Weather_Storm" },
{ CustomWeather::WeatherType::RainHeavy, "Data/Environment/Weather/BigWorld/Weather_Dq_Tabeisha_Rain_Heavy" },
case 1: { CustomWeather::WeatherType::FountainRain, "Data/Environment/Weather/BigWorld/Weather_LY_Fountain_Rain" },
return "Data/Environment/Weather/BigWorld/Weather_Cloudy"; { CustomWeather::WeatherType::SnowLight, "Data/Environment/Weather/BigWorld/Weather_Snowmountain_Snow_Light" },
{ CustomWeather::WeatherType::EastCoast, "Data/Environment/Weather/BigWorld/Weather_Snowmountain_EastCoast" },
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";
}
}
CustomWeather::CustomWeather() : Feature(), CustomWeather::CustomWeather() : Feature(),
NF(f_Enabled, "Custom Weather", "World", false), NF(f_Enabled, "Custom Weather", "CustomWeather", false),
NF(f_Lightning, "Lightning", "World", false), NF(f_Lightning, "Lightning", "CustomWeather", false),
toBeUpdate(), nextUpdate(0) NF(f_WeatherType, "WeatherType", "CustomWeather", CustomWeather::WeatherType::ClearSky)
{ {
events::GameUpdateEvent += MY_METHOD_HANDLER(CustomWeather::OnGameUpdate); events::GameUpdateEvent += MY_METHOD_HANDLER(CustomWeather::OnGameUpdate);
} }
@ -58,9 +37,8 @@ namespace cheat::feature
void CustomWeather::DrawMain() void CustomWeather::DrawMain()
{ {
ConfigWidget(f_Enabled, "Custom Weather."); ConfigWidget(f_Enabled, "Custom Weather.");
if (f_Enabled) { if (f_Enabled)
ImGui::Combo(("Weather Type"), &current_weather, WeatherType, ARRAYSIZE(WeatherType)); ConfigWidget(f_WeatherType, "Select weather type.");
}
ConfigWidget(f_Lightning, "Lightning target enemy, works with RainHeavy weather."); ConfigWidget(f_Lightning, "Lightning target enemy, works with RainHeavy weather.");
} }
@ -73,7 +51,7 @@ namespace cheat::feature
{ {
ImGui::Text("Custom Weather"); ImGui::Text("Custom Weather");
if (f_Lightning) if (f_Lightning)
ImGui::Text("Lightning"); ImGui::Text("Lightning");
} }
CustomWeather& CustomWeather::GetInstance() CustomWeather& CustomWeather::GetInstance()
@ -87,28 +65,28 @@ namespace cheat::feature
if (!f_Enabled) if (!f_Enabled)
return; return;
auto currentTime = util::GetCurrentTimeMillisec(); UPDATE_DELAY(100);
if (currentTime < nextUpdate)
return;
auto Enviro = app::EnviroSky_get_Instance(nullptr); auto Enviro = app::EnviroSky_get_Instance(nullptr);
if (Enviro != nullptr) { if (Enviro != nullptr)
app::EnviroSky_ChangeWeather(Enviro, string_to_il2cppi(GetWeather()), 1, 1, 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(); 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) if (manager.avatar()->distance(Monsters) >= 30)
continue; continue;
for (auto& entity : manager.entities(game::filters::combined::Lightning)) { for (auto& entity : manager.entities(game::filters::combined::Lightning))
{
entity->setRelativePosition(Monsters->relativePosition()); entity->setRelativePosition(Monsters->relativePosition());
} }
} }
} }
} }
nextUpdate = currentTime + (int)f_DelayUpdate;
} }
} }

View File

@ -1,27 +1,36 @@
#pragma once #pragma once
#include <cheat-base/cheat/Feature.h> #include <cheat-base/cheat/Feature.h>
#include <cheat-base/config/config.h> #include <cheat-base/config/config.h>
#include <cheat-base/thread-safe.h>
namespace cheat::feature namespace cheat::feature
{ {
class CustomWeather : public Feature class CustomWeather : public Feature
{ {
public: public:
enum class WeatherType
{
ClearSky,
Cloudy,
Foggy,
Storm,
RainHeavy,
FountainRain,
SnowLight,
EastCoast,
};
config::Field<config::Toggle<Hotkey>> f_Enabled; config::Field<config::Toggle<Hotkey>> f_Enabled;
config::Field<config::Toggle<Hotkey>> f_Lightning; config::Field<config::Toggle<Hotkey>> f_Lightning;
config::Field<config::Enum<WeatherType>> f_WeatherType;
static CustomWeather& GetInstance(); static CustomWeather& GetInstance();
const FeatureGUIInfo& GetGUIInfo() const override; const FeatureGUIInfo& GetGUIInfo() const override;
void DrawMain() override; void DrawMain() override;
bool NeedStatusDraw() const override; bool NeedStatusDraw() const override;
void DrawStatus() override; void DrawStatus() override;
private: private:
int current_weather;
std::string GetWeather();
SafeQueue<uint32_t> toBeUpdate;
SafeValue<int64_t> nextUpdate;
int f_DelayUpdate = 1;
void OnGameUpdate(); void OnGameUpdate();
CustomWeather(); CustomWeather();
}; };