how to add your own gameover song (code)
Select messages from
#
through
#
Forum FAQ
[
/[
Print
]\
]
Soldier Of Fortune 2
->
SOF2 Tutorials
#1:
how to add your own gameover song (code)
Author:
kingsfloo
,
Location: Argentina
Posted: Wed Apr 08, 2015 6:09 pm
—
i´m bored then i decide to make this very little tutorial about how to add your own gameover song in your client mod ...its very very easy and i think everyone can do it whitout any problems....
first go to cg_local.h
// all of the model, shader, and sound references that are
// loaded at gamestate time are stored in cgMedia_t
// Other media that can be tied to clients, weapons, or items are
// stored in the clientInfo_t, itemInfo_t, weaponInfo_t
then put the new song i put this exactly here...under the fragselfsound
qhandle_t fragSelfSound;
qhandle_t gameoverSound; //there is your song
now go to cg_main.c
/*
=================
CG_RegisterSounds
called during a precache command
=================
*/
then just put your song...i put my song here
cgs.media.gogglesOffSound = trap_S_RegisterSound ( "sound/weapons/goggles/turn_off.mp3" );
cgs.media.gameoverSound = trap_S_RegisterSound ( "sound/mysong/gameover.mp3" ); //gameover song what u hear when the map end...u need just put the route where u are going to save your song...is important the cgs.media.gameoverSound this name (gameoverSound) need to be exactly like u write in local.h
finally go to cg_event.c and the part CG_GameOver need to look like this
/*
=============
CG_GameOver
=============
*/
static void CG_GameOver ( entityState_t *ent )
{
switch ( ent->eventParm )
{
case GAME_OVER_TIMELIMIT:
Com_sprintf ( cgs.gameover, MAX_QPATH, "Timelimit Hit" );
trap_S_StartLocalSound ( cgs.media.gameoverSound, CHAN_AUTO ); //Floo add gameover sound 2013
break;
case GAME_OVER_SCORELIMIT:
if ( cgs.gametypeData->teams )
{
switch ( ent->otherEntityNum )
{
case TEAM_RED:
Com_sprintf ( cgs.gameover, MAX_QPATH, "%s%s^7 Team hit the score limit", cgs.teamData.teamcolor[1], cgs.teamData.redName );
trap_S_StartLocalSound ( cgs.media.gameoverSound, CHAN_AUTO ); //your gameoversong..again be carefull to write the cgs.media part, respect how u write this in local.h and main
break;
case TEAM_BLUE:
Com_sprintf ( cgs.gameover, MAX_QPATH, "%s%s^7 Team hit the score limit", cgs.teamData.teamcolor[2], cgs.teamData.blueName );
trap_S_StartLocalSound ( cgs.media.gameoverSound, CHAN_AUTO ); //your gameover song
break;
}
}
else
{
Com_sprintf ( cgs.gameover, MAX_QPATH, "%s" S_COLOR_WHITE " hit the score limit", cgs.clientinfo[ent->otherEntityNum].name );
trap_S_StartLocalSound ( cgs.media.gameoverSound, CHAN_AUTO ); //your gameover song
}
break;
default:
return;
}
CG_CenterPrint ( cgs.gameover, 0.43f );
Com_Printf ( "@%s
", cgs.gameover );
}
ok, thats all what u need to add in the source code...now u need to add the .mp3 song into your rocmod_2.1c.pk3:
1) remember what u add in main with this route? sound/mysong/gameover.mp3...thats what we need to do...create a folder called sound, inside this other called mysong, and inside this put the gameover.mp3 song (dont modificate the name)
2) open your rocmod.pk3 with winrar or paskape and put the folder inside the pk3
3) go to the game and when the timelimit hit or the map end u will hear your song!
note: the song need to be 44100 Hz and in Mono (no stereo or others things)
End...like i say its basic and easy to do...
#2:
Re: how to add your own gameover song (code)
Author:
Punisher
,
Posted: Wed Apr 08, 2015 7:27 pm
—
Nice tutorial made,
Quote:
i´m bored
Play sof2 :d
#3:
Re: how to add your own gameover song (code)
Author:
kingsfloo
,
Location: Argentina
Posted: Fri Apr 10, 2015 5:00 am
—
lol ya i play sometimes
...usually a bit in the night
#4:
Re: how to add your own gameover song (code)
Author:
abdouraoui
,
Posted: Fri Apr 10, 2015 10:43 am
—
Thanks Floo nice job i like it
Soldier Of Fortune 2
->
SOF2 Tutorials
output generated using
printer-friendly topic mod
.
All times are GMT + 2 Hours
Page
1
of
1