Simulating reverb through lineattack and puffs?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Caligari87
Admin
Posts: 6233
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Simulating reverb through lineattack and puffs?

Post by Caligari87 »

So this is hypothetical and I'm not near any place where I can test, but can a puff check the range to its activator (in my use case, the player) and perform an action? For example, player's weapon performs a line attack, which generates a puff. I want the puff to check if it's within a certain range of the player who fired it, and if so play a local sound with a delay and volume attenuation based on that range. I imagine this would have something to do with pointers, which I haven't used before.

8-)
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: Simulating reverb through lineattack and puffs?

Post by D2JK »

Sure you can. Here's some useful stuff:

+PUFFGETSOWNER
"Used on puff objects. If set, the puff's target is set to the actor who fired the shot once it is spawned. Usually used in conjunction with A_GiveToTarget to achieve certain special effect.

GetDistance()
"Gets the distance between the calling actor and the pointer. Note that this function is to be used where an expression is expected. It is mostly useful when combined with A_JumpIf and can be used in place of such functions like A_JumpIfCloser."

Then in ZScript, if you're using that, it should be fairly simple to do some if checks.

Code: Select all

Death:
 TNT1 A 0
  {
   int D = GetDistance(1, AAPTR_TARGET);

   if (D < 256)                           A_PlaySound(...);
   else if (D >= 256  &&  D < 512)        A_PlaySound(...);
   else                                   A_PlaySound(...);
  }
Code not tested, but it's something like that anyway. :)
User avatar
Caligari87
Admin
Posts: 6233
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Simulating reverb through lineattack and puffs?

Post by Caligari87 »

Ah, GetDistance was what I was lacking. :D Gonna whip up some code and test this tonight. Thanks!

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49231
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Simulating reverb through lineattack and puffs?

Post by Graf Zahl »

Beware: That only works under the assumption that the shooting player is also the listener.
User avatar
Caligari87
Admin
Posts: 6233
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Simulating reverb through lineattack and puffs?

Post by Caligari87 »

Understood. I'm intending for singleplayer anyway, so that shouldn't be an issue. Hopefully.

8-)
Locked

Return to “Editing (Archive)”