From 058a9f03af9ca8eb44e7a0d3af49861c1f86ee39 Mon Sep 17 00:00:00 2001 From: Pirulax Date: Mon, 15 Jul 2024 22:24:29 +0200 Subject: [PATCH] GetWeaponAE/GetAE/GetSpeechAE --- source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp | 2 +- source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h | 8 ++++---- source/game_sa/Audio/entities/AEScriptAudioEntity.cpp | 2 +- source/game_sa/Buoyancy.cpp | 2 +- source/game_sa/Entity/Ped/Ped.h | 5 ++++- source/game_sa/GameLogic.cpp | 2 +- source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp | 2 +- .../game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp | 4 ++-- source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp | 2 +- source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp | 2 +- source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp | 6 +++--- source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp | 2 +- source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp | 6 +++--- source/game_sa/Weapon.cpp | 6 +++--- 14 files changed, 27 insertions(+), 24 deletions(-) diff --git a/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp b/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp index a3e7091f35..83d6a51b00 100644 --- a/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp +++ b/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp @@ -484,7 +484,7 @@ eCJMood CAEPedSpeechAudioEntity::GetCurrentCJMood() { if (mem.m_nPedType == PED_TYPE_GANG2) { return true; } - auto& memSpeech = mem.m_pedSpeech; + auto& memSpeech = mem.GetSpeechAE(); return memSpeech.m_PedAudioType == PED_TYPE_GANG && notsa::contains({ VOICE_GNG_RYDER, VOICE_GNG_SWEET, VOICE_GNG_SMOKE }, (eGngSpeechVoices)memSpeech.m_VoiceID); } diff --git a/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h b/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h index 9aee513dd6..793ba43ec6 100644 --- a/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h +++ b/source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h @@ -233,9 +233,9 @@ class NOTSA_EXPORT_VTABLE CAEPedSpeechAudioEntity : public CAEAudioEntity { private: auto&& GetNextPlayTimeRef(this auto&& self, eGlobalSpeechContext gCtx) { - return IsGlobalContextPain(_gCtx) - ? m_NextTimeCanSayPain[_gCtx - CTX_GLOBAL_PAIN_START + 1] - : gGlobalSpeechContextNextPlayTime[_gCtx] + return IsGlobalContextPain(gCtx) + ? self.m_NextTimeCanSayPain[gCtx - CTX_GLOBAL_PAIN_START + 1] + : gGlobalSpeechContextNextPlayTime[gCtx]; } public: @@ -318,7 +318,7 @@ class NOTSA_EXPORT_VTABLE CAEPedSpeechAudioEntity : public CAEAudioEntity { void I_PlayLoadedSound(CEntity* attachTo); protected: - std::array m_Sounds{}; + std::array m_Sounds{}; //!< Not actually used bool m_IsInitialized{}; eAudioPedType m_PedAudioType{ PED_TYPE_UNK }; ePedSpeechVoiceS16 m_VoiceID{ VOICE_UNK }; //!< Exact enum to use depends on `m_PedAudioType` (See `PedSpeechVoices.h`) diff --git a/source/game_sa/Audio/entities/AEScriptAudioEntity.cpp b/source/game_sa/Audio/entities/AEScriptAudioEntity.cpp index 19875e88b9..1457e2b045 100644 --- a/source/game_sa/Audio/entities/AEScriptAudioEntity.cpp +++ b/source/game_sa/Audio/entities/AEScriptAudioEntity.cpp @@ -723,7 +723,7 @@ void CAEScriptAudioEntity::ProcessMissionAudioEvent(eAudioEvents eventId, CVecto break; case AE_CAS9_AD: if (CLocalisation::Blood() && physical && physical->IsPed()) { - physical->AsPed()->GetPedAE().AddAudioEvent(AE_PED_CRUNCH, 0.0f, 1.0f, physical, 0, 0, 0); + physical->AsPed()->GetAE().AddAudioEvent(AE_PED_CRUNCH, 0.0f, 1.0f, physical, 0, 0, 0); } break; case AE_CAS9_BA: { diff --git a/source/game_sa/Buoyancy.cpp b/source/game_sa/Buoyancy.cpp index ca2b418bd4..0091519afb 100644 --- a/source/game_sa/Buoyancy.cpp +++ b/source/game_sa/Buoyancy.cpp @@ -322,7 +322,7 @@ void cBuoyancy::AddSplashParticles(CPhysical* entity, CVector vecFrom, CVector v vecPedParticlePos.z += 0.5F; g_fx.m_Wake->AddParticle(&vecPedParticlePos, &vecPedVelocity, 0.0F, &curParticle, fPedAngle, 1.2F, 0.6F, 0); - ped->GetPedAE().AddAudioEvent(eAudioEvents::AE_PED_SWIM_WAKE, 0.0F, 1.0F, nullptr, 0, 0, 0); + ped->GetAE().AddAudioEvent(eAudioEvents::AE_PED_SWIM_WAKE, 0.0F, 1.0F, nullptr, 0, 0, 0); } } diff --git a/source/game_sa/Entity/Ped/Ped.h b/source/game_sa/Entity/Ped/Ped.h index 3151fda75d..d16cc195c0 100644 --- a/source/game_sa/Entity/Ped/Ped.h +++ b/source/game_sa/Entity/Ped/Ped.h @@ -105,9 +105,11 @@ class NOTSA_EXPORT_VTABLE CPed : public CPhysical { static inline int16 m_sGunFlashBlendStart = 10'000; // 0x8D1370 +protected: // Use accessors CAEPedAudioEntity m_pedAudio; CAEPedSpeechAudioEntity m_pedSpeech; CAEPedWeaponAudioEntity m_weaponAudio; +public: char field_43C[36]; CPed* m_roadRageWith; char field_464[4]; @@ -571,7 +573,8 @@ class NOTSA_EXPORT_VTABLE CPed : public CPhysical { auto&& GetAE(this auto&& self) { return self.m_pedAudio; } auto&& GetSpeechAE(this auto&& self) { return self.m_pedSpeech; } - + auto&& GetWeaponAE(this auto&& self) { return self.m_weaponAudio; } + /*! * @notsa * @brief Is the ped jogging, running or sprinting diff --git a/source/game_sa/GameLogic.cpp b/source/game_sa/GameLogic.cpp index 253da88d2f..1cd8c4fe5e 100644 --- a/source/game_sa/GameLogic.cpp +++ b/source/game_sa/GameLogic.cpp @@ -378,7 +378,7 @@ void CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed* player, CVecto fire->Extinguish(); fire = nullptr; } - player->GetPedAE().TurnOffJetPack(); + player->GetAE().TurnOffJetPack(); player->bInVehicle = false; if (auto vehicle = player->m_pVehicle) { CEntity::CleanUpOldReference(vehicle); diff --git a/source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp b/source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp index 96f10e480d..a52fc686e4 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp @@ -73,7 +73,7 @@ void CTaskComplexDie::SayDeathSample(CPed* ped) const { case WEAPON_FALL: ped->Say(CTX_GLOBAL_PAIN_DEATH_HIGH); if (CLocalisation::Blood()) - ped->GetPedAE().AddAudioEvent(AE_PED_CRUNCH, 0.0f, 1.0f, ped); + ped->GetAE().AddAudioEvent(AE_PED_CRUNCH, 0.0f, 1.0f, ped); break; default: ped->Say(CTX_GLOBAL_PAIN_DEATH_LOW); diff --git a/source/game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp b/source/game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp index 10d3bd7f25..ffa6e53469 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp @@ -65,7 +65,7 @@ CTask* CTaskComplexInAirAndLand::CreateNextSubTask(CPed* ped) { else newTask = new CTaskSimpleLand(ANIM_ID_FALL_COLLAPSE); - ped->GetPedAE().AddAudioEvent(AE_PED_COLLAPSE_AFTER_FALL, 0.0F, 1.0F, 0, 0, 0, 0); + ped->GetAE().AddAudioEvent(AE_PED_COLLAPSE_AFTER_FALL, 0.0F, 1.0F, 0, 0, 0, 0); if (ped->m_pPlayerData) { CVector empty{}; @@ -91,7 +91,7 @@ CTask* CTaskComplexInAirAndLand::CreateNextSubTask(CPed* ped) { auto newTask = new CTaskSimpleLand(landAnimId); - ped->GetPedAE().AddAudioEvent(AE_PED_LAND_ON_FEET_AFTER_FALL, 0.0F, 1.0F, 0, 0, 0, 0); + ped->GetAE().AddAudioEvent(AE_PED_LAND_ON_FEET_AFTER_FALL, 0.0F, 1.0F, 0, 0, 0, 0); if (ped->m_pPlayerData) { CVector empty{}; diff --git a/source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp b/source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp index b5e58a867d..0cd2852026 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp @@ -13,7 +13,7 @@ CTask* CTaskComplexUseGoggles::CreateNextSubTask(CPed* ped) { return nullptr; case TASK_SIMPLE_GOGGLES_ON: ped->PutOnGoggles(); - ped->m_weaponAudio.AddAudioEvent(AE_WEAPON_FIRE); + ped->GetWeaponAE().AddAudioEvent(AE_WEAPON_FIRE); return nullptr; default: return nullptr; diff --git a/source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp b/source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp index 4a82fcc999..91f24a723e 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp @@ -114,7 +114,7 @@ bool CTaskSimpleBikeJacked::ProcessPed(CPed* ped) { // Play animation and some sound effect m_firstAnim = CAnimManager::BlendAnimation(ped->m_pRwClump, m_vehicle->GetRideAnimData()->m_nAnimGroup, ANIM_ID_BIKE_HIT); m_firstAnim->SetFinishCallback(FinishAnimBikeHitCB, this); - ped->GetPedAE().AddAudioEvent(AE_PED_JACKED_BIKE); + ped->GetAE().AddAudioEvent(AE_PED_JACKED_BIKE); } if (!m_taskUtilityLineUpPedWithCar) { diff --git a/source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp b/source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp index be108151c7..c0111c7b79 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp @@ -105,7 +105,7 @@ bool CTaskSimpleJetPack::MakeAbortable(class CPed* ped, eAbortPriority priority, m_bIsFinished = true; StopJetPackEffect(); - ped->GetPedAE().TurnOffJetPack(); + ped->GetAE().TurnOffJetPack(); return true; } @@ -275,8 +275,8 @@ void CTaskSimpleJetPack::ProcessThrust(CPed* ped) { m_PrevVelocity = ped->GetMoveSpeed(); if (!m_bIsFinished) { - ped->GetPedAE().TurnOnJetPack(); - ped->GetPedAE().UpdateJetPack((float)m_ThrustFwd, m_ThrustAngle); + ped->GetAE().TurnOnJetPack(); + ped->GetAE().UpdateJetPack((float)m_ThrustFwd, m_ThrustAngle); } } diff --git a/source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp b/source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp index 1ae3cb2cac..ddb1821226 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp @@ -278,7 +278,7 @@ void CTaskSimplePlayerOnFoot::ProcessPlayerWeapon(CPlayerPed* player) { damageCalculator.ComputeDamageResponse(targetEntity, eventDamage.m_damageResponse, false); targetEntity->GetEventGroup().Add(&eventDamage, false); CCrime::ReportCrime(eCrimeType::CRIME_SEALTH_KILL_PED_WITH_KNIFE, targetEntity, player); - player->m_weaponAudio.AddAudioEvent(AE_WEAPON_STEALTH_KILL); + player->GetWeaponAE().AddAudioEvent(AE_WEAPON_STEALTH_KILL); } player->ClearWeaponTarget(); } else { diff --git a/source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp b/source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp index 007cc5336f..11b4552480 100644 --- a/source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp +++ b/source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp @@ -623,7 +623,7 @@ void CTaskSimpleSwim::ProcessEffects(CPed* ped) { FxPrtMult_c fxPrtMult(1.0f, 1.0f, 1.0f, 0.2f, 0.4f, 0.0f, 0.5f); CVector particleVelocity; g_fx.m_Wake->AddParticle(&particlePosition, &particleVelocity, 0.0f, &fxPrtMult, fLimitedRadianAngle, 1.2f, 0.6f, 0); - ped->GetPedAE().AddAudioEvent(AE_PED_SWIM_WAKE, 0.0f, 1.0f); + ped->GetAE().AddAudioEvent(AE_PED_SWIM_WAKE, 0.0f, 1.0f); if (m_nSwimState == SWIM_SPRINTING) { RpHAnimHierarchy* animHierarchy = GetAnimHierarchyFromSkinClump(ped->m_pRwClump); // todo: almost CPed::GetBoneMatrix @@ -637,7 +637,7 @@ void CTaskSimpleSwim::ProcessEffects(CPed* ped) { auto fx = g_fxMan.CreateFxSystem("water_swim", static_cast(bonePos), nullptr, false); if (fx) { fx->PlayAndKill(); - ped->GetPedAE().AddAudioEvent(AE_PED_SWIM_STROKE_SPLASH, 0.0f, 1.0f); + ped->GetAE().AddAudioEvent(AE_PED_SWIM_STROKE_SPLASH, 0.0f, 1.0f); } } }; @@ -653,7 +653,7 @@ void CTaskSimpleSwim::ProcessEffects(CPed* ped) { } g_fx.TriggerWaterSplash(particlePosition); m_bTriggerWaterSplash = true; - ped->GetPedAE().AddAudioEvent(AE_PED_SWIM_DIVE_SPLASH, 0.0f, 1.0f); + ped->GetAE().AddAudioEvent(AE_PED_SWIM_DIVE_SPLASH, 0.0f, 1.0f); break; } case SWIM_UNDERWATER_SPRINTING: { diff --git a/source/game_sa/Weapon.cpp b/source/game_sa/Weapon.cpp index 8ed4ecd5c3..a5db777a83 100644 --- a/source/game_sa/Weapon.cpp +++ b/source/game_sa/Weapon.cpp @@ -942,7 +942,7 @@ void CWeapon::Update(CPed* owner) { const auto ProcessReloadAudioIf = [&](auto Pred) { const auto ProcessOne = [&](uint32 delay, eAudioEvents ae) { if (Pred(delay, ae)) { - owner->m_weaponAudio.AddAudioEvent(ae); + owner->GetWeaponAE().AddAudioEvent(ae); } }; ProcessOne(owner->bIsDucking ? ao->CrouchRLoadA : ao->RLoadA, AE_WEAPON_RELOAD_A); @@ -1278,7 +1278,7 @@ bool CWeapon::FireFromCar(CVehicle* vehicle, bool leftSide, bool rightSide) { return notsa::IsFixBugs() ? false : true; } if (const auto d = vehicle->m_pDriver) { - d->m_weaponAudio.AddAudioEvent(AE_WEAPON_FIRE); + d->GetWeaponAE().AddAudioEvent(AE_WEAPON_FIRE); } if (!CCheat::IsActive(CHEAT_INFINITE_AMMO)) { if (m_AmmoInClip) { // NOTE: I'm pretty sure this is redundant @@ -1767,7 +1767,7 @@ bool CWeapon::Fire(CEntity* firedBy, CVector* startPosn, CVector* barrelPosn, CE if (m_Type != WEAPON_CAMERA) { firedByPed->bFiringWeapon = true; } - firedByPed->m_weaponAudio.AddAudioEvent(AE_WEAPON_FIRE); + firedByPed->GetWeaponAE().AddAudioEvent(AE_WEAPON_FIRE); if (isPlayerFiring && targetEnt && targetEnt->IsPed() && m_Type != WEAPON_PISTOL_SILENCED) { firedByPed->Say(CTX_GLOBAL_SHOOT, 200); // 0x74280E }