forked from ZDoom/gzdoom
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbbannouncer.cpp
366 lines (322 loc) · 10.6 KB
/
bbannouncer.cpp
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/*
** bbannouncer.cpp
** The announcer from Blood (The Voice).
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** It's been so long since I played a bloodbath, I don't know when all
** these sounds are used, so much of this usage is me guessing. Some of
** it has also obviously been reused for events that were never present
** in bloodbaths.
**
** I should really have a base Announcer class and derive the Bloodbath
** announcer off of that. That way, multiple announcer styles could be
** supported easily.
*/
// HEADER FILES ------------------------------------------------------------
#include "actor.h"
#include "gstrings.h"
#include "d_player.h"
#include "g_levellocals.h"
// MACROS ------------------------------------------------------------------
// TYPES -------------------------------------------------------------------
struct SoundAndString
{
const char *Message;
const char *Sound;
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void PronounMessage (const char *from, char *to, int pronoun,
const char *victim, const char *killer);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CVAR (Bool, cl_bbannounce, false, CVAR_ARCHIVE)
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static const char *BeginSounds[] =
{
"VO1.SFX", // Let the bloodbath begin
"VO2.SFX", // The festival of blood continues
};
static const SoundAndString WorldKillSounds[] =
{
{ "TXT_SELFOBIT1", "VO7.SFX" }, // Excrement
{ "TXT_SELFOBIT2", "VO8.SFX" }, // Hamburger
{ "TXT_SELFOBIT3", "VO9.SFX" }, // Scrotum separation
};
static const SoundAndString SuicideSounds[] =
{
{ "TXT_SELFOBIT5", "VO13.SFX" }, // Unassisted death
{ "TXT_SELFOBIT5", "VO5.SFX" }, // Kevorkian approves
{ "TXT_SELFOBIT4", "VO12.SFX" }, // Population control
{ "TXT_SELFOBIT6", "VO16.SFX" } // Darwin award
};
static const SoundAndString KillSounds[] =
{
{ "TXT_OBITUARY1", "BONED.SFX" }, // Boned
{ "TXT_OBITUARY3", "CREAMED.SFX" }, // Creamed
{ "TXT_OBITUARY4", "DECIMAT.SFX" }, // Decimated
{ "TXT_OBITUARY5", "DESTRO.SFX" }, // Destroyed
{ "TXT_OBITUARY6", "DICED.SFX" }, // Diced
{ "TXT_OBITUARY7", "DISEMBO.SFX" }, // Disembowled
{ "TXT_OBITUARY8", "FLATTE.SFX" }, // Flattened
{ "TXT_OBITUARY9", "JUSTICE.SFX" }, // Justice
{ "TXT_OBITUARY10", "MADNESS.SFX" }, // Madness
{ "TXT_OBITUARY11", "KILLED.SFX" }, // Killed
{ "TXT_OBITUARY12", "MINCMEAT.SFX" }, // Mincemeat
{ "TXT_OBITUARY13", "MASSACR.SFX" }, // Massacred
{ "TXT_OBITUARY14", "MUTILA.SFX" }, // Mutilated
{ "TXT_OBITUARY15", "REAMED.SFX" }, // Reamed
{ "TXT_OBITUARY16", "RIPPED.SFX" }, // Ripped
{ "TXT_OBITUARY17", "SLAUGHT.SFX" }, // Slaughtered
{ "TXT_OBITUARY18", "SMASHED.SFX" }, // Smashed
{ "TXT_OBITUARY19", "SODOMIZ.SFX" }, // Sodomized
{ "TXT_OBITUARY20", "SPLATT.SFX" }, // Splattered
{ "TXT_OBITUARY21", "SQUASH.SFX" }, // Squashed
{ "TXT_OBITUARY22", "THROTTL.SFX" }, // Throttled
{ "TXT_OBITUARY23", "WASTED.SFX" }, // Wasted
{ "TXT_OBITUARY24", "VO10.SFX" }, // Body bagged
{ "TXT_OBITUARY28", "VO25.SFX" }, // Hosed
{ "TXT_OBITUARY26", "VO27.SFX" }, // Toasted
{ "TXT_OBITUARY25", "VO28.SFX" }, // Sent to hell
{ "TXT_OBITUARY29", "VO35.SFX" }, // Sprayed
{ "TXT_OBITUARY30", "VO36.SFX" }, // Dog meat
{ "TXT_OBITUARY31", "VO39.SFX" }, // Beaten like a cur
{ "TXT_OBITUARY27", "VO41.SFX" }, // Snuffed
{ "TXT_OBITUARY2", "CASTRA.SFX" }, // Castrated
};
static const char *GoodJobSounds[] =
{
"VO22.SFX", // Fine work
"VO23.SFX", // Well done
"VO44.SFX", // Excellent
};
static const char *TooBadSounds[] =
{
"VO17.SFX", // Go play Mario
"VO18.SFX", // Need a tricycle?
"VO37.SFX", // Bye bye now
};
static const char *TelefragSounds[] =
{
"VO29.SFX", // Pass the jelly
"VO34.SFX", // Spillage
"VO40.SFX", // Whipped and creamed
"VO42.SFX", // Spleen vented
"VO43.SFX", // Vaporized
"VO38.SFX", // Ripped him loose
"VO14.SFX", // Shat upon
};
#if 0 // Sounds I don't know what to do with
"VO6.SFX", // Asshole
"VO15.SFX", // Finish him
"VO19.SFX", // Talented
"VO20.SFX", // Good one
"VO21.SFX", // Lunch meat
"VO26.SFX", // Humiliated
"VO30.SFX", // Punishment delivered
"VO31.SFX", // Bobbit-ized
"VO32.SFX", // Stiffed
"VO33.SFX", // He shoots... He scores
#endif
static int LastAnnounceTime;
static FRandom pr_bbannounce ("BBAnnounce");
// CODE --------------------------------------------------------------------
//==========================================================================
//
// DoVoiceAnnounce
//
//==========================================================================
void DoVoiceAnnounce (const char *sound)
{
// Don't play announcements too close together
if (LastAnnounceTime == 0 || LastAnnounceTime <= primaryLevel->time-5)
{
LastAnnounceTime = primaryLevel->time;
S_Sound (CHAN_VOICE, 0, sound, 1, ATTN_NONE);
}
}
//==========================================================================
//
// AnnounceGameStart
//
// Called when a new map is entered.
//
//==========================================================================
bool AnnounceGameStart ()
{
LastAnnounceTime = 0;
if (cl_bbannounce && deathmatch)
{
DoVoiceAnnounce (BeginSounds[pr_bbannounce() & 1]);
}
return false;
}
//==========================================================================
//
// AnnounceKill
//
// Called when somebody dies.
//
//==========================================================================
bool AnnounceKill (AActor *killer, AActor *killee)
{
const char *killerName;
const SoundAndString *choice;
const char *message;
int rannum = pr_bbannounce();
if (cl_bbannounce && deathmatch)
{
bool playSound = killee->CheckLocalView();
if (killer == NULL)
{ // The world killed the player
if (killee->player->userinfo.GetGender() == GENDER_MALE)
{ // Only males have scrotums to separate
choice = &WorldKillSounds[rannum % 3];
}
else
{
choice = &WorldKillSounds[rannum & 1];
}
killerName = NULL;
}
else if (killer == killee)
{ // The player killed self
choice = &SuicideSounds[rannum & 3];
killerName = killer->player->userinfo.GetName();
}
else
{ // Another player did the killing
if (killee->player->userinfo.GetGender() == GENDER_MALE)
{ // Only males can be castrated
choice = &KillSounds[rannum % countof(KillSounds)];
}
else
{
choice = &KillSounds[rannum % (countof(KillSounds) - 1)];
}
killerName = killer->player->userinfo.GetName();
// Blood only plays the announcement sound on the killer's
// computer. I think it sounds neater to also hear it on
// the killee's machine.
playSound |= killer->CheckLocalView();
}
message = GStrings(choice->Message);
if (message != NULL)
{
char assembled[1024];
PronounMessage (message, assembled, killee->player->userinfo.GetGender(),
killee->player->userinfo.GetName(), killerName);
Printf (PRINT_MEDIUM, "%s\n", assembled);
}
if (playSound)
{
DoVoiceAnnounce (choice->Sound);
}
return message != NULL;
}
return false;
}
//==========================================================================
//
// AnnounceTelefrag
//
// Called when somebody dies by telefragging.
//
//==========================================================================
bool AnnounceTelefrag (AActor *killer, AActor *killee)
{
int rannum = pr_bbannounce();
if (cl_bbannounce && multiplayer)
{
const char *message = GStrings("OB_MPTELEFRAG");
if (message != NULL)
{
char assembled[1024];
PronounMessage (message, assembled, killee->player->userinfo.GetGender(),
killee->player->userinfo.GetName(), killer->player->userinfo.GetName());
Printf (PRINT_MEDIUM, "%s\n", assembled);
}
if (killee->CheckLocalView() ||
killer->CheckLocalView())
{
DoVoiceAnnounce (TelefragSounds[rannum % 7]);
}
return message != NULL;
}
return false;
}
//==========================================================================
//
// AnnounceSpree
//
// Called when somebody is on a spree.
//
//==========================================================================
bool AnnounceSpree (AActor *who)
{
return false;
}
//==========================================================================
//
// AnnounceSpreeLoss
//
// Called when somebody on a spree gets killed.
//
//==========================================================================
bool AnnounceSpreeLoss (AActor *who)
{
if (cl_bbannounce)
{
if (who->CheckLocalView())
{
DoVoiceAnnounce (TooBadSounds[M_Random() % 3]);
}
}
return false;
}
//==========================================================================
//
// AnnounceMultikill
//
// Called when somebody is quickly raking in kills.
//
//==========================================================================
bool AnnounceMultikill (AActor *who)
{
if (cl_bbannounce)
{
if (who->CheckLocalView())
{
DoVoiceAnnounce (GoodJobSounds[M_Random() % 3]);
}
}
return false;
}