Auto Challenge

This commit is contained in:
Miya 2022-08-09 12:22:11 +08:00
parent 6e11d301b2
commit fb555cf7dd
7 changed files with 121 additions and 1 deletions

View File

@ -24,6 +24,7 @@
<ClInclude Include="src\user\cheat\visuals\AnimationChanger.h" />
<ClInclude Include="src\user\cheat\visuals\TextureChanger.h" />
<ClInclude Include="src\user\cheat\visuals\FreeCamera.h" />
<ClInclude Include="src\user\cheat\world\AutoChallenge.h" />
<ClInclude Include="src\user\cheat\world\AutoSeelie.h" />
<ClInclude Include="src\user\cheat\world\CustomWeather.h" />
<ClInclude Include="src\user\cheat\world\FakeTime.h" />
@ -117,6 +118,7 @@
<ClCompile Include="src\user\cheat\visuals\AnimationChanger.cpp" />
<ClCompile Include="src\user\cheat\visuals\TextureChanger.cpp" />
<ClCompile Include="src\user\cheat\visuals\FreeCamera.cpp" />
<ClCompile Include="src\user\cheat\world\AutoChallenge.cpp" />
<ClCompile Include="src\user\cheat\world\AutoSeelie.cpp" />
<ClCompile Include="src\user\cheat\world\CustomWeather.cpp" />
<ClCompile Include="src\user\cheat\world\FakeTime.cpp" />

View File

@ -255,6 +255,9 @@
<ClInclude Include="src\user\cheat\visuals\AnimationChanger.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\user\cheat\world\AutoChallenge.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Font Include="res\Ruda-Bold.ttf" />
@ -468,6 +471,9 @@
<ClCompile Include="src\user\cheat\visuals\AnimationChanger.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\user\cheat\world\AutoChallenge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\res.rc">

View File

@ -42,6 +42,7 @@
#include <cheat/world/AutoFish.h>
#include <cheat/world/AutoCook.h>
#include <cheat/world/AutoChallenge.h>
#include <cheat/world/CustomWeather.h>
#include <cheat/visuals/NoFog.h>
@ -97,6 +98,7 @@ namespace cheat
FEAT_INST(FreezeEnemies),
FEAT_INST(ElementalSight),
FEAT_INST(KillAura),
FEAT_INST(AutoChallenge),
FEAT_INST(MobVacuum),
FEAT_INST(FakeTime),

View File

@ -320,7 +320,7 @@ namespace cheat::game::filters
WhitelistFilter DreamForm = { {EntityType__Enum_1::Field, EntityType__Enum_1::Platform }, "_AnimalSeelie" };
SimpleFilter StarlightCoalescence = { EntityType__Enum_1::Field, "_PaperStar" };
SimpleFilter TheRavenForum = { EntityType__Enum_1::Gadget, "_NightCrowStatue" };
WhitelistFilter TimeTrialChallengeCollection = { { EntityType__Enum_1::Field, EntityType__Enum_1::Gadget }, { "SkillObj_EmptyGadget", "_GlideChampOrb" } };
}
namespace combined

View File

@ -320,6 +320,7 @@ namespace cheat::game::filters
extern WhitelistFilter DreamForm;
extern SimpleFilter StarlightCoalescence;
extern SimpleFilter TheRavenForum;
extern WhitelistFilter TimeTrialChallengeCollection;
}
namespace combined

View File

@ -0,0 +1,80 @@
#include "pch-il2cpp.h"
#include "AutoChallenge.h"
#include <cheat/events.h>
#include <cheat/game/EntityManager.h>
#include <cheat/game/filters.h>
namespace cheat::feature
{
AutoChallenge::AutoChallenge() : Feature(),
NF(f_Enabled, "Auto challenge", "AutoChallenge", false),
NF(f_Delay, "Collect delay", "AutoChallenge", 1000),
NF(f_Range, "Collect range", "AutoChallenge", 20.f)
{
events::GameUpdateEvent += MY_METHOD_HANDLER(AutoChallenge::OnGameUpdate);
}
const FeatureGUIInfo& AutoChallenge::GetGUIInfo() const
{
static const FeatureGUIInfo info{ "Auto Challenge", "World", true };
return info;
}
void AutoChallenge::DrawMain()
{
ConfigWidget("Enabled", f_Enabled, "Auto collect time challenge item");
ImGui::SetNextItemWidth(200.f);
ConfigWidget("Range", f_Range, 0.1f, 0.f, 300.f, "Collect range.");
ImGui::SameLine();
ImGui::SetNextItemWidth(200.f);
ConfigWidget("Delay", f_Delay, 1, 0, 2000, "Collect delay.");
}
bool AutoChallenge::NeedStatusDraw() const
{
return f_Enabled;
}
void AutoChallenge::DrawStatus()
{
ImGui::Text("Challenge [%.01fm]", f_Range.value());
}
AutoChallenge& AutoChallenge::GetInstance()
{
static AutoChallenge instance;
return instance;
}
void AutoChallenge::OnGameUpdate()
{
static uint64_t lastTime = 0;
auto timestamp = app::MoleMole_TimeUtil_get_NowTimeStamp(nullptr);
if (!f_Enabled || lastTime + f_Delay > timestamp)
return;
auto& entityManager = game::EntityManager::instance();
auto avatarEntity = entityManager.avatar();
for (auto& entity : entityManager.entities(game::filters::puzzle::TimeTrialChallengeCollection))
{
if (avatarEntity->distance(entity) > f_Range)
continue;
auto combat = entity->combat();
if (combat != nullptr)
{
auto combatProp = combat->fields._combatProperty_k__BackingField;
auto maxHP = app::MoleMole_SafeFloat_get_Value(combatProp->fields.maxHP, nullptr);
// so many entities named "SkillObj_EmptyGadget", but the collection's hp is 99999.f
if (maxHP > 99998 && maxHP < 99999.9)
{
entity->setRelativePosition(avatarEntity->relativePosition());
}
}
}
}
}

View File

@ -0,0 +1,29 @@
#pragma once
#include <cheat-base/cheat/Feature.h>
#include <cheat-base/config/config.h>
namespace cheat::feature
{
class AutoChallenge : public Feature
{
public:
config::Field<config::Toggle<Hotkey>> f_Enabled;
config::Field<int> f_Delay;
config::Field<float> f_Range;
static AutoChallenge& GetInstance();
void OnGameUpdate();
const FeatureGUIInfo& GetGUIInfo() const override;
void DrawMain() override;
virtual bool NeedStatusDraw() const override;
void DrawStatus() override;
private:
AutoChallenge();
};
}