NoCooldown.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #include "NoCooldown.h"
  2. namespace cheat {
  3. static bool LCAvatarCombat_OnSkillStart(app::LCAvatarCombat* __this, uint32_t skillID, float multipler);
  4. static void ActorAbilityPlugin_AddDynamicFloatWithRange_Hook(app::MoleMole_ActorAbilityPlugin* __this, app::String* key, float value, float minValue, float maxValue, bool forceDoAtRemote);
  5. static bool HumanoidMoveFSM_CheckSprintCooldown_Hook(void* __this);
  6. NoCooldown::NoCooldown() {
  7. f_EnabledSkill = config::getValue("functions:NoCooldown:Skill", "enabled", false);
  8. f_EnabledBow = config::getValue("functions:NoCooldown:Bow", "enabled", false);
  9. f_EnabledSprint = config::getValue("functions:NoCooldown:Sprint", "enabled", false);
  10. f_HotkeySkill = Hotkey("functions:NoCooldown:Skill");
  11. f_HotkeyBow = Hotkey("functions:NoCooldown:Bow");
  12. f_HotkeySprint = Hotkey("functions:NoCooldown:Sprint");
  13. HookManager::install(app::MoleMole_LCAvatarCombat_OnSkillStart, LCAvatarCombat_OnSkillStart);
  14. HookManager::install(app::MoleMole_ActorAbilityPlugin_AddDynamicFloatWithRange, ActorAbilityPlugin_AddDynamicFloatWithRange_Hook);
  15. HookManager::install(app::MoleMole_HumanoidMoveFSM_CheckSprintCooldown, HumanoidMoveFSM_CheckSprintCooldown_Hook);
  16. }
  17. NoCooldown& NoCooldown::getInstance() {
  18. static NoCooldown instance;
  19. return instance;
  20. }
  21. void NoCooldown::GUI() {
  22. ConfigCheckbox(_("NO_SKILL_COOLDOWN_TITLE"), f_EnabledSkill, _("NO_SKILL_COOLDOWN_DESCRIPTION"));
  23. if (f_EnabledSkill.getValue()) {
  24. ImGui::Indent();
  25. f_HotkeySkill.Draw();
  26. ImGui::Unindent();
  27. }
  28. ConfigCheckbox(_("INSTANT_BOW_CHARGE_TITLE"), f_EnabledBow, _("INSTANT_BOW_CHARGE_DESCRIPTION"));
  29. if (f_EnabledBow.getValue()) {
  30. ImGui::Indent();
  31. f_HotkeyBow.Draw();
  32. ImGui::Unindent();
  33. }
  34. ConfigCheckbox(_("NO_SPRINT_COOLDOWN_TITLE"), f_EnabledSprint, _("NO_SPRINT_COOLDOWN_DESCRIPTION"));
  35. if (f_EnabledSprint.getValue()) {
  36. ImGui::Indent();
  37. f_HotkeySprint.Draw();
  38. ImGui::Unindent();
  39. }
  40. }
  41. void NoCooldown::Outer() {
  42. if (f_HotkeySkill.IsPressed())
  43. f_EnabledSkill.setValue(!f_EnabledSkill.getValue());
  44. if (f_HotkeyBow.IsPressed())
  45. f_EnabledBow.setValue(!f_EnabledBow.getValue());
  46. if (f_HotkeySprint.IsPressed())
  47. f_EnabledSprint.setValue(!f_EnabledSprint.getValue());
  48. }
  49. void NoCooldown::Status() {
  50. if (f_EnabledSkill.getValue())
  51. ImGui::Text(_("NO_SKILL_COOLDOWN_TITLE"));
  52. if (f_EnabledBow.getValue())
  53. ImGui::Text(_("INSTANT_BOW_CHARGE_TITLE"));
  54. if (f_EnabledSprint.getValue())
  55. ImGui::Text(_("NO_SPRINT_COOLDOWN_TITLE"));
  56. }
  57. std::string NoCooldown::getModule() {
  58. return _("MODULE_PLAYER");
  59. }
  60. bool LCAvatarCombat_OnSkillStart(app::LCAvatarCombat* __this, uint32_t skillID, float multipler) {
  61. auto& noCooldown = NoCooldown::getInstance();
  62. if (noCooldown.f_EnabledSkill.getValue())
  63. multipler = 0;
  64. return CALL_ORIGIN(LCAvatarCombat_OnSkillStart, __this, skillID, multipler);
  65. }
  66. void ActorAbilityPlugin_AddDynamicFloatWithRange_Hook(app::MoleMole_ActorAbilityPlugin* __this, app::String* key, float value, float minValue, float maxValue, bool forceDoAtRemote) {
  67. auto& noCooldown = NoCooldown::getInstance();
  68. if (noCooldown.f_EnabledBow.getValue() && il2cppi_to_string(key) == "_Enchanted_Time") {
  69. value = maxValue;
  70. //LOG_INFO("value: %d, minValue: %d, maxValue: %d, nextValidAbilityID: %d", value, minValue, maxValue, __this->fields.nextValidAbilityID);
  71. //__this->fields.nextValidAbilityID = 36;
  72. }
  73. CALL_ORIGIN(ActorAbilityPlugin_AddDynamicFloatWithRange_Hook, __this, key, value, minValue, maxValue, forceDoAtRemote);
  74. }
  75. bool HumanoidMoveFSM_CheckSprintCooldown_Hook(void* __this) {
  76. auto& noCooldown = NoCooldown::getInstance();
  77. if (noCooldown.f_EnabledSprint.getValue())
  78. return true;
  79. return CALL_ORIGIN(HumanoidMoveFSM_CheckSprintCooldown_Hook, __this);
  80. }
  81. }