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
{
const char* WeatherType[]{ "ClearSky", "Cloudy", "Foggy", "Storm", "RainHeavy", "FountainRain", "SnowLight", "EastCoast" };
std::string CustomWeather::GetWeather() {
switch (current_weather)
static std::map<CustomWeather::WeatherType, std::string> 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";
}
}
{ 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);
}
@ -58,9 +37,8 @@ namespace cheat::feature
void CustomWeather::DrawMain()
{
ConfigWidget(f_Enabled, "Custom Weather.");
if (f_Enabled) {
ImGui::Combo(("Weather Type"), &current_weather, WeatherType, ARRAYSIZE(WeatherType));
}
if (f_Enabled)
ConfigWidget(f_WeatherType, "Select weather type.");
ConfigWidget(f_Lightning, "Lightning target enemy, works with RainHeavy weather.");
}
@ -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;
}
}

View File

@ -1,27 +1,36 @@
#pragma once
#include <cheat-base/cheat/Feature.h>
#include <cheat-base/config/config.h>
#include <cheat-base/thread-safe.h>
namespace cheat::feature
{
class CustomWeather : public Feature
{
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_Lightning;
config::Field<config::Enum<WeatherType>> 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<uint32_t> toBeUpdate;
SafeValue<int64_t> nextUpdate;
int f_DelayUpdate = 1;
void OnGameUpdate();
CustomWeather();
};