summaryrefslogtreecommitdiffstats
path: root/src/audio/AudioManager.cpp
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2019-06-13 21:16:55 +0200
committerFilip Gawin <filip.gawin@zoho.com>2019-06-29 14:03:39 +0200
commit6c0f81f12abe7e4fca2ca3f386743148e2fff492 (patch)
treeae87b6dd378474c0977618f36fca5f357ff0252d /src/audio/AudioManager.cpp
parentAudioManager::GetPhrase (diff)
downloadre3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar.gz
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar.bz2
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar.lz
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar.xz
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.tar.zst
re3-6c0f81f12abe7e4fca2ca3f386743148e2fff492.zip
Diffstat (limited to '')
-rw-r--r--src/audio/AudioManager.cpp91
1 files changed, 83 insertions, 8 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 5a290d28..1bcd98ae 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -11,20 +11,95 @@ cAudioManager::PlayerJustLeftCar(void)
}
void
-cAudioManager::GetPhrase(uint32 *phrase, uint32 *prevPhrase,
+cAudioManager::GetPhrase(eAudioSamples *phrase, eAudioSamples *prevPhrase,
eAudioSamples sample, uint32 maxOffset)
{
- *phrase = (uint32)sample +
- (uint32)m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] %
- maxOffset;
- if(*phrase == *prevPhrase && ++*phrase >= (uint32)sample + maxOffset)
- *phrase = (uint32)sample;
+ *phrase = eAudioSamples(
+ sample +
+ (uint32)m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] %
+ maxOffset);
+ if(*phrase == *prevPhrase &&
+ ++*(uint32 *)phrase >= (uint32)sample + maxOffset)
+ *phrase = sample;
*prevPhrase = *phrase;
}
+static bool &bUsedPlayerTalkSfx = *(bool *)0x6508f4;
+static eAudioSamples &lastPlayerTalkSfx = *(eAudioSamples *)0x6508f0;
+
+uint32
+cAudioManager::GetPlayerTalkSfx(eSound sound)
+{
+ eAudioSamples sfx;
+
+ if(!bUsedPlayerTalkSfx) {
+ bUsedPlayerTalkSfx = true;
+ lastPlayerTalkSfx = NO_SAMPLE;
+ }
+ switch(sound) {
+ case SOUND_PED_DAMAGE:
+ cAudioManager::GetPhrase(&sfx, &lastPlayerTalkSfx,
+ AUDIO_SAMPLE_PED_DAMAGE_REACTION_1,
+ 11u);
+ break;
+
+ case SOUND_PED_HIT:
+ cAudioManager::GetPhrase(&sfx, &lastPlayerTalkSfx,
+ AUDIO_SAMPLE_PED_HIT_REACTION_1, 10u);
+ break;
+
+ case SOUND_PED_LAND:
+ cAudioManager::GetPhrase(&sfx, &lastPlayerTalkSfx,
+ AUDIO_SAMPLE_PED_FALL_REACTION_1, 6u);
+ break;
+
+ default: sfx = NO_SAMPLE; break;
+ }
+ return sfx;
+}
+
+static bool &bUsedGenericMaleTalkSfx = *(bool *)0x650B0C;
+static eAudioSamples &lastGenericMaleTalkSfx = *(eAudioSamples *)0x650B08;
+
+uint32
+cAudioManager::GetGenericMaleTalkSfx(eSound sample)
+{
+ eAudioSamples sfx;
+
+ if(!bUsedGenericMaleTalkSfx) {
+ bUsedGenericMaleTalkSfx = 1;
+ lastGenericMaleTalkSfx = NO_SAMPLE;
+ }
+ switch(sample) {
+ case SOUND_PED_DEATH:
+ cAudioManager::GetPhrase(&sfx, &lastGenericMaleTalkSfx,
+ AUDIO_SAMPLE_PED_MALE_DEATH_1, 8u);
+ break;
+ case SOUND_PED_BULLET_HIT:
+ case SOUND_PED_DEFEND:
+ cAudioManager::GetPhrase(&sfx, &lastGenericMaleTalkSfx,
+ AUDIO_SAMPLE_INJURED_PED_MALE_OUCH_1,
+ 15u);
+ break;
+ case SOUND_PED_BURNING:
+ cAudioManager::GetPhrase(&sfx, &lastGenericMaleTalkSfx,
+ AUDIO_SAMPLE_PED_MALE_BURNING_1, 8u);
+ break;
+ case SOUND_PED_FLEE_SPRINT:
+ cAudioManager::GetPhrase(&sfx, &lastGenericMaleTalkSfx,
+ AUDIO_SAMPLE_PED_MALE_FLEE_SPRINT_1,
+ 6u);
+ break;
+ default: return NO_SAMPLE;
+ }
+ return sfx;
+}
+
WRAPPER void cAudioManager::Service() { EAXJMP(0x57A2A0); }
STARTPATCHES
- InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP);
- InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP);
+InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP);
+InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP);
+InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP);
+InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP);
ENDPATCHES