mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-22 07:52:30 +00:00
Clean up a bunch of the K_Play[something]Taunt/Sound functions
- Less copypasted code - Cleaner to read at-a-glance - Don't play for objects that don't have skins set - Don't play if R_CanShowSkinInDemo is false
This commit is contained in:
parent
59b335ed09
commit
b7927fc7a4
2 changed files with 91 additions and 45 deletions
130
src/k_kart.c
130
src/k_kart.c
|
|
@ -2693,13 +2693,33 @@ static void K_RegularVoiceTimers(player_t *player)
|
||||||
player->karthud[khud_tauntvoices] = 4*TICRATE;
|
player->karthud[khud_tauntvoices] = 4*TICRATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_PlayAttackTaunt(mobj_t *source)
|
static UINT8 K_ObjectToSkinIDForSounds(mobj_t *source)
|
||||||
{
|
{
|
||||||
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
|
if (source->player)
|
||||||
boolean tasteful = (!source->player || !source->player->karthud[khud_tauntvoices]);
|
return source->player->skin;
|
||||||
|
|
||||||
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
|
if (!source->skin)
|
||||||
S_StartSound(source, sfx_kattk1+pick);
|
return MAXSKINS;
|
||||||
|
|
||||||
|
return ((skin_t *)source->skin)-skins;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void K_PlayGenericTastefulTaunt(mobj_t *source, sfxenum_t sfx_id)
|
||||||
|
{
|
||||||
|
UINT8 skinid = K_ObjectToSkinIDForSounds(source);
|
||||||
|
if (skinid >= numskins)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean tasteful = (!source->player || source->player->karthud[khud_tauntvoices]);
|
||||||
|
|
||||||
|
if (
|
||||||
|
cv_kartvoices.value
|
||||||
|
&& (tasteful || cv_kartvoices.value == 2)
|
||||||
|
&& R_CanShowSkinInDemo(skinid)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
S_StartSound(source, sfx_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (!tasteful)
|
if (!tasteful)
|
||||||
return;
|
return;
|
||||||
|
|
@ -2707,23 +2727,27 @@ void K_PlayAttackTaunt(mobj_t *source)
|
||||||
K_TauntVoiceTimers(source->player);
|
K_TauntVoiceTimers(source->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void K_PlayAttackTaunt(mobj_t *source)
|
||||||
|
{
|
||||||
|
// Gotta roll the RNG every time this is called for sync reasons
|
||||||
|
sfxenum_t pick = P_RandomKey(PR_VOICES, 2);
|
||||||
|
K_PlayGenericTastefulTaunt(source, sfx_kattk1+pick);
|
||||||
|
}
|
||||||
|
|
||||||
void K_PlayBoostTaunt(mobj_t *source)
|
void K_PlayBoostTaunt(mobj_t *source)
|
||||||
{
|
{
|
||||||
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
|
// Gotta roll the RNG every time this is called for sync reasons
|
||||||
boolean tasteful = (!source->player || !source->player->karthud[khud_tauntvoices]);
|
sfxenum_t pick = P_RandomKey(PR_VOICES, 2);
|
||||||
|
K_PlayGenericTastefulTaunt(source, sfx_kbost1+pick);
|
||||||
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
|
|
||||||
S_StartSound(source, sfx_kbost1+pick);
|
|
||||||
|
|
||||||
if (!tasteful)
|
|
||||||
return;
|
|
||||||
|
|
||||||
K_TauntVoiceTimers(source->player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_PlayOvertakeSound(mobj_t *source)
|
void K_PlayOvertakeSound(mobj_t *source)
|
||||||
{
|
{
|
||||||
boolean tasteful = (!source->player || !source->player->karthud[khud_voices]);
|
UINT8 skinid = K_ObjectToSkinIDForSounds(source);
|
||||||
|
if (skinid >= numskins)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean tasteful = (!source->player || source->player->karthud[khud_voices]);
|
||||||
|
|
||||||
if (!(gametyperules & GTR_CIRCUIT)) // Only in race
|
if (!(gametyperules & GTR_CIRCUIT)) // Only in race
|
||||||
return;
|
return;
|
||||||
|
|
@ -2732,8 +2756,14 @@ void K_PlayOvertakeSound(mobj_t *source)
|
||||||
if (leveltime < starttime+(10*TICRATE))
|
if (leveltime < starttime+(10*TICRATE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
|
if (
|
||||||
|
cv_kartvoices.value
|
||||||
|
&& (tasteful || cv_kartvoices.value == 2)
|
||||||
|
&& R_CanShowSkinInDemo(skinid)
|
||||||
|
)
|
||||||
|
{
|
||||||
S_StartSound(source, sfx_kslow);
|
S_StartSound(source, sfx_kslow);
|
||||||
|
}
|
||||||
|
|
||||||
if (!tasteful)
|
if (!tasteful)
|
||||||
return;
|
return;
|
||||||
|
|
@ -2741,11 +2771,12 @@ void K_PlayOvertakeSound(mobj_t *source)
|
||||||
K_RegularVoiceTimers(source->player);
|
K_RegularVoiceTimers(source->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_PlayPainSound(mobj_t *source, mobj_t *other)
|
static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sfx_id)
|
||||||
{
|
{
|
||||||
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
|
UINT8 skinid = K_ObjectToSkinIDForSounds(source);
|
||||||
skin_t *skin = (source->player ? &skins[source->player->skin] : ((skin_t *)source->skin));
|
if (skinid >= numskins)
|
||||||
sfxenum_t sfx_id = skin->soundsid[S_sfx[sfx_khurt1 + pick].skinsound];
|
return;
|
||||||
|
|
||||||
boolean alwaysHear = false;
|
boolean alwaysHear = false;
|
||||||
|
|
||||||
if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL)
|
if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL)
|
||||||
|
|
@ -2753,31 +2784,29 @@ void K_PlayPainSound(mobj_t *source, mobj_t *other)
|
||||||
alwaysHear = P_IsDisplayPlayer(other->player);
|
alwaysHear = P_IsDisplayPlayer(other->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cv_kartvoices.value)
|
if (
|
||||||
|
cv_kartvoices.value
|
||||||
|
&& R_CanShowSkinInDemo(skinid)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
S_StartSound(alwaysHear ? NULL : source, sfx_id);
|
S_StartSound(
|
||||||
|
alwaysHear ? NULL : source,
|
||||||
|
skins[skinid].soundsid[S_sfx[sfx_id].skinsound]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
K_RegularVoiceTimers(source->player);
|
K_RegularVoiceTimers(source->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void K_PlayPainSound(mobj_t *source, mobj_t *other)
|
||||||
|
{
|
||||||
|
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
|
||||||
|
K_PlayGenericCombatSound(source, other, sfx_khurt1 + pick);
|
||||||
|
}
|
||||||
|
|
||||||
void K_PlayHitEmSound(mobj_t *source, mobj_t *other)
|
void K_PlayHitEmSound(mobj_t *source, mobj_t *other)
|
||||||
{
|
{
|
||||||
skin_t *skin = (source->player ? &skins[source->player->skin] : ((skin_t *)source->skin));
|
K_PlayGenericCombatSound(source, other, sfx_khitem);
|
||||||
sfxenum_t sfx_id = skin->soundsid[S_sfx[sfx_khitem].skinsound];
|
|
||||||
boolean alwaysHear = false;
|
|
||||||
|
|
||||||
if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL)
|
|
||||||
{
|
|
||||||
alwaysHear = P_IsDisplayPlayer(other->player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cv_kartvoices.value)
|
|
||||||
{
|
|
||||||
S_StartSound(alwaysHear ? NULL : source, sfx_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
K_RegularVoiceTimers(source->player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_TryHurtSoundExchange(mobj_t *victim, mobj_t *attacker)
|
void K_TryHurtSoundExchange(mobj_t *victim, mobj_t *attacker)
|
||||||
|
|
@ -2813,7 +2842,14 @@ void K_TryHurtSoundExchange(mobj_t *victim, mobj_t *attacker)
|
||||||
|
|
||||||
void K_PlayPowerGloatSound(mobj_t *source)
|
void K_PlayPowerGloatSound(mobj_t *source)
|
||||||
{
|
{
|
||||||
if (cv_kartvoices.value)
|
UINT8 skinid = K_ObjectToSkinIDForSounds(source);
|
||||||
|
if (skinid >= numskins)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (
|
||||||
|
cv_kartvoices.value
|
||||||
|
&& R_CanShowSkinInDemo(skinid)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
S_StartSound(source, sfx_kgloat);
|
S_StartSound(source, sfx_kgloat);
|
||||||
}
|
}
|
||||||
|
|
@ -2821,6 +2857,22 @@ void K_PlayPowerGloatSound(mobj_t *source)
|
||||||
K_RegularVoiceTimers(source->player);
|
K_RegularVoiceTimers(source->player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MOVED so we don't have to extern K_ObjectToSkinID
|
||||||
|
void P_PlayVictorySound(mobj_t *source)
|
||||||
|
{
|
||||||
|
UINT8 skinid = K_ObjectToSkinIDForSounds(source);
|
||||||
|
if (skinid >= numskins)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (
|
||||||
|
cv_kartvoices.value
|
||||||
|
&& R_CanShowSkinInDemo(skinid)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
S_StartSound(source, sfx_kwin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void K_HandleDelayedHitByEm(player_t *player)
|
static void K_HandleDelayedHitByEm(player_t *player)
|
||||||
{
|
{
|
||||||
if (player->confirmVictimDelay == 0)
|
if (player->confirmVictimDelay == 0)
|
||||||
|
|
|
||||||
|
|
@ -547,12 +547,6 @@ void P_PlayDeathSound(mobj_t *source)
|
||||||
S_StartSound(source, sfx_s3k35);
|
S_StartSound(source, sfx_s3k35);
|
||||||
}
|
}
|
||||||
|
|
||||||
void P_PlayVictorySound(mobj_t *source)
|
|
||||||
{
|
|
||||||
if (cv_kartvoices.value)
|
|
||||||
S_StartSound(source, sfx_kwin);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// P_StartPositionMusic
|
// P_StartPositionMusic
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue