added Mob Drop Radius so mob drops can work better with large kill aura's and added RadishDrop and CarrotDrop so the vacuum dont pick up the ones in the ground

This commit is contained in:
biswop 2022-07-10 16:42:56 +10:00
parent 83cc1642e2
commit d54d54e66f
4 changed files with 139 additions and 29 deletions

View File

@ -47,7 +47,7 @@ namespace cheat::game::filters
SimpleFilter Electrogranum = { app::EntityType__Enum_1::Gadget, "ThunderSeedCreate" };
SimpleFilter FishingPoint = { app::EntityType__Enum_1::FishPool, "_FishingShoal" };
SimpleFilter Geoculus = { app::EntityType__Enum_1::GatherObject, "RockCrystalShell" };
WhitelistFilter ItemDrops = { std::vector<app::EntityType__Enum_1> {app::EntityType__Enum_1::GatherObject, app::EntityType__Enum_1::DropItem }, std::vector<std::string> {"_Food_BirdMeat", "_Food_Meat", "_DropItem" } };
WhitelistFilter ItemDrops = { std::vector<app::EntityType__Enum_1> {app::EntityType__Enum_1::GatherObject, app::EntityType__Enum_1::DropItem }, std::vector<std::string> {"_Food_BirdMeat", "_Food_Meat", "_DropItem","_Fishmeat" } };
SimpleFilter Lumenspar = { app::EntityType__Enum_1::GatherObject, "CelestiaSplinter" };
SimpleFilter KeySigil = { app::EntityType__Enum_1::GatherObject, "RuneContent" };
SimpleFilter ShrineOfDepth = { app::EntityType__Enum_1::Gadget, "Temple" };
@ -103,7 +103,7 @@ namespace cheat::game::filters
SimpleFilter WeaselThief = { app::EntityType__Enum_1::Monster, "Thoarder_Weasel" };
SimpleFilter Kitsune = { app::EntityType__Enum_1::EnvAnimal, "Vulpes" };
SimpleFilter BakeDanuki = { app::EntityType__Enum_1::Monster, "Inu_Tanuki" };
SimpleFilter Meat = { app::EntityType__Enum_1::GatherObject , std::vector<std::string> { "_Food_BirdMeat", "_Food_Meat", "_Fishmeat" }};
SimpleFilter Meat = { app::EntityType__Enum_1::GatherObject , std::vector<std::string> { "_Food_BirdMeat", "_Food_Meat", "_Fishmeat" } };
}
namespace mineral
@ -125,7 +125,7 @@ namespace cheat::game::filters
SimpleFilter DunlinsTooth = { app::EntityType__Enum_1::GatherObject, "_DunlinsTooth" };
SimpleFilter AmethystLumpDrop = { app::EntityType__Enum_1::GatherObject, "_Thundercrystaldrop" };
SimpleFilter CrystalChunkDrop = { app::EntityType__Enum_1::GatherObject,"_Drop_Crystal"};
SimpleFilter CrystalChunkDrop = { app::EntityType__Enum_1::GatherObject,"_Drop_Crystal" };
SimpleFilter ElectroCrystalDrop = { app::EntityType__Enum_1::GatherObject, "_Drop_Ore_ElectricRock" };
SimpleFilter IronChunkDrop = { app::EntityType__Enum_1::GatherObject, "_Drop_Stone" };
SimpleFilter NoctilucousJadeDrop = { app::EntityType__Enum_1::GatherObject,"_NightBerth" };
@ -153,7 +153,7 @@ namespace cheat::game::filters
SimpleFilter RuinGrader = { app::EntityType__Enum_1::Monster, "_Konungmathr" };
SimpleFilter RuinSentinel = { app::EntityType__Enum_1::Monster, "_Apparatus_Enigma" };
SimpleFilter Samachurl = { app::EntityType__Enum_1::Monster, "_Shaman" };
SimpleFilter ShadowyHusk = { app::EntityType__Enum_1::Monster, "ForlornVessel_Strong" };
SimpleFilter ShadowyHusk = { app::EntityType__Enum_1::Monster, "ForlornVessel_Strong" };
SimpleFilter Slime = { app::EntityType__Enum_1::Monster, "_Slime" };
SimpleFilter FloatingFungus = { app::EntityType__Enum_1::Monster, "_Fungus" };
SimpleFilter Specter = { app::EntityType__Enum_1::Monster, "_Sylph" };
@ -250,6 +250,8 @@ namespace cheat::game::filters
SimpleFilter Wheat = { app::EntityType__Enum_1::GatherObject, "_Plant_Wheat" };
SimpleFilter WindwheelAster = { app::EntityType__Enum_1::GatherObject, "_WindmilDaisy" };
SimpleFilter Wolfhook = { app::EntityType__Enum_1::GatherObject, "_GogoFruit" };
SimpleFilter RadishDrop = { app::EntityType__Enum_1::GatherObject, "_Plant_Carrot02_Clear" };
SimpleFilter CarrotDrop = { app::EntityType__Enum_1::GatherObject, "_Plant_Radish02_Clear" };
}
namespace puzzle
@ -257,7 +259,7 @@ namespace cheat::game::filters
SimpleFilter AncientRime = { app::EntityType__Enum_1::Gadget, "_IceSolidBulk" };
SimpleFilter BakeDanuki = { app::EntityType__Enum_1::Monster, "Animal_Inu_Tanuki_" };
SimpleFilter BloattyFloatty = { app::EntityType__Enum_1::Field, "_Flower_PongPongTree_" };
WhitelistFilter CubeDevices = { std::vector<app::EntityType__Enum_1> {app::EntityType__Enum_1::Gadget, app::EntityType__Enum_1::Platform }, std::vector<std::string> {"_ElecStone", "_ElecSwitch" }};
WhitelistFilter CubeDevices = { std::vector<app::EntityType__Enum_1> {app::EntityType__Enum_1::Gadget, app::EntityType__Enum_1::Platform }, std::vector<std::string> {"_ElecStone", "_ElecSwitch" } };
SimpleFilter EightStoneTablets = { app::EntityType__Enum_1::Gadget, "_HistoryBoard" };
SimpleFilter ElectricConduction = { app::EntityType__Enum_1::Gear, "_ElectricPowerSource" };
SimpleFilter RelayStone = { app::EntityType__Enum_1::Worktop, "_ElectricTransfer_" };
@ -475,11 +477,11 @@ namespace cheat::game::filters
app::EntityType__Enum_1::Monster
},
std::vector<std::string> {
// Environmental mobs
"Cat", "DogPrick", "Vulpues", "Inu_Tanuki",
// Overworld bosses
"Ningyo", "Regisvine", "Hypostasis", "Planelurker", "Nithhoggr"
}
// Environmental mobs
"Cat", "DogPrick", "Vulpues", "Inu_Tanuki",
// Overworld bosses
"Ningyo", "Regisvine", "Hypostasis", "Planelurker", "Nithhoggr"
}
};
SimpleFilter OrganicTargets = Monsters + Animals; // Solael: Please don't mess around with this filter.
//m0nkrel: We can choose the entities we need ourselves so as not to magnetize cats, dogs, etc.

