summaryrefslogtreecommitdiffstats
path: root/src
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
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 'src')
-rw-r--r--src/audio/AudioManager.cpp91
-rw-r--r--src/audio/AudioManager.h18
-rw-r--r--src/audio/AudioSamples.h173
3 files changed, 267 insertions, 15 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
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index d6d831f1..94b430db 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -72,7 +72,7 @@ enum eAudioType : int32 {
class tAudioEntity
{
-public:
+ public:
eAudioType m_nType;
void *m_pEntity;
char m_bIsUsed;
@@ -100,7 +100,8 @@ public:
static_assert(sizeof(tPedComment) == 0x1c, "tPedComment: error");
-class cPedComments {
+class cPedComments
+{
public:
tPedComment m_asPedComments[40];
char field_1120[40];
@@ -113,7 +114,8 @@ static_assert(sizeof(cPedComments) == 0x48c, "cPedComments: error");
class CEntity;
-class cAudioCollision {
+class cAudioCollision
+{
public:
CEntity *m_pEntity1;
CEntity *m_pEntity2;
@@ -130,7 +132,8 @@ public:
static_assert(sizeof(cAudioCollision) == 0x28, "cAudioCollision: error");
-class cAudioCollisionManager {
+class cAudioCollisionManager
+{
public:
cAudioCollision m_asCollisions1[10];
cAudioCollision m_asCollisions2[10];
@@ -212,8 +215,11 @@ public:
void PlayerJustLeftCar(void);
void Service();
- void GetPhrase(uint32 *a2, uint32 *a3, eAudioSamples sample,
- uint32 maxOffset);
+ void GetPhrase(eAudioSamples *phrase, eAudioSamples *prevPhrase,
+ eAudioSamples sample, uint32 maxOffset);
+
+ uint32 GetPlayerTalkSfx(eSound sound);
+ uint32 GetGenericMaleTalkSfx(eSound sound);
};
static_assert(sizeof(cAudioManager) == 0x4B14, "cAudioManager: error");
diff --git a/src/audio/AudioSamples.h b/src/audio/AudioSamples.h
index 49d21ff6..24544e56 100644
--- a/src/audio/AudioSamples.h
+++ b/src/audio/AudioSamples.h
@@ -2,7 +2,7 @@
#include "common.h"
-enum eAudioSamples : int32 {
+enum eAudioSamples : uint32 {
AUDIO_SAMPLE_VEHICLE_HORN_0 = 0,
AUDIO_SAMPLE_VEHICLE_HORN_1 = 1,
AUDIO_SAMPLE_VEHICLE_HORN_2 = 2,
@@ -3038,3 +3038,174 @@ enum eAudioSamples : int32 {
TOTAL_AUDIO_SAMPLES = 3032,
NO_SAMPLE = 3033,
};
+
+enum eSound {
+ SOUND_CAR_DOOR_CLOSE_BONNET = 0,
+ SOUND_CAR_DOOR_CLOSE_BUMPER = 1,
+ SOUND_CAR_DOOR_CLOSE_FRONT_LEFT = 0x2,
+ SOUND_CAR_DOOR_CLOSE_FRONT_RIGHT = 0x3,
+ SOUND_CAR_DOOR_CLOSE_BACK_LEFT = 0x4,
+ SOUND_CAR_DOOR_CLOSE_BACK_RIGHT = 0x5,
+ SOUND_CAR_DOOR_OPEN_BONNET = 0x6,
+ SOUND_CAR_DOOR_OPEN_BUMPER = 0x7,
+ SOUND_CAR_DOOR_OPEN_FRONT_LEFT = 0x8,
+ SOUND_CAR_DOOR_OPEN_FRONT_RIGHT = 0x9,
+ SOUND_CAR_DOOR_OPEN_BACK_LEFT = 0xA,
+ SOUND_CAR_DOOR_OPEN_BACK_RIGHT = 0xB,
+ SOUND_CAR_WINDSHIELD_CRACK = 0xC,
+ SOUND_CAR_JUMP = 0xD,
+ SOUND_E = 0xE,
+ SOUND_F = 0xF,
+ SOUND_CAR_ENGINE_START = 0x10,
+ SOUND_CAR_LIGHT_BREAK = 0x11,
+ SOUND_CAR_HYDRALIC_1 = 0x12,
+ SOUND_CAR_HYDRALIC_2 = 0x13,
+ SOUND_CAR_HYDRALIC_3 = 0x14,
+ SOUND_CAR_JERK = 0x15,
+ SOUND_CAR_SPLASH = 0x16,
+ SOUND_17 = 0x17,
+ SOUND_18 = 0x18,
+ SOUND_19 = 0x19,
+ SOUND_CAR_TANK_TURRET_ROTATE = 0x1A,
+ SOUND_CAR_BOMB_TICK = 0x1B,
+ SOUND_PLANE_ON_GROUND = 0x1C,
+ SOUND_STEP_START = 0x1D,
+ SOUND_STEP_END = 0x1E,
+ SOUND_FALL_LAND = 0x1F,
+ SOUND_FALL_COLLAPSE = 0x20,
+ SOUND_21 = 0x21,
+ SOUND_22 = 0x22,
+ SOUND_23 = 0x23,
+ SOUND_24 = 0x24,
+ SOUND_25 = 0x25,
+ SOUND_26 = 0x26,
+ SOUND_WEAPON_PUNCH_ATTACK = 0x27,
+ SOUND_28 = 0x28,
+ SOUND_29 = 0x29,
+ SOUND_2A = 0x2A,
+ SOUND_2B = 0x2B,
+ SOUND_2C = 0x2C,
+ SOUND_2D = 0x2D,
+ SOUND_WEAPON_BAT_ATTACK = 0x2E,
+ SOUND_WEAPON_SHOT_FIRED = 0x2F,
+ SOUND_WEAPON_RELOAD = 0x30,
+ SOUND_31 = 0x31,
+ SOUND_32 = 0x32,
+ SOUND_33 = 0x33,
+ SOUND_WEAPON_FLAMETHROWER_FIRE = 0x34,
+ SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM = 0x35,
+ SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM = 0x36,
+ SOUND_WEAPON_HIT_PED = 0x37,
+ SOUND_WEAPON_HIT_VEHICLE = 0x38,
+ SOUND_GARAGE_NO_MONEY = 0x39,
+ SOUND_GARAGE_BAD_VEHICLE = 0x3A,
+ SOUND_GARAGE_OPENING = 0x3B,
+ SOUND_3C = 0x3C,
+ SOUND_GARAGE_BOMB1_SET = 0x3D,
+ SOUND_GARAGE_BOMB2_SET = 0x3E,
+ SOUND_GARAGE_BOMB3_SET = 0x3F,
+ SOUND_40 = 0x40,
+ SOUND_41 = 0x41,
+ SOUND_GARAGE_VEHICLE_DECLINED = 0x42,
+ SOUND_GARAGE_VEHICLE_ACCEPTED = 0x43,
+ SOUND_GARAGE_DOOR_CLOSED = 0x44,
+ SOUND_GARAGE_DOOR_OPENED = 0x45,
+ SOUND_CRANE_PICKUP = 0x46,
+ SOUND_PICKUP_WEAPON_BOUGHT = 0x47,
+ SOUND_PICKUP_WEAPON = 0x48,
+ SOUND_PICKUP_HEALTH = 0x49,
+ SOUND_4A = 0x4A,
+ SOUND_4B = 0x4B,
+ SOUND_PICKUP_ADRENALINE = 0x4C,
+ SOUND_PICKUP_ARMOUR = 0x4D,
+ SOUND_PICKUP_BONUS = 0x4E,
+ SOUND_PICKUP_MONEY = 0x4F,
+ SOUND_PICKUP_HIDDEN_PACKAGE = 0x50,
+ SOUND_PICKUP_PACMAN_PILL = 0x51,
+ SOUND_PICKUP_PACMAN_PACKAGE = 0x52,
+ SOUND_PICKUP_FLOAT_PACKAGE = 0x53,
+ SOUND_BOMB_TIMED_ACTIVATED = 0x54,
+ SOUND_55 = 0x55,
+ SOUND_BOMB_ONIGNITION_ACTIVATED = 0x56,
+ SOUND_BOMB_TICK = 0x57,
+ SOUND_RAMPAGE_START = 0x58,
+ SOUND_RAMPAGE_ONGOING = 0x59,
+ SOUND_RAMPAGE_PASSED = 0x5A,
+ SOUND_RAMPAGE_FAILED = 0x5B,
+ SOUND_RAMPAGE_KILL = 0x5C,
+ SOUND_RAMPAGE_CAR_BLOWN = 0x5D,
+ SOUND_EVIDENCE_PICKUP = 0x5E,
+ SOUND_UNLOAD_GOLD = 0x5F,
+ SOUND_PAGER = 0x60,
+ SOUND_PED_DEATH = 0x61,
+ SOUND_PED_DAMAGE = 0x62,
+ SOUND_PED_HIT = 0x63,
+ SOUND_PED_LAND = 0x64,
+ SOUND_PED_BULLET_HIT = 0x65,
+ SOUND_PED_BOMBER = 0x66,
+ SOUND_PED_BURNING = 0x67,
+ SOUND_PED_ARREST_FBI = 0x68,
+ SOUND_PED_ARREST_SWAT = 0x69,
+ SOUND_PED_ARREST_COP = 0x6A,
+ SOUND_PED_HELI_PLAYER_FOUND = 0x6B,
+ SOUND_PED_HANDS_UP = 0x6C,
+ SOUND_PED_HANDS_COWER = 0x6D,
+ SOUND_PED_FLEE_SPRINT = 0x6E,
+ SOUND_PED_CAR_JACKING = 0x6F,
+ SOUND_PED_MUGGING = 0x70,
+ SOUND_PED_CAR_JACKED = 0x71,
+ SOUND_PED_ROBBED = 0x72,
+ SOUND_PED_TAXI_WAIT = 0x73,
+ SOUND_PED_ATTACK = 0x74,
+ SOUND_PED_DEFEND = 0x75,
+ SOUND_PED_PURSUIT_ARMY = 0x76,
+ SOUND_PED_PURSUIT_FBI = 0x77,
+ SOUND_PED_PURSUIT_SWAT = 0x78,
+ SOUND_PED_PURSUIT_COP = 0x79,
+ SOUND_PED_HEALING = 0x7A,
+ SOUND_PED_7B = 0x7B,
+ SOUND_PED_LEAVE_VEHICLE = 0x7C,
+ SOUND_PED_EVADE = 0x7D,
+ SOUND_PED_FLEE_RUN = 0x7E,
+ SOUND_PED_CAR_COLLISION = 0x7F,
+ SOUND_PED_SOLICIT = 0x80,
+ SOUND_PED_EXTINGUISHING_FIRE = 0x81,
+ SOUND_PED_WAIT_DOUBLEBACK = 0x82,
+ SOUND_PED_CHAT_SEXY = 0x83,
+ SOUND_PED_CHAT_EVENT = 0x84,
+ SOUND_PED_CHAT = 0x85,
+ SOUND_PED_BODYCAST_HIT = 0x86,
+ SOUND_PED_TAXI_CALL = 0x87,
+ SOUND_INJURED_PED_MALE_OUCH = 0x88,
+ SOUND_INJURED_PED_FEMALE = 0x89,
+ SOUND_8A = 0x8A,
+ SOUND_RACE_START_3 = 0x8B,
+ SOUND_RACE_START_2 = 0x8C,
+ SOUND_RACE_START_1 = 0x8D,
+ SOUND_RACE_START_GO = 0x8E,
+ SOUND_SPLASH = 0x8F,
+ SOUND_WATER_FALL = 0x90,
+ SOUND_SPLATTER = 0x91,
+ SOUND_CAR_PED_COLLISION = 0x92,
+ SOUND_CLOCK_TICK = 0x93,
+ SOUND_PART_MISSION_COMPLETE = 0x94,
+ SOUND_FRONTEND_MENU_STARTING = 0x95,
+ SOUND_FRONTEND_MENU_COMPLETED = 0x96,
+ SOUND_FRONTEND_MENU_DENIED = 0x97,
+ SOUND_FRONTEND_MENU_SUCCESS = 0x98,
+ SOUND_FRONTEND_EXIT = 0x99,
+ SOUND_9A = 0x9A,
+ SOUND_9B = 0x9B,
+ SOUND_FRONTEND_AUDIO_TEST = 0x9C,
+ SOUND_FRONTEND_FAIL = 0x9D,
+ SOUND_FRONTEND_NO_RADIO = 0x9E,
+ SOUND_FRONTEND_RADIO_CHANGE = 0x9F,
+ SOUND_A0 = 0xA0,
+ SOUND_AMMUNATION_WELCOME_1 = 0xA1,
+ SOUND_AMMUNATION_WELCOME_2 = 0xA2,
+ SOUND_AMMUNATION_WELCOME_3 = 0xA3,
+ SOUND_LIGHTNING = 0xA4,
+ SOUND_A5 = 0xA5,
+ SOUND_TOTAL_SOUNDS = 166,
+ SOUND_TOTAL_PED_SOUNDS = 167,
+};