Help With A_SprayDecal Offset/Direction

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!)
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Help With A_SprayDecal Offset/Direction

Post by 22alpha22 »

I'm having trouble with A_SprayDecal, specifically how to use offset and direction parameters. I'm using A_SprayDecal as a replacement for GZDoom's inflexible built in blood generation, calling it from DamageMObj. I thought I had figured out how the Offset and Direction parameters worked because from limited testing on a tiny test map, the blood generated as expected but on actual larger normal maps, the blood often doesn't generate at all or in it does in the completely wrong places.

Here is how I currently have it implemented.

Code: Select all

				Blood = String.Format("%sBlood%s",Clr,Size);
				
				Double DPitch;
				Double DHeight;
				Vector2 VAngle;
				Vector3 Position;
				Vector3 Direction;

				For (Int I = 0; I < Num; I++)
				{
					If (Inflictor)
					{
						VAngle = AngleToVector(FRandom(Inflictor.Angle - 15.0,Inflictor.Angle + 15.0));
						DPitch = Clamp(FRandom(Inflictor.Pitch - 7.5,Inflictor.Pitch + 7.5),-89.0,89.0);
						DHeight = Clamp(Inflictor.Pos.Z - Pos.Z,Pos.Z,Pos.Z + Height);
					}
					Else If (Source)
					{
						VAngle = AngleToVector(FRandom(Source.Angle - 15.0,Source.Angle + 15.0));
						DPitch = Clamp(FRandom(Source.Pitch - 7.5,Source.Pitch + 7.5),-89.0,89.0);
						DHeight = Pos.Z + (Height / 2);
					}
					Else
					{
						VAngle = AngleToVector(FRandom(0.0,360.0));
						DPitch = FRandom(-30.0,30.0);
						DHeight = Pos.Z + (Height / 2);
					}

					Position = (0.0,0.0,DHeight);
					Direction = (VAngle.X,VAngle.Y,Sin(-DPitch));

					A_SprayDecal(Blood,172.0,Position,Direction);
				}
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: Help With A_SprayDecal Offset/Direction

Post by 22alpha22 »

Bumping this, does anyone at all understand how to use the offset and direction fields of A_SprayDecal?
User avatar
Player701
 
 
Posts: 1697
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: Help With A_SprayDecal Offset/Direction

Post by Player701 »

The most obvious issue with your code seems to be that you're essentially adding Pos.Z to offset, which is an error because offset is already intended to be relative to the calling actor's position, which naturally includes the Z coordinate. If you fix that and it's still not working right, could you please send me a runnable example for further testing?

Return to “Scripting”