/
l4d2_sound_manipulation.sp
229 lines (200 loc) · 7.5 KB
/
l4d2_sound_manipulation.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
Source is Copyright (C) Valve Corporation.
All trademarks are property of their respective owners.
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/>.
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define MAX_ROCHELLESOUND 8
#define MAX_ELLISSOUND 6
#define MAX_NICKSOUND 14
#define MAX_COACHSOUND 18
new Handle:cBlockHB;
new Handle:cSurvivorMelee;
public Plugin:myinfo =
{
name = "Sound Manipulation",
author = "Sir",
description = "Allows control over certain sounds",
version = "1.0",
url = "https://github.com/SirPlease/SirCoding"
}
new const String: sCoachSound[MAX_COACHSOUND+1][] =
{
"player/survivor/voice/coach/meleeswing01.wav",
"player/survivor/voice/coach/meleeswing02.wav",
"player/survivor/voice/coach/meleeswing03.wav",
"player/survivor/voice/coach/meleeswing04.wav",
"player/survivor/voice/coach/meleeswing05.wav",
"player/survivor/voice/coach/meleeswing06.wav",
"player/survivor/voice/coach/meleeswing07.wav",
"player/survivor/voice/coach/meleeswing08.wav",
"player/survivor/voice/coach/meleeswing09.wav",
"player/survivor/voice/coach/meleeswing10.wav",
"player/survivor/voice/coach/meleeswing11.wav",
"player/survivor/voice/coach/meleeswing12.wav",
"player/survivor/voice/coach/meleeswing13.wav",
"player/survivor/voice/coach/meleeswing14.wav",
"player/survivor/voice/coach/meleeswing15.wav",
"player/survivor/voice/coach/meleeswing16.wav",
"player/survivor/voice/coach/meleeswing17.wav",
"player/survivor/voice/coach/meleeswing18.wav",
"player/survivor/voice/coach/meleeswing19.wav"
};
new const String: sRochelleSound[MAX_ROCHELLESOUND+1][] =
{
"player/survivor/voice/producer/meleeswing01.wav",
"player/survivor/voice/producer/meleeswing02.wav",
"player/survivor/voice/producer/meleeswing03.wav",
"player/survivor/voice/producer/meleeswing04.wav",
"player/survivor/voice/producer/meleeswing05.wav",
"player/survivor/voice/producer/meleeswing06.wav",
"player/survivor/voice/producer/meleeswing07.wav",
"player/survivor/voice/producer/meleeswing08.wav",
"player/survivor/voice/producer/meleeswing09.wav"
};
new const String: sEllisSound[MAX_ELLISSOUND+1][] =
{
"player/survivor/voice/mechanic/meleeswing01.wav",
"player/survivor/voice/mechanic/meleeswing02.wav",
"player/survivor/voice/mechanic/meleeswing03.wav",
"player/survivor/voice/mechanic/meleeswing04.wav",
"player/survivor/voice/mechanic/meleeswing05.wav",
"player/survivor/voice/mechanic/meleeswing06.wav",
"player/survivor/voice/mechanic/meleeswing07.wav"
};
new const String: sNickSound[MAX_NICKSOUND+1][] =
{
"player/survivor/voice/gambler/meleeswing01.wav",
"player/survivor/voice/gambler/meleeswing02.wav",
"player/survivor/voice/gambler/meleeswing03.wav",
"player/survivor/voice/gambler/meleeswing04.wav",
"player/survivor/voice/gambler/meleeswing05.wav",
"player/survivor/voice/gambler/meleeswing06.wav",
"player/survivor/voice/gambler/meleeswing07.wav",
"player/survivor/voice/gambler/meleeswing08.wav",
"player/survivor/voice/gambler/meleeswing09.wav",
"player/survivor/voice/gambler/meleeswing10.wav",
"player/survivor/voice/gambler/meleeswing11.wav",
"player/survivor/voice/gambler/meleeswing12.wav",
"player/survivor/voice/gambler/meleeswing13.wav",
"player/survivor/voice/gambler/meleeswing14.wav",
"player/survivor/voice/gambler/meleeswing15.wav"
};
public OnPluginStart()
{
cBlockHB = CreateConVar("sound_block_hb", "0", "Block the Heartbeat Sound, very useful for 1v1 matchmodes");
cSurvivorMelee = CreateConVar("sound_survivor_melee", "1", "Let the Survivors actually use their melee swing grunts");
//Event
HookEvent("player_hurt", PlayerHurt);
//Sound Hook
AddNormalSoundHook(NormalSHook:SoundHook);
}
public OnMapStart()
{
for (new i = 0; i <= MAX_ROCHELLESOUND; i++)
{
PrefetchSound(sRochelleSound[i]);
PrecacheSound(sRochelleSound[i], true);
}
for (new i = 0; i <= MAX_NICKSOUND; i++)
{
PrefetchSound(sNickSound[i]);
PrecacheSound(sNickSound[i], true);
}
for (new i = 0; i <= MAX_ELLISSOUND; i++)
{
PrefetchSound(sEllisSound[i]);
PrecacheSound(sEllisSound[i], true);
}
for (new i = 0; i <= MAX_COACHSOUND; i++)
{
PrefetchSound(sCoachSound[i]);
PrecacheSound(sCoachSound[i], true);
}
}
public Action:SoundHook(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity)
{
if (StrEqual(sample, "player/heartbeatloop.wav", false) && GetConVarBool(cBlockHB))
{
numClients = 0;
return Plugin_Changed;
}
return Plugin_Continue;
}
public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new String:weapon[64];
GetEventString(event, "weapon", weapon, sizeof(weapon));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new health = GetEventInt(event, "health");
if (StrEqual(weapon, "melee") && IsSi(victim))
{
// SI Died
if (health <= 0 && GetConVarBool(cSurvivorMelee))
{
if (attacker <= 0 || attacker > MaxClients) return Plugin_Handled;
new String:clientModel[42];
GetClientModel(attacker, clientModel, sizeof(clientModel));
//
//Make sure the Survivors have their Melee Sounds!
//
//Coach
if (StrEqual(clientModel, "models/survivors/survivor_coach.mdl"))
{
new rndPick = GetRandomInt(0, MAX_COACHSOUND);
EmitSoundToAll(sCoachSound[rndPick], attacker, SNDCHAN_VOICE);
}
//Nick
else if (StrEqual(clientModel, "models/survivors/survivor_gambler.mdl"))
{
new rndPick = GetRandomInt(0, MAX_NICKSOUND);
EmitSoundToAll(sNickSound[rndPick], attacker, SNDCHAN_VOICE);
}
//Rochelle
else if (StrEqual(clientModel, "models/survivors/survivor_producer.mdl"))
{
new rndPick = GetRandomInt(0, MAX_ROCHELLESOUND);
EmitSoundToAll(sRochelleSound[rndPick], attacker, SNDCHAN_VOICE);
}
//Ellis
else if (StrEqual(clientModel, "models/survivors/survivor_mechanic.mdl"))
{
new rndPick = GetRandomInt(0, MAX_ELLISSOUND);
EmitSoundToAll(sEllisSound[rndPick], attacker, SNDCHAN_VOICE);
}
//No Matching Survivors
else return Plugin_Continue;
//L4D1 Survivor.. No Files yet
//else if (StrEqual(clientModel, "models/survivors/survivor_manager.mdl"))
//else if (StrEqual(clientModel, "models/survivors/survivor_teenangst.mdl"))
//else if (StrEqual(clientModel, "models/survivors/survivor_namvet.mdl"))
//else if (StrEqual(clientModel, "models/survivors/survivor_biker.mdl"))
}
}
return Plugin_Continue;
}
bool:IsSi(client)
{
if (IsClientConnected(client)
&& IsClientInGame(client)
&& GetClientTeam(client) == 3)
{
return true;
}
return false;}