-
Notifications
You must be signed in to change notification settings - Fork 7
/
Misc.hpp
79 lines (70 loc) · 2.41 KB
/
Misc.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <iostream>
#include <thread>
#include <chrono>
#include "LocalPlayer.hpp"
#include "Offsets.hpp"
#include "DMALibrary/Memory/Memory.h"
#include "HidTable.hpp"
#include "KmboxNet.hpp"
struct Misc {
// Variables
LocalPlayer* Myself;
const int SuperGlideMinimumDelay = 7;
Misc(LocalPlayer* Myself) {
this->Myself = Myself;
}
void Initialize() {
// idk, nothing for now
}
void Update() {
while (mem.GetKeyboard()->IsKeyDown(0x43)) {
static float startjumpTime = 0;
static bool startSg = false;
static float traversalProgressTmp = 0.0;
float worldtime = mem.Read<float>(Myself->BasePointer + OFF_TIME_BASE); // Current time
float traversalStartTime = mem.Read<float>(Myself->BasePointer + OFFSET_TRAVERSAL_START_TIME); // Time to start wall climbing
float traversalProgress = mem.Read<float>(Myself->BasePointer + OFFSET_TRAVERSAL_PROGRESS); // Wall climbing, if > 0.87 it is almost over.
auto HangOnWall = -(traversalStartTime - worldtime);
if (HangOnWall > 0.1 && HangOnWall < 0.12)
{
kmNet_keyup(KEY_SPACEBAR);
}
if (traversalProgress > 0.87f && !startSg && HangOnWall > 0.1f && HangOnWall < 1.5f)
{
//start SG
startjumpTime = worldtime;
startSg = true;
}
if (startSg)
{
// Press Space
kmNet_keydown(KEY_SPACEBAR);
// Pressed Space, track time
auto start = std::chrono::high_resolution_clock::now();
if (mem.Read<float>(Myself->BasePointer + OFF_TIME_BASE) - startjumpTime < 0.011)
{
// Check Current Time
auto now = std::chrono::high_resolution_clock::now();
// Check Elapsed Time
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
// Check if Elapsed Time is less than 4ms, then sleep for the remaining time to reach 4ms
if (elapsed.count() < SuperGlideMinimumDelay) {
std::this_thread::sleep_for(std::chrono::milliseconds(SuperGlideMinimumDelay - elapsed.count()));
now = std::chrono::high_resolution_clock::now();
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
}
// Press Duck
kmNet_keydown(KEY_LEFTCONTROL);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// Release Space
kmNet_keyup(KEY_SPACEBAR);
std::this_thread::sleep_for(std::chrono::milliseconds(600));
}
kmNet_keyup(KEY_LEFTCONTROL);
startSg = false;
break;
}
}
}
};