Local parameters for A_PlaySound and ACS PlaySound

Moderator: GZDoom Developers

Post Reply
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

ZDoom PR: https://github.com/rheit/zdoom/pull/862
ACC PR: https://github.com/rheit/acc/pull/64
Example file: https://www.dropbox.com/s/hs622re9eykoz ... n.pk3?dl=1 (each player is locally playing a raining sound loop, which is only ever heard by himself and not by any other players, so for example, 2 or more players won't cause sound build-up because only 1 copy of the sound is heard on the player's machine)

This adds a "local" parameter to A_PlaySound and ACS Playsound which would make the sound behave exactly like if it were played with [wiki]LocalAmbientSound[/wiki]. "Local" in this context means:

Code: Select all

//============================================================================
//
// AActor :: CheckLocalView
//
// Returns true if this actor is local for the player. Here, local means the
// player is either looking out this actor's eyes, or this actor is the player
// and the player is looking out the eyes of something non-"sentient."
//
//============================================================================
So whatever worked with LocalAmbientSound.

Spoiler: old crap
Last edited by Nash on Sat Oct 15, 2016 1:12 pm, edited 2 times in total.
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Would it be better to assign the loop flag constant (CHAN_LOOP) to a variable so that there would only be a single call to S_Sound? Even before I intervened, there were already 2 S_Sound calls to handle the looping stuff. Wanted to ask first if that's better before I touch code that wasn't mine... Scratch this, this doesn't make sense at all, and will not even work. my bad

UPDATE: Resolved conflicts with the recent de-actionifying rewrite.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Graf Zahl »

The feature is ok, but I have problems with the amount of redundant code this adds.
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

I think that's what I was talking about in that striked out part in my other post. I'll see if I can clean it all up as soon as I get some time!
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Just dropping a note to say that I will be very busy with work and won't be able to do anything related to my gaming hobbies until the 2nd week of June, please don't close this 'til then!

July 2016 mini update: I've read Graf's suggestion and have it done in a local copy but no time to push the PR yet, still busy with IRL currently

August 2016 update: I'm working on this right now
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Okay I did the subfunction and there's no more code redundancy, but this turned out to be a little more complicated... the sound actually needs to be started unconditionally no matter what. Only if the current view is actually the same as the sound source, should the sound be audible. If the current view != source, cut out the sound volume (but DON'T stop the sound! It has to continue playing inaudibly).

Currently with my test WAD, if the sound was started with the local parameter, but you don't happen to be viewing through the source's view at that moment, the sound will just not play at all. Hmm...

Makes me wonder if the original logic of [wiki]LocalAmbientSound[/wiki] has been broken all along (what if the script was called but the current view happens to be another non-player camera?...
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Confirming my suspicions...

Test WAD for regular ZDoom/GZDoom: https://www.dropbox.com/s/5g1l4t6bwsee2 ... t.wad?dl=1

Press the blood wall to hear a long, repetitive sound of the Cyberdemon, using [wiki]LocalAmbientSound[/wiki].

- Sound will be fired off and you will hear it if you are currently viewing through yourself (either in first or third person)

- Use command AddBot then F12 to coop-spy through the bot. Press the wall. Sound will fail to fire off if you aren't viewing through yourself.

- More over, if you first fired off the sound in your own view, then do coop spy to view through the bot, the sound will continue playing like as if it's coming from the bot, and not you. :O

So in conclusion, ZDoom's sound playing mechanism has no way to play a sound and then selectively filter its "audience" in real-time. A sound will either be fired off or it won't. I won't concern myself with this issue then and just go ahead and do my thing.
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

New PRs in the OP. Is this better?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Graf Zahl »

Yes, this is better. Sorry, I missed it while I was busy elsewhere.
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Thanks! And no problem, we understand by now.

One step closer to removing crappy mod-side hacks... :D
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Local parameters for A_PlaySound and ACS PlaySound

Post by Nash »

Sorry for the double post... just a reminder that the ACC side hasn't been merged yet.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”