Bouncing Actors?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Bouncing Actors?

Post by Azagthoth »

Hello. I have a few questions about bouncing actors.

1. Is it possible to make actors bounce on sky? And what's the point of DONTBOUNCEONSKY when it already doesn't do that?
2. Can I change the volume of BounceSound? Maybe base the volume on the velocity it hits the ground with even?
3. How exactly does BOUNCEAUTOOFFFLOORONLY work?

This is what I got so far:

Code: Select all

ACTOR Boulder
{
	Radius 50
	Height 100
	Speed 65
	Gravity 0.8
	BounceFactor 0.8
	Damage 200
	PROJECTILE
	BounceSound "cyber/hoof"
	DeathSound "weapons/rocklx"
	+BOUNCEAUTOOFFFLOORONLY
	+ALLOWBOUNCEONACTORS
	+BOUNCEONWALLS
	+BOUNCEONFLOORS
	+BOUNCEONCEILINGS
	+CANBOUNCEWATER
	+RIPPER
	-NOGRAVITY
	States
	{
		Spawn:
			BOLD ABCDABCDABCDABCDABCDABCDABCDABCDABCD 5
			goto Death
		Death:
			TNT1 A 0 A_Scream
			stop
	}
}
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Bouncing Actors?

Post by Player701 »

Azagthoth wrote:1. And what's the point of DONTBOUNCEONSKY when it already doesn't do that?
It actually does.

Code: Select all

class TestImpBall : DoomImpBall
{
    Default
    {
        -NOGRAVITY;
        BounceType "Doom";
    }
}
Summon TestImpBall and see what happens e.g. in Doom II MAP01 outdoor area when it hits the sky ceiling or walls. Now, add DONTBOUNCEONSKY, and it will disappear instead of bouncing.
Azagthoth wrote:2. Can I change the volume of BounceSound? Maybe base the volume on the velocity it hits the ground with even?
Sadly, no, I don't think so. The volume is hard-coded to 1 in the source code. You could try your luck with a feature request though.
Azagthoth wrote:3. How exactly does BOUNCEAUTOOFFFLOORONLY work?
Let's see what the wiki says:
ZDoom Wiki wrote:
  • BOUNCEAUTOOFF
Missile stops bouncing if the velocity is too low after a bounce. Always triggered by a bounce on the ceiling, since moving downwards will always count as not moving upwards enough. Implied by the Doom bounce type.
  • BOUNCEAUTOOFFFLOORONLY
Missile stops bouncing if the velocity is too low after a bounce on the floor.
So, compared to BOUNCEAUTOOFF (which is set automatically if the Doom bounce type is used), it will not prevent the missile from bouncing further after bouncing off a ceiling.
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Re: Bouncing Actors?

Post by Azagthoth »

Player701 wrote:It actually does.
I guess it does in GZDoom, just not in Zandronum for some reason.
Player701 wrote:The volume is hard-coded
I see. Maybe something could be done with USEBOUNCESTATE instead of using BounceSound? But I would need a way to get the velocity of the actor. I read somewhere that GetActorVel is a thing in ACS but I can't find any info on it. Do you know of any functions like that?
Player701 wrote:Missile stops bouncing if the velocity is too low after a bounce.
But how "low" is too low. I can't see/hear any difference between having it and not having it. The sound still goes ape shit once it gets closer to the ground and that's what I'm trying to prevent.
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Bouncing Actors?

Post by Player701 »

Azagthoth wrote:I see. Maybe something could be done with USEBOUNCESTATE instead of using BounceSound? But I would need a way to get the velocity of the actor. I read somewhere that GetActorVel is a thing in ACS but I can't find any info on it. Do you know of any functions like that?
DECORATE expressions provide velx, vely and velz to retrieve the three components of the velocity vector. You will of course have to implement some formula to derive the volume from these values, should probably start at finding the absolute value (vector length) of the actor's velocity: l = sqrt(velx*velx + vely*vely + velz*velz). Note that while velocity can theoretically be arbitrarily large, volume is capped to 1.0 (passing a higher value will have no effect). If your Zandronum does not have DECORATE expresions, then there is ACS: GetActorVelX, GetActorVelY, GetActorVelZ. Substitute the volume argument of A_PlaySound (called from your bounce state) with your formula, or use ACS_ExecuteWithResult if expressions are not supported.
Azagthoth wrote:But how "low" is too low. I can't see/hear any difference between having it and not having it. The sound still goes ape shit once it gets closer to the ground and that's what I'm trying to prevent.
Z-velocity must be less than 3.0 for this condition to trigger, see relevant code in p_map.cpp, p_mobj.cpp. Probably the same in older versions (incl. Zandronum).
Last edited by Player701 on Tue Aug 17, 2021 11:31 pm, edited 1 time in total.
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Re: Bouncing Actors?

Post by Azagthoth »

Excellent! Apparently Zandronum does support DECORATE expressions so no need for ACS. Thank you very much.
Post Reply

Return to “Scripting”