Skip to content

Commit

Permalink
GetWeaponAE/GetAE/GetSpeechAE
Browse files Browse the repository at this point in the history
  • Loading branch information
Pirulax committed Jul 15, 2024
1 parent 910ea08 commit 058a9f0
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion source/game_sa/Audio/entities/AEPedSpeechAudioEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions source/game_sa/Audio/entities/AEPedSpeechAudioEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -318,7 +318,7 @@ class NOTSA_EXPORT_VTABLE CAEPedSpeechAudioEntity : public CAEAudioEntity {
void I_PlayLoadedSound(CEntity* attachTo);

protected:
std::array<CAESound*, 5> m_Sounds{};
std::array<CAESound*, 5> 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`)
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Audio/entities/AEScriptAudioEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Buoyancy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 4 additions & 1 deletion source/game_sa/Entity/Ped/Ped.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Tasks/TaskTypes/TaskComplexDie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/game_sa/Tasks/TaskTypes/TaskComplexInAirAndLand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand All @@ -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{};
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Tasks/TaskTypes/TaskComplexUseGoggles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Tasks/TaskTypes/TaskSimpleBikeJacked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions source/game_sa/Tasks/TaskTypes/TaskSimpleJetPack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool CTaskSimpleJetPack::MakeAbortable(class CPed* ped, eAbortPriority priority,
m_bIsFinished = true;

StopJetPackEffect();
ped->GetPedAE().TurnOffJetPack();
ped->GetAE().TurnOffJetPack();

return true;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/Tasks/TaskTypes/TaskSimplePlayerOnFoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -637,7 +637,7 @@ void CTaskSimpleSwim::ProcessEffects(CPed* ped) {
auto fx = g_fxMan.CreateFxSystem("water_swim", static_cast<CVector*>(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);
}
}
};
Expand All @@ -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: {
Expand Down
6 changes: 3 additions & 3 deletions source/game_sa/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 058a9f0

Please sign in to comment.