add percent crash damage mode

let you decide how many times to kill monsters
This commit is contained in:
Miya 2022-08-25 03:28:51 +08:00
parent 80901959c9
commit 68dbba8b04
2 changed files with 44 additions and 18 deletions

View File

@ -16,12 +16,14 @@ namespace cheat::feature
KillAura::KillAura() : Feature(), KillAura::KillAura() : Feature(),
NF(f_Enabled, "Kill aura", "KillAura", false), NF(f_Enabled, "Kill aura", "KillAura", false),
NF(f_DamageMode, "Damage mode", "Damage mode", false), NF(f_DamageMode, "Damage mode", "Damage mode", false),
NF(f_PercentDamageMode, "Percent damage mode", "Damage mode", false),
NF(f_InstantDeathMode, "Instant death", "Instant death", false), NF(f_InstantDeathMode, "Instant death", "Instant death", false),
NF(f_OnlyTargeted, "Only targeted", "KillAura", true), NF(f_OnlyTargeted, "Only targeted", "KillAura", true),
NF(f_Range, "Range", "KillAura", 15.0f), NF(f_Range, "Range", "KillAura", 15.0f),
NF(f_AttackDelay, "Attack delay time (in ms)", "KillAura", 100), NF(f_AttackDelay, "Attack delay time (in ms)", "KillAura", 100),
NF(f_RepeatDelay, "Repeat delay time (in ms)", "KillAura", 1000), NF(f_RepeatDelay, "Repeat delay time (in ms)", "KillAura", 1000),
NF(f_DamageValue, "Crash damage value", "Damage mode", 233.0f) NF(f_DamageValue, "Crash damage value", "Damage mode", 233.0f),
NF(f_PercentDamageTimes, "Times to kill", "Damage mode", 3)
{ {
events::GameUpdateEvent += MY_METHOD_HANDLER(KillAura::OnGameUpdate); events::GameUpdateEvent += MY_METHOD_HANDLER(KillAura::OnGameUpdate);
HookManager::install(app::MoleMole_BaseMoveSyncPlugin_ConvertSyncTaskToMotionInfo, BaseMoveSyncPlugin_ConvertSyncTaskToMotionInfo_Hook); HookManager::install(app::MoleMole_BaseMoveSyncPlugin_ConvertSyncTaskToMotionInfo, BaseMoveSyncPlugin_ConvertSyncTaskToMotionInfo_Hook);
@ -40,9 +42,20 @@ namespace cheat::feature
ImGui::TextColored(ImColor(255, 165, 0, 255), "Choose any or both modes below."); ImGui::TextColored(ImColor(255, 165, 0, 255), "Choose any or both modes below.");
ConfigWidget("Crash Damage Mode", f_DamageMode, "Kill aura causes crash damage for monster around you."); ConfigWidget("Crash Damage Mode", f_DamageMode, "Kill aura causes crash damage for monster around you.");
if (f_DamageMode) { ImGui::Indent();
ConfigWidget("Percent mode", f_PercentDamageMode, "Crash damage with percent value.");
if (f_DamageMode)
{
if (!f_PercentDamageMode)
{
ConfigWidget("Damage Value", f_DamageValue, 1, 0, 10000000, "Crash damage value"); ConfigWidget("Damage Value", f_DamageValue, 1, 0, 10000000, "Crash damage value");
} }
else
{
ConfigWidget("Kill times", f_PercentDamageTimes, 1, 1, 100, "How many times to kill.");
}
}
ImGui::Unindent();
ConfigWidget("Instant Death Mode", f_InstantDeathMode, "Kill aura will attempt to instagib any valid target."); ConfigWidget("Instant Death Mode", f_InstantDeathMode, "Kill aura will attempt to instagib any valid target.");
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextColored(ImColor(255, 165, 0, 255), "Can get buggy with bosses like PMA and Hydro Hypo."); ImGui::TextColored(ImColor(255, 165, 0, 255), "Can get buggy with bosses like PMA and Hydro Hypo.");
@ -59,8 +72,9 @@ namespace cheat::feature
void KillAura::DrawStatus() void KillAura::DrawStatus()
{ {
ImGui::Text("Kill Aura [%s]\n[%.01fm|%s|%dms|%dms]", ImGui::Text("Kill Aura [%s%s]\n[%.01fm|%s|%dms|%dms]",
f_DamageMode && f_InstantDeathMode ? "Extreme" : f_DamageMode ? "Crash" : f_InstantDeathMode ? "Instant" : "None", f_DamageMode && f_InstantDeathMode ? "Extreme" : f_DamageMode ? "Crash" : f_InstantDeathMode ? "Instant" : "None",
f_DamageMode ? !f_PercentDamageMode ? "|Fixed" : fmt::format("|Rate({})", f_PercentDamageTimes.value()).c_str() : "",
f_Range.value(), f_Range.value(),
f_OnlyTargeted ? "Aggro" : "All", f_OnlyTargeted ? "Aggro" : "All",
f_AttackDelay.value(), f_AttackDelay.value(),
@ -159,6 +173,8 @@ namespace cheat::feature
auto crashEvt = app::MoleMole_EventHelper_Allocate_103(*app::MoleMole_EventHelper_Allocate_103__MethodInfo); auto crashEvt = app::MoleMole_EventHelper_Allocate_103(*app::MoleMole_EventHelper_Allocate_103__MethodInfo);
app::MoleMole_EvtCrash_Init(crashEvt, monster->runtimeID(), nullptr); app::MoleMole_EvtCrash_Init(crashEvt, monster->runtimeID(), nullptr);
if(!f_PercentDamageMode)
{
//Migita^Rin#1762: Fixed inaccurate damage caused by floating point precision(Maybe) //Migita^Rin#1762: Fixed inaccurate damage caused by floating point precision(Maybe)
float FPValue; float FPValue;
if (f_DamageValue <= 10000000) FPValue = 27.0f; if (f_DamageValue <= 10000000) FPValue = 27.0f;
@ -174,6 +190,14 @@ namespace cheat::feature
crashEvt->fields.maxHp = f_DamageValue / 0.4f + FPValue; crashEvt->fields.maxHp = f_DamageValue / 0.4f + FPValue;
crashEvt->fields.velChange = 10000000; crashEvt->fields.velChange = 10000000;
}
else
{
auto maxHP = app::MoleMole_SafeFloat_get_Value(combat->fields._combatProperty_k__BackingField->fields.maxHP, nullptr);
// should works. :p
crashEvt->fields.maxHp = maxHP / f_PercentDamageTimes / 0.4f + 5.0f;
crashEvt->fields.velChange = 10000000;
}
crashEvt->fields.hitPos = monster->absolutePosition(); crashEvt->fields.hitPos = monster->absolutePosition();
app::MoleMole_EventManager_FireEvent(eventManager, reinterpret_cast<app::BaseEvent*>(crashEvt), false, nullptr); app::MoleMole_EventManager_FireEvent(eventManager, reinterpret_cast<app::BaseEvent*>(crashEvt), false, nullptr);

View File

@ -10,12 +10,14 @@ namespace cheat::feature
public: public:
config::Field<config::Toggle<Hotkey>> f_Enabled; config::Field<config::Toggle<Hotkey>> f_Enabled;
config::Field<config::Toggle<Hotkey>> f_DamageMode; config::Field<config::Toggle<Hotkey>> f_DamageMode;
config::Field<config::Toggle<Hotkey>> f_PercentDamageMode;
config::Field<config::Toggle<Hotkey>> f_InstantDeathMode; config::Field<config::Toggle<Hotkey>> f_InstantDeathMode;
config::Field<bool> f_OnlyTargeted; config::Field<bool> f_OnlyTargeted;
config::Field<float> f_Range; config::Field<float> f_Range;
config::Field<int> f_AttackDelay; config::Field<int> f_AttackDelay;
config::Field<int> f_RepeatDelay; config::Field<int> f_RepeatDelay;
config::Field<float> f_DamageValue; config::Field<float> f_DamageValue;
config::Field<int> f_PercentDamageTimes;
static KillAura& GetInstance(); static KillAura& GetInstance();