-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSpinbot.cpp
More file actions
108 lines (97 loc) · 3.41 KB
/
Spinbot.cpp
File metadata and controls
108 lines (97 loc) · 3.41 KB
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
#include "Spinbot.h"
#include "AimAndMovementHelper.h"
#include "Interfaces.h"
using namespace Skim;
CSpinBot *CSpinBot::g_pInstance;
//========================================
// Static functions called by concommmands
//========================================
void SBSetAng(const CCommand &args)
{
if(args.ArgC() != 2)
{
Msg("Usage: skim_spin_angle x y");
return;
}
CSpinBot::g_pInstance->PutAng(args);
}
// Its helper
void CSpinBot::PutAng(const CCommand &args)
{
}
//========================================
//========Constructor & Destructor========
//========================================
CSpinBot::CSpinBot()
{
m_enabled = new ConVar(PREFIX "spin", "0", 0, "Set at 1 for spin, 2 for reverse, 3 for set specific angle");
m_spinAmount = new ConVar(PREFIX "spin_factor", "12", 0, "Angle you spin every tick");
m_stopOnA1 = new ConVar(PREFIX "spin_stopon_a1", "1", 0, "Stops spinning when you use your attack");
m_stopOnA2 = new ConVar(PREFIX "spin_stopon_a2", "0", 0, "Stops spinning when you use your attack 2");
c1 = new ConCommand(PREFIX "spin_angle", SBSetAng, "Sets your angles to this");
m_bRunning = false;
m_aOldAngle = QAngle(0,0,0);
}
CSpinBot::~CSpinBot()
{
FreeConCMD(m_enabled);
FreeConCMD(m_spinAmount);
FreeConCMD(m_stopOnA1);
FreeConCMD(m_stopOnA2);
FreeConCMD(c1);
}
//========================================
//=======Figures out if we go or no=======
//========================================
inline bool CSpinBot::CanGo(CUserCmd* pCmd)
{
if(!(m_enabled->GetInt())
|| (m_stopOnA1->GetBool() && pCmd->buttons & IN_ATTACK)
|| (m_stopOnA2->GetBool() && pCmd->buttons & IN_ATTACK2))
return false;
return true;
}
//========================================
//========Functions from basehack=========
//========================================
void CSpinBot::Run(CUserCmd* pCmd)
{
if(CanGo(pCmd))
{
m_aOldAngle = pCmd->viewangles;
m_bRunning = true;
if(m_enabled->GetInt() == 1)
Spin(pCmd);
else if(m_enabled->GetInt() == 2)
Reverse(pCmd);
else if(m_enabled->GetInt() == 3)
SetAng(pCmd);
CSpinBot::m_pOldCmd = pCmd;
}
}
void CSpinBot::Run_PaintTraverse()
{
// I added the paint traverse hook thinking changing pCmd viewangles changes view angles you see ;[
}
void CSpinBot::Run_BeforeCM(int& sequence_number, float& input_sample_frametime, bool& active){}
//========================================
//========Set angles on createmove========
//========================================
void CSpinBot::Spin(CUserCmd* pCmd)
{
float spin = pCmd->tick_count * m_spinAmount->GetInt() % 360;// + pCmd->viewangles.y;
Skim::AimAndMovementHelper::SetAngles(pCmd->forwardmove, pCmd->sidemove, spin, pCmd->viewangles.y);
pCmd->viewangles.y = spin;
}
void CSpinBot::Reverse(CUserCmd* pCmd)
{
//pCmd->viewangles = QAngle(pCmd->viewangles.x, pCmd->viewangles.y + 180 % 360, 0);
pCmd->viewangles = QAngle(pCmd->viewangles.x + 180 % 360, pCmd->viewangles.y, 0);
pCmd->forwardmove *= -1;
//pCmd->sidemove *= -1;
}
void CSpinBot::SetAng(CUserCmd* pCmd)
{
Skim::AimAndMovementHelper::SetAngles(pCmd->forwardmove, pCmd->sidemove, m_aSetAngle.y, pCmd->viewangles.y);
pCmd->viewangles = QAngle(m_aSetAngle.x, m_aSetAngle.y, 0);
}