Added SetCollider for Mob Vacuum

This commit is contained in:
Joaquin 2022-09-01 23:09:12 -06:00
parent abfaa2f5a9
commit abf50fb81f
2 changed files with 23 additions and 4 deletions

View File

@ -22,7 +22,8 @@ namespace cheat::feature
NF(f_Distance, "Distance", "MobVacuum", 1.5f),
NF(f_Radius, "Radius", "MobVacuum", 10.0f),
NF(f_OnlyTarget, "Only targeted", "MobVacuum", true),
NF(f_Instantly, "Instantly", "MobVacuum", false)
NF(f_Instantly, "Instantly", "MobVacuum", false),
NF(f_SetCollider, "SetCollider", "MobVacuum", false)
{
events::GameUpdateEvent += MY_METHOD_HANDLER(MobVacuum::OnGameUpdate);
events::MoveSyncEvent += MY_METHOD_HANDLER(MobVacuum::OnMoveSync);
@ -63,6 +64,7 @@ namespace cheat::feature
ConfigWidget("Instant Vacuum", f_Instantly, "Vacuum entities instantly.");
ConfigWidget("Only Hostile/Aggro", f_OnlyTarget, "If enabled, vacuum will only affect monsters targeting you. Will not affect animals.");
ConfigWidget("Remove Collider", f_SetCollider, "If enabled, monsters won't be able to push you despite the distance or size");
ConfigWidget("Speed", f_Speed, 0.1f, 1.0f, 15.0f, "If 'Instant Vacuum' is not checked, mob will be vacuumed at the specified speed.");
ConfigWidget("Radius (m)", f_Radius, 0.1f, 5.0f, 150.0f, "Radius of vacuum.");
ConfigWidget("Distance (m)", f_Distance, 0.1f, 0.5f, 10.0f, "Distance between the player and the monster.");
@ -75,13 +77,13 @@ namespace cheat::feature
void MobVacuum::DrawStatus()
{
ImGui::Text("Vacuum [%s]\n[%s|%.01fm|%.01fm|%s]",
ImGui::Text("Vacuum [%s]\n[%s|%.01fm|%.01fm|%s|%s]",
f_IncludeMonsters && f_IncludeAnimals ? "All" : f_IncludeMonsters ? "Monsters" : f_IncludeAnimals ? "Animals" : "None",
f_Instantly ? "Instant" : fmt::format("Normal|{:.1f}", f_Speed.value()).c_str(),
f_Radius.value(),
f_Distance.value(),
f_OnlyTarget ? "Aggro" : "All"
);
f_OnlyTarget ? "Aggro" : "All",
f_SetCollider ? "RCollider" : "ECollider");
}
MobVacuum& MobVacuum::GetInstance()
@ -142,6 +144,18 @@ namespace cheat::feature
return avatarEntity->relativePosition() + avatarEntity->forward() * f_Distance;
}
// Set Monster's collider
// Taiga#5555: There might be an in-game function for this already I'm just not sure which one
void SetMonsterCollider(game::Entity* entity, bool v)
{
auto objName = entity->name();
auto name = objName.substr(0, objName.find_first_of(" "));
// path example: "EntityRoot/MonsterRoot/Monster_Fungus_Raptor_01(Clone)/Collider"
auto collider = app::GameObject_Find(string_to_il2cppi("/EntityRoot/MonsterRoot/" + name + "/Collider"), nullptr);
if (collider != nullptr)
app::GameObject_SetActive(collider, v, nullptr);
}
// Mob vacuum update function.
// Changes position of monster, if mob vacuum enabled.
void MobVacuum::OnGameUpdate()
@ -169,6 +183,8 @@ namespace cheat::feature
if (!IsEntityForVac(entity))
continue;
SetMonsterCollider(entity, !f_SetCollider);
if (f_Instantly)
{
entity->setRelativePosition(targetPos);
@ -211,6 +227,8 @@ namespace cheat::feature
if (!IsEntityForVac(entity))
return;
SetMonsterCollider(entity, !f_SetCollider);
app::Vector3 targetPos = CalcMobVacTargetPos();
app::Vector3 entityPos = entity->relativePosition();
if (app::Vector3_Distance(targetPos, entityPos, nullptr) < 0.2)

View File

@ -29,6 +29,7 @@ namespace cheat::feature
config::Field<float> f_Distance;
config::Field<bool> f_OnlyTarget;
config::Field<bool> f_Instantly;
config::Field<config::Toggle<Hotkey>> f_SetCollider;
static MobVacuum& GetInstance();