2019-06-24 14:57:54 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
|
|
|
#include "AudioManager.h"
|
|
|
|
|
|
|
|
cAudioManager &AudioManager = *(cAudioManager*)0x880FC0;
|
|
|
|
|
|
|
|
void
|
|
|
|
cAudioManager::PlayerJustLeftCar(void)
|
|
|
|
{
|
|
|
|
// UNUSED: This is a perfectly empty function.
|
|
|
|
}
|
|
|
|
|
2019-06-12 17:56:45 +00:00
|
|
|
void
|
2019-06-13 19:16:55 +00:00
|
|
|
cAudioManager::GetPhrase(eAudioSamples *phrase, eAudioSamples *prevPhrase,
|
2019-06-12 17:56:45 +00:00
|
|
|
eAudioSamples sample, uint32 maxOffset)
|
|
|
|
{
|
2019-06-13 19:16:55 +00:00
|
|
|
*phrase = eAudioSamples(
|
|
|
|
sample +
|
|
|
|
(uint32)m_anRandomTable[m_sQueueSample.m_nEntityIndex & 3] %
|
|
|
|
maxOffset);
|
|
|
|
if(*phrase == *prevPhrase &&
|
|
|
|
++*(uint32 *)phrase >= (uint32)sample + maxOffset)
|
|
|
|
*phrase = sample;
|
2019-06-12 17:56:45 +00:00
|
|
|
*prevPhrase = *phrase;
|
|
|
|
}
|
|
|
|
|
2019-06-13 19:16:55 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-06-25 12:25:39 +00:00
|
|
|
WRAPPER void cAudioManager::Service() { EAXJMP(0x57A2A0); }
|
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
STARTPATCHES
|
2019-06-13 19:16:55 +00:00
|
|
|
InjectHook(0x56AD20, &cAudioManager::PlayerJustLeftCar, PATCH_JUMP);
|
|
|
|
InjectHook(0x570DB0, &cAudioManager::GetPhrase, PATCH_JUMP);
|
|
|
|
InjectHook(0x570E00, &cAudioManager::GetPlayerTalkSfx, PATCH_JUMP);
|
|
|
|
InjectHook(0x575460, &cAudioManager::GetGenericMaleTalkSfx, PATCH_JUMP);
|
2019-06-12 17:56:45 +00:00
|
|
|
ENDPATCHES
|