-
Notifications
You must be signed in to change notification settings - Fork 2
/
shavit-parkourinflux.sp
174 lines (132 loc) · 4.54 KB
/
shavit-parkourinflux.sp
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include <sourcemod>
#include <sdktools>
#undef REQUIRE_PLUGIN
#include <shavit>
#pragma newdecls required
#define TRACEDIF 8.0
#define PLYHULL_MINS view_as<float>( { -16.0, -16.0, 0.0 } )
#define PLYHULL_MAXS view_as<float>( { 16.0, 16.0, 72.0 } )
public Plugin myinfo =
{
name = "[shavit] Parkour",
author = "Haze",
description = "Shavit Parkour Style",
version = "1.1",
url = ""
}
// Player variable.
bool gB_ParkourStyle[MAXPLAYERS+1];
char g_sSpecialString[128];
float gF_TickInterval[MAXPLAYERS+1];
// Walls
float g_flNextWallJump[MAXPLAYERS+1];
float g_flNextBoost[MAXPLAYERS+1];
//ConVars
ConVar g_hSpecialString;
ConVar g_hWallJumpBoost;
ConVar g_hBoost;
public void OnPluginStart()
{
g_hSpecialString = CreateConVar("shavit_parkour_string", "parkour", "Special string value to use in shavit-styles.cfg");
g_hWallJumpBoost = CreateConVar("shavit_parkour_walljumpboost", "500.0", "Changes the wall jump boost on parkour style.", 0, true, 100.0);
g_hBoost = CreateConVar("shavit_parkour_boost", "500.0", "Changes the boost on parkour style.", 0, true, 100.0);
g_hSpecialString.AddChangeHook(ConVar_OnSpecialStringChanged);
g_hSpecialString.GetString(g_sSpecialString, sizeof(g_sSpecialString));
AutoExecConfig();
}
/**
* ConVar changed callbacks.
*/
public void ConVar_OnSpecialStringChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
convar.GetString(g_sSpecialString, sizeof(g_sSpecialString));
}
public void Shavit_OnStyleChanged(int client, int oldstyle, int newstyle)
{
char[] sSpecial = new char[128];
Shavit_GetStyleStrings(newstyle, sSpecialString, sSpecial, 128);
gB_ParkourStyle[client] = (StrContains(sSpecial, g_sSpecialString) != -1);
}
public void OnClientDisconnect(int client)
{
gB_ParkourStyle[client] = false;
gF_TickInterval[client] = 0.0;
g_flNextWallJump[client] = 0.0;
g_flNextBoost[client] = 0.0;
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
{
if(!gB_ParkourStyle[client])
{
return Plugin_Continue;
}
if(status == Timer_Paused)
{
return Plugin_Continue;
}
gF_TickInterval[client] += GetTickInterval();
if(buttons & IN_ATTACK && g_flNextBoost[client] < gF_TickInterval[client])
{
float vec[3], velocity[3];
GetClientEyeAngles(client, vec);
GetAngleVectors(vec, vec, NULL_VECTOR, NULL_VECTOR);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity);
for(int i = 0; i < 3; i++)
{
velocity[i] += vec[i] * g_hBoost.FloatValue;
}
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity);
g_flNextBoost[client] = gF_TickInterval[client] + 3.0;
}
if(buttons & IN_ATTACK2 && g_flNextWallJump[client] < gF_TickInterval[client])
{
float pos[3], normal[3], velocity[3];
GetClientAbsOrigin(client, pos);
if(FindWall(pos, normal))
{
GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity);
for(int i = 0; i < 3; i++)
{
velocity[i] += normal[i] * g_hWallJumpBoost.FloatValue;
}
if(velocity[2] < g_hWallJumpBoost.FloatValue)
{
velocity[2] = g_hWallJumpBoost.FloatValue;
}
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity);
g_flNextWallJump[client] = gF_TickInterval[client] + 0.5;
}
}
return Plugin_Continue;
}
stock bool FindWall(const float pos[3], float normal[3])
{
float end[3];
end = pos; end[0] += TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
end = pos; end[0] -= TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
end = pos; end[1] += TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
end = pos; end[1] -= TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
end = pos; end[2] += TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
end = pos; end[2] -= TRACEDIF;
if(GetTraceNormal(pos, end, normal)) return true;
return false;
}
stock bool GetTraceNormal(const float pos[3], const float end[3], float normal[3])
{
TR_TraceHullFilter(pos, end, PLYHULL_MINS, PLYHULL_MAXS, MASK_PLAYERSOLID, TrcFltr_AnythingButThoseFilthyScrubs);
if(TR_GetFraction() != 1.0)
{
TR_GetPlaneNormal(null, normal);
return true;
}
return false;
}
public bool TrcFltr_AnythingButThoseFilthyScrubs(int ent, int mask, any data)
{
return (ent == 0 || ent > MaxClients);
}