Add comprehensive NPC voice system with interaction and combat sounds

Implements full NPC voice interaction system supporting 6 different sound categories
for all playable races/genders. System loads ~450+ voice clips from MPQ archives.

Voice Categories:
- Greeting: Play on NPC right-click interaction
- Farewell: Play when closing gossip/dialog windows
- Vendor: Play when opening merchant/vendor windows
- Pissed: Play after clicking NPC 5+ times (spam protection)
- Aggro: Play when NPC enters combat with player
- Flee: Play when NPC is fleeing (ready for low-health triggers)

Features:
- Race/gender detection from NPC display IDs via CreatureDisplayInfoExtra.dbc
- Intelligent click tracking for pissed sounds
- Combat sounds use player character vocal files for humanoid NPCs
- Cooldown system prevents voice spam (2s default, combat sounds bypass)
- Generic fallback voices for unsupported NPC types
- 3D positional audio support

Voice Support:
- All playable races: Human, Dwarf, Gnome, Night Elf, Orc, Tauren, Troll, Undead
- Male and female variants for each race
- StandardNPC sounds for social interactions
- Character vocal sounds for combat

Technical Changes:
- Refactored NpcVoiceManager to support multiple sound categories
- Added callbacks: NpcFarewell, NpcVendor, NpcAggro
- Extended voice loading to parse both StandardNPC and Character vocal paths
- Integrated with GameHandler for gossip, vendor, and combat events
- Added detailed voice detection logging for debugging

Also includes:
- Sound manifest files added to docs/ for reference
- Blacksmith hammer pitch increased to 1.6x (was 1.4x)
- Blacksmith volume reduced 30% to 0.25 (was 0.35)
This commit is contained in:
Kelsi 2026-02-09 16:03:51 -08:00
parent 251f0ac246
commit 28d009f7db
8 changed files with 10908 additions and 198 deletions

View file

@ -47,26 +47,50 @@ public:
bool initialize(pipeline::AssetManager* assets);
void shutdown();
// Play greeting sound for NPC at given position
// Play NPC interaction sounds
void playGreeting(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
void playFarewell(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
void playVendor(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
void playPissed(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
// Play NPC combat sounds
void playAggro(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
void playFlee(uint64_t npcGuid, VoiceType voiceType, const glm::vec3& position);
void setVolumeScale(float scale) { volumeScale_ = scale; }
float getVolumeScale() const { return volumeScale_; }
private:
enum class SoundCategory {
GREETING,
FAREWELL,
VENDOR,
PISSED,
AGGRO,
FLEE
};
void loadVoiceSounds();
bool loadSound(const std::string& path, VoiceSample& sample);
VoiceType detectVoiceType(uint32_t creatureEntry) const;
void playSound(uint64_t npcGuid, VoiceType voiceType, SoundCategory category, const glm::vec3& position);
pipeline::AssetManager* assetManager_ = nullptr;
float volumeScale_ = 1.0f;
// Voice samples grouped by type
std::unordered_map<VoiceType, std::vector<VoiceSample>> voiceLibrary_;
// Voice samples grouped by type and category
std::unordered_map<VoiceType, std::vector<VoiceSample>> greetingLibrary_;
std::unordered_map<VoiceType, std::vector<VoiceSample>> farewellLibrary_;
std::unordered_map<VoiceType, std::vector<VoiceSample>> vendorLibrary_;
std::unordered_map<VoiceType, std::vector<VoiceSample>> pissedLibrary_;
std::unordered_map<VoiceType, std::vector<VoiceSample>> aggroLibrary_;
std::unordered_map<VoiceType, std::vector<VoiceSample>> fleeLibrary_;
// Cooldown tracking (prevent spam clicking same NPC)
std::unordered_map<uint64_t, std::chrono::steady_clock::time_point> lastPlayTime_;
std::unordered_map<uint64_t, int> clickCount_; // Track clicks for pissed sounds
static constexpr float GREETING_COOLDOWN = 2.0f; // seconds
static constexpr int PISSED_CLICK_THRESHOLD = 5; // clicks before pissed
std::mt19937 rng_;
};