GetLineAngle?

Moderator: GZDoom Developers

Post Reply
User avatar
LOZ_98
Posts: 67
Joined: Thu Mar 22, 2018 7:46 pm
Graphics Processor: nVidia (Modern GZDoom)

GetLineAngle?

Post by LOZ_98 »

an ACS Function to return the angle of a linedef would be nice, It'd be useful to change an actor's angle based on the value returned from a linedef angle, a tag of 0 would return the angle of the linedef the script was activated from, in a similar fashion to LineSide.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GetLineAngle?

Post by Nash »

This is better suited for, and also already do-able through ZScript, I think.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: GetLineAngle?

Post by Graf Zahl »

Agreed. I will no longer consider features for ACS that go beyond simple map action scripting. Use ZScript for such tasks.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: GetLineAngle?

Post by Matt »

How do you do this in ZScript though? Is there a special pre-calculated thing we can use, or just atan2 and the vertex positions?

(also how do you tell if an angle is 170 degrees or -10 (or 350 or -190)?)
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GetLineAngle?

Post by Nash »

Manual calculation for now. GZDoom could use a built-in way to simply get the line angle in degrees.

(I don't badly need it right now and I currently use the atan2 way which is enough for what small use context I have, but anyone else feel free to make a new suggestion)
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: GetLineAngle?

Post by Major Cooke »

Can you give some example code on how you do it?
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: GetLineAngle?

Post by XxMiltenXx »

Code: Select all

double lineAngle = atan2(line.v1.p.Y - line.v2.p.Y, line.v1.p.X - line.v2.p.X;
This is if you already have a line. If you want to find one from an actor, you can use the linetrace function.

Code: Select all

FLineTraceData CheckLines;
LineTrace(angle, distance, pitch, data: CheckLines);
Then you can access the line via "CheckLines.HitLine"
User avatar
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: GetLineAngle?

Post by phantombeta »

XxMiltenXx wrote:

Code: Select all

double lineAngle = atan2(line.v1.p.Y - line.v2.p.Y, line.v1.p.X - line.v2.p.X;
Or you could just use the pre-calculated delta value from the Line struct, which is both a small optimization and something that makes the code way more readable.

Code: Select all

double lineAngle = atan2 (l.delta.Y, l.delta.X);
Something like this.
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: GetLineAngle?

Post by XxMiltenXx »

phantombeta wrote: Or you could just use the pre-calculated delta value from the Line struct, which is both a small optimization and something that makes the code way more readable.

Code: Select all

double lineAngle = atan2 (l.delta.Y, l.delta.X);
Something like this.
Ah, yes. This certainly makes it better. Thanks
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”