Walls now sound different depending on which direction the probe was going when it found them. Also no compass chime while Z-targeting.

This commit is contained in:
Caturria 2023-08-30 23:47:56 -04:00
commit 954f3fb607
4 changed files with 30 additions and 9 deletions

View file

@ -371,6 +371,9 @@ void accessible_audio_compass_cleanup(AccessibleActor* actor)
} }
void accessible_audio_compass(AccessibleActor* actor) { void accessible_audio_compass(AccessibleActor* actor) {
Player* player = GET_PLAYER(actor->play); Player* player = GET_PLAYER(actor->play);
if (player->stateFlags1 & PLAYER_STATE1_TARGETING)
return;
actor->world.pos = player->actor.world.pos; actor->world.pos = player->actor.world.pos;
actor->world.pos.z -= 50; actor->world.pos.z -= 50;
bool shouldChime = false; bool shouldChime = false;

View file

@ -68,7 +68,8 @@ static float lerp(float x, float y, float z) {
//Pan the sound based on its projected position. //Pan the sound based on its projected position.
float pan; float pan;
//Use the game's panning mechanism, which returns a signed 8-bit integer between 0 (far-left) and 127 (far-right). //Use the game's panning mechanism, which returns a signed 8-bit integer between 0 (far-left) and 127 (far-right).
//It would appear that the correct thing to do is interpret this value as a gain factor in decibels. In practice, values below 38 or above 90 are never seen, so a sound that's panned far to one side or the other amounts to about -25DB worth of attenuation. //It would appear that the correct thing to do is interpret this value as a gain factor in decibels. In practice, values below 38 or above 90 are never seen, so a sound that's panned far to one side or the other amounts to about -25DB worth of attenuation.
//Also: lie about the value of Z and give it a constant value to prevent weird behaviour when Z is far away.
s8 panSigned = Audio_ComputeSoundPanSigned(extras->x, extras->z, 4); s8 panSigned = Audio_ComputeSoundPanSigned(extras->x, extras->z, 4);
int db; int db;
if (panSigned < 64) if (panSigned < 64)

View file

@ -133,7 +133,7 @@ void ActorAccessibility_Shutdown() {
policy->pitch = 1.5; policy->pitch = 1.5;
policy->runsAlways = false; policy->runsAlways = false;
policy->sound = sfx; policy->sound = sfx;
policy->volume = 0.5; policy->volume = 1.0;
policy->initUserData = NULL; policy->initUserData = NULL;
policy->cleanupUserData = NULL; policy->cleanupUserData = NULL;
policy->pitchModifier = 0.1; policy->pitchModifier = 0.1;

View file

@ -13,7 +13,7 @@ void CollisionPoly_GetVertices(CollisionPoly* poly, Vec3s* vtxList, Vec3f* dest)
#define MIN_INCLINE_DISTANCE 5.0 #define MIN_INCLINE_DISTANCE 5.0
#define MIN_DECLINE_DISTANCE 5.0 #define MIN_DECLINE_DISTANCE 5.0
#define DEFAULT_PROBE_SPEED 5.5 #define DEFAULT_PROBE_SPEED 5.5
#define NOMINMAX
static Player fakePlayer;//Used for wall height detection. static Player fakePlayer;//Used for wall height detection.
static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; // From z_player.c. static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; // From z_player.c.
@ -228,10 +228,17 @@ class Platform: protected TerrainCueSound {
class Wall: protected TerrainCueSound { class Wall: protected TerrainCueSound {
int frames; int frames;
Vec3s probeRot;
f32 targetPitch;
public: public:
Wall(AccessibleActor* actor, Vec3f pos) : TerrainCueSound(actor, pos) { Wall(AccessibleActor* actor, Vec3f pos, Vec3s rot) : TerrainCueSound(actor, pos) {
probeRot = rot;
currentPitch = 0.5; currentPitch = 0.5;
targetPitch = (f32) probeRot.y / (16384.0f * 2.0f);
if (probeRot.y != 0 && targetPitch < -0.4)
targetPitch = -0.4;
currentSFX = NA_SE_IT_SWORD_CHARGE; currentSFX = NA_SE_IT_SWORD_CHARGE;
frames = 0; frames = 0;
@ -243,10 +250,20 @@ class Wall: protected TerrainCueSound {
void run() { void run() {
frames++; frames++;
if (frames == 20) { if (frames == 20) {
frames = 0; frames = 0;
play(); play();
} ActorAccessibility_SeekSound(this, 0, 44100 * 2);
}
f32 pitchModifier;
if (targetPitch < 0)
pitchModifier = LERP(2.5, 0.5 + targetPitch, (f32)frames / 20.0f);
else if (targetPitch > 0)
pitchModifier = LERP(0.1, (0.5 + targetPitch), (f32)frames / 20.0f);
ActorAccessibility_SetSoundPitch(this, 0, pitchModifier);
} }
}; };
class Spike : protected TerrainCueSound { class Spike : protected TerrainCueSound {
@ -416,7 +433,7 @@ class Ground : protected TerrainCueSound {
destroyCurrentSound(); destroyCurrentSound();
new (&wall) Wall(actor, pos); new (&wall) Wall(actor, pos, relRot);
currentSound = (TerrainCueSound*)&wall; currentSound = (TerrainCueSound*)&wall;
terrainDiscovered = DISCOVERED_WALL; terrainDiscovered = DISCOVERED_WALL;
} }