-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
drunkwalk.sp
77 lines (64 loc) · 2.2 KB
/
drunkwalk.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
/**
* Drunk Walk perk.
* Copyright (C) 2023 Filip Tomaszewski
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define IsDemoman Int[0]
#define BaseSpeed Float[0]
#define MinSpeed Float[1]
#define MaxSpeed Float[2]
#define TurnAngle Float[3]
DEFINE_CALL_APPLY_REMOVE(DrunkWalk)
public void DrunkWalk_Init(const Perk perk)
{
Events.OnSound(perk, DrunkWalk_OnSound);
}
public void DrunkWalk_ApplyPerk(const int client, const Perk perk)
{
Cache[client].IsDemoman = Shared[client].ClassForPerk == TFClass_DemoMan;
Cache[client].BaseSpeed = GetBaseSpeed(client);
Cache[client].MinSpeed = perk.GetPrefFloat("minspeed", 0.35);
Cache[client].MaxSpeed = perk.GetPrefFloat("maxspeed", 1.8);
Cache[client].TurnAngle = perk.GetPrefFloat("turnangle", 15.0);
if (Cache[client].IsDemoman)
Cache[client].Delay(3.5, DrunkWalk_DemomanDeny);
}
public void DrunkWalk_RemovePerk(const int client, const RTDRemoveReason eRemoveReason)
{
ResetSpeed(client);
}
public void DrunkWalk_DemomanDeny(const int client)
{
EmitSoundToAll("vo/demoman_no02.mp3", client, SNDCHAN_VOICE);
}
bool DrunkWalk_OnSound(const int client, const char[] sSound)
{
if (Cache[client].IsDemoman)
return true;
if (IsFootstepSound(sSound))
DrunkWalk_Tick(client);
return true;
}
void DrunkWalk_Tick(const int client)
{
RotateClientSmooth(client, Cache[client].TurnAngle * GetRandomSign());
float fSpeed = GetRandomFloat(Cache[client].MinSpeed, Cache[client].MaxSpeed);
SetSpeed(client, Cache[client].BaseSpeed, fSpeed);
}
#undef IsDemoman
#undef BaseSpeed
#undef MinSpeed
#undef MaxSpeed
#undef TurnAngle