View File

@ -247,6 +247,8 @@ namespace cheat::game::filters
extern SimpleFilter Wheat;
extern SimpleFilter WindwheelAster;
extern SimpleFilter Wolfhook;
extern SimpleFilter RadishDrop;
extern SimpleFilter CarrotDrop;
}
namespace puzzle
@ -255,7 +257,7 @@ namespace cheat::game::filters
extern SimpleFilter BakeDanuki;
extern SimpleFilter BloattyFloatty;
extern WhitelistFilter CubeDevices;
extern SimpleFilter EightStoneTablets;
extern SimpleFilter ElectricConduction;
extern SimpleFilter RelayStone;
@ -302,7 +304,7 @@ namespace cheat::game::filters
extern SimpleFilter MonsterBosses;
extern SimpleFilter MonsterShielded;
extern SimpleFilter MonsterEquips;
extern BlacklistFilter Living;
extern BlacklistFilter Living;
extern SimpleFilter OrganicTargets;
}
}

View File

@ -9,32 +9,34 @@
namespace cheat::feature
{
VacuumLoot::VacuumLoot() : Feature(),
NF(f_Enabled, "Vacuum Loot", "VacuumLoot", false),
NF(f_Enabled, "Vacuum Loot", "VacuumLoot", false),
NF(f_DelayTime, "Delay time (in ms)", "VacuumLoot", 1000),
NF(f_Distance, "Distance", "VacuumLoot", 1.5f),
NF(f_Radius, "Radius", "VacuumLoot", 20.0f),
NF(f_Distance, "Distance", "VacuumLoot", 1.5f),
NF(f_MobDropRadius, "Mob Drop Radius", "VacuumLoot", 1.5f),
NF(f_Radius, "Radius", "VacuumLoot", 20.0f),
nextTime(0)
{
InstallFilters();
InstallFiltersMobDrop();
events::GameUpdateEvent += MY_METHOD_HANDLER(VacuumLoot::OnGameUpdate);
}
const FeatureGUIInfo& VacuumLoot::GetGUIInfo() const
{
static const FeatureGUIInfo info{ "", "World", true };
static const FeatureGUIInfo info{ "Vacuum Loot", "World", true };
return info;
}
void VacuumLoot::DrawMain()
{
if (ImGui::BeginGroupPanel("Vacuum Loot", false))
{
ConfigWidget("Enabled", f_Enabled, "Vacuum Loot drops"); ImGui::SameLine(); ImGui::SetNextItemWidth(100.0f);
ConfigWidget("Delay Time (ms)", f_DelayTime, 1, 0, 1000, "Delay (in ms) between loot vacuum.");
ConfigWidget("Radius (m)", f_Radius, 0.1f, 5.0f, 100.0f, "Radius of loot vacuum.");
ConfigWidget("Mob Drop Radius (m)", f_MobDropRadius, 0.1f, 5.0f, 100.0f, "Radius of Mob Drop vacuum.");
ConfigWidget("Distance (m)", f_Distance, 0.1f, 1.0f, 10.0f, "Distance between the player and the loot.\n"
"Values under 1.5 may be too intruding.");
if (ImGui::TreeNode(this, "Loot Types"))
if (ImGui::TreeNode("Loot Types"))
{
for (auto& [section, filters] : m_Sections)
{
@ -44,8 +46,17 @@ namespace cheat::feature
}
ImGui::TreePop();
}
}
ImGui::EndGroupPanel();
if (ImGui::TreeNode("Mob Drop Types"))
{
for (auto& [sectionMobDrop, filtersMobDrop] : m_SectionsMobDrop)
{
ImGui::PushID(sectionMobDrop.c_str());
DrawSectionMobDrop(sectionMobDrop, filtersMobDrop);
ImGui::PopID();
}
ImGui::TreePop();
}
}
bool VacuumLoot::NeedStatusDraw() const
@ -81,6 +92,23 @@ namespace cheat::feature
return distance <= f_Radius;
}
bool VacuumLoot::IsEntityForMobDropVac(game::Entity* entity)
{
// Go through all sections. For each section, go through all filters.
// If a filter matches the given entity and that filter is enabled, return true.
bool entityValid = std::any_of(m_SectionsMobDrop.begin(), m_SectionsMobDrop.end(),
[entity](std::pair<std::string, filtersMobDrop> const& sectionMobDrop) {
return std::any_of(sectionMobDrop.second.begin(), sectionMobDrop.second.end(), [entity](const FilterInfoMobDrop& FilterInfoMobDrop) {
return FilterInfoMobDrop.second->IsValid(entity) && FilterInfoMobDrop.first; });
});
if (!entityValid)return false;
auto& manager = game::EntityManager::instance();
auto distance = manager.avatar()->distance(entity);
return distance <= f_MobDropRadius;
}
void VacuumLoot::OnGameUpdate()
{
@ -93,7 +121,6 @@ namespace cheat::feature
auto& manager = game::EntityManager::instance();
auto avatarEntity = manager.avatar();
for (const auto& entity : manager.entities())
{
if (!IsEntityForVac(entity))
@ -102,6 +129,14 @@ namespace cheat::feature
entity->setRelativePosition(avatarEntity->relativePosition() + avatarEntity->forward() * f_Distance);
}
nextTime = currentTime + f_DelayTime.value();
for (const auto& entity : manager.entities())
{
if (!IsEntityForMobDropVac(entity))
continue;
entity->setRelativePosition(avatarEntity->relativePosition() + avatarEntity->forward() * f_Distance);
}
nextTime = currentTime + f_DelayTime.value();
}
void VacuumLoot::DrawSection(const std::string& section, const Filters& filters)
@ -120,13 +155,13 @@ namespace cheat::feature
if (ImGui::BeginTable(section.c_str(), columns == 0 ? 1 : columns )) {
int i = 0;
for (std::pair<config::Field<bool>, game::IEntityFilter*> filter : filters) {
if (i % (columns == 0 ? 1 : columns) == 0)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
}
else
else
ImGui::TableNextColumn();
ImGui::PushID(&filter);
@ -147,6 +182,52 @@ namespace cheat::feature
info.first.FireChanged();
}
}
}
void VacuumLoot::DrawSectionMobDrop(const std::string& sectionMobDrop, const filtersMobDrop& filtersMobDrop)
{
bool checked = std::all_of(filtersMobDrop.begin(), filtersMobDrop.end(), [](const FilterInfoMobDrop& filterMobDrop) { return filterMobDrop.first; });
bool changed = false;
if (ImGui::BeginSelectableGroupPanel(sectionMobDrop.c_str(), checked, changed, true))
{
// TODO : Get Max Container Width and Calculate Max Item Width of Checkbox + Text / or specify same width for all columns
// then divide MaxWidth by ItemWidth/ColumnWidth and asign a floor result >= 1 to columns.
// Though this is also just fine IMO.
int columns = 2;
if (ImGui::BeginTable(sectionMobDrop.c_str(), columns == 0 ? 1 : columns)) {
int i = 0;
for (std::pair<config::Field<bool>, game::IEntityFilter*> filterMobDrop : filtersMobDrop) {
if (i % (columns == 0 ? 1 : columns) == 0)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
}
else
ImGui::TableNextColumn();
ImGui::PushID(&filterMobDrop);
ConfigWidget(filterMobDrop.first);
ImGui::PopID();
i++;
}
ImGui::EndTable();
}
}
ImGui::EndSelectableGroupPanel();
if (changed)
{
for (const auto& info : filtersMobDrop)
{
info.first.value() = checked;
info.first.FireChanged();
}
}
}
void VacuumLoot::AddFilter(const std::string& section, const std::string& name, game::IEntityFilter* filter)
@ -158,14 +239,20 @@ namespace cheat::feature
bool newItem(filter);
filters.push_back({ config::CreateField<bool>(name,name,fmt::format("VacuumLoot::Filters::{}", section),false, newItem) , filter });
}
void VacuumLoot::AddFilterMobDrop(const std::string& sectionMobDrop, const std::string& nameMobDrop, game::IEntityFilter* filterMobDrop)
{
if (m_SectionsMobDrop.count(sectionMobDrop) == 0)
m_SectionsMobDrop[sectionMobDrop] = {};
auto& filtersMobDrop = m_SectionsMobDrop[sectionMobDrop];
bool newItem(filterMobDrop);
filtersMobDrop.push_back({ config::CreateField<bool>(nameMobDrop,nameMobDrop,fmt::format("VacuumLoot::filtersMobDrop::{}", sectionMobDrop),false, newItem) , filterMobDrop });
}
#define ADD_FILTER_FIELD(section, name) AddFilter(util::MakeCapital(#section), util::SplitWords(#name), &game::filters::##section##::##name##)
void VacuumLoot::InstallFilters()
{
// Add more in the future
ADD_FILTER_FIELD(featured, ItemDrops);
// ADD_FILTER_FIELD(mineral, AmethystLump);
// ADD_FILTER_FIELD(mineral, ArchaicStone);
// ADD_FILTER_FIELD(mineral, CorLapis);
@ -193,9 +280,9 @@ namespace cheat::feature
ADD_FILTER_FIELD(plant, Apple);
ADD_FILTER_FIELD(plant, Cabbage);
ADD_FILTER_FIELD(plant, Carrot);
ADD_FILTER_FIELD(plant, CarrotDrop);
ADD_FILTER_FIELD(plant, Potato);
ADD_FILTER_FIELD(plant, Radish);
ADD_FILTER_FIELD(plant, RadishDrop);
ADD_FILTER_FIELD(plant, Sunsettia);
ADD_FILTER_FIELD(plant, Wheat);
@ -204,6 +291,16 @@ namespace cheat::feature
ADD_FILTER_FIELD(living, Crab);
ADD_FILTER_FIELD(living, Eel);
ADD_FILTER_FIELD(living, LizardTail);
ADD_FILTER_FIELD(living, Fish);
}
#undef ADD_FILTER_FIELD
#define ADD_FILTER_FIELD(sectionMobDrop, nameMobDrop) AddFilterMobDrop(util::MakeCapital(#sectionMobDrop), util::SplitWords(#nameMobDrop), &game::filters::##sectionMobDrop##::##nameMobDrop##)
void VacuumLoot::InstallFiltersMobDrop()
{
// Add more in the future
ADD_FILTER_FIELD(featured, ItemDrops);
ADD_FILTER_FIELD(equipment, Artifacts);
ADD_FILTER_FIELD(equipment, Bow);

View File

@ -15,6 +15,7 @@ namespace cheat::feature
config::Field<config::Toggle<Hotkey>> f_Enabled;
config::Field<float> f_Distance;
config::Field<float> f_Radius;
config::Field<float> f_MobDropRadius;
config::Field<int> f_DelayTime;
static VacuumLoot& GetInstance();
@ -31,14 +32,22 @@ namespace cheat::feature
using FilterInfo = std::pair<config::Field<bool>, game::IEntityFilter*>;
using Filters = std::vector<FilterInfo>;
using Sections = std::map<std::string, Filters>;
using FilterInfoMobDrop = std::pair<config::Field<bool>, game::IEntityFilter*>;
using filtersMobDrop = std::vector<FilterInfoMobDrop>;
using SectionsMobDrop = std::map<std::string, filtersMobDrop>;
Sections m_Sections;
SectionsMobDrop m_SectionsMobDrop;
SafeValue<int64_t> nextTime;
VacuumLoot();
void DrawSection(const std::string& section, const Filters& filters);
void DrawSectionMobDrop(const std::string& sectionMobDrop, const filtersMobDrop& filtersMobDrop);
void InstallFilters();
void InstallFiltersMobDrop();
void AddFilter(const std::string& section, const std::string& name, game::IEntityFilter* filter);
void AddFilterMobDrop(const std::string& sectionMobDrop, const std::string& nameMobDrop, game::IEntityFilter* filterMobDrop);
bool IsEntityForVac(cheat::game::Entity* entity);
bool IsEntityForMobDropVac(cheat::game::Entity* entity);
};
}