mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge remote-tracking branch 'pub/next'
This commit is contained in:
commit
d9f7f155a2
1 changed files with 82 additions and 38 deletions
108
src/k_kart.c
108
src/k_kart.c
|
|
@ -5283,9 +5283,17 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
|
||||||
static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
||||||
{
|
{
|
||||||
const INT32 numsnds = 13;
|
const INT32 numsnds = 13;
|
||||||
|
|
||||||
|
const fixed_t closedist = 160*FRACUNIT;
|
||||||
|
const fixed_t fardist = 1536*FRACUNIT;
|
||||||
|
|
||||||
|
const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6
|
||||||
|
|
||||||
INT32 class, s, w; // engine class number
|
INT32 class, s, w; // engine class number
|
||||||
|
|
||||||
UINT8 volume = 255;
|
UINT8 volume = 255;
|
||||||
fixed_t volumedampen = 0;
|
fixed_t volumedampen = FRACUNIT;
|
||||||
|
|
||||||
INT32 targetsnd = 0;
|
INT32 targetsnd = 0;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
|
|
@ -5301,81 +5309,117 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
||||||
|
|
||||||
class = s + (3*w);
|
class = s + (3*w);
|
||||||
|
|
||||||
// Silence the engines
|
|
||||||
if (leveltime < 8 || player->spectator)
|
if (leveltime < 8 || player->spectator)
|
||||||
{
|
{
|
||||||
player->karthud[khud_enginesnd] = 0; // Reset sound number
|
// Silence the engines, and reset sound number while we're at it.
|
||||||
|
player->kartstuff[k_enginesnd] = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ((leveltime % 8) != ((player-players) % 8)) // Per-player offset, to make engines sound distinct!
|
if ((leveltime % 8) != ((player-players) % 8)) // Per-player offset, to make engines sound distinct!
|
||||||
#else
|
#else
|
||||||
if (leveltime % 8) // .25 seconds of wait time between engine sounds
|
if (leveltime % 8)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
// .25 seconds of wait time between each engine sound playback
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (player->respawn.state == RESPAWNST_DROP) // Dropdashing
|
if (player->respawn.state == RESPAWNST_DROP) // Dropdashing
|
||||||
|
{
|
||||||
|
// Dropdashing
|
||||||
targetsnd = ((cmd->buttons & BT_ACCELERATE) ? 12 : 0);
|
targetsnd = ((cmd->buttons & BT_ACCELERATE) ? 12 : 0);
|
||||||
else if (K_PlayerEBrake(player) == true) // Spindashing
|
}
|
||||||
|
else if (K_PlayerEBrake(player) == true)
|
||||||
|
{
|
||||||
|
// Spindashing
|
||||||
targetsnd = ((cmd->buttons & BT_DRIFT) ? 12 : 0);
|
targetsnd = ((cmd->buttons & BT_DRIFT) ? 12 : 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
targetsnd = (((6*K_GetForwardMove(player))/25) + ((player->speed / mapobjectscale)/5))/2;
|
{
|
||||||
|
// Average out the value of forwardmove and the speed that you're moving at.
|
||||||
|
targetsnd = (((6 * cmd->forwardmove) / 25) + ((player->speed / mapobjectscale) / 5)) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (targetsnd < 0)
|
if (targetsnd < 0) { targetsnd = 0; }
|
||||||
targetsnd = 0;
|
if (targetsnd > 12) { targetsnd = 12; }
|
||||||
if (targetsnd > 12)
|
|
||||||
targetsnd = 12;
|
|
||||||
|
|
||||||
if (player->karthud[khud_enginesnd] < targetsnd)
|
if (player->kartstuff[k_enginesnd] < targetsnd) { player->kartstuff[k_enginesnd]++; }
|
||||||
player->karthud[khud_enginesnd]++;
|
if (player->kartstuff[k_enginesnd] > targetsnd) { player->kartstuff[k_enginesnd]--; }
|
||||||
if (player->karthud[khud_enginesnd] > targetsnd)
|
|
||||||
player->karthud[khud_enginesnd]--;
|
|
||||||
|
|
||||||
if (player->karthud[khud_enginesnd] < 0)
|
if (player->kartstuff[k_enginesnd] < 0) { player->kartstuff[k_enginesnd] = 0; }
|
||||||
player->karthud[khud_enginesnd] = 0;
|
if (player->kartstuff[k_enginesnd] > 12) { player->kartstuff[k_enginesnd] = 12; }
|
||||||
if (player->karthud[khud_enginesnd] > 12)
|
|
||||||
player->karthud[khud_enginesnd] = 12;
|
// This code calculates how many players (and thus, how many engine sounds) are within ear shot,
|
||||||
|
// and rebalances the volume of your engine sound based on how far away they are.
|
||||||
|
|
||||||
|
// This results in multiple things:
|
||||||
|
// - When on your own, you will hear your own engine sound extremely clearly.
|
||||||
|
// - When you were alone but someone is gaining on you, yours will go quiet, and you can hear theirs more clearly.
|
||||||
|
// - When around tons of people, engine sounds will try to rebalance to not be as obnoxious.
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
UINT8 thisvol = 0;
|
UINT8 thisvol = 0;
|
||||||
fixed_t dist;
|
fixed_t dist;
|
||||||
|
|
||||||
if (!playeringame[i] || !players[i].mo || players[i].spectator || players[i].exiting)
|
if (!playeringame[i] || !players[i].mo)
|
||||||
|
{
|
||||||
|
// This player doesn't exist.
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (players[i].spectator)
|
||||||
|
{
|
||||||
|
// This player isn't playing an engine sound.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (P_IsDisplayPlayer(&players[i]))
|
if (P_IsDisplayPlayer(&players[i]))
|
||||||
{
|
{
|
||||||
volumedampen += FRACUNIT; // We already know what this is gonna be, let's not waste our time.
|
// Don't dampen yourself!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dist = P_AproxDistance(P_AproxDistance(player->mo->x-players[i].mo->x,
|
dist = P_AproxDistance(
|
||||||
player->mo->y-players[i].mo->y), player->mo->z-players[i].mo->z) / 2;
|
P_AproxDistance(
|
||||||
|
player->mo->x - players[i].mo->x,
|
||||||
|
player->mo->y - players[i].mo->y),
|
||||||
|
player->mo->z - players[i].mo->z) / 2;
|
||||||
|
|
||||||
dist = FixedDiv(dist, mapobjectscale);
|
dist = FixedDiv(dist, mapobjectscale);
|
||||||
|
|
||||||
if (dist > 1536<<FRACBITS)
|
if (dist > fardist)
|
||||||
|
{
|
||||||
|
// ENEMY OUT OF RANGE !
|
||||||
continue;
|
continue;
|
||||||
else if (dist < 160<<FRACBITS) // engine sounds' approx. range
|
}
|
||||||
|
else if (dist < closedist)
|
||||||
|
{
|
||||||
|
// engine sounds' approx. range
|
||||||
thisvol = 255;
|
thisvol = 255;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
thisvol = (15 * (((160<<FRACBITS) - dist)>>FRACBITS)) / (((1536<<FRACBITS)-(160<<FRACBITS))>>(FRACBITS+4));
|
{
|
||||||
|
thisvol = (15 * ((closedist - dist) / FRACUNIT)) / ((fardist - closedist) >> (FRACBITS+4));
|
||||||
|
}
|
||||||
|
|
||||||
if (thisvol == 0)
|
volumedampen += (thisvol * dampenval);
|
||||||
continue;
|
|
||||||
|
|
||||||
volumedampen += (thisvol * 257); // 255 * 257 = FRACUNIT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (volumedampen > FRACUNIT)
|
if (volumedampen > FRACUNIT)
|
||||||
volume = FixedDiv(volume<<FRACBITS, volumedampen)>>FRACBITS;
|
{
|
||||||
|
volume = FixedDiv(volume * FRACUNIT, volumedampen) / FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
if (volume <= 0) // Might as well
|
if (volume <= 0)
|
||||||
|
{
|
||||||
|
// Don't need to play the sound at all.
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->karthud[khud_enginesnd]) + (class*numsnds), volume);
|
S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class * numsnds), volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void K_UpdateInvincibilitySounds(player_t *player)
|
static void K_UpdateInvincibilitySounds(player_t *player)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue