-
Notifications
You must be signed in to change notification settings - Fork 0
/
tickbase.cpp
112 lines (88 loc) · 2.93 KB
/
tickbase.cpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "tickbase.hpp"
#include "../misc/misc.hpp"
bool CanFireWeapon(c_base_combat_weapon* wp, float curtime)
{
if (!wp)
return false;
bool can_fire = ticks2time(g_local->m_nTickBase()) >= g_local->m_nTickBase();
if (!can_fire)
return false;
if (curtime >= wp->m_flNextPrimaryAttack())
return true;
return false;
}
bool IsFiring(c_base_combat_weapon* wp, float curtime)
{
return g::cmd->buttons & in_attack && CanFireWeapon(wp, curtime);
}
void tickbase::PreMovement()
{
m_shift_data.m_next_shift_amount = m_shift_data.m_ticks_to_shift = 0;
}
void tickbase::PostMovement()
{
if (!g_vars.config.ragebot.aimbot.exploits.active)
return;
auto weapon = g_local->get_active_weapon();
if (!weapon || !g::cmd) {
return;
}
auto data = weapon->get_cs_weapon_data();
if (!data) {
return;
}
if (weapon->m_iItemDefinitionIndex() == weapon_revolver ||
weapon->m_iItemDefinitionIndex() == weapon_c4 ||
data->weapon_type == weapontype_knife ||
data->weapon_type == weapontype_grenade)
{
m_shift_data.m_did_shift_before = false;
m_shift_data.m_should_be_ready = false;
m_shift_data.m_should_disable = true;
return;
}
if (!m_shift_data.m_should_attempt_shift) {
m_shift_data.m_did_shift_before = false;
m_shift_data.m_should_be_ready = false;
return;
}
m_shift_data.m_should_disable = false;
bool bFastRecovery = false;
float flNonShiftedTime = ticks2time(g_local->m_nTickBase() - g::ragebot::goal_shift);
bool bCanShootNormally = CanFireWeapon(weapon, ticks2time(g_local->m_nTickBase()));
bool bCanShootIn12Ticks = CanFireWeapon(weapon, flNonShiftedTime);
bool bIsShooting = IsFiring(weapon, ticks2time(g_local->m_nTickBase()));
m_shift_data.m_can_shift_tickbase = bCanShootIn12Ticks || (!bCanShootNormally || bFastRecovery) && (m_shift_data.m_did_shift_before);
if (m_shift_data.m_can_shift_tickbase && !c_misc::get().m_in_duck) {
m_shift_data.m_next_shift_amount = g::ragebot::goal_shift;
}
else {
m_shift_data.m_next_shift_amount = 0;
m_shift_data.m_should_be_ready = false;
}
if (m_shift_data.m_next_shift_amount > 0) {
if (bCanShootIn12Ticks) {
if (m_shift_data.m_prepare_recharge && !bIsShooting) {
m_shift_data.m_needs_recharge = g::ragebot::goal_shift;
m_shift_data.m_prepare_recharge = false;
}
else {
if (bIsShooting) {
m_prediction.m_shifted_command = g::cmd->command_number;
m_prediction.m_shifted_ticks = abs(m_shift_data.m_current_shift);
m_prediction.m_original_tickbase = g_local->m_nTickBase();
m_shift_data.m_ticks_to_shift = m_shift_data.m_next_shift_amount;
}
}
}
else {
m_shift_data.m_prepare_recharge = true;
m_shift_data.m_should_be_ready = false;
}
}
else {
m_shift_data.m_prepare_recharge = true;
m_shift_data.m_should_be_ready = false;
}
m_shift_data.m_did_shift_before = m_shift_data.m_next_shift_amount > 0;
}