|
| 1 | +#include "Reducer.h" |
| 2 | + |
| 3 | +Reducer::Reducer() : IModule(0, Category::COMBAT, "Tries do reduce your knockback relatively legit") { |
| 4 | + this->mode.addEntry(EnumEntry("Jump", 0)) |
| 5 | + .addEntry(EnumEntry("Sneak", 1)) |
| 6 | + .addEntry(EnumEntry("JumpReset", 2)); |
| 7 | + this->registerEnumSetting("Mode", &this->mode, 0); |
| 8 | +} |
| 9 | + |
| 10 | +Reducer::~Reducer() { |
| 11 | +} |
| 12 | + |
| 13 | +const char* Reducer::getModuleName() { |
| 14 | + if (this->isEnabled()) { |
| 15 | + std::string mod = std::string("Reducer (") + std::string(this->mode.GetSelectedEntry().GetName()) + std::string(")"); |
| 16 | + |
| 17 | + return mod.c_str(); |
| 18 | + } |
| 19 | + |
| 20 | + return "Reducer"; |
| 21 | +} |
| 22 | + |
| 23 | +void Reducer::onEnable() { |
| 24 | + if (Game.getLocalPlayer() == nullptr) { |
| 25 | + this->setEnabled(false); |
| 26 | + return; |
| 27 | + } |
| 28 | + |
| 29 | + this->hitCount = 0; |
| 30 | + this->ticks = 0; |
| 31 | +} |
| 32 | + |
| 33 | +void Reducer::onTick(GameMode* gm) { |
| 34 | + if (Game.getLocalPlayer() == nullptr) return; |
| 35 | + |
| 36 | + LocalPlayer* player = Game.getLocalPlayer(); |
| 37 | + |
| 38 | + switch (this->mode.selected) { |
| 39 | + case 0: |
| 40 | + if (player->damageTime > 0 && player->onGround) player->jumpFromGround(); |
| 41 | + break; |
| 42 | + case 1: |
| 43 | + if (player->damageTime > 0 && !player->isSneaking()) { |
| 44 | + player->setSneaking(true); |
| 45 | + player->setSneaking(false); |
| 46 | + } |
| 47 | + break; |
| 48 | + case 2: |
| 49 | + ticks++; |
| 50 | + |
| 51 | + if (player->damageTime == 1) { |
| 52 | + this->hitCount++; |
| 53 | + } |
| 54 | + |
| 55 | + if (player->damageTime > 0) { |
| 56 | + this->ticks = 0; |
| 57 | + } |
| 58 | + |
| 59 | + if (this->ticks >= 20) { |
| 60 | + this->hitCount = 0; |
| 61 | + } |
| 62 | + |
| 63 | + if (player->damageTime > 0 && this->hitCount == 2 && player->onGround) { |
| 64 | + player->jumpFromGround(); |
| 65 | + this->hitCount = 0; |
| 66 | + } |
| 67 | + break; |
| 68 | + } |
| 69 | +} |
0 commit comments