-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkid-parkour.sp
158 lines (110 loc) · 3.25 KB
/
kid-parkour.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
#include <sourcemod>
#include <sdktools>
#include <shavit>
#include <msharedutil/arrayvec>
#include <msharedutil/ents>
#pragma newdecls required
#pragma semicolon 1
#define TRACEDIF 8.0
#define WALLJUMP_BOOST 500.0
#define BOOST 500.0
float g_flNextWallJump[MAXPLAYERS+1];
float g_flNextBoost[MAXPLAYERS+1];
public Plugin myinfo =
{
author = "",
url = "",
name = "parkour",
description = "KiD Fearless",
version = "",
};
public void OnClientPutInServer( int client )
{
g_flNextWallJump[client] = 0.0;
g_flNextBoost[client] = 0.0;
}
public Action Shavit_OnStart(int client, int track)
{
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 ( !IsPlayerAlive( client ) )
{
return Plugin_Continue;
}
char[] sSpecial = new char[32];
Shavit_GetStyleStrings(style, sSpecialString, sSpecial, 32);
if(StrContains(sSpecial, "parkour", false) == -1)
{
return Plugin_Continue;
}
if (( buttons & IN_ATTACK2 && (Shavit_GetClientTime(client) > g_flNextWallJump[client])) && status == Timer_Running)
{
float pos[3];
float normal[3];
GetClientAbsOrigin( client, pos );
if ( FindWall( pos, normal ) )
{
float velocity[3];
GetEntityVelocity( client, velocity );
for ( int i = 0; i < 3; i++ )
{
velocity[i] += normal[i] * WALLJUMP_BOOST;
}
if ( velocity[2] < WALLJUMP_BOOST )
{
velocity[2] = WALLJUMP_BOOST;
}
TeleportEntity( client, NULL_VECTOR, NULL_VECTOR, velocity );
g_flNextWallJump[client] = Shavit_GetClientTime(client) + 0.5;
}
}
if (( buttons & IN_ATTACK && (Shavit_GetClientTime(client) > g_flNextBoost[client])) && status == Timer_Running)
{
float vec[3];
GetClientEyeAngles( client, vec );
GetAngleVectors( vec, vec, NULL_VECTOR, NULL_VECTOR );
float velocity[3];
GetEntityVelocity( client, velocity );
for ( int i = 0; i < 3; i++ )
{
velocity[i] += vec[i] * BOOST;
}
TeleportEntity( client, NULL_VECTOR, NULL_VECTOR, velocity );
g_flNextBoost[client] = Shavit_GetClientTime(client) + 3.0;
}
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 );
}