| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 2009 Karl Kuglin |
| 4 |
|
| 5 |
This file is part of the Open Arena source code. |
| 6 |
Parts of this file utilize code originally written for Tremulous by |
| 7 |
Tony J. White. |
| 8 |
Use of that code is governed by GPL version 2 and any later versions. |
| 9 |
|
| 10 |
Open Arena source code is free software; you can redistribute it |
| 11 |
and/or modify it under the terms of the GNU General Public License as |
| 12 |
published by the Free Software Foundation; either version 2 of the License, |
| 13 |
or (at your option) any later version. |
| 14 |
|
| 15 |
Open Arena source code is distributed in the hope that it will be |
| 16 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with Open Arena source code; if not, write to the Free Software |
| 22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 |
=========================================================================== |
| 24 |
*/ |
| 25 |
// NOTE: This code is by no means complete. |
| 26 |
|
| 27 |
#include "g_local.h" |
| 28 |
|
| 29 |
killspree_t *killSprees[ MAX_KSPREE ]; |
| 30 |
deathspree_t *deathSprees[ MAX_DSPREE ]; |
| 31 |
multikill_t *multiKills[ MAX_MULTIKILLS ]; |
| 32 |
|
| 33 |
/* |
| 34 |
================= |
| 35 |
G_ReadAltKillSettings |
| 36 |
Since this is cvar dependent, it has to be placed in G_InitGame after cvars are registered. |
| 37 |
================= |
| 38 |
*/ |
| 39 |
qboolean G_ReadAltKillSettings( gentity_t *ent, int skiparg ) |
| 40 |
{ |
| 41 |
//Let's Initialize some Spree structs/objects |
| 42 |
killspree_t *k = NULL; |
| 43 |
deathspree_t *d = NULL; |
| 44 |
multikill_t *m = NULL; |
| 45 |
//spree counters |
| 46 |
int ksc = 0, dsc = 0, mc = 0; |
| 47 |
int spreeDivisor; |
| 48 |
|
| 49 |
//Give us an int to use in "for" loops |
| 50 |
int i = 0; |
| 51 |
|
| 52 |
//File Stuff |
| 53 |
fileHandle_t file; |
| 54 |
int length; |
| 55 |
qboolean kspree_read; |
| 56 |
qboolean dspree_read; |
| 57 |
qboolean mkill_read; |
| 58 |
char *cnf, *cnf2; |
| 59 |
char *t; |
| 60 |
|
| 61 |
//Let's clear out any existing killing sprees/death sprees. YAYY BG_FREE!!!!! |
| 62 |
for( i = 0; i < MAX_KSPREE && killSprees[ i ]; i++ ) { |
| 63 |
BG_Free( killSprees[ i ] ); |
| 64 |
killSprees[ i ] = NULL; |
| 65 |
} |
| 66 |
|
| 67 |
for( i = 0; i < MAX_KSPREE && deathSprees[ i ]; i++ ) { |
| 68 |
BG_Free( deathSprees[ i ] ); |
| 69 |
deathSprees[ i ] = NULL; |
| 70 |
} |
| 71 |
|
| 72 |
for( i = 0; i < MAX_MULTIKILLS && multiKills[ i ]; i++ ) { |
| 73 |
BG_Free( multiKills[ i ] ); |
| 74 |
multiKills[ i ] = NULL; |
| 75 |
} |
| 76 |
|
| 77 |
// If the config file is not defined...forget reading/loading |
| 78 |
if( !g_sprees.string[0] ) { |
| 79 |
//Let's disable multikills to keep stock excellent sound |
| 80 |
if( g_altExcellent.integer == 1 ) |
| 81 |
{ |
| 82 |
trap_Cvar_Set( "g_altExcellent", "0" ); |
| 83 |
} |
| 84 |
return qfalse; |
| 85 |
} |
| 86 |
/* |
| 87 |
only set spreeDivisor to cvar g_spreeDiv if g_spreeDiv is >= "2". |
| 88 |
0 will cause problems and having 1 is just a fool who wants to hear something |
| 89 |
on every kill. |
| 90 |
*/ |
| 91 |
if( g_spreeDiv.integer >= 2 ) { |
| 92 |
level.spreeDivisor = g_spreeDiv.integer; |
| 93 |
spreeDivisor = level.spreeDivisor; |
| 94 |
} else { |
| 95 |
level.spreeDivisor = 5; |
| 96 |
// We don't want to change the value, keep reminding the server operator. |
| 97 |
//g_spreeDiv.integer = 5; |
| 98 |
spreeDivisor = 5; |
| 99 |
G_Printf( "Error: cvar g_spreeDiv must not be set to 0 or 1, reverting to default settings!\n" ); |
| 100 |
G_Printf( "Error: Set g_spreeDiv higher than 1 if 5 is not desired!\n" ); |
| 101 |
} |
| 102 |
|
| 103 |
length = trap_FS_FOpenFile( g_sprees.string, &file, FS_READ ); |
| 104 |
|
| 105 |
//If the file can't be accessed/opened. |
| 106 |
if( length < 0 ) { |
| 107 |
G_Printf( "Could not open configuration file for Sprees and Multikills %s\n", g_sprees.string ); |
| 108 |
trap_Cvar_Set( "g_altExcellent", "0" ); |
| 109 |
return qfalse; |
| 110 |
} |
| 111 |
//Allocate some memory. |
| 112 |
cnf = BG_Alloc( length + 1 ); |
| 113 |
cnf2 = cnf; |
| 114 |
|
| 115 |
//Load the whole file up. |
| 116 |
trap_FS_Read( cnf, length, file ); |
| 117 |
*( cnf + length ) = '\0'; |
| 118 |
trap_FS_FCloseFile( file ); |
| 119 |
|
| 120 |
kspree_read = dspree_read = mkill_read = qfalse; |
| 121 |
|
| 122 |
//Let's start parsing em. |
| 123 |
COM_BeginParseSession( g_sprees.string ); |
| 124 |
while( 1 ) |
| 125 |
{ |
| 126 |
t = COM_Parse( &cnf ); |
| 127 |
if( !*t ) |
| 128 |
break; |
| 129 |
if( !Q_stricmp( t, "[kspree]" ) ) { |
| 130 |
|
| 131 |
if( ksc >= MAX_KSPREE ) |
| 132 |
return qfalse; |
| 133 |
k = BG_Alloc( sizeof( killspree_t ) ); |
| 134 |
killSprees[ ksc++ ] = k; |
| 135 |
kspree_read = qtrue; |
| 136 |
dspree_read = qfalse; |
| 137 |
mkill_read = qfalse; |
| 138 |
|
| 139 |
} else if ( !Q_stricmp( t, "[dspree]" ) ) { |
| 140 |
|
| 141 |
if( dsc >= MAX_DSPREE ) |
| 142 |
return qfalse; |
| 143 |
d = BG_Alloc( sizeof( deathspree_t ) ); |
| 144 |
deathSprees[ dsc++ ] = d; |
| 145 |
dspree_read = qtrue; |
| 146 |
kspree_read = qfalse; |
| 147 |
mkill_read = qfalse; |
| 148 |
} else if ( !Q_stricmp( t, "[mkill]" ) ) { |
| 149 |
|
| 150 |
if( mc >= MAX_MULTIKILLS ) |
| 151 |
return qfalse; |
| 152 |
m = BG_Alloc( sizeof( multikill_t ) ); |
| 153 |
multiKills[ mc++ ] = m; |
| 154 |
mkill_read = qtrue; |
| 155 |
kspree_read = qfalse; |
| 156 |
dspree_read = qfalse; |
| 157 |
//Parse a killing spree |
| 158 |
} else if ( kspree_read ) { |
| 159 |
if( !Q_stricmp( t, "level" ) ) { |
| 160 |
readFile_int( &cnf, &k->spreeLevel ); |
| 161 |
//Let's take the spreeLevel and multiply it by the spreeDivisor to give us our count |
| 162 |
k->streakCount = ( ( k->spreeLevel ) * ( spreeDivisor ) ); |
| 163 |
} else if ( !Q_stricmp( t, "message" ) ) { |
| 164 |
readFile_string( &cnf, k->spreeMsg, sizeof( k->spreeMsg ) ); |
| 165 |
} else if ( !Q_stricmp( t, "printpos" ) ) { |
| 166 |
readFile_int( &cnf, &k->position ); |
| 167 |
} else if ( !Q_stricmp( t, "sound" ) ) { |
| 168 |
readFile_string( &cnf, k->sound2Play, sizeof( k->sound2Play ) ); |
| 169 |
} else { |
| 170 |
COM_ParseError( "Killing Spree unrecognized token \"%s\"", t ); |
| 171 |
} |
| 172 |
} else if ( dspree_read ) { |
| 173 |
if( !Q_stricmp( t, "level" ) ) { |
| 174 |
readFile_int( &cnf, &d->spreeLevel ); |
| 175 |
//Let's take the spreeLevel and multiply it by the spreeDivisor to give us our count |
| 176 |
d->streakCount = ( ( d->spreeLevel ) * ( spreeDivisor ) ); |
| 177 |
} else if ( !Q_stricmp( t, "message" ) ) { |
| 178 |
readFile_string( &cnf, d->spreeMsg, sizeof( d->spreeMsg ) ); |
| 179 |
} else if ( !Q_stricmp( t, "printpos" ) ) { |
| 180 |
readFile_int( &cnf, &d->position ); |
| 181 |
} else if ( !Q_stricmp( t, "sound" ) ) { |
| 182 |
readFile_string( &cnf, d->sound2Play, sizeof( d->sound2Play ) ); |
| 183 |
} else { |
| 184 |
COM_ParseError( "Death Spree unrecognized token \"%s\"", t ); |
| 185 |
} |
| 186 |
} else if ( mkill_read ) { |
| 187 |
if ( !Q_stricmp( t, "kills" ) ) { |
| 188 |
readFile_int( &cnf, &m->kills ); |
| 189 |
} else if ( !Q_stricmp( t, "message" ) ) { |
| 190 |
readFile_string( &cnf, m->killMsg, sizeof( m->killMsg ) ); |
| 191 |
} else if ( !Q_stricmp( t, "sound" ) ) { |
| 192 |
readFile_string( &cnf, m->sound2Play, sizeof( m->sound2Play ) ); |
| 193 |
} else { |
| 194 |
COM_ParseError( "Multikill unrecognized token \"%s\"", t ); |
| 195 |
} |
| 196 |
} else { |
| 197 |
COM_ParseError( "unexpected token \"%s\"", t ); |
| 198 |
} |
| 199 |
} |
| 200 |
//Let's "free" some memory now. |
| 201 |
BG_Free( cnf2 ); |
| 202 |
G_Printf("Sprees/Kills: loaded %d killing sprees, %d death sprees, and %d multikills.\n", ksc, dsc, mc ); |
| 203 |
//Mark the Upper Bounds of the Arrays (Since they start numbering at 0, We subtract 1 ) |
| 204 |
level.kSpreeUBound = ( ksc - 1 ); |
| 205 |
level.dSpreeUBound = ( dsc - 1 ); |
| 206 |
if( mc > 0 ) { |
| 207 |
level.mKillUBound = ( mc - 1 ); |
| 208 |
} else { |
| 209 |
level.mKillUBound = -1; |
| 210 |
//KK-OAX We don't have any kills defined, revert to stock. |
| 211 |
//FIXME: Make sure this change shows up in the console... |
| 212 |
if( g_altExcellent.integer == 1 ) { |
| 213 |
trap_Cvar_Set( "g_altExcellent", "0" ); |
| 214 |
} |
| 215 |
|
| 216 |
} |
| 217 |
return qtrue; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
static char *fillPlaceHolder( char *stringToSearch, char *placeHolder, char *replaceWith ) |
| 222 |
{ |
| 223 |
static char output[ MAX_SAY_TEXT ]; |
| 224 |
char *p; |
| 225 |
|
| •226 |
if( !( p = strstr( stringToSearch, placeHolder ) ) ) |
| 227 |
return stringToSearch; |
| 228 |
|
| 229 |
Q_snprintf( output, MAX_SAY_TEXT, "%.*s%s%s", (int)(p - stringToSearch), stringToSearch, replaceWith, p+strlen(placeHolder)); |
| 230 |
|
| 231 |
return output; |
| 232 |
} |
| 233 |
|
| 234 |
//This concatenate's the message to broadcast to the clients. |
| 235 |
static char *CreateMessage( gentity_t *ent, char *message, char *spreeNumber ) |
| 236 |
{ |
| •237 |
static char output[ MAX_SAY_TEXT ] = { "" }; |
| 238 |
|
| 239 |
char name[ MAX_NAME_LENGTH ]; |
| 240 |
//Do some sanity checks |
| 241 |
if( !ent ) { |
| 242 |
return output; |
| 243 |
} else if ( !*message ) { |
| 244 |
return output; |
| 245 |
} else if ( !spreeNumber ) { |
| 246 |
return output; |
| 247 |
} |
| 248 |
//Get the player name. |
| 249 |
Q_strncpyz( name, ent->client->pers.netname, sizeof( name ) ); |
| 250 |
//Do Our Replacements |
| 251 |
Q_strncpyz( output, fillPlaceHolder( message, "[n]", name ), sizeof( output ) ); |
| 252 |
//The following line has a risk of copying output into output. Q_strncpyz can handle the case. |
| 253 |
Q_strncpyz( output, fillPlaceHolder( output, "[k]", spreeNumber ), sizeof( output ) ); |
| 254 |
return output; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
/* |
| 259 |
================ |
| 260 |
G_RunStreakLogic |
| 261 |
KK-OAX This is called from player_die. |
| 262 |
It does all the adding resetting of kill/death streaks |
| 263 |
to be compared against the kill/death spree levels. |
| 264 |
================ |
| 265 |
*/ |
| 266 |
void G_RunStreakLogic( gentity_t *attacker, gentity_t *victim ) |
| 267 |
{ |
| 268 |
//We only want to sanity check for the victim at this point. |
| 269 |
if( !victim || !victim->client ) |
| 270 |
return; |
| 271 |
|
| 272 |
//We will reset the victim's killstreak counter |
| 273 |
victim->client->pers.killstreak = 0; |
| 274 |
//Add one to the death streak counter |
| 275 |
victim->client->pers.deathstreak++; |
| 276 |
|
| 277 |
//Let's check for a deathspree for the victim |
| 278 |
G_CheckForSpree( victim, victim->client->pers.deathstreak, qfalse ); |
| 279 |
|
| 280 |
//Move on to the attacker |
| 281 |
//Make sure they are a client and that the attacker and victim are not the same client |
| 282 |
//We don't want suicide to count towards a killstreak... |
| 283 |
if( ( attacker ) |
| 284 |
&& ( attacker->client ) |
| 285 |
&& ( attacker != victim ) ) { |
| 286 |
|
| 287 |
//Check the gametype--If FFA enabled, everybody's on the same team. |
| 288 |
if( g_gametype.integer >= GT_TEAM && g_ffa_gt!= 1 ) { |
| 289 |
//If they are on the same team we don't want to count it towards a killing spree. |
| 290 |
if( OnSameTeam( victim, attacker ) ) { |
| 291 |
return; |
| 292 |
} |
| 293 |
} |
| 294 |
//Add to the killstreak, reset the deathstreak |
| 295 |
attacker->client->pers.deathstreak = 0; |
| 296 |
attacker->client->pers.killstreak++; |
| 297 |
|
| 298 |
//Let's check for a killingspree for the attacker |
| 299 |
G_CheckForSpree( attacker, attacker->client->pers.killstreak, qtrue ); |
| 300 |
|
| 301 |
} |
| 302 |
} |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
//If the streak / spree divisor is a whole number, we have a spree |
| 307 |
static qboolean TestSpreeWhole( int streak2Test ) { |
| 308 |
float float2Test; |
| 309 |
float spreeFDiv; |
| 310 |
float resultf; |
| 311 |
int spreeDiv; |
| 312 |
int result; |
| 313 |
|
| 314 |
float2Test = streak2Test; |
| 315 |
spreeFDiv = level.spreeDivisor; |
| 316 |
spreeDiv = level.spreeDivisor; |
| 317 |
result = ( streak2Test / spreeDiv ); |
| 318 |
resultf = ( float2Test / spreeFDiv ); |
| 319 |
|
| 320 |
if( result == resultf ) { |
| 321 |
return qtrue; |
| 322 |
} else { |
| 323 |
return qfalse; |
| 324 |
} |
| 325 |
} |
| 326 |
|
| 327 |
/* |
| 328 |
================== |
| 329 |
G_CheckForSpree |
| 330 |
================== |
| 331 |
*/ |
| 332 |
void G_CheckForSpree( gentity_t *ent, int streak2Test, qboolean checkKillSpree ) |
| 333 |
{ |
| 334 |
int i; |
| 335 |
char *returnedString; |
| 336 |
//If somebody want's to award killing sprees above 99 kills he/she can mod this his/herself!!! :) |
| 337 |
char streakcount[ 3 ]; |
| 338 |
char *sound; |
| 339 |
int position; |
| 340 |
int soundIndex; |
| 341 |
|
| 342 |
qboolean isSpree = qfalse; |
| 343 |
int divisionHolder; |
| 344 |
|
| 345 |
//Probably Not Needed, but to protect Server Ops from Crashing their Stuff MidMatch |
| 346 |
if( level.spreeDivisor < 1 ) { |
| 347 |
return; |
| 348 |
} |
| 349 |
divisionHolder = ( streak2Test / level.spreeDivisor ); |
| 350 |
//if it's a deathspree |
| 351 |
if( !checkKillSpree ) { |
| 352 |
//Is the streak higher than the largest level defined? |
| 353 |
if( divisionHolder > level.dSpreeUBound ) { |
| 354 |
//Let's make sure it's a whole number to mimic the other sprees |
| 355 |
isSpree = TestSpreeWhole( streak2Test ); |
| 356 |
if( !isSpree ) { |
| 357 |
return; |
| 358 |
} |
| 359 |
//We've made it this far...now do the largest spree defined. |
| 360 |
Q_snprintf( streakcount, sizeof( streakcount ), "%i", streak2Test ); |
| 361 |
//Check if deathSprees is NULL (actual problem!) |
| 362 |
if(!deathSprees[ level.dSpreeUBound ]) |
| 363 |
return; |
| 364 |
returnedString = CreateMessage( ent, deathSprees[ level.dSpreeUBound ]->spreeMsg, streakcount ); |
| 365 |
position = deathSprees[ level.dSpreeUBound ]->position; |
| 366 |
sound = deathSprees[ level.dSpreeUBound ]->sound2Play; |
| 367 |
soundIndex = G_SoundIndex( sound ); |
| 368 |
//Play the Sound |
| 369 |
G_GlobalSound( soundIndex ); |
| 370 |
//Print the Message |
| 371 |
if( position == CENTER_PRINT ) { |
| 372 |
AP( va("cp \"%s\"", returnedString ) ); |
| 373 |
} else { |
| 374 |
AP( va("chat \"%s\"", returnedString ) ); |
| 375 |
} |
| 376 |
} else { |
| 377 |
for( i = 0; deathSprees[ i ]; i++ ) { |
| 378 |
//If the deathSpree is equal to the streak to test |
| 379 |
if( deathSprees[ i ]->streakCount == streak2Test ) { |
| 380 |
//Using Q_snprintf to change the int into a char for replacement. |
| 381 |
Q_snprintf( streakcount, sizeof( streakcount ), "%i", deathSprees[ i ]->streakCount ); |
| 382 |
//Let's grab the message to show, fill up the placeholders and concatenate it. |
| 383 |
returnedString = CreateMessage ( ent, deathSprees[ i ]->spreeMsg, streakcount ); |
| 384 |
//Grab the Print Position ( 1 for Center Printing, 2 for Chat ) |
| 385 |
position = deathSprees[ i ]->position; |
| 386 |
//Grab the Sound |
| 387 |
sound = deathSprees[ i ]->sound2Play; |
| 388 |
//Index the Sound |
| 389 |
soundIndex = G_SoundIndex( sound ); |
| 390 |
//Play the Sound |
| 391 |
G_GlobalSound( soundIndex ); |
| 392 |
//Print the Message |
| 393 |
if( position == CENTER_PRINT ) { |
| 394 |
AP( va("cp \"%s\"", returnedString ) ); |
| 395 |
} else { |
| 396 |
AP( va("chat \"%s\"", returnedString ) ); |
| 397 |
} |
| 398 |
break; |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
} else /*if( checkKillSpree )*/ { |
| 403 |
//Is the streak higher than the largest level defined? |
| 404 |
if( divisionHolder > level.kSpreeUBound ) { |
| 405 |
//Let's make sure it's a whole number to mimic the other sprees |
| 406 |
isSpree = TestSpreeWhole( streak2Test ); |
| 407 |
if( !isSpree ) { |
| 408 |
return; |
| 409 |
} |
| 410 |
//We've made it this far...now do the largest spree defined. |
| 411 |
Q_snprintf( streakcount, sizeof( streakcount ), "%i", streak2Test ); |
| 412 |
//Check if killSprees is NULL (actual problem!) |
| 413 |
if(!killSprees[ level.kSpreeUBound ]) |
| 414 |
return; |
| 415 |
returnedString = CreateMessage( ent, killSprees[ level.kSpreeUBound ]->spreeMsg, streakcount ); |
| 416 |
position = killSprees[ level.kSpreeUBound ]->position; |
| 417 |
sound = killSprees[ level.kSpreeUBound ]->sound2Play; |
| 418 |
soundIndex = G_SoundIndex( sound ); |
| 419 |
soundIndex = G_SoundIndex( sound ); |
| 420 |
//G_GlobalSound( soundIndex ); |
| 421 |
G_Sound(ent,0,soundIndex); |
| 422 |
/* Doesn't do anything at the moment. cp does not work while kill message is displayed |
| 423 |
* if( position == CENTER_PRINT ) { |
| 424 |
//Only Center print for player doing the killing spree |
| 425 |
CP( va("cp \"%s\"", returnedString ) ); |
| 426 |
}*/ |
| 427 |
AP( va("chat \"%s\"", returnedString ) ); |
| 428 |
} else { |
| 429 |
for( i = 0; killSprees[ i ]; i++ ) { |
| 430 |
if( killSprees[ i ]->streakCount == streak2Test ) { |
| 431 |
Q_snprintf( streakcount, sizeof( streakcount ), "%i", killSprees[ i ]->streakCount ); |
| 432 |
returnedString = CreateMessage ( ent, killSprees[ i ]->spreeMsg, streakcount ); |
| 433 |
position = killSprees[ i ]->position; |
| 434 |
sound = killSprees[ i ]->sound2Play; |
| 435 |
soundIndex = G_SoundIndex( sound ); |
| 436 |
soundIndex = G_SoundIndex( sound ); |
| 437 |
//G_GlobalSound( soundIndex ); |
| 438 |
G_Sound(ent,0,soundIndex); |
| 439 |
/*if( position == CENTER_PRINT ) { |
| 440 |
//Only Center print for player doing the killing spree |
| 441 |
CP( va("cp \"%s\"", returnedString ) ); |
| 442 |
}*/ |
| 443 |
AP( va("chat \"%s\"", returnedString ) ); |
| 444 |
break; |
| 445 |
} |
| 446 |
} |
| 447 |
} |
| 448 |
} /*else { |
| 449 |
G_Printf("Killing Spree Error in G_CheckForSpree\n"); |
| 450 |
return; |
| 451 |
}*/ |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
/* |
| 456 |
=============== |
| 457 |
G_checkForMultiKill |
| 458 |
=============== |
| 459 |
*/ |
| 460 |
void G_checkForMultiKill( gentity_t *ent ) { |
| 461 |
|
| 462 |
int i; |
| 463 |
char *returnedString; |
| 464 |
char *sound; |
| 465 |
int soundIndex; |
| 466 |
int multiKillCount; |
| 467 |
char multiKillString[ 2 ]; |
| 468 |
gclient_t *client; |
| 469 |
int clientNum; |
| 470 |
|
| 471 |
client = ent->client; |
| 472 |
clientNum = client - level.clients; |
| 473 |
|
| 474 |
//Let's grab the multikill count for the player first |
| 475 |
multiKillCount = ent->client->pers.multiKillCount; |
| 476 |
|
| 477 |
if( multiKillCount > multiKills[ level.mKillUBound ]->kills ) { |
| 478 |
Q_snprintf( multiKillString, sizeof( multiKillString ), "%i", multiKillCount ); |
| 479 |
if(!multiKills[ level.mKillUBound ]) |
| 480 |
return; //If null |
| 481 |
returnedString = CreateMessage ( ent, multiKills[ level.mKillUBound ]->killMsg, multiKillString ); |
| 482 |
sound = multiKills[ level.mKillUBound ]->sound2Play; |
| 483 |
soundIndex = G_SoundIndex( sound ); |
| 484 |
G_Sound(ent, 0, soundIndex ); |
| 485 |
AP( va("chat \"%s\"", returnedString ) ); |
| 486 |
return; |
| 487 |
} else { |
| 488 |
for( i = 0; multiKills[ i ]; i++ ) { |
| 489 |
//If the multikill count is equal to a killLevel let's do this. |
| 490 |
|
| 491 |
if( multiKills[ i ]->kills == multiKillCount ) { |
| 492 |
Q_snprintf( multiKillString, sizeof( multiKillString ), "%i", multiKills[ i ]->kills ); |
| 493 |
//Build the Message |
| 494 |
returnedString = CreateMessage ( ent, multiKills[ i ]->killMsg, multiKillString ); |
| 495 |
//Grab the sound |
| 496 |
sound = multiKills[ i ]->sound2Play; |
| 497 |
//Index the sound |
| 498 |
soundIndex = G_SoundIndex( sound ); |
| 499 |
//Play the sound |
| 500 |
G_Sound(ent, 0, soundIndex ); |
| 501 |
/* Print the String |
| 502 |
Since we don't want to clutter screens (the player is already going to get the excellent icon) |
| 503 |
we won't give them an option to centerprint. |
| 504 |
*/ |
| 505 |
AP( va("chat \"%s\"", returnedString ) ); |
| 506 |
break; |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
} |
| 511 |
|
| 512 |
} |
| 513 |
|
| 514 |
|
| •515 |
|