public override void PreUpdate() { timerUntilValidChestStateChange++; // This is a pretty niche finding for tiles above said player Tile playerTile = Main.tile[(int)player.Center.X / 16, (int)player.Center.Y / 16]; for (int i = (int)player.Top.X - 1; i < player.Top.X + 1; i++) { for (int j = (int)player.Top.Y - 1; playerTile.wall <= 0 ? j > player.Top.Y - 350 : j > player.Top.Y - 600; j--) { Tile tile = Main.tile[i / 16, j / 16]; if (tile.active() && tile.collisionType == 1) { hasTilesAbove = true; break; } else { hasTilesAbove = false; } } } bool hasLegArmor = GeneralHelpers.CheckPlayerArmorSlot(player, GeneralHelpers.IDs.ArmorSlotID.LegSlot); legFrameSnapShotNew = player.legFrame.Y / 20; chestStateNew = player.chest; // Good Values -> 25 (first), 44 (second), 14 = midair // Main.NewText($"{chestStateNew}, {chestStateOld}"); if (Main.soundVolume > 0f) { if (ModContent.GetInstance <AmbientConfigServer>().chestSounds) { if (timerUntilValidChestStateChange > 10) { if ((chestStateNew != chestStateOld) && chestStateNew != -1) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ambient/player/chest_open"), player.Center).Volume = 0.35f; } if ((chestStateNew != chestStateOld) && chestStateNew == -1) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ambient/player/chest_close"), player.Center); } else if ((chestStateNew != chestStateOld) && chestStateOld > -1) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ambient/player/chest_close"), player.Center); } } } } int randWood = Main.rand.Next(1, 8); int randSand = Main.rand.Next(1, 7); int randStone = Main.rand.Next(1, 9); int randGrass = Main.rand.Next(1, 9); int randSnow = Main.rand.Next(1, 12); int randWet = Main.rand.Next(1, 4); int randDirt = Main.rand.Next(1, 5); int randReverb = Main.rand.Next(1, 7); string pathWood = $"Sounds/Custom/steps/wood/step{randWood}"; string pathSand = $"Sounds/Custom/steps/sand/step{randSand}"; string pathStone = $"Sounds/Custom/steps/stone/step{randStone}"; string pathGrass = $"Sounds/Custom/steps/grass/step{randGrass}"; string pathSnow = $"Sounds/Custom/steps/snow/step{randSnow}"; string pathWet = $"Sounds/Custom/steps/wet/step{randWet}"; string pathDirt = $"Sounds/Custom/steps/dirt/step{randDirt}"; string pathReverbSnow = $"Sounds/Custom/steps/snow/reverb/step{randReverb}"; string pathReverbStone = $"Sounds/Custom/steps/stone/reverb/step{randReverb}"; string pathReverbSand = $"Sounds/Custom/steps/sand/reverb/step{randReverb}"; string pathReverbWood = $"Sounds/Custom/steps/wood/reverb/step{randReverb}"; string pathReverbGrass = $"Sounds/Custom/steps/grass/reverb/step{randReverb}"; string pathReverbDirt = $"Sounds/Custom/steps/dirt/reverb/step{randReverb}"; if (player.velocity.Y != 0f) { isOnWoodTile = false; isOnDirtyTile = false; isOnSnowyTile = false; isOnStoneTile = false; isOnGrassyTile = false; isOnSandyTile = false; } bool stepping = (legFrameSnapShotNew == 44 && legFrameSnapShotOld != 44) || (legFrameSnapShotNew == 25 && legFrameSnapShotOld != 25); bool landing = legFrameSnapShotNew != 14 && legFrameSnapShotOld == 14; if (ModContent.GetInstance <AmbientConfigClient>().footsteps) { int tileReq = player.TilesAround(20, player.ZoneRockLayerHeight || player.ZoneDirtLayerHeight); reverbRequirement = !ModContent.GetInstance <AmbientConfigServer>().noReverbMath ? (player.ZoneRockLayerHeight && tileReq > 100) || (player.ZoneDirtLayerHeight && tileReq > 650) : player.ZoneRockLayerHeight || player.ZoneDirtLayerHeight; var actualVol = Ambience.fStepsVol / 100; if (Ambience.fStepsVol != 0 && !player.mount.Active && player.velocity.Y == 0 && Main.soundVolume != 0f && !player.pulley) { if (landing && isOnSandyTile && soundInstanceSandStep != null) { soundInstanceSandStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathSand : pathReverbSand), player.Bottom); soundInstanceSandStep.Volume = player.wet ? 0.8f * actualVol : actualVol; soundInstanceSandStep.Pitch = player.wet ? -0.5f : 0f; } if (landing && isOnGrassyTile && soundInstanceGrassStep != null) { if (!Main.raining || hasTilesAbove) { soundInstanceGrassStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathGrass : pathReverbGrass), player.Bottom); soundInstanceGrassStep.Volume = player.wet ? 0.6f * actualVol : 0.8f * actualVol; soundInstanceGrassStep.Pitch = player.wet ? -0.5f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet && !player.ZoneSnow && player.ZoneOverworldHeight) { soundInstanceGrassStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceGrassStep.Volume = player.wet ? 0.3f * actualVol : 0.6f * actualVol; soundInstanceGrassStep.Pitch = Main.rand.NextFloat(-0.3f, 0.3f); } } if (landing && isOnDirtyTile && soundInstanceDirtStep != null) { if (!Main.raining || hasTilesAbove) { soundInstanceDirtStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathDirt : pathReverbDirt), player.Bottom); soundInstanceDirtStep.Volume = player.wet ? 0.04f * actualVol : 0.15f * actualVol; soundInstanceDirtStep.Pitch = player.wet ? -0.7f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet && !player.ZoneSnow && player.ZoneOverworldHeight) { soundInstanceDirtStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceDirtStep.Volume = player.wet ? 0.3f * actualVol : 0.6f * actualVol; soundInstanceDirtStep.Pitch = Main.rand.NextFloat(-0.3f, 0.3f); } } if (landing && isOnStoneTile && soundInstanceStoneStep != null) { soundInstanceStoneStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathStone : pathReverbStone), player.Bottom); soundInstanceStoneStep.Volume = player.wet ? 0.2f * actualVol : 0.3f * actualVol; soundInstanceStoneStep.Pitch = player.wet ? -0.5f : 0f; } if (landing && isOnSnowyTile && soundInstanceSnowStep != null) { soundInstanceSnowStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathSnow : pathReverbSnow), player.Bottom); soundInstanceSnowStep.Volume = player.wet ? 0.1f * actualVol : 0.2f * actualVol; soundInstanceSnowStep.Pitch = player.wet ? -0.5f : 0f; } if (landing && isOnWoodTile && soundInstanceWoodStep != null && !isOnDirtyTile) { if (!Main.raining || hasTilesAbove) // no rain or has tiles covering said player { soundInstanceWoodStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathWood : pathReverbWood), player.Bottom); soundInstanceWoodStep.Volume = player.wet ? actualVol * 0.3f : 0.45f * actualVol; soundInstanceWoodStep.Pitch = player.wet ? -0.5f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet && !player.ZoneSnow && player.ZoneOverworldHeight) { soundInstanceWoodStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceWoodStep.Volume = player.wet ? 0.5f * actualVol : actualVol / 4; soundInstanceWoodStep.Pitch = Main.rand.NextFloat(-0.3f, 0.3f); } } // Top: landing sounds // Bottom: walking sounds if (stepping && isOnSandyTile && soundInstanceSandStep != null) { soundInstanceSandStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathSand : pathReverbSand), player.Bottom); soundInstanceSandStep.Volume = player.wet ? actualVol * 0.25f : actualVol * 0.75f; soundInstanceSandStep.Pitch = player.wet ? -0.5f : 0f; } if (stepping && isOnGrassyTile && soundInstanceGrassStep != null) { if (!Main.raining || hasTilesAbove) // rain and no tiles covering said player { soundInstanceGrassStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathGrass : pathReverbGrass), player.Bottom); soundInstanceGrassStep.Volume = player.wet ? actualVol / 5 : actualVol / 2; soundInstanceGrassStep.Pitch = player.wet ? -0.5f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet) { soundInstanceGrassStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceGrassStep.Volume = player.wet ? actualVol / 8 : actualVol / 4; soundInstanceGrassStep.Pitch = Main.rand.NextFloat(-0.4f, 0.4f); } } if (stepping && isOnDirtyTile && soundInstanceDirtStep != null) { if (!Main.raining || hasTilesAbove) // rain and no tiles covering said player { soundInstanceDirtStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathDirt : pathReverbDirt), player.Bottom); soundInstanceDirtStep.Volume = player.wet ? 0.01f : 0.045f; soundInstanceDirtStep.Pitch = player.wet ? -0.5f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet) { soundInstanceDirtStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceDirtStep.Volume = player.wet ? 0.125f : 0.25f; soundInstanceDirtStep.Pitch = Main.rand.NextFloat(-0.4f, 0.4f); } } if (stepping && isOnStoneTile && soundInstanceStoneStep != null) { soundInstanceStoneStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathStone : pathReverbStone), player.Bottom); soundInstanceStoneStep.Volume = player.wet ? actualVol / 12 : actualVol / 8; soundInstanceStoneStep.Pitch = player.wet ? -0.5f : 0f; } if (stepping && isOnWoodTile && soundInstanceWoodStep != null) { if (!Main.raining || hasTilesAbove) // rain and no tiles covering said player { soundInstanceWoodStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathWood : pathReverbWood), player.Bottom); soundInstanceWoodStep.Volume = player.wet ? actualVol / 12 : actualVol / 8; soundInstanceWoodStep.Pitch = player.wet ? -0.5f : 0f; } if (!hasTilesAbove && Main.raining && !player.wet) { soundInstanceWoodStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, pathWet), player.Bottom); soundInstanceWoodStep.Volume = player.wet ? actualVol / 8 : actualVol / 4; soundInstanceWoodStep.Pitch = Main.rand.NextFloat(-0.3f, 0.3f); } } if (stepping && isOnSnowyTile && soundInstanceSnowStep != null) { soundInstanceSnowStep = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, !reverbRequirement ? pathSnow : pathReverbSnow), player.Bottom); soundInstanceSnowStep.Volume = player.wet ? 0.06f : 0.12f; soundInstanceSnowStep.Pitch = player.wet ? -0.2f : 0.3f; } } } legFrameSnapShotOld = legFrameSnapShotNew; chestStateOld = chestStateNew; }