ending a looping sound

Discussions about Coding and Scripting
User avatar
Barbie
Godlike
Posts: 2394
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

ending a looping sound

Post by Barbie » Tue Dec 07, 2021 1:02 pm

Is there a possibility to stop a looping sound that is initiated by SpecialEvent.PlayersPlaySoundEffect.Trigger() → PlayerPawn.ClientPlaySound() → Actor.PlaySound()? I tried it with triggering another SpecialEvent that plays a none looping sound at InitialStage PlayersPlaySoundEffect with but that did not interrupt or override the looping sound.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
Aspide
Experienced
Posts: 109
Joined: Wed Jun 09, 2021 12:13 am

Re: ending a looping sound

Post by Aspide » Tue Dec 07, 2021 7:41 pm

I don't think is possible, once the ClientPlaySound function is called (and the sound loops) there is nothing that can be done to stop the sound from repeating forever. An alternative solution would be to use the WorkingTriggeredAmbientSound from Operation Na Pali (olextras.u), the only problem is that this is Ambient Sound instead of ClientPlaySound, but adding many of those actors all over the map should have the same effect.

Here is the code of WorkingTriggeredAmbientSound:

Code: Select all

// ============================================================
// This package is for use with the Partial Conversion, Operation: Na Pali, by Team Vortex.
// WorkingTriggeredAmbientSound : Triggering changes the actor's ambientsound
// ============================================================

class WorkingTriggeredAmbientSound expands Triggers;
var () bool bInitiallyPlaying;  //is the sound playing on default?
var () sound TheSound; //the ambience.

function PreBeginPlay(){
  Super.PreBeginPlay();
  if (bInitiallyPlaying)
    ambientsound=TheSound;
}

function Trigger( actor Other, pawn EventInstigator )
{
  if (AmbientSound!=None)
    AmbientSound=none;
  else
    AmbientSound=TheSound;
}

state() TriggerToggled
{
}


state() OppositeWhileTriggered
{
  function Trigger( actor Other, pawn EventInstigator )
  {
   if (AmbientSound==none^^bInitiallyPlaying)
     global.Trigger(other,eventinstigator);
  }
  function UnTrigger( actor Other, pawn EventInstigator )
  {
   if (AmbientSound!=none^^!bInitiallyPlaying)
     global.Trigger(other,eventinstigator);
  }

}

defaultproperties
{
}
Somewhere in Nevada...

User avatar
sektor2111
Godlike
Posts: 5873
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: ending a looping sound

Post by sektor2111 » Tue Dec 07, 2021 8:40 pm

A new thing added that changes said sound to a sort of null sound with no looping property - Editing Map or injecting in map some "vaccine" patcher...

User avatar
Barbie
Godlike
Posts: 2394
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: ending a looping sound

Post by Barbie » Tue Dec 14, 2021 1:45 am

Seems to be v469 specific bug in OpenAL (see bug report on github).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett