By the way, i wanted to create this topic for all users, like me, who comes from a different program language and, most of all, doesn't know exactly how to understand completly the source code or else.
So i suggest this topic in order to put your questions about the "dark" side of the code that you aren't able to understand.
So i propose in order to start a piece of cpma source code about hitsounds:
the main function is CG_CheckLocalSounds and start within cg_playerstate.c
in CG_CheckLocalSounds, change this
// hit changes
if ( ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS] ) {
trap_S_StartLocalSound( cgs.media.hitSound[2], CHAN_LOCAL_SOUND );
} else if ( ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS] ) {
trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );
}
to
// hit changes
// CPM: Hit tones
if (cpm_hittones)
{
int delta;
delta = ps->persistant[PERS_HITS] - ops->persistant[PERS_HITS];
if (delta > 75)
trap_S_StartLocalSound( cgs.media.hitSound[3], CHAN_LOCAL_SOUND );
else if (delta > 50)
trap_S_StartLocalSound( cgs.media.hitSound[2], CHAN_LOCAL_SOUND );
else if (delta > 25)
trap_S_StartLocalSound( cgs.media.hitSound[1], CHAN_LOCAL_SOUND );
else if (delta > 0)
trap_S_StartLocalSound( cgs.media.hitSound[0], CHAN_LOCAL_SOUND );
else if (delta < 0)
trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );
}
else
{
if ( ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS] ) {
trap_S_StartLocalSound( cgs.media.hitSound[2], CHAN_LOCAL_SOUND );
} else if ( ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS] ) {
trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );
}
}
// !CPM
Code: Select all
void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {
int highScore, health, armor, reward;
sfxHandle_t sfx;
delta is an integer and is equal to = ?????delta = ps->persistant[PERS_HITS] - ops->persistant[PERS_HITS];
i still not understand that ps->persistant and ops->persistant (aren't the same variable inside the playerState_t table?)
[USING THAT CODE]: i got ever the same hitsound....