
Simulating reverb through lineattack and puffs?
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.
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.
- Caligari87
- Admin
- Posts: 6233
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Simulating reverb through lineattack and puffs?
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.


Re: Simulating reverb through lineattack and puffs?
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 not tested, but it's something like that anyway. 
+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(...);
}

- Caligari87
- Admin
- Posts: 6233
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Simulating reverb through lineattack and puffs?
Ah, GetDistance was what I was lacking.
Gonna whip up some code and test this tonight. Thanks!



- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49231
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Simulating reverb through lineattack and puffs?
Beware: That only works under the assumption that the shooting player is also the listener.
- Caligari87
- Admin
- Posts: 6233
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Simulating reverb through lineattack and puffs?
Understood. I'm intending for singleplayer anyway, so that shouldn't be an issue. Hopefully.

