Skip to content

Commit

Permalink
ChaosMod/EffectSound3D: Stop FollowEntity effect sounds on entity dea…
Browse files Browse the repository at this point in the history
…th by default
  • Loading branch information
pongo1231 committed Jan 18, 2025
1 parent b0477e5 commit 4b3ca26
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ChaosMod/Components/EffectSound/EffectSound3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void EffectSound3D::OnRun()
case EffectSoundPlayType::FollowEntity:
{
if (!sound.PlayOptions.Entity || !DOES_ENTITY_EXIST(sound.PlayOptions.Entity)
|| (sound.PlayOptions.PlayFlags & EffectSoundPlayFlags_StopOnEntityDeath
|| (!(sound.PlayOptions.PlayFlags & EffectSoundPlayFlags_DontStopOnEntityDeath)
&& IS_ENTITY_DEAD(sound.PlayOptions.Entity, false)))
{
uninitSound();
Expand Down
4 changes: 2 additions & 2 deletions ChaosMod/Components/LuaScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ LuaScripts::ParseScriptRaw(std::string scriptName, std::string_view script, Pars
[effectId, getEffectSoundPlayOptions](const sol::this_state &lua, bool state)
{
auto soundPlayOptions = getEffectSoundPlayOptions();
soundPlayOptions->PlayFlags = state ? soundPlayOptions->PlayFlags | EffectSoundPlayFlags_StopOnEntityDeath
: soundPlayOptions->PlayFlags & ~EffectSoundPlayFlags_StopOnEntityDeath;
soundPlayOptions->PlayFlags = state ? soundPlayOptions->PlayFlags & ~EffectSoundPlayFlags_DontStopOnEntityDeath
: soundPlayOptions->PlayFlags | EffectSoundPlayFlags_DontStopOnEntityDeath;
};

EffectData effectData;
Expand Down
4 changes: 2 additions & 2 deletions ChaosMod/Effects/EffectSoundPlayOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ enum class EffectSoundPlayType

enum EffectSoundPlayFlags
{
EffectSoundPlayFlags_Looping = (1 << 0),
EffectSoundPlayFlags_StopOnEntityDeath = (1 << 1)
EffectSoundPlayFlags_Looping = (1 << 0),
EffectSoundPlayFlags_DontStopOnEntityDeath = (1 << 1)
};

struct EffectSoundPlayOptions
Expand Down
4 changes: 1 addition & 3 deletions ChaosMod/Effects/db/Peds/PedsSpawnAngryJesus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ static void OnStart()

auto ped = CreatePoolPed(4, modelHash, playerPos.x, playerPos.y, playerPos.z, 0.f);
CurrentEffect::SetEffectSoundPlayOptions(
{ .PlayType = EffectSoundPlayType::FollowEntity,
.PlayFlags = EffectSoundPlayFlags_Looping | EffectSoundPlayFlags_StopOnEntityDeath,
.Entity = ped });
{ .PlayType = EffectSoundPlayType::FollowEntity, .PlayFlags = EffectSoundPlayFlags_Looping, .Entity = ped });
if (IS_PED_IN_ANY_VEHICLE(playerPed, false))
SET_PED_INTO_VEHICLE(ped, GET_VEHICLE_PED_IS_IN(playerPed, false), -2);

Expand Down
4 changes: 1 addition & 3 deletions ChaosMod/Effects/db/Peds/PedsSpawnImpotentRage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ static void OnStart()

Ped ped = CreatePoolPed(4, model, playerPos.x, playerPos.y, playerPos.z, GET_ENTITY_HEADING(playerPed));
CurrentEffect::SetEffectSoundPlayOptions(
{ .PlayType = EffectSoundPlayType::FollowEntity,
.PlayFlags = EffectSoundPlayFlags_Looping | EffectSoundPlayFlags_StopOnEntityDeath,
.Entity = ped });
{ .PlayType = EffectSoundPlayType::FollowEntity, .PlayFlags = EffectSoundPlayFlags_Looping, .Entity = ped });
SET_ENTITY_HEALTH(ped, 1000, 0);
SET_PED_ARMOUR(ped, 1000);

Expand Down

0 comments on commit 4b3ca26

Please sign in to comment